Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class KingK_BbCodeManager_BbCode_Formatter_Base extends XFCP_KingK_BbCodeManager_BbCode_Formatter_Base
- {
- /****
- * CREATE CUSTOM TAGS
- ***/
- protected $_customTags = null;
- //@extended
- public function getTags()
- {
- $parentTags = parent::getTags();
- if($this->_customTags === null)
- {
- $this->bakeCustomTags();
- }
- if($this->_customTags !== null)
- {
- return array_merge((array) $parentTags, (array) $this->_customTags);
- }
- return $parentTags;
- }
- public function bakeCustomTags()
- {
- $customTags = XenForo_Model::create('KingK_BbCodeManager_Model_CustomBbCode')->getAllCustomBbCodes('strict');
- if(!is_array($customTags))
- {
- return false;
- }
- $allCustomTags = array();
- foreach($customTags AS $custom)
- {
- if((boolean)$custom['active'])
- {
- if($custom['replacementBegin'])
- {
- if($custom['advancedOptions'])
- {
- $allCustomTags[$custom['tag']]['hasOption'] = true;
- $allCustomTags[$custom['tag']]['numberOfOptions'] = $custom['numberOfOptions'];
- $allCustomTags[$custom['tag']]['replacementBegin'] = $custom['replacementBegin'];
- $allCustomTags[$custom['tag']]['replacementEnd'] = $custom['replacementEnd'];
- $allCustomTags[$custom['tag']]['callback'] = array($this, 'renderAdvancedOptionsTag');
- if($custom['plainCallback'])
- {
- $allCustomTags[$custom['tag']]['parseCallback'] = array($this, 'parseValidatePlainIfNoOption');
- }
- }
- else
- {
- /*
- We're in the XenForo standard replacement tag system which is using the sprintf cmd
- If the user has written a percentage (ie:width, height) and didn't double it, then it will occur an error
- Let's fix it
- */
- $fixSprintfPattern = '#(?<!%)%(?![%s])#';
- $custom['replacementBegin'] = preg_replace($fixSprintfPattern, '%%', $custom['replacementBegin']);
- $custom['replacementEnd'] = preg_replace($fixSprintfPattern, '%%', $custom['replacementEnd']);
- $allCustomTags[$custom['tag']]['hasOption'] = ($custom['requiresOption'] == 0 ? false : true);
- $allCustomTags[$custom['tag']]['replace'] = array($custom['replacementBegin'], $custom['replacementEnd']);
- }
- }
- elseif($custom['phpcallback_class'])
- {
- $allCustomTags[$custom['tag']]['phpcallback_class'] = $custom['phpcallback_class'];
- $allCustomTags[$custom['tag']]['phpcallback_method'] = $custom['phpcallback_method'];
- $allCustomTags[$custom['tag']]['callback'] = array($this, 'renderAdvancedTag');
- if($custom['plainCallback'])
- {
- $allCustomTags[$custom['tag']]['parseCallback'] = array($this, 'parseValidatePlainIfNoOption');
- }
- $this->_preLoadTemplatesFromCallback($custom['phpcallback_class'], $custom['phpcallback_method']);
- }
- elseif($custom['template_active'])
- {
- $this->_preloadCustomTemplates[] = $custom['template_name'];
- $allCustomTags[$custom['tag']]['template_name'] = $custom['template_name'];
- $allCustomTags[$custom['tag']]['callback'] = array($this, 'renderTemplateTag');
- if($custom['template_callback_class'])
- {
- $allCustomTags[$custom['tag']]['template_callback']['class'] = $custom['template_callback_class'];
- $allCustomTags[$custom['tag']]['template_callback']['method'] = $custom['template_callback_method'];
- $this->_preLoadTemplatesFromCallback($custom['template_callback_class'], $custom['template_callback_method']);
- }
- if($custom['plainCallback'])
- {
- $allCustomTags[$custom['tag']]['parseCallback'] = array($this, 'parseValidatePlainIfNoOption');
- }
- }
- if($custom['trimLeadingLinesAfter'] > 0 && $custom['trimLeadingLinesAfter'] < 3)
- {
- $allCustomTags[$custom['tag']]['trimLeadingLinesAfter'] = $custom['trimLeadingLinesAfter'];
- }
- if($custom['regex'])
- {
- $allCustomTags[$custom['tag']]['optionRegex'] = $custom['regex'];
- }
- if($custom['plainChildren'])
- {
- $allCustomTags[$custom['tag']]['plainChildren'] = true;
- }
- if($custom['stopSmilies'])
- {
- $allCustomTags[$custom['tag']]['stopSmilies'] = true;
- }
- if($custom['stopLineBreakConversion'])
- {
- $allCustomTags[$custom['tag']]['stopLineBreakConversion'] = true;
- }
- if($custom['parseOptions'])
- {
- $allCustomTags[$custom['tag']]['parseOptions'] = true;
- }
- if($custom['parser_has_usr'])
- {
- $allCustomTags[$custom['tag']]['parser_perms']['parser_has_usr'] = $custom['parser_has_usr'];
- }
- if($custom['parser_usr'])
- {
- $allCustomTags[$custom['tag']]['parser_perms']['parser_usr'] = $custom['parser_usr'];
- }
- if($custom['parser_return'])
- {
- $allCustomTags[$custom['tag']]['parser_perms']['parser_return'] = $custom['parser_return'];
- }
- if($custom['parser_return_delay'])
- {
- $allCustomTags[$custom['tag']]['parser_perms']['parser_return_delay'] = $custom['parser_return_delay'];
- }
- $allCustomTags[$custom['tag']]['view_perms']['can_view_content'] = true;
- if($custom['view_has_usr'])
- {
- $visitor = XenForo_Visitor::getInstance();
- $visitorUserGroupIds = array_merge(array((string)$visitor['user_group_id']), (explode(',', $visitor['secondary_group_ids'])));
- $visitorsOk = unserialize($custom['view_usr']);
- $canViewBbCode = (array_intersect($visitorUserGroupIds, $visitorsOk)) ? true : false;
- $allCustomTags[$custom['tag']]['view_perms']['can_view_content'] = $canViewBbCode;
- $allCustomTags[$custom['tag']]['view_perms']['view_return'] = $custom['view_return'];
- if($custom['view_return'] == 'default_template' && array_search('bbcm_viewer_content_protected', $this->_preloadCustomTemplates) === false)
- {
- $this->_preloadCustomTemplates[] = 'bbcm_viewer_content_protected';
- }
- if($custom['view_return_delay'])
- {
- $allCustomTags[$custom['tag']]['view_perms']['view_return_delay'] = $custom['view_return_delay'];
- }
- }
- }
- }
- $this->_customTags = $allCustomTags;
- }
- /****
- * RENDER TAGS
- ***/
- public function renderAdvancedOptionsTag(array $tag, array $rendererStates)
- {
- $this->_bakeCurrentPostParams($tag);
- $tagInfo['numberOfOptions'] = $this->_tags[$tag['tag']]['numberOfOptions'];
- $tagInfo['replacementBegin'] = $this->_tags[$tag['tag']]['replacementBegin'];
- $tagInfo['replacementEnd'] = $this->_tags[$tag['tag']]['replacementEnd'];
- if (!empty($tag['option']) && $this->parseMultipleOptions($tag['option']))
- {
- $options = $this->parseMultipleOptions($tag['option']);
- if( isset($this->_tags[$tag['tag']]['parseOptions']) )
- {
- //No need to securise the Bb Code (no xen:raw setting here) => second arg is "false"
- $options = $this->parseAndSecuriseBbCodesInOptions($options, false);
- }
- $parserPermissionsReturn = $this->checkBbCodeParsingPerms($tag, $rendererStates);
- if($parserPermissionsReturn !== true)
- {
- return $parserPermissionsReturn;
- }
- $viewPermissionsReturn = $this->checkBbCodeViewPerms($tag, $rendererStates);
- if($viewPermissionsReturn !== true)
- {
- return $viewPermissionsReturn;
- }
- if((int)count($options) == $tagInfo['numberOfOptions'])
- {
- for($replaceIndex = 0; $replaceIndex <= ($tagInfo['numberOfOptions'] - 1); $replaceIndex++)
- {
- if(!(isset($options[$replaceIndex])))
- {
- //With the fix in the for loop, this protection shouldn't be needed anymore but let's keep it for safety
- continue;
- }
- $replaceNumber = $replaceIndex + 1;
- $tagInfo['replacementBegin'] = str_replace('{' . $replaceNumber . '}', $options[$replaceIndex], $tagInfo['replacementBegin']);
- $tagInfo['replacementEnd'] = str_replace('{' . $replaceNumber . '}', $options[$replaceIndex], $tagInfo['replacementEnd']);
- $content = $this->renderSubTree($tag['children'], $rendererStates);
- }
- return $tagInfo['replacementBegin'] . $content . $tagInfo['replacementEnd'];
- }
- else
- {
- return $tag['original'][0] . $tag['children'][0] . $tag['original'][1];
- }
- }
- }
- public function renderTemplateTag(array $tag, array $rendererStates, $increment = true)
- {
- if($increment == true)
- {
- $this->_bakeCurrentPostParams($tag);
- }
- if(!isset($rendererStates['canUseBbCode']))
- {
- $parserPermissionsReturn = $this->checkBbCodeParsingPerms($tag, $rendererStates);
- if($parserPermissionsReturn !== true)
- {
- //Will a short loop with changing the rendererStates
- return $parserPermissionsReturn;
- }
- $rendererStates['isPost'] = ($this->getPostParams() !== NULL) ? true : false;
- $rendererStates['canUseBbCode'] = true;
- }
- if(!isset($rendererStates['canViewBbCode']))
- {
- $viewPermissionsReturn = $this->checkBbCodeViewPerms($tag, $rendererStates);
- if($viewPermissionsReturn !== true)
- {
- return $viewPermissionsReturn;
- }
- $rendererStates['canViewBbCode'] = true;
- }
- $content = $this->renderSubTree($tag['children'], $rendererStates);
- $options = array();
- $templateName = $this->_tags[$tag['tag']]['template_name'];
- if (!empty($tag['option']) && $this->parseMultipleOptions($tag['option']))
- {
- $options = $this->parseMultipleOptions($tag['option']);
- array_unshift($options, 'killMe');
- unset($options[0]);
- if( isset($this->_tags[$tag['tag']]['parseOptions']) )
- {
- $options = $this->parseAndSecuriseBbCodesInOptions($options);
- }
- else
- {
- $options = $this->secureBbCodesInOptions($options);
- }
- }
- if (!$this->_view)
- {
- $fallBack = true;
- }
- if( isset($this->_tags[$tag['tag']]['template_callback']) )
- {
- $template_callback_class = $this->_tags[$tag['tag']]['template_callback']['class'];
- $template_callback_method = $this->_tags[$tag['tag']]['template_callback']['method'];
- XenForo_Application::autoload($template_callback_class);
- call_user_func_array(array($template_callback_class, $template_callback_method), array(&$content, &$options, &$templateName, &$fallBack, $rendererStates, $this));
- }
- if($fallBack === true)
- {
- //Can me modified by the above template Callback
- $fallBack = '<div class="template_fallback_' . $tag['tag'] . '">' . $this->renderSubTree($tag['children'], $rendererStates) . '</div>';
- }
- $templateArguments = array('content' => $content, 'options' => $options, 'rendererStates' => $rendererStates);
- return $this->renderCustomTemplate($templateName, $templateArguments, $fallBack);
- }
- public function renderAdvancedTag(array $tag, array $rendererStates, $increment = true)
- {
- if($increment == true)
- {
- $this->_bakeCurrentPostParams($tag);
- }
- if(!isset($rendererStates['canUseBbCode']))
- {
- $parserPermissionsReturn = $this->checkBbCodeParsingPerms($tag, $rendererStates);
- if($parserPermissionsReturn !== true)
- {
- //Will a short loop with changing the rendererStates
- return $parserPermissionsReturn;
- }
- $rendererStates['isPost'] = ($this->getPostParams() !== NULL) ? true : false;
- $rendererStates['canUseBbCode'] = true;
- }
- if(!isset($rendererStates['canViewBbCode']))
- {
- $viewPermissionsReturn = $this->checkBbCodeViewPerms($tag, $rendererStates);
- if($viewPermissionsReturn !== true)
- {
- return $viewPermissionsReturn;
- }
- $rendererStates['canViewBbCode'] = true;
- }
- $phpcallback_class = $this->_tags[$tag['tag']]['phpcallback_class'];
- $phpcallback_method = $this->_tags[$tag['tag']]['phpcallback_method'];
- XenForo_Application::autoload($phpcallback_class);
- return call_user_func_array(array($phpcallback_class, $phpcallback_method), array($tag, $rendererStates, &$this));
- }
- //@extended
- public function renderValidTag(array $tagInfo, array $tag, array $rendererStates)
- {
- $parent = parent::renderValidTag($tagInfo, $tag, $rendererStates);
- if (!empty($tagInfo['replace']))
- {
- //Implement the tool for "Standard Bb Codes" (Bb Codes which don't use the Advanced Options)
- $this->_bakeCurrentPostParams($tag);
- $parserPermissionsReturn = $this->checkBbCodeParsingPerms($tag, $rendererStates);
- if($parserPermissionsReturn !== true)
- {
- return $parserPermissionsReturn;
- }
- $viewPermissionsReturn = $this->checkBbCodeViewPerms($tag, $rendererStates);
- if($viewPermissionsReturn !== true)
- {
- return $viewPermissionsReturn;
- }
- }
- return $parent;
- }
- public function parseMultipleOptions($tag)
- {
- $options = XenForo_Application::get('options');
- $separator = (empty($options->Bbcm_BbCode_Options_Separator)) ? ', ' : $options->Bbcm_BbCode_Options_Separator;
- $attributes = explode($separator, $tag);
- return $attributes;
- }
- /****
- * PERMISSIONS TOOLS
- ***/
- public function checkBbCodeParsingPerms(array $tag, array $rendererStates)
- {
- if( !isset($this->_tags[$tag['tag']]['parser_perms']) || !isset($this->_tags[$tag['tag']]['parser_perms']['parser_has_usr']) )
- {
- //No need to check parser_has_usr value since the key won't be there if disable (see @bakeCustomTags)
- return true;
- }
- $perms = $this->_tags[$tag['tag']]['parser_perms'];
- $postParams = $this->getPostParams();
- if( $postParams !== NULL)
- {
- $posterUserGroupIds = array_merge(array((string)$postParams['user_group_id']), (explode(',', $postParams['secondary_group_ids'])));
- $postersOk = unserialize($perms['parser_usr']);
- if(array_intersect($posterUserGroupIds, $postersOk))
- {
- return true;
- }
- }
- if( isset($perms['parser_return_delay']) )
- {
- $autorisedLimit = $perms['parser_return_delay'];
- $post_date = $this->getPostParam('post_date');
- if($post_date !== NULL)
- {
- $interval = XenForo_Application::$time - $post_date;
- $diff_hours = floor($interval / 3600);
- if($diff_hours <= $autorisedLimit)
- {
- return true;
- }
- }
- }
- $output = '';
- if($perms['parser_return'] == 'content')
- {
- $output = $this->renderSubTree($tag['children'], $rendererStates);
- }
- elseif($perms['parser_return'] == 'content_bb')
- {
- $output = $tag['original'][0] . $this->renderSubTree($tag['children'], $rendererStates) . $tag['original'][1];
- }
- elseif($perms['parser_return'] == 'callback')
- {
- $rendererStates['isPost'] = ($postParams !== NULL) ? true : false;
- $rendererStates['canUseBbCode'] = false; //Default: if is not a post, no way to get this value anyway
- return $this->renderAdvancedTag($tag, $rendererStates, false);
- }
- elseif($perms['parser_return'] == 'template')
- {
- $rendererStates['isPost'] = ($postParams !== NULL) ? true : false;
- $rendererStates['canUseBbCode'] = false;
- return $this->renderTemplateTag($tag, $rendererStates, false);
- }
- return $output;
- }
- public function checkBbCodeViewPerms(array $tag, array $rendererStates)
- {
- if( !isset($this->_tags[$tag['tag']]['view_perms']) )
- {
- return true;
- }
- $perms = $this->_tags[$tag['tag']]['view_perms'];
- if($perms['can_view_content'] === true)
- {
- return true;
- }
- if( isset($perms['view_return_delay']) )
- {
- $autorisedLimit = $perms['view_return_delay'];
- $post_date = $this->getPostParam('post_date');
- if($post_date !== NULL)
- {
- $interval = XenForo_Application::$time - $post_date;
- $diff_hours = floor($interval / 3600);
- if($diff_hours < $autorisedLimit)
- {
- return true;
- }
- }
- }
- $rendererStates['canViewBbCode'] = false;
- $output = '';
- if($perms['view_return'] == 'phrase')
- {
- $output = new XenForo_Phrase('bbcm_viewer_content_protected');
- }
- elseif($perms['view_return'] == 'callback')
- {
- return $this->renderAdvancedTag($tag, $rendererStates, false);
- }
- elseif($perms['view_return'] == 'template')
- {
- return $this->renderTemplateTag($tag, $rendererStates, false);
- }
- elseif($perms['view_return'] == 'default_template')
- {
- $fallBack = new XenForo_Phrase('bbcm_viewer_content_protected');
- $templateArguments = array('phrase' => $fallBack, 'rendererStates' => $rendererStates);
- return $this->renderCustomTemplate('bbcm_viewer_content_protected', $templateArguments, $fallBack);
- }
- return $output;
- }
- /****
- * PARSER TOOLS
- ***/
- protected $_parser;
- public function getParser()
- {
- if (!isset($this->_parser))
- {
- $this->_parser = new XenForo_BbCode_Parser($this);
- }
- return $this->_parser;
- }
- public function secureBbCodesInOptions(array $options)
- {
- foreach ($options as &$option)
- {
- $option = htmlspecialchars($option);
- }
- return $options;
- }
- public function parseAndSecuriseBbCodesInOptions(array $options, $secure = true)
- {
- foreach ($options as &$option)
- {
- if($secure === true)
- {
- $option = htmlspecialchars($option); //Protection
- }
- $option = $this->ParseMyBBcodesOptions($option);
- }
- return $options;
- }
- public function ParseMyBBcodesOptions($string)
- {
- $tester = strlen($string) - strlen(strip_tags($string));
- if (empty($tester) AND preg_match('#[\[{](.+?)(?:=.+?)?[}\]].+?[{\[]/\1([}\]])#i', $string, $captures))
- {
- if(isset($captures[2]) && $captures[2] == '}')
- {
- //This is an old special tag {a}...{/a}, convert it back to a normal tag [a]...[/a]
- $string = preg_replace('#[\[{]((.+?)(?:=.+?)?)[}\]](.+?)[{\[](/\2)[}\]]#i', '[$1]$3[$4]', $string);
- }
- $parser = $this->getParser();
- $string = $parser->render($string);
- //Fix for htmlspecialchars
- $string = str_replace(array('&lt;', '&gt;', '&amp;'), array('<', '>', '&'), $string);
- }
- return $string;
- }
- /****
- * TAG ALIGN FIX @extended
- ***/
- public function renderTagAlign(array $tag, array $rendererStates)
- {
- $options = XenForo_Application::get('options');
- if(!$options->Bbcm_PatchAlignBbCode)
- {
- return parent::renderTagAlign($tag, $rendererStates);
- }
- $text = $this->renderSubTree($tag['children'], $rendererStates);
- if (trim($text) === '')
- {
- $text = '<br />';
- }
- switch (strtolower($tag['tag']))
- {
- case 'left':
- case 'center':
- case 'right':
- return '<div align="' . $tag['tag'] . '">' . $text . '</div>';
- default:
- return $text;
- }
- }
- /****
- * PRELOAD & RENDER TEMPLATES TOOL
- ***/
- protected $_preloadCustomTemplates = array();
- //@Extended
- public function preLoadTemplates(XenForo_View $view)
- {
- //Preload Custom Templates
- if($this->_view && is_array($this->_preloadCustomTemplates))
- {
- foreach($this->_preloadCustomTemplates as $templateName)
- {
- $this->_view->preLoadTemplate($templateName);
- }
- }
- return parent::preLoadTemplates($view);
- }
- protected function _preLoadTemplatesFromCallback($class, $method)
- {
- //Search if the callback has some templates to preload (from the method "preloadTemplates")
- if(method_exists($class, 'preloadTemplates'))
- {
- $templateNames = $class::preloadTemplates($method);
- if(!is_array($templateNames))
- {
- $templateNames = array($templateNames);
- }
- foreach($templateNames as $templateName)
- {
- if(!empty($templateName) && array_search($templateName, $this->_preloadCustomTemplates) === false)
- {
- $this->_preloadCustomTemplates[] = $templateName;
- }
- }
- }
- }
- public function renderCustomTemplate($templateName, array $params = array(), $fallBack = false)
- {
- if ($this->_view)
- {
- //Create and render template
- $template = $this->_view->createTemplateObject($templateName, $params);
- return $template->render();
- }
- return $fallBack;
- }
- /****
- * GET THREAD/POSTS PARAMS TOOLS
- ***/
- protected $_threadParams = null;
- protected $_postsDatas = null;
- protected $_bbCodesMap = null;
- protected $_bbCodesIncrementation = array();
- protected $_currentPostParams = null;
- //@extended
- public function setView(XenForo_View $view = null)
- {
- parent::setView($view);
- if ($view)
- {
- $params = $view->getParams();
- if(isset($params['posts']))
- {
- $this->_postsDatas = $params['posts'];
- $this->_createBbCodesMap($params['posts']);
- }
- if(isset($params['thread']))
- {
- $this->_threadParams = $params['thread'];
- }
- }
- }
- protected function _createBbCodesMap($posts = NULL)
- {
- if( $posts === NULL || !is_array($posts) )
- {
- return;
- }
- foreach($posts as $post_id => $post)
- {
- $BbCodesTree = $this->getParser()->parse($post['message']);
- $it = new RecursiveIteratorIterator( new RecursiveArrayIterator($BbCodesTree) );
- foreach ($it as $tagKey => $tagName)
- {
- if($tagKey === 'tag')
- {
- $this->_bbCodesMap[$tagName][] = $post_id;
- }
- }
- }
- if(self::$debug === true)
- {
- echo "Bb Codes Map:<br />";
- Zend_Debug::dump($this->_bbCodesMap);
- }
- }
- protected function _bakeCurrentPostParams($tag)
- {
- $id = $this->_getCurrentTagId($tag);
- $tagName = $tag['tag'];
- if( !isset($this->_bbCodesMap[$tagName][$id]) )
- {
- self::$debug_phrase_init .= (self::$debug === true) ? "According to the Tag Map, the position '$id' of the '$tag' doesn't exist<br />" : '';
- $this->_currentPostParams = NULL;
- return;
- }
- $postId = $this->_bbCodesMap[$tagName][$id];
- if ( !isset($this->_postsDatas[$postId]) )
- {
- self::$debug_phrase_init .= (self::$debug === true) ? "The post id ($id) doesn't exist<br />" : '';
- $this->_currentPostParams = NULL;
- return;
- }
- $this->_currentPostParams = $this->_postsDatas[$postId];
- $this->_debugInit($tag['tag']);
- }
- protected function _getCurrentTagId($tag)
- {
- $tagName = $tag['tag'];
- /***
- Let's implement an incrementation fix for identical nested tags
- Why? Identical Nested Tags don't recall their parse function (php/template/etc...). Only the parent tag is used.
- #Example: [hl]This is the parent tag [hl=orange]This is a identical nested tag[/hl] Back to the parent[/hl]
- If we check the renderTemplateTag, we will be able to see that the function will be only call once
- This is a problem. The function _bakeCurrentPostParams will only be launched once, so is the below incrementation.
- The ID of the Tag won't be correct anymore according to our Tags Map ($this->_bbCodesMap)
- Solution: Check the children of the tag, detect the number of identical nested tags and use it as a fix.
- **/
- $fix = 0;
- if( isset($tag['children']) )
- {
- $it = new RecursiveIteratorIterator( new RecursiveArrayIterator($tag['children']) );
- foreach ($it as $tagKey => $childTagName)
- {
- if($tagKey === 'tag')
- {
- if($childTagName === $tagName)
- {
- $fix++;
- }
- }
- }
- if($fix)
- {
- self::$debug_phrase_init .= (self::$debug === true) ? "Fix: $fix<br />" : '';
- }
- }
- //End of Fix - $fix is ready to use
- if( !isset($this->_bbCodesIncrementation[$tagName]) )
- {
- $this->_bbCodesIncrementation[$tagName] = 0;
- }
- else
- {
- $this->_bbCodesIncrementation[$tagName] = $this->_bbCodesIncrementation[$tagName]+1+$fix;
- }
- return $this->_bbCodesIncrementation[$tagName];
- }
- public function getThreadParams()
- {
- return $this->_threadParams;
- }
- public function getThreadParam($param)
- {
- if( isset($this->_threadParams[$param]) )
- {
- return $this->_threadParams[$param];
- }
- self::$debug_phrase_init .= (self::$debug === true) ? "This Thread parameter is missing: $param <br />" : '';
- return NULL;
- }
- public function getPostParams()
- {
- return $this->_currentPostParams;
- }
- public function getPostParam($param)
- {
- if( isset($this->_currentPostParams[$param]) )
- {
- return $this->_currentPostParams[$param];
- }
- if(self::$debug === true)
- {
- $callers = debug_backtrace();
- $caller = $callers[1]['function'];
- $line = $callers[1]['line'];
- self::$debug_phrase_init .= "This Post parameter is missing: $param (calling function: $caller - line:$line)<br />";
- }
- return NULL;
- }
- /****
- * Debug Module
- * Yes, it's ugly but it can help a lot when developping - will be removed if no problem occurs
- ***/
- protected static $debug = false;
- protected static $debug_phrase_init;
- protected function _debugInit($tagName)
- {
- if(self::$debug === true)
- {
- $tagId = $this->_bbCodesIncrementation[$tagName];
- $postId = $this->getPostParam('post_id');
- $debugPhrase = self::$debug_phrase_init;
- echo "The tag being processed is $tagName (ID:$tagId - Post ID:$postId)<br />$debugPhrase";
- self::$debug_phrase_init = '';
- }
- }
- }
- //Zend_Debug::dump($abc);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement