/**
  * Perform rendering
  *
  * @todo add more video sites, anyone...
  *
  * @see Plugin::RenderItemAsHtml()
  */
 function RenderItemAsHtml(&$params)
 {
     $content =& $params['data'];
     // fp> removed some embeds to make it xhtml compliant, using only object. (Hari style ;)
     // anyone, feel free to clean up the ones that have no object tag at all.
     $search_list = array('#\\[video:youtube:(.+?)]#', '#\\[video:dailymotion:(.+?)]#', '#\\[video:google:(.+?)]#', '#\\[video:livevideo:(.+?)]#', '#\\[video:ifilm:(.+?)]#', '#\\[video:vimeo:(.+?)]#');
     $replace_list = array('<div class="videoblock"><object data="http://www.youtube.com/v/\\1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"><param name="movie" value="http://www.youtube.com/v/\\1"></param><param name="wmode" value="transparent"></param></object></div>', '<div class="videoblock"><object data="http://www.dailymotion.com/swf/\\1" type="application/x-shockwave-flash" width="425" height="335" allowfullscreen="true"><param name="movie" value="http://www.dailymotion.com/swf/\\1"></param><param name="allowfullscreen" value="true"></param></object></div>', '<div class="videoblock"><embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=\\1&hl=en" flashvars=""></embed></div>', '<div class="videoblock"><object src="http://www.livevideo.com/flvplayer/embed/\\1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"><param name="movie" value="http://www.livevideo.com/flvplayer/embed/\\1"></param><param name="wmode" value="transparent"></param></object></div>', '<div class="videoblock"><embed width="425" height="350" src="http://www.ifilm.com/efp" quality="high" bgcolor="000000" name="efp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="flvbaseclip=\\1"> </embed></div>', '<div class="videoblock"><object data="http://vimeo.com/moogaloop.swf?clip_id=$1&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" width="400" height="225" type="application/x-shockwave-flash">	<param name="allowfullscreen" value="true" />	<param name="allowscriptaccess" value="always" />	<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=$1&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /></object></div>');
     $content = replace_content_outcode($search_list, $replace_list, $content);
     return true;
 }
 /**
  * Perform rendering
  *
  * @todo add more video sites, anyone...
  *
  * @see Plugin::RenderItemAsHtml()
  */
 function RenderItemAsHtml(&$params)
 {
     $content =& $params['data'];
     // fp> removed some embeds to make it xhtml compliant, using only object. (Hari style ;)
     // anyone, feel free to clean up the ones that have no object tag at all.
     $search_list = array('#\\[video:youtube:(.+?)]#', '#\\[video:dailymotion:(.+?)]#', '#\\[video:vimeo:(.+?)]#', '#\\[video:google:(.+?)]#', '#\\[video:livevideo:(.+?)]#', '#\\[video:ifilm:(.+?)]#');
     $replace_list = array('<div class="videoblock"><iframe id="ytplayer" type="text/html" width="425" height="350" src="//www.youtube.com/embed/\\1" allowfullscreen="allowfullscreen" frameborder="0"></iframe></div>', '<div class="videoblock"><iframe src="//www.dailymotion.com/embed/video/\\1" width="425" height="335" frameborder="0" allowfullscreen></iframe></div>', '<div class="videoblock"><iframe src="//player.vimeo.com/video/$1" width="400" height="225" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>', '<div class="videoblock">The Google video service is not available anymore.</div>', '<div class="videoblock">The Live Video service is not available anymore.</div>', '<div class="videoblock">The iFilm video service is not available anymore.</div>');
     $content = replace_content_outcode($search_list, $replace_list, $content);
     return true;
 }
 /**
  * Render content of Item, Comment, Message
  *
  * @param string Content
  * @param object Blog
  * @param boolean Allow empty Blog
  * return boolean
  */
 function render_content(&$content, $item_Blog = NULL, $allow_null_blog = false)
 {
     // Prepare existing links
     $content = $this->prepare_existing_links($content, $item_Blog, $allow_null_blog);
     // reset already linked usernames
     $this->already_linked_usernames = array();
     if ((!empty($item_Blog) || $allow_null_blog) && $this->get_coll_setting('autolink_username', $item_Blog, $allow_null_blog)) {
         // Replace @usernames with user identity link
         $content = replace_content_outcode('#@([A-Za-z0-9_.]+)#i', '@', $content, array($this, 'replace_usernames'));
     }
     // load global defs
     $this->load_link_array($item_Blog, $allow_null_blog);
     // reset already linked:
     $this->already_linked_array = array();
     if (preg_match_all('|[\'"](http://[^\'"]+)|i', $content, $matches)) {
         // There are existing links:
         $this->already_linked_array = $matches[1];
     }
     $link_attrs = '';
     if ((!empty($item_Blog) || $allow_null_blog) && $this->get_coll_setting($this->setting_nofollow_explicit, $item_Blog, $allow_null_blog)) {
         // Add attribute rel="nofollow" for auto-links
         $link_attrs .= ' rel="nofollow"';
     }
     if ($this->Settings->get('autolink_urls')) {
         // First, make the URLs clickable:
         $content = make_clickable($content, '&amp;', 'make_clickable_callback', $link_attrs);
     }
     if (!empty($this->replacement_link_array)) {
         // Make the desired remaining terms/definitions clickable:
         $content = make_clickable($content, '&amp;', array($this, 'make_clickable_callback'), $link_attrs);
     }
     return true;
 }
 /**
  * Render the dots before <img> tag
  *
  * @param array Associative array of parameters. $params['File'] - attachment, $params['data'] - output
  * @param string Content of the Item/Comment
  */
 function render_infodots(&$params, $content)
 {
     if (empty($params['File']) || empty($params['Link'])) {
         // Check input data
         return;
     }
     $File = $params['File'];
     $Link = $params['Link'];
     if (!$File->is_image()) {
         // This plugin works only with image files
         return;
     }
     if (($LinkOwner =& $Link->get_LinkOwner()) === false || ($Blog =& $LinkOwner->get_Blog()) === false) {
         // Couldn't get Blog object
         return;
     }
     global $thumbnail_sizes;
     $thumbnail_width = isset($thumbnail_sizes[$params['image_size']]) ? $thumbnail_sizes[$params['image_size']][1] : 0;
     if ($File->get_image_size('width') < $this->get_coll_setting('coll_min_width', $Blog) || $thumbnail_width < $this->get_coll_setting('coll_min_width', $Blog)) {
         // Don't draw a dot on image if width is less than setting value
         return;
     }
     if (!isset($this->loaded_objects[$this->object_ID])) {
         // Load the info dots if they were not loaded before
         replace_content_outcode('#<div class="infodots_info" id="infodot_(\\d+)_(\\d+)" xy="(-?\\d+):(-?\\d+)"[^>]*>(.+?)</div>#is', array($this, 'load_infodot_from_rendered_content'), $content, 'replace_content_callback');
         $this->loaded_objects[$this->object_ID] = 1;
     }
     if (empty($this->dots[$Link->ID])) {
         // No dots for this Link
         return;
     }
     $before_image = '<div class="infodots_image">' . "\n";
     foreach ($this->dots[$Link->ID] as $d => $dot) {
         // Init html element for each dot
         $before_image .= '<div class="infodots_dot" rel="infodot_' . $Link->ID . '_' . ($d + 1) . '" style="left:' . $dot['x'] . 'px;top:' . $dot['y'] . 'px"></div>' . "\n";
     }
     // Append info dots html to current image tag
     $params['before_image'] = $params['before_image'] . $before_image;
     $params['after_image'] = '</div>' . $params['after_image'];
 }
