コード例 #1
2
 /**
  * Inserts tag links into an HTML-formatted text.
  *
  * @param string $html
  * @param array $tags
  * @param array $options
  * @return string
  */
 public static function autoTag($html, array $tags, array &$options = array())
 {
     if (empty($tags)) {
         return $html;
     }
     $html = strval($html);
     $htmlNullified = utf8_strtolower($html);
     $htmlNullified = preg_replace_callback('#<a[^>]+>.+?</a>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified);
     $htmlNullified = preg_replace_callback('#<[^>]+>#', array(__CLASS__, '_autoTag_nullifyHtmlCallback'), $htmlNullified);
     // prepare the options
     $onceOnly = empty($options['onceOnly']) ? false : true;
     $options['autoTagged'] = array();
     // reset this
     // sort tags with the longest one first
     // since 1.0.3
     usort($tags, array(__CLASS__, '_autoTag_sortTagsByLength'));
     foreach ($tags as $tag) {
         $offset = 0;
         $tagText = utf8_strtolower($tag['tag']);
         $tagLength = utf8_strlen($tagText);
         while (true) {
             $pos = utf8_strpos($htmlNullified, $tagText, $offset);
             if ($pos !== false) {
                 // the tag has been found
                 if (self::_autoTag_hasValidCharacterAround($html, $pos, $tagText)) {
                     // and it has good surrounding characters
                     // start replacing
                     $displayText = utf8_substr($html, $pos, $tagLength);
                     $template = new XenForo_Template_Public('tinhte_xentag_bb_code_tag_tag');
                     $template->setParam('tag', $tag);
                     $template->setParam('displayText', $displayText);
                     $replacement = $template->render();
                     if (strlen($replacement) === 0) {
                         // in case template system hasn't been initialized
                         $replacement = sprintf('<a href="%s">%s</a>', XenForo_Link::buildPublicLink('tags', $tag), $displayText);
                     }
                     $html = utf8_substr_replace($html, $replacement, $pos, $tagLength);
                     $htmlNullified = utf8_substr_replace($htmlNullified, str_repeat('_', utf8_strlen($replacement)), $pos, $tagLength);
                     // sondh@2012-09-20
                     // keep track of the auto tagged tags
                     $options['autoTagged'][$tagText][$pos] = $replacement;
                     $offset = $pos + utf8_strlen($replacement);
                     if ($onceOnly) {
                         // auto link only once per tag
                         // break the loop now
                         break;
                         // while (true)
                     }
                 } else {
                     $offset = $pos + $tagLength;
                 }
             } else {
                 // no match has been found, stop working with this tag
                 break;
                 // while (true)
             }
         }
     }
     return $html;
 }
コード例 #2
0
 public static function hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
 {
     $model = XenForo_Model::create("AssociationMc_Model_AssociationEntry");
     $entry = $model->getEntryById($hookParams['user']['user_id']);
     if ($entry != null) {
         $myTemplate = new XenForo_Template_Public("association_profile_sidebar", array("mcName" => $entry['last_username']));
         $contents .= $myTemplate->render();
     }
 }
コード例 #3
0
ファイル: Template.php プロジェクト: Sywooch/forums
 public function __construct($templateName, array $params = array())
 {
     if (self::$bdSocialShare_Helper_visitor !== null) {
         $params['visitor'] = self::$bdSocialShare_Helper_visitor;
     }
     $params['xenOptions'] = XenForo_Application::getOptions()->getOptions();
     parent::__construct(sprintf('__%s_%d_%d', $templateName, self::$bdSocialShare_Helper_styleId, self::$bdSocialShare_Helper_languageId), $params);
 }
コード例 #4
0
ファイル: Listener.php プロジェクト: Sywooch/forums
 public static function template_hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
 {
     $options = XenForo_Application::get('options');
     $enableadvxenforo = $options->enableadvxenforo;
     $thread_id = $hookParams['thread']['thread_id'];
     if ($enableadvxenforo) {
         $PermissionEnable = XenForo_Visitor::getInstance()->hasPermission('adv_xenforo', 'adv_xenforo_enable_adv') ? TRUE : FALSE;
         if ($hookName == 'account_preferences_options' && $PermissionEnable) {
             $ourTemplate = $template->create('adv_xenforo_account_options', $template->getparams());
             $rendered = $ourTemplate->render();
             $contents = $contents . $rendered;
         }
         $hasPermission = XenForo_Visitor::getInstance()->hasPermission('adv_xenforo', 'adv_xenforo_show') ? TRUE : FALSE;
         $advs = XenForo_Application::getSimpleCacheData('adv_xenforo');
         $user = XenForo_Visitor::getInstance()->toArray();
         $enable_adv = $PermissionEnable === TRUE ? $user['enable_adv'] : TRUE;
         $containerData = self::$containerData;
         if (empty(self::$containerData)) {
             $containerData = XenForo_Template_Public::getExtraContainerData();
         }
         if ($enable_adv) {
             if ($hasPermission === TRUE && $advs["AdvsHook"]) {
                 $isMobile = XenForo_Visitor::isBrowsingWith('mobile');
                 switch (TRUE) {
                     case $isMobile == TRUE:
                         $adv_adv = 'adv_small';
                         break;
                     default:
                         $adv_adv = 'adv_large';
                         break;
                 }
                 foreach ($advs["AdvsHook"] as $_asv) {
                     if ($_asv['active'] && XenForo_Helper_Criteria::userMatchesCriteria($_asv['user_criteria'], TRUE, $user) && XenForo_Helper_Criteria::pageMatchesCriteria($_asv['page_criteria'], TRUE, $template->getParams(), $containerData)) {
                         $ourTemplate = $template->create('ads_xf_ar_xenforo', array('advanced' => $_asv[$adv_adv]));
                         $rendered = $ourTemplate->render();
                         if ($hookName == 'message_content' && Turki_Adv_Helper_Criteria::postCriteria($_asv['post_criteria'], TRUE) === FALSE) {
                             if ($hookParams['message']['thread_id']) {
                                 $decode = XenForo_Helper_Criteria::prepareCriteriaForSelection($_asv['post_criteria']);
                                 $position = $decode['active']['page'] ? $hookParams['message']['position'] % $options->messagesPerPage : $hookParams['message']['position'];
                                 if ($position == $decode['active']['post_id'] - 1) {
                                     $contents = $decode['active']['position'] ? Turki_Adv_Helper_Helpers::advhtml($contents, $rendered) : $contents . $rendered;
                                 }
                             }
                         } else {
                             if ($hookName == $_asv['adv_hook_name'] && Turki_Adv_Helper_Criteria::postCriteria($_asv['post_criteria'], TRUE)) {
                                 $contents = $_asv['display'] == 'top' ? $rendered . $contents : $contents . $rendered;
                             }
                         }
                     }
                 }
             }
         }
         self::_templateHook($hookName, $contents, $hookParams, $template);
     }
 }
コード例 #5
0
ファイル: Extended.php プロジェクト: Sywooch/forums
 public static function WidgetFramework_mergeExtraContainerData(array $extraData)
 {
     if (empty($extraData)) {
         return;
     }
     if (self::$_WidgetFramework_pageContainerTemplate === null or self::$_WidgetFramework_pageContainerTemplate->getParam('contents') === null) {
         XenForo_Template_Public::$_extraData = XenForo_Application::mapMerge(XenForo_Template_Public::$_extraData, $extraData);
     } else {
         // these extra data came too late
         // page container has already started rendering...
         self::$_WidgetFramework_lateExtraData = XenForo_Application::mapMerge(self::$_WidgetFramework_lateExtraData, $extraData);
     }
 }
コード例 #6
0
ファイル: Template.php プロジェクト: billyprice1/bdApi
 public function __construct($templateName, array $params = array())
 {
     if (self::$bdApi_visitor !== null) {
         $params['visitor'] = self::$bdApi_visitor;
     }
     $languageId = 0;
     if (!empty($params['visitor']['language_id'])) {
         $languageId = $params['visitor']['language_id'];
     }
     if (empty($languageId)) {
         $languageId = XenForo_Application::getOptions()->get('defaultLanguageId');
     }
     $params['xenOptions'] = XenForo_Application::getOptions()->getOptions();
     parent::__construct(sprintf('__%s_%d', $templateName, $languageId), $params);
 }
コード例 #7
0
ファイル: XenForoSDK.php プロジェクト: nickcuper/xenforo-sdk
 public function renderTemplate($name, $params = array(), $styleId = null, $languageId = null)
 {
     // user
     $user = $this->getUser();
     // Template
     $template = new XenForo_Template_Public($name, $params);
     $template->setStyleId($styleId !== null ? $styleId : $user['style_id']);
     $template->setLanguageId($languageId !== null ? $languageId : $user['language_id']);
     return $template->render();
 }
コード例 #8
0
 public static function hookRight($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
 {
     $myTemplate = new XenForo_Template_Public("association_visitor_right", $hookParams);
     $contents .= $myTemplate->render();
 }
コード例 #9
0
ファイル: Integration.php プロジェクト: Sywooch/forums
 /**
  * Inserts tag links into an HTML-formatted text.
  *
  * @param string $html
  * @param array $tags
  * @param array $options
  */
 public static function autoTag($html, array $tagsOrTexts, array &$options = array())
 {
     if (empty($tagsOrTexts)) {
         return $html;
     }
     $html = strval($html);
     $tagTexts = Tinhte_XenTag_Helper::getTextsFromTagsOrTexts($tagsOrTexts);
     // prepare the options
     $onceOnly = empty($options['onceOnly']) ? false : true;
     $options['autoTagged'] = array();
     // reset this
     // sort tags with the longest one first
     // since 1.0.3
     usort($tagTexts, array(__CLASS__, '_autoTag_sortTagsByLength'));
     foreach ($tagTexts as $tagText) {
         $offset = 0;
         $tagLength = utf8_strlen($tagText);
         while (true) {
             $pos = Tinhte_XenTag_Helper::utf8_stripos($html, $tagText, $offset);
             if ($pos !== false) {
                 // the tag has been found
                 if (!self::_autoTag_isBetweenHtmlTags($html, $pos) and self::_autoTag_hasValidCharacterAround($html, $pos, $tagText)) {
                     // and it's not between HTML tags,
                     // with good surrounding characters
                     // start replacing
                     $template = new XenForo_Template_Public('tinhte_xentag_bb_code_tag_tag');
                     $template->setParam('tag', $tagText);
                     $template->setParam('displayText', utf8_substr($html, $pos, $tagLength));
                     $replacement = $template->render();
                     $html = utf8_substr_replace($html, $replacement, $pos, $tagLength);
                     // sondh@2012-09-20
                     // keep track of the auto tagged tags
                     $options['autoTagged'][$tagText][$pos] = $replacement;
                     $offset = $pos + utf8_strlen($replacement);
                     if ($onceOnly) {
                         // auto link only once per tag
                         // break the loop now
                         break;
                         // while (true)
                     }
                 } else {
                     $offset = $pos + $tagLength;
                 }
             } else {
                 // no match has been found, stop working with this tag
                 break;
                 // while (true)
             }
         }
     }
     return $html;
 }
コード例 #10
0
ファイル: Public.php プロジェクト: namgiangle90/tokyobaito
 /**
  * Resets the template system state.
  */
 public static function reset()
 {
     self::$_templateCache = array();
     self::$_toLoad = array();
 }
コード例 #11
0
ファイル: CssOutput.php プロジェクト: Sywooch/forums
 /**
  * Does any preparations necessary for outputting to be done.
  */
 protected function _prepareForOutput()
 {
     $this->_displayStyles = XenForo_Application::get('displayStyles');
     $styles = XenForo_Application::get('styles');
     $smilieSprites = XenForo_Model::create('XenForo_Model_DataRegistry')->get('smilieSprites');
     if (is_array($smilieSprites)) {
         $this->_smilieSprites = $smilieSprites;
     }
     if ($this->_styleId && isset($styles[$this->_styleId])) {
         $style = $styles[$this->_styleId];
     } else {
         $style = reset($styles);
     }
     if ($style) {
         $properties = unserialize($style['properties']);
         $this->_styleId = $style['style_id'];
         $this->_styleModifiedDate = $style['last_modified_date'];
     } else {
         $properties = array();
         $this->_styleId = 0;
     }
     $defaultProperties = XenForo_Application::get('defaultStyleProperties');
     XenForo_Template_Helper_Core::setStyleProperties(XenForo_Application::mapMerge($defaultProperties, $properties), false);
     XenForo_Template_Public::setStyleId($this->_styleId);
     XenForo_Template_Abstract::setLanguageId(0);
 }
コード例 #12
0
ファイル: Public.php プロジェクト: darkearl/projectT122015
 /**
  * Performs any pre-view rendering setup, such as getting style information and
  * ensuring the correct data is registered.
  *
  * @param XenForo_ControllerResponse_Abstract|null $controllerResponse
  */
 public function preRenderView(XenForo_ControllerResponse_Abstract $controllerResponse = null)
 {
     parent::preRenderView($controllerResponse);
     if (!empty($this->_viewStateChanges['styleId'])) {
         $styleId = $this->_viewStateChanges['styleId'];
         $forceStyleId = true;
     } else {
         $user = XenForo_Visitor::getInstance();
         $styleId = !empty($user['style_id']) ? $user['style_id'] : 0;
         $forceStyleId = $user['is_admin'] ? true : false;
     }
     XenForo_Template_Abstract::setLanguageId(XenForo_Phrase::getLanguageId());
     $styles = XenForo_Application::isRegistered('styles') ? XenForo_Application::get('styles') : XenForo_Model::create('XenForo_Model_Style')->getAllStyles();
     if ($styleId && isset($styles[$styleId]) && ($styles[$styleId]['user_selectable'] || $forceStyleId)) {
         $style = $styles[$styleId];
     } else {
         $defaultStyleId = XenForo_Application::get('options')->defaultStyleId;
         $style = isset($styles[$defaultStyleId]) ? $styles[$defaultStyleId] : reset($styles);
     }
     $defaultProperties = XenForo_Application::get('defaultStyleProperties');
     if ($style) {
         $properties = XenForo_Helper_Php::safeUnserialize($style['properties']);
         XenForo_Template_Helper_Core::setStyleProperties(XenForo_Application::mapMerge($defaultProperties, $properties));
         XenForo_Template_Public::setStyleId($style['style_id']);
     } else {
         XenForo_Template_Helper_Core::setStyleProperties($defaultProperties);
     }
     // setup the default template params
     if ($style) {
         $this->_defaultTemplateParams['visitorStyle'] = $style;
     }
     // expose the user fields info array
     $this->_defaultTemplateParams['userFieldsInfo'] = XenForo_Application::get('userFieldsInfo');
 }
コード例 #13
0
ファイル: CssOutput.php プロジェクト: hahuunguyen/DTUI_201105
 /**
  * Does any preperations necessary for outputting to be done.
  */
 protected function _prepareForOutput()
 {
     $cacheData = XenForo_Model::create('XenForo_Model_DataRegistry')->getMulti(array('styles', 'displayStyles', 'options'));
     if (is_array($cacheData['displayStyles'])) {
         $this->_displayStyles = $cacheData['displayStyles'];
     }
     $styles = $cacheData['styles'];
     if (!is_array($styles)) {
         $styles = XenForo_Model::create('XenForo_Model_Style')->rebuildStyleCache();
     }
     if (!is_array($cacheData['options'])) {
         $cacheData['options'] = XenForo_Model::create('XenForo_Model_Option')->rebuildOptionCache();
     }
     $options = new XenForo_Options($cacheData['options']);
     XenForo_Application::setDefaultsFromOptions($options);
     XenForo_Application::set('options', $options);
     if ($this->_styleId && isset($styles[$this->_styleId])) {
         $style = $styles[$this->_styleId];
     } else {
         $style = reset($styles);
     }
     if ($style) {
         $properties = unserialize($style['properties']);
         $this->_styleId = $style['style_id'];
         $this->_styleModifiedDate = $style['last_modified_date'];
     } else {
         $properties = array();
         $this->_styleId = 0;
     }
     XenForo_Template_Helper_Core::setStyleProperties($properties, false);
     XenForo_Template_Public::setStyleId($this->_styleId);
     XenForo_Template_Abstract::setLanguageId(0);
 }
コード例 #14
0
ファイル: 20130522.php プロジェクト: ThemeHouse-XF/SvgOutputa
 /**
  * Does any preperations necessary for outputting to be done.
  */
 protected function _prepareForOutput()
 {
     $styles = XenForo_Application::get('styles');
     if ($this->_styleId && isset($styles[$this->_styleId])) {
         $style = $styles[$this->_styleId];
     } else {
         $style = reset($styles);
     }
     if ($style) {
         $properties = unserialize($style['properties']);
         $this->_styleId = $style['style_id'];
         $this->_styleModifiedDate = $style['last_modified_date'];
     } else {
         $properties = array();
         $this->_styleId = 0;
     }
     $languages = XenForo_Application::get('languages');
     if ($this->_languageId && isset($languages[$this->_languageId])) {
         $language = $languages[$this->_languageId];
     } else {
         $language = reset($languages);
     }
     if ($language) {
         $this->_textDirection = $language['text_direction'];
         $this->_languageId = $language['language_id'];
     } else {
         $this->_textDirection = 'LTR';
         $this->_languageId = 0;
     }
     XenForo_Template_Helper_Core::setStyleProperties($properties, false);
     XenForo_Template_Public::setStyleId($this->_styleId);
     XenForo_Template_Abstract::setLanguageId($this->_languageId);
 }