|
@@ -41,8 +41,6 @@ function jeemod_entity_info_alter(&$entity_info) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* Implements hook_video_embed_field_handlers_alter().
|
|
|
*/
|
|
@@ -106,3 +104,81 @@ function jeemod_handle_vimeo($url, $settings) {
|
|
|
'?' . $settings_str . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>',
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Implements hook_field_formatter_info().
|
|
|
+ */
|
|
|
+function jeemod_field_formatter_info() {
|
|
|
+ return array(
|
|
|
+ 'share_butons' => array(
|
|
|
+ 'label' => t('Share butons (Twitter, Facebook)'),
|
|
|
+ 'field types' => array('text'),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Implements hook_field_formatter_view().
|
|
|
+ */
|
|
|
+function jeemod_field_formatter_view($entity_type, $entity, $field, $instance, $lang_code, $items, $display) {
|
|
|
+ $element = array();
|
|
|
+ foreach ($items as $delta => $item) {
|
|
|
+ $element[$delta] = array(
|
|
|
+ '#theme' => 'jeemod_share_links',
|
|
|
+ '#entity' => $entity,
|
|
|
+ // '#url' => $entity->field_partager['und'][0]['url'],
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return $element;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+* Implements hook_theme().
|
|
|
+*/
|
|
|
+function jeemod_theme() {
|
|
|
+ return array(
|
|
|
+ 'jeemod_share_links' => array(
|
|
|
+ 'template' => 'jeemod_share_links',
|
|
|
+ 'variables' => array(
|
|
|
+ 'entity' => NULL,
|
|
|
+ // 'url' => NULL,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+function jeemod_preprocess_jeemod_share_links(&$vars){
|
|
|
+ global $base_url;
|
|
|
+ // dsm($vars);
|
|
|
+ $entity = $vars['entity'];
|
|
|
+
|
|
|
+ $sitetitle = variable_get('site_name', '');
|
|
|
+ $nodetitle = $entity->title;
|
|
|
+ $nodeurl = $base_url . base_path() . "#principe-" . $entity->nid;
|
|
|
+
|
|
|
+ $text = $nodetitle ." | ". $sitetitle . " - " . $nodeurl;
|
|
|
+
|
|
|
+ $tags = explode(' ', str_replace('#', '', $entity->field_partager['und'][0]['value']));
|
|
|
+
|
|
|
+ $vars['twitter_url'] = url("https://twitter.com/intent/tweet", array(
|
|
|
+ 'absolute'=>true,
|
|
|
+ 'query'=>array(
|
|
|
+ // "button_hashtag"=>implode(',',$tags),
|
|
|
+ "button_hashtag"=>$tags[0],
|
|
|
+ "text"=>$text,
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ $vars['twitter_title'] = "Twitter $nodetitle";
|
|
|
+
|
|
|
+ $vars['fb_url'] = url("https://www.facebook.com/sharer.php", array(
|
|
|
+ 'absolute'=>true,
|
|
|
+ 'query'=>array(
|
|
|
+ "u"=>$nodeurl,
|
|
|
+ "t"=>$text,
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ $vars['fb_title'] = "Partager $nodetitle";
|
|
|
+
|
|
|
+
|
|
|
+}
|