Beispiel #5
0
 /**
  * Perform rendering
  *
  * @param array Associative array of parameters
  *   'data': the data (by reference). You probably want to modify this.
  *   'format': see {@link format_to_output()}. Only 'htmlbody' and 'entityencoded' will arrive here.
  * @return boolean true if we can render something for the required output format
  */
 function RenderItemAsHtml(&$params)
 {
     $content =& $params['data'];
     if (!empty($params['Item'])) {
         // Get Item from params
         $Item =& $params['Item'];
     } elseif (!empty($params['Comment'])) {
         // Get Item from Comment
         $Comment =& $params['Comment'];
         $Item =& $Comment->get_Item();
     }
     if (!empty($Item)) {
         // We are rendering Item or Comment now, Get a setting depending on Blog
         $item_Blog =& $Item->get_Blog();
         $this->min_h_level = $this->get_coll_setting('min_h_level', $item_Blog);
     }
     if ($this->min_h_level > 2 && $this->min_h_level <= 6) {
         // Restrict <h_> tags by minimum heading level
         foreach ($this->replace as $r => $replace) {
             // Do replace
             $this->replace[$r] = preg_replace_callback('#([^<]*<)(h[2-6])(>[^<]*</)\\2(>)#i', array($this, 'restrict_min_h_level'), $replace);
         }
     }
     $content = replace_content_outcode($this->search, $this->replace, $content);
     // Find bullet lists
     if (stristr($content, '<code') !== false || stristr($content, '<pre') !== false || strstr($content, '`') !== false) {
         // Call replace_content() on everything outside code/pre:
         $content = callback_on_non_matching_blocks($content, '~(`|<(code|pre)[^>]*>).*?(\\1|</\\2>)~is', array($this, 'find_bullet_lists'));
     } else {
         // No code/pre blocks, replace on the whole thing
         $content = $this->find_bullet_lists($content);
     }
     return true;
 }
