public static function ShareaholicPublic::draw_canvases in Share Buttons, Related Posts, Content Analytics - Shareaholic 8
Same name and namespace in other branches
- 7.3 public.php \ShareaholicPublic::draw_canvases()
This static function inserts the shareaholic canvas in a node
Parameters
string $node The node object to insert the canvas into:
1 call to ShareaholicPublic::draw_canvases()
- ShareaholicPublic::insert_widgets in ./
public.php - Inserts the Shareaholic widget/apps on the page By drawing the canvas on a piece of content
File
- ./
public.php, line 301
Class
- ShareaholicPublic
- This class is all about drawing the stuff in publishers' templates that visitors can see.
Code
public static function draw_canvases(&$node, $view_mode) {
$settings = ShareaholicUtilities::get_settings();
$page_type = $node->type;
$sb_above_weight = -1000;
$rec_above_weight = -999;
$sb_below_weight = 1000;
$rec_below_weight = 1001;
if ($view_mode === 'teaser') {
$page_type = 'teaser';
}
foreach (array(
'share_buttons',
'recommendations',
) as $app) {
if (isset($node->shareaholic_options["shareaholic_hide_{$app}"]) && $node->shareaholic_options["shareaholic_hide_{$app}"]) {
continue;
}
$title = $node->title;
$summary = isset($node->teaser) ? $node->teaser : '';
$link = url('node/' . $node->nid, array(
'absolute' => TRUE,
));
if (isset($settings[$app]["{$page_type}_above_content"]) && $settings[$app]["{$page_type}_above_content"] == 'on') {
$id = $settings['location_name_ids'][$app]["{$page_type}_above_content"];
$id_name = $page_type . '_above_content';
$node->content["shareaholic_{$app}_{$page_type}_above_content"] = array(
'#markup' => self::canvas($id, $app, $id_name, $title, $link),
'#weight' => $app === 'share_buttons' ? $sb_above_weight : $rec_above_weight,
);
}
if (isset($settings[$app]["{$page_type}_below_content"]) && $settings[$app]["{$page_type}_below_content"] == 'on') {
$id = $settings['location_name_ids'][$app]["{$page_type}_below_content"];
$id_name = $page_type . '_below_content';
$node->content["shareaholic_{$app}_{$page_type}_below_content"] = array(
'#markup' => self::canvas($id, $app, $id_name, $title, $link),
'#weight' => $app === 'share_buttons' ? $sb_below_weight : $rec_below_weight,
);
}
}
}