class SocialContentVK in Social Content 7.2
@file Social Content VK class.
Hierarchy
- class \SocialContent
- class \SocialContentVK
Expanded class hierarchy of SocialContentVK
1 string reference to 'SocialContentVK'
- social_content_vk_social_content_class_info in modules/
vk/ social_content_vk.module - Implements hook_social_content_class_info().
File
- modules/
vk/ social_content_vk.class.inc, line 7 - Social Content VK class.
View source
class SocialContentVK extends SocialContent {
/**
* The label for this global.
*
* @return string
* The label.
*/
public function getLabel() {
if (isset($this->settings['instance']) && !empty($this->settings['instance']['type'])) {
return t('VK (@type)', array(
'@type' => ucfirst($this->settings['instance']['type']),
));
}
return t('VK');
}
/**
* The machine name for the global.
*
* @return string
* The machine name.
*/
public function getMachineName() {
return 'vk';
}
/**
* Get the source being used to get the rows i.e. account / hashtag.
*
* @return string
* The hashtag / account being used to fetch the rows.
*/
public function getSource() {
return 'account';
}
/**
* Fields to save from the row.
*
* Get fields to save.
*
* @return array
* List of fields to save.
*/
public function fields() {
return array(
'id' => 'id',
'text' => 'body',
) + parent::fields();
}
/**
* The shared global settings form for all VK instances.
*
* @return array
* Global settings form.
*/
public function globalSettingsForm() {
$settings = $this->settings['global'];
$form['api_url'] = array(
'#type' => 'textfield',
'#title' => t('API URL'),
'#description' => t('Do not include trailing slash. Example: !url', array(
'!url' => 'https://api.vk.com',
)),
'#default_value' => isset($settings['api_url']) ? $settings['api_url'] : NULL,
'#required' => TRUE,
);
$form['api_version'] = array(
'#type' => 'textfield',
'#title' => t('API version'),
'#description' => t("i.e. 'v1'."),
'#default_value' => isset($settings['api_version']) ? $settings['api_version'] : '5.21',
'#required' => TRUE,
);
return $form;
}
/**
* Instance settings form.
*
* @return array
* Any instance settings that will be included on all
* instance forms for the current global.
*/
public function instanceSettingsForm() {
$settings = $this->settings['instance'];
$form = parent::instanceSettingsForm($settings);
$form['owner_id'] = array(
'#type' => 'textfield',
'#title' => t('VK Owner ID'),
'#description' => t('The VK user/group id to pull the statuses from. Use negative numbers for groups.'),
'#default_value' => isset($settings['owner_id']) ? $settings['owner_id'] : NULL,
);
return $form;
}
/**
* Get the rows to import.
*
* @param mixed $last_id
* The id of the last import.
*
* @return mixed
*/
public function getRows($last_id = NULL) {
$settings = array_merge($this->settings['global'], $this->settings['instance']);
if (!empty($settings['owner_id'])) {
$params = array(
'owner_id' => $settings['owner_id'],
'photo_sizes' => 1,
);
if (!empty($settings['limit'])) {
$params['count'] = $settings['limit'];
}
if (!empty($settings['api_version'])) {
$params['v'] = $settings['api_version'];
}
$url = $settings['api_url'] . '/method/wall.get';
$result = $this
->httpRequest(url($url, array(
'query' => $params,
'external' => TRUE,
)));
if ($result->code == 200) {
$response = json_decode($result->data);
if (!isset($response->error)) {
return $response->response->items;
}
else {
watchdog('social_content_vk', 'Error fetching feed, data: %data', array(
'%data' => $response->error->error_msg,
), WATCHDOG_WARNING);
}
}
}
return FALSE;
}
/**
* Do the uploads and attach expected fields to a row about to be imported.
*/
public function prepareRow($row) {
$row->created = $row->date;
return parent::prepareRow($row);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialContent:: |
protected | property | ||
SocialContent:: |
protected | property | ||
SocialContent:: |
protected | function | Apply global template to instance. | |
SocialContent:: |
protected | function | Attach declare fields onto wrapper. | |
SocialContent:: |
public | function | Delete global settings. | |
SocialContent:: |
public static | function | Utility static function to delete log history of an internal id(nid). | |
SocialContent:: |
public | function | Delete the current instance as well as it's history if required. | |
SocialContent:: |
public static | function | Utility static function to get all instances. | |
SocialContent:: |
protected | function | Get the value of a nested property, providing array of property names. | |
SocialContent:: |
public | function | Remote fields map to local fields. | |
SocialContent:: |
public | function | Get an internal form of the gievn type. | |
SocialContent:: |
public static | function | The root element to use in forms. | |
SocialContent:: |
public static | function | Utility static function to get a count number of imports for an instance. | |
SocialContent:: |
public | function | Get all instances for the current global. | |
SocialContent:: |
public | function | The title to use for the current instance. | |
SocialContent:: |
public static | function | Utility static function to get last imported external id. | |
SocialContent:: |
public static | function | Utility static function to get a global object from instance id. | |
SocialContent:: |
protected static | function | Utility method make remote request. | |
SocialContent:: |
public | function | Do the import. | |
SocialContent:: |
protected | function | The default field keys which will be on all instance's forms. | |
SocialContent:: |
public | function | Whether the current instance is enabled for import. | |
SocialContent:: |
public | function | Load global settings. | |
SocialContent:: |
public | function | Load instance settings for the current global. | |
SocialContent:: |
protected | function | Log import of row to history. | |
SocialContent:: |
protected | function | Utility static function to get and save a remote file. | |
SocialContent:: |
public | function | Save the form values of a form that was request with the getForm method. | |
SocialContent:: |
public | function | Save global settings. | |
SocialContent:: |
public | function | Save instance settings. | 3 |
SocialContent:: |
public | function | Allow for overridding of intsnace settings. | |
SocialContent:: |
public | function | Translate a node to a set given languages | |
SocialContent:: |
protected static | function | Strip non utf8 characters that can sometimes come through. | |
SocialContent:: |
public | function | Class constructor to instantiate a new object. | |
SocialContentVK:: |
public | function |
Fields to save from the row. Overrides SocialContent:: |
|
SocialContentVK:: |
public | function |
The label for this global. Overrides SocialContent:: |
|
SocialContentVK:: |
public | function |
The machine name for the global. Overrides SocialContent:: |
|
SocialContentVK:: |
public | function |
Get the rows to import. Overrides SocialContent:: |
|
SocialContentVK:: |
public | function |
Get the source being used to get the rows i.e. account / hashtag. Overrides SocialContent:: |
|
SocialContentVK:: |
public | function |
The shared global settings form for all VK instances. Overrides SocialContent:: |
|
SocialContentVK:: |
public | function |
Instance settings form. Overrides SocialContent:: |
|
SocialContentVK:: |
public | function |
Do the uploads and attach expected fields to a row about to be imported. Overrides SocialContent:: |