Beispiel #6
0
 /**
  * Perform rendering (at display time, i-e: NOT cached)
  *
  * @todo does this actually get fed out in the xml feeds?
  *
  * @see Plugin::DisplayItemAsHtml()
  */
 function DisplayItemAsHtml(&$params)
 {
     $content =& $params['data'];
     $content = replace_content_outcode('~<!-- \\[adsense:\\] -->~', array($this, 'DisplayItem_callback'), $content, 'replace_content_callback');
     return true;
 }
    /**
     * Render content of Item, Comment, Message
     *
     * @todo get rid of global $blog
     * 
     * @param string Content
     * @param object Blog
     * @param boolean Allow empty Blog
     * return boolean
     */
    function render_content(&$content, $item_Blog = NULL, $allow_null_blog = false)
    {
        global $ItemCache, $admin_url, $blog, $evo_charset;
        $regexp_modifier = '';
        if ($evo_charset == 'utf-8') {
            // Add this modifier to work with UTF-8 strings correctly
            $regexp_modifier = 'u';
        }
        // Regular links:
        $search = array('#\\[\\[((https?|mailto)://((?:[^<>{}\\s\\]]|,(?!\\s))+?))\\]\\]#i', '#\\[\\[((https?|mailto)://([^<>{}\\s\\]]+)) ([^\\n\\r]+?)\\]\\]#i', '#\\(\\(((https?|mailto)://((?:[^<>{}\\s\\]]|,(?!\\s))+?))\\)\\)#i', '#\\(\\(((https?|mailto)://([^<>{}\\s\\]]+)) ([^\\n\\r]+?)\\)\\)#i');
        $replace = array('<a href="$1">$1</a>', '<a href="$1">$4</a>', '<a href="$1">$1</a>', '<a href="$1">$4</a>');
        $content = replace_content_outcode($search, $replace, $content);
        /* QUESTION: fplanque, implementation of this planned? then use make_clickable() - or remove this comment
        	$ret = preg_replace("#([\n ])aim:([^,< \n\r]+)#i", "\\1<a href=\"aim:goim?screenname=\\2\\3&message=Hello\">\\2\\3</a>", $ret);
        
        	$ret = preg_replace("#([\n ])icq:([^,< \n\r]+)#i", "\\1<a href=\"http://wwp.icq.com/scripts/search.dll?to=\\2\\3\">\\2\\3</a>", $ret);
        
        	$ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^,< \n\r]*)?)#i", "\\1<a href=\"http://www.\\2.\\3\\4\">www.\\2.\\3\\4</a>", $ret);
        
        	$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([^,< \n\r]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); */
        // To use function replace_special_chars()
        load_funcs('locales/_charset.funcs.php');
        // WIKIWORDS:
        $search_wikiwords = array();
        $replace_links = array();
        if ($this->get_coll_setting('link_without_brackets', $item_Blog, $allow_null_blog)) {
            // Create the links from standalone WikiWords
            // STANDALONE WIKIWORDS:
            $search = '/
					(?<= \\s | ^ )													# Lookbehind for whitespace
					([\\p{Lu}]+[\\p{Ll}0-9_]+([\\p{Lu}]+[\\p{L}0-9_]+)+)	# WikiWord or WikiWordLong
					(?= [\\.,:;!\\?] \\s | \\s | $ )											# Lookahead for whitespace or punctuation
				/x' . $regexp_modifier;
            // x = extended (spaces + comments allowed)
            if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
                // Construct array of wikiwords to look up in post urltitles
                $wikiwords = array();
                foreach ($matches as $match) {
                    // Convert the WikiWord to an urltitle
                    $WikiWord = $match[0];
                    $Wiki_Word = preg_replace('*([^\\p{Lu}_])([\\p{Lu}])*' . $regexp_modifier, '$1-$2', $WikiWord);
                    $wiki_word = evo_strtolower($Wiki_Word);
                    // echo '<br />Match: [', $WikiWord, '] -> [', $wiki_word, ']';
                    $wiki_word = replace_special_chars($wiki_word);
                    $wikiwords[$WikiWord] = $wiki_word;
                }
                // Lookup all urltitles at once in DB and preload cache:
                $ItemCache =& get_ItemCache();
                $ItemCache->load_urltitle_array($wikiwords);
                // Construct arrays for replacing wikiwords by links:
                foreach ($wikiwords as $WikiWord => $wiki_word) {
                    // WikiWord
                    $search_wikiwords[] = '/
						(?<= \\s | ^ ) 						# Lookbehind for whitespace or start
						(?<! <span\\ class="NonExistentWikiWord"> )
						' . $WikiWord . '							# Specific WikiWord to replace
						(?= [\\.,:;!\\?] \\s | \\s | $ )							# Lookahead for whitespace or end of string
						/sx';
                    // s = dot matches newlines, x = extended (spaces + comments allowed)
                    // Find matching Item:
                    if (($Item =& $ItemCache->get_by_urltitle($wiki_word, false)) !== false) {
                        // Item Found
                        $permalink = $Item->get_permanent_url();
                        // WikiWord
                        $replace_links[] = '<a href="' . $permalink . '">' . $Item->get('title') . '</a>';
                    } else {
                        // Item not found
                        $create_link = isset($blog) ? '<a href="' . $admin_url . '?ctrl=items&amp;action=new&amp;blog=' . $blog . '&amp;post_title=' . preg_replace('*([^\\p{Lu}_])([\\p{Lu}])*' . $regexp_modifier, '$1%20$2', $WikiWord) . '&amp;post_urltitle=' . $wiki_word . '" title="Create...">?</a>' : '';
                        // WikiWord
                        $replace_links[] = '<span class="NonExistentWikiWord">' . $WikiWord . $create_link . '</span>';
                    }
                }
            }
        }
        // BRACKETED WIKIWORDS:
        $search = '/
				(?<= \\(\\( | \\[\\[ )										# Lookbehind for (( or [[
				([\\p{L}0-9]+[\\p{L}0-9_\\-]*)									# Anything from Wikiword to WikiWordLong
				(?= ( \\s .*? )? ( \\)\\) | \\]\\] ) )			# Lookahead for )) or ]]
			/x' . $regexp_modifier;
        // x = extended (spaces + comments allowed)
        if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
            // Construct array of wikiwords to look up in post urltitles
            $wikiwords = array();
            foreach ($matches as $match) {
                // Convert the WikiWord to an urltitle
                $WikiWord = $match[0];
                if (preg_match('/^[\\p{Ll}0-9_\\-]+$/' . $regexp_modifier, $WikiWord)) {
                    // This WikiWord already matches a slug format
                    $Wiki_Word = $WikiWord;
                    $wiki_word = $Wiki_Word;
                } else {
                    // Convert WikiWord to slug format
                    $Wiki_Word = preg_replace(array('*([^\\p{Lu}_])([\\p{Lu}])*' . $regexp_modifier, '*([^0-9])([0-9])*' . $regexp_modifier), '$1-$2', $WikiWord);
                    $wiki_word = evo_strtolower($Wiki_Word);
                }
                // echo '<br />Match: [', $WikiWord, '] -> [', $wiki_word, ']';
                $wiki_word = replace_special_chars($wiki_word);
                $wikiwords[$WikiWord] = $wiki_word;
            }
            // Lookup all urltitles at once in DB and preload cache:
            $ChapterCache =& get_ChapterCache();
            $ChapterCache->load_urlname_array($wikiwords);
            $ItemCache =& get_ItemCache();
            $ItemCache->load_urltitle_array($wikiwords);
            // Construct arrays for replacing wikiwords by links:
            foreach ($wikiwords as $WikiWord => $wiki_word) {
                // [[WikiWord text]]
                $search_wikiwords[] = '*
					\\[\\[
					' . $WikiWord . '							# Specific WikiWord to replace
					\\s (.+?)
					\\]\\]
					*sx';
                // s = dot matches newlines, x = extended (spaces + comments allowed)
                // ((WikiWord text))
                $search_wikiwords[] = '*
					\\(\\(
					' . $WikiWord . '							# Specific WikiWord to replace
					\\s (.+?)
					\\)\\)
					*sx';
                // s = dot matches newlines, x = extended (spaces + comments allowed)
                // [[Wikiword]]
                $search_wikiwords[] = '*
					\\[\\[
					' . $WikiWord . '							# Specific WikiWord to replace
					\\]\\]
					*sx';
                // s = dot matches newlines, x = extended (spaces + comments allowed)
                // ((Wikiword))
                $search_wikiwords[] = '*
					\\(\\(
					' . $WikiWord . '							# Specific WikiWord to replace
					\\)\\)
					*sx';
                // s = dot matches newlines, x = extended (spaces + comments allowed)
                // Find matching Chapter or Item:
                $permalink = '';
                $link_text = preg_replace(array('*([^\\p{Lu}_])([\\p{Lu}])*' . $regexp_modifier, '*([^0-9])([0-9])*' . $regexp_modifier), '$1 $2', $WikiWord);
                $link_text = ucwords(str_replace('-', ' ', $link_text));
                if (($Chapter =& $ChapterCache->get_by_urlname($wiki_word, false)) !== false) {
                    // Chapter is found
                    $permalink = $Chapter->get_permanent_url();
                    $existing_link_text = $Chapter->get('name');
                } elseif (($Item =& $ItemCache->get_by_urltitle($wiki_word, false)) !== false) {
                    // Item is found
                    $permalink = $Item->get_permanent_url();
                    $existing_link_text = $Item->get('title');
                }
                if (!empty($permalink)) {
                    // Chapter or Item are found
                    // [[WikiWord text]]
                    $replace_links[] = '<a href="' . $permalink . '">$1</a>';
                    // ((WikiWord text))
                    $replace_links[] = '<a href="' . $permalink . '">$1</a>';
                    // [[Wikiword]]
                    $replace_links[] = '<a href="' . $permalink . '">' . $existing_link_text . '</a>';
                    // ((Wikiword))
                    $replace_links[] = '<a href="' . $permalink . '">' . $link_text . '</a>';
                } else {
                    // Chapter and Item are not found
                    $create_link = isset($blog) ? '<a href="' . $admin_url . '?ctrl=items&amp;action=new&amp;blog=' . $blog . '&amp;post_title=' . preg_replace('*([^\\p{Lu}_])([\\p{Lu}])*' . $regexp_modifier, '$1%20$2', $WikiWord) . '&amp;post_urltitle=' . $wiki_word . '" title="Create...">?</a>' : '';
                    // [[WikiWord text]]
                    $replace_links[] = '<span class="NonExistentWikiWord">$1' . $create_link . '</span>';
                    // ((WikiWord text))
                    $replace_links[] = '<span class="NonExistentWikiWord">$1' . $create_link . '</span>';
                    // [[Wikiword]]
                    $replace_links[] = '<span class="NonExistentWikiWord">' . $link_text . $create_link . '</span>';
                    // ((Wikiword))
                    $replace_links[] = '<span class="NonExistentWikiWord">' . $link_text . $create_link . '</span>';
                }
            }
        }
        // echo '<br />---';
        // pre_dump( $search_wikiwords );
        $content = replace_content_outcode($search_wikiwords, $replace_links, $content);
        return true;
    }
Beispiel #8
0
 /**
  *
  * Render comments if required
  *
  * @see Plugin::FilterCommentContent()
  */
 function FilterCommentContent(&$params)
 {
     $Comment =& $params['Comment'];
     $comment_Item =& $Comment->get_Item();
     $item_Blog =& $comment_Item->get_Blog();
     if (in_array($this->code, $Comment->get_renderers_validated())) {
         // apply_comment_rendering is set to always render
         $content =& $params['data'];
         if (!isset($this->comment_search_list)) {
             $this->comment_search_list = $this->prepare_search_list('coll_comment_search_list', $item_Blog);
         }
         if (!isset($this->comment_replace_list)) {
             $this->comment_replace_list = explode("\n", str_replace("\r", '', $this->get_coll_setting('coll_comment_replace_list', $item_Blog)));
         }
         $content = replace_content_outcode($this->comment_search_list, $this->comment_replace_list, $content, array($this, 'parse_bbcode'));
     }
 }
Beispiel #9
0
    /**
     * Get the prerendered content. If it has not been generated yet, it will.
     *
     * NOTE: This calls {@link Item::dbupdate()}, if renderers get changed (from Plugin hook).
     *       (not for preview though)
     *
     * @param string Format, see {@link format_to_output()}.
     *        Only "htmlbody", "entityencoded", "xml" and "text" get cached.
     * @return string
     */
    function get_prerendered_content($format)
    {
        global $Plugins;
        global $preview;
        if ($preview) {
            $this->update_renderers_from_Plugins();
            $post_renderers = $this->get_renderers_validated();
            // Call RENDERER plugins:
            $r = $this->content;
            $Plugins->render($r, $post_renderers, $format, array('Item' => $this), 'Render');
            // Check and clear inline files, to avoid to have placeholders without corresponding attachment
            $r = $this->check_and_clear_inline_files($r);
            if ($this->is_intro() || !$this->get_type_setting('allow_breaks')) {
                // Don't use the content separators for intro items and if it is disabled by item type:
                $r = replace_content_outcode(array('[teaserbreak]', '[pagebreak]'), '', $r, 'replace_content', 'str');
            }
            return $r;
        }
        $r = null;
        $post_renderers = $this->get_renderers_validated();
        $cache_key = $format . '/' . implode('.', $post_renderers);
        // logic gets used below, for setting cache, too.
        $use_cache = $this->ID && in_array($format, array('htmlbody', 'entityencoded', 'xml', 'text'));
        // $use_cache = false;
        if ($use_cache) {
            // the format/item can be cached:
            $ItemPrerenderingCache =& get_ItemPrerenderingCache();
            if (isset($ItemPrerenderingCache[$format][$this->ID][$cache_key])) {
                // already in PHP cache.
                $r = $ItemPrerenderingCache[$format][$this->ID][$cache_key];
                // Save memory, typically only accessed once.
                unset($ItemPrerenderingCache[$format][$this->ID][$cache_key]);
            } else {
                // Try loading from DB cache, including all items in MainList/ItemList.
                global $DB;
                if (!isset($ItemPrerenderingCache[$format])) {
                    // only do the prefetch loading once.
                    $prefetch_IDs = $this->get_prefetch_itemlist_IDs();
                    // Load prerendered content for all items in MainList/ItemList.
                    // We load the current $format only, since it's most likely that only one gets used.
                    $ItemPrerenderingCache[$format] = array();
                    $rows = $DB->get_results("\n\t\t\t\t\t\tSELECT itpr_itm_ID, itpr_format, itpr_renderers, itpr_content_prerendered\n\t\t\t\t\t\t\tFROM T_items__prerendering\n\t\t\t\t\t\t WHERE itpr_itm_ID IN (" . $DB->quote($prefetch_IDs) . ")\n\t\t\t\t\t\t\t AND itpr_format = '" . $format . "'", OBJECT, 'Preload prerendered item content for MainList/ItemList (' . $format . ')');
                    foreach ($rows as $row) {
                        $row_cache_key = $row->itpr_format . '/' . $row->itpr_renderers;
                        if (!isset($ItemPrerenderingCache[$format][$row->itpr_itm_ID])) {
                            // init list
                            $ItemPrerenderingCache[$format][$row->itpr_itm_ID] = array();
                        }
                        $ItemPrerenderingCache[$format][$row->itpr_itm_ID][$row_cache_key] = $row->itpr_content_prerendered;
                    }
                    // Set the value for current Item.
                    if (isset($ItemPrerenderingCache[$format][$this->ID][$cache_key])) {
                        $r = $ItemPrerenderingCache[$format][$this->ID][$cache_key];
                        // Save memory, typically only accessed once.
                        unset($ItemPrerenderingCache[$format][$this->ID][$cache_key]);
                    }
                } else {
                    // This item has not been fetched by the initial prefetch query; only get this item.
                    // dh> This is quite unlikely to happen, but you never know.
                    // This gets not added to ItemPrerenderingCache, since it would only waste
                    // memory - an item gets typically only accessed once per page, and even if
                    // it would get accessed more often, there is a cache higher in the chain
                    // ($this->content_pages).
                    $cache = $DB->get_var("\n\t\t\t\t\t\tSELECT itpr_content_prerendered\n\t\t\t\t\t\t\tFROM T_items__prerendering\n\t\t\t\t\t\t WHERE itpr_itm_ID = " . $this->ID . "\n\t\t\t\t\t\t\t AND itpr_format = '" . $format . "'\n\t\t\t\t\t\t\t AND itpr_renderers = '" . implode('.', $post_renderers) . "'", 0, 0, 'Check prerendered item content');
                    if ($cache !== NULL) {
                        // Retrieved from cache:
                        // echo ' retrieved from prerendered cache';
                        $r = $cache;
                    }
                }
            }
        }
        if (!isset($r)) {
            // Not cached yet:
            global $Debuglog;
            if ($this->update_renderers_from_Plugins()) {
                $post_renderers = $this->get_renderers_validated();
                // might have changed from call above
                $cache_key = $format . '/' . implode('.', $post_renderers);
                // Save new renderers with item:
                $this->dbupdate();
            }
            // Call RENDERER plugins:
            $r = $this->content;
            $Plugins->render($r, $post_renderers, $format, array('Item' => $this), 'Render');
            // Check and clear inline files, to avoid to have placeholders without corresponding attachment
            $r = $this->check_and_clear_inline_files($r);
            if ($this->is_intro() || !$this->get_type_setting('allow_breaks')) {
                // Don't use the content separators for intro items and if it is disabled by item type:
                $r = replace_content_outcode(array('[teaserbreak]', '[pagebreak]'), '', $r, 'replace_content', 'str');
            }
            $Debuglog->add('Generated pre-rendered content [' . $cache_key . '] for item #' . $this->ID, 'items');
            if ($use_cache) {
                // save into DB (using REPLACE INTO because it may have been pre-rendered by another thread since the SELECT above)
                global $servertimenow;
                $DB->query('REPLACE INTO T_items__prerendering ( itpr_itm_ID, itpr_format, itpr_renderers, itpr_content_prerendered, itpr_datemodified )
					VALUES ( ' . $this->ID . ', ' . $DB->quote($format) . ', ' . $DB->quote(implode('.', $post_renderers)) . ', ' . $DB->quote($r) . ', ' . $DB->quote(date2mysql($servertimenow)) . ' )', 'Cache prerendered item content');
            }
        }
        return $r;
    }
Beispiel #10
0
 /**
  * Perform rendering
  *
  * @param array Associative array of parameters
  *   'data': the data (by reference). You probably want to modify this.
  *   'format': see {@link format_to_output()}. Only 'htmlbody' and 'entityencoded' will arrive here.
  * @return boolean true if we can render something for the required output format
  */
 function RenderItemAsHtml(&$params)
 {
     $content =& $params['data'];
     $content = replace_content_outcode($this->search, $this->replace, $content);
     // Find bullet lists
     if (stristr($content, '<code') !== false || stristr($content, '<pre') !== false) {
         // Call replace_content() on everything outside code/pre:
         $content = callback_on_non_matching_blocks($content, '~<(code|pre)[^>]*>.*?</\\1>~is', array($this, 'find_bullet_lists'));
     } else {
         // No code/pre blocks, replace on the whole thing
         $content = $this->find_bullet_lists($content);
     }
     return true;
 }
Beispiel #11
0
 /**
  *
  * Render comments if required
  *
  * @see Plugin::FilterCommentContent()
  */
 function FilterCommentContent(&$params)
 {
     $Comment =& $params['Comment'];
     $comment_Item =& $Comment->get_Item();
     $item_Blog =& $comment_Item->get_Blog();
     if (in_array($this->code, $Comment->get_renderers_validated())) {
         // apply_comment_rendering is set to render
         $content =& $params['data'];
         $content = replace_content_outcode($this->search_text, $this->replace_func, $content, 'replace_content_callback');
     }
 }
 /**
  * Perform rendering
  *
  * @param array Associative array of parameters
  * 							(Output format, see {@link format_to_output()})
  * @return boolean true if we can render something for the required output format
  */
 function RenderItemAsHtml(&$params)
 {
     $content =& $params['data'];
     $Item =& $params['Item'];
     /**
      * @var Blog
      */
     $item_Blog = $params['Item']->get_Blog();
     // Define the setting names depending on what is rendering now
     if (!empty($params['Comment'])) {
         // Comment is rendering
         $this->setting_nofollow_exist = 'autolink_comment_nofollow_exist';
         $this->setting_nofollow_explicit = 'autolink_comment_nofollow_explicit';
         $this->setting_nofollow_auto = 'autolink_comment_nofollow_auto';
     } else {
         // Item is rendering
         $this->setting_nofollow_exist = 'autolink_post_nofollow_exist';
         $this->setting_nofollow_explicit = 'autolink_post_nofollow_explicit';
         $this->setting_nofollow_auto = 'autolink_post_nofollow_auto';
     }
     // Prepare existing links
     $content = $this->prepare_existing_links($content, $item_Blog);
     // reset already linked usernames
     $this->already_linked_usernames = array();
     if (!empty($item_Blog) && $this->get_coll_setting('autolink_username', $item_Blog)) {
         // Replace @usernames with user identity link
         $content = replace_content_outcode('#@([A-Za-z0-9_.]+)#i', '@', $content, array($this, 'replace_usernames'));
     }
     // load global defs
     $this->load_link_array($item_Blog);
     // reset already linked:
     $this->already_linked_array = array();
     if (preg_match_all('|[\'"](http://[^\'"]+)|i', $content, $matches)) {
         // There are existing links:
         $this->already_linked_array = $matches[1];
     }
     $link_attrs = '';
     if (!empty($item_Blog) && $this->get_coll_setting($this->setting_nofollow_explicit, $item_Blog)) {
         // Add attribute rel="nofollow" for auto-links
         $link_attrs .= ' rel="nofollow"';
     }
     if ($this->Settings->get('autolink_urls')) {
         // First, make the URLs clickable:
         $content = make_clickable($content, '&amp;', 'make_clickable_callback', $link_attrs);
     }
     if (!empty($this->replacement_link_array)) {
         // Make the desired remaining terms/definitions clickable:
         $content = make_clickable($content, '&amp;', array($this, 'make_clickable_callback'), $link_attrs);
     }
     return true;
 }