/**
  * Support function for above
  *
  * @param Item
  * @return boolean TRUE - if content is displayed
  */
 function disp_contents(&$disp_Item)
 {
     // Check if only the title was displayed before the first picture
     $displayed_only_title = false;
     // Set this var to TRUE when some content(title, excerpt or picture) is displayed
     $content_is_displayed = false;
     echo $this->disp_params['item_start'];
     // Is this the current item?
     global $disp, $Item;
     if (!empty($Item) && $disp_Item->ID == $Item->ID) {
         // The current page is currently displaying the Item this link is pointing to
         // Let's display it as selected
         $link_class = $this->disp_params['link_selected_class'];
     } else {
         // Default link class
         $link_class = $this->disp_params['link_default_class'];
     }
     if ($this->disp_params['disp_title']) {
         // Display title
         $disp_Item->title(array('link_type' => $this->disp_params['item_title_link_type'], 'link_class' => $link_class));
         $displayed_only_title = true;
         $content_is_displayed = true;
     }
     if ($this->disp_params['disp_excerpt']) {
         $excerpt = $disp_Item->dget('excerpt', 'htmlbody');
         if (!empty($excerpt)) {
             // Note: Excerpts are plain text -- no html (at least for now)
             echo '<div class="item_excerpt">' . $excerpt . '</div>';
             $displayed_only_title = false;
             $content_is_displayed = true;
         }
     }
     if ($this->disp_params['disp_teaser']) {
         // we want to show some or all of the post content
         $content = $disp_Item->get_content_teaser(1, false, 'htmlbody');
         if ($words = $this->disp_params['disp_teaser_maxwords']) {
             // limit number of words
             $content = strmaxwords($content, $words, array('continued_link' => $disp_Item->get_permanent_url(), 'continued_text' => '&hellip;'));
         }
         echo '<div class="item_content">' . $content . '</div>';
         $displayed_only_title = false;
         $content_is_displayed = true;
         /* fp> does that really make sense?
         				we're no longer in a linkblog/linkroll use case here, are we?
         			$disp_Item->more_link( array(
         					'before'    => '',
         					'after'     => '',
         					'link_text' => T_('more').' &raquo;',
         				) );
         				*/
     }
     if (in_array($this->disp_params['attached_pics'], array('first', 'all'))) {
         // Display attached pictures
         $picture_limit = $this->disp_params['attached_pics'] == 'first' ? 1 : 1000;
         $LinkOnwer = new LinkItem($disp_Item);
         if ($FileList = $LinkOnwer->get_attachment_FileList($picture_limit)) {
             // Get list of attached files
             while ($File =& $FileList->get_next()) {
                 if ($File->is_image()) {
                     // Get only images
                     switch ($this->disp_params['item_pic_link_type']) {
                         // Set url for picture link
                         case 'none':
                             $pic_url = NULL;
                             break;
                         case 'permalink':
                             $pic_url = $disp_Item->get_permanent_url();
                             break;
                         case 'linkto_url':
                             $pic_url = $disp_Item->url;
                             break;
                         case 'auto':
                         default:
                             $pic_url = empty($disp_Item->url) ? $disp_Item->get_permanent_url() : $disp_Item->url;
                             break;
                     }
                     if ($displayed_only_title) {
                         // If only the title was displayed - Insert new line before the first picture
                         echo '<br />';
                         $displayed_only_title = false;
                     }
                     // Print attached picture
                     echo $File->get_tag('', '', '', '', $this->disp_params['thumb_size'], $pic_url);
                     $content_is_displayed = true;
                 }
             }
         }
     }
     echo $this->disp_params['item_end'];
     return $content_is_displayed;
 }
示例#2
0
 /**
  * Get placeholder image File that has the same name as the current video File
  *
  * @param object File
  * @return object placeholder File
  */
 function &get_placeholder_File($video_File)
 {
     $r = NULL;
     if (empty($video_File)) {
         // No File for placeholder
         return $r;
     }
     if (!isset($this->placeholder_FileList)) {
         // Get list of attached fallback files
         $LinkOwner = new LinkItem($this);
         if (!($this->placeholder_FileList =& $LinkOwner->get_attachment_FileList(1000))) {
             // No attached files
             return $r;
         }
     }
     // Get file name without extension
     $video_file_name_without_ext = preg_replace('#^(.+)\\.[^\\.]+$#', '$1', $video_File->get_name());
     // Rewind internal index to first position
     $this->placeholder_FileList->current_idx = 0;
     while ($attached_File =& $this->placeholder_FileList->get_next()) {
         if ($video_File->get_name() != $attached_File->get_name() && preg_match('#^' . $video_file_name_without_ext . '\\.(jpg|jpeg|png|gif)+$#', $attached_File->get_name())) {
             // It is a file with same name but with image extension
             return $attached_File;
         }
     }
     return $r;
 }
示例#3
0
 /**
  * Convert inline image tags like [image:123:abc] into HTML img tags
  *
  * @param string Source content
  * @param array Params
  * @return string Content
  */
 function render_inline_images($content, $params = array())
 {
     if (isset($params['check_code_block']) && $params['check_code_block'] && (stristr($content, '<code') !== false || stristr($content, '<pre') !== false)) {
         // Call $this->render_inline_images() on everything outside code/pre:
         $params['check_code_block'] = false;
         $content = callback_on_non_matching_blocks($content, '~<(code|pre)[^>]*>.*?</\\1>~is', array($this, 'render_inline_images'), array($params));
         return $content;
     }
     // No code/pre blocks, replace on the whole thing
     $params = array_merge(array('before' => '<div>', 'before_image' => '<div class="image_block">', 'before_image_legend' => '<div class="image_legend">', 'after_image_legend' => '</div>', 'after_image' => '</div>', 'after' => '</div>', 'image_size' => 'fit-400x320', 'image_link_to' => 'original', 'limit' => 1000), $params);
     // Find all matches with image inline tags
     preg_match_all('/\\[image:(\\d+)(:?)([^\\]]*)\\]/i', $content, $images);
     if (!empty($images[0])) {
         // There are image inline tags in the content
         foreach ($images[0] as $i => $current_link_tag) {
             $current_link_ID = (int) $images[1][$i];
             $current_link_caption = empty($images[2][$i]) ? '#' : $images[3][$i];
             if (empty($current_link_ID)) {
                 // Invalid link ID, Go to next match
                 continue;
             }
             if (!isset($FileList)) {
                 // Get list of attached files only first time
                 $LinkOnwer = new LinkItem($this);
                 $FileList = $LinkOnwer->get_attachment_FileList($params['limit'], 'inline');
                 if (empty($FileList)) {
                     // This Item has not the inline attached files, Exit here
                     break;
                 }
             }
             if ($File =& $FileList->get_by_field('link_ID', $current_link_ID)) {
                 // File is found by link ID
                 if (!$File->exists()) {
                     global $Debuglog;
                     $Debuglog->add(sprintf('File linked to item #%d does not exist (%s)!', $this->ID, $File->get_full_path()), array('error', 'files'));
                     break;
                 } elseif ($File->is_image()) {
                     // Generate the IMG tag with all the alt, title and desc if available
                     $image_tag = $this->get_attached_image_tag($File, $params);
                     // Replace inline image tag with HTML img tag
                     $content = str_replace($current_link_tag, $image_tag, $content);
                 } else {
                     // Display error if file is not an image
                     $content = str_replace($current_link_tag, '<div class="error">' . sprintf(T_('This file cannot be included here because it is not an image: %s'), $current_link_tag) . '</div>', $content);
                 }
             }
         }
     }
     return $content;
 }