MENU_CALLBACK, 'file' => 'jeemod.pages.inc', ); $items['jee/chapter'] = $base+array( 'title' => 'jee', 'page callback' => 'jeemod_chapter', 'page arguments' => array(2), 'access callback' => TRUE, // 'access arguments' => array('use materio search api'), ); $items['jee/static'] = $base+array( 'title' => 'jee', 'page callback' => 'jeemod_static', // 'page arguments' => array(2), 'access callback' => TRUE, // 'access arguments' => array('use materio search api'), ); return $items; } /** * Implements hook_entity_info_alter(). */ function jeemod_entity_info_alter(&$entity_info) { $entity_info['node']['view modes']['chapter'] = array( 'label' => t('chapter'), 'custom settings' => TRUE, ); } /** * Implements hook_video_embed_field_handlers_alter(). */ function jeemod_video_embed_field_handlers_alter(&$handlers) { $handlers['vimeo']['function'] = 'jeemod_handle_vimeo'; } /** * Wrapper function to allow forcing API to be enabled for Vimeo videos. */ function jeemod_handle_vimeo($url, $settings) { // dsm($settings, 'settings'); // dsm($url, 'url'); $settings['api'] = 1; // $r = db_query("SELECT entity_id FROM {field_data_field_video} WHERE field_video_video_url = :url", array( // ':url' => $url // )); // foreach($r as $result){ // $id = $result->entity_id; // } // $id = // $settings['player_id'] = "video".$id; // return video_embed_field_handle_vimeo($url, $settings); // needed to rewrite the whole output here // https://github.com/jrue/Vimeo-jQuery-API // Get ID of video from URL $vid = _video_embed_field_get_vimeo_id($url); if (!$vid) { return array( '#markup' => l($url, $url), ); } // Construct the embed code $settings['portrait'] = 0; $width = $settings['width']; $height = $settings['height']; unset($settings['width']); unset($settings['height']); unset($settings['color']); unset($settings['portrait']); unset($settings['title']); unset($settings['byline']); unset($settings['autoplay']); unset($settings['loop']); $settings['player_id'] = "video-".uniqid(); $settings_str = _video_embed_code_get_settings_str($settings); return array( '#markup' => '', ); } /** * 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 . url('node/'.$entity->nid);//$base_url . base_path() . "#principe-" . $entity->nid; $text = $nodetitle ." | ". $sitetitle . " - " . $nodeurl; $tags = explode(' ', str_replace('#', '', $entity->field_partager['und'][0]['value'])); // twitter $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"; // face book $vars['fb_url'] = url("https://www.facebook.com/sharer.php", array( 'absolute'=>true, 'query'=>array( "u"=>$nodeurl, "t"=>$text, ) )); $vars['fb_title'] = "Partager $nodetitle"; // mail // $vars['mail_url'] = "mailto:?subject=$nodetitle&body=$text"; $vars['mail_url'] = url("mailto:", array( 'absolute'=>true, 'query'=>array( "subject"=>$text, "body"=>$text, ) )); $vars['mail_title'] = "Envoyer par email $nodetitle"; }