Esempio n. 1
0
 /** Returns a reference to the singleton instance of this class
  *
  *	@return	mixed	reference to the vB5_Template_NodeText object
  *
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Esempio n. 2
0
 /**
  * Fetch node's preview
  *
  */
 public function actionFetchNodePreview()
 {
     $preview = '';
     $nodeid = isset($_REQUEST['nodeid']) ? intval($_REQUEST['nodeid']) : array();
     if (!empty($nodeid)) {
         if (!vb::getUserContext()->getChannelPermission('forumpermissions', 'canviewthreads', $nodeid)) {
             return '';
         }
         $contenttypes = vB_Types::instance()->getContentTypes();
         $typelist = array();
         foreach ($contenttypes as $key => $type) {
             $typelist[$type['id']] = $key;
         }
         $api = Api_InterfaceAbstract::instance();
         $contentTypes = array('vBForum_Text', 'vBForum_Gallery', 'vBForum_Poll', 'vBForum_Video', 'vBForum_Link');
         $nodes = $api->callApi('node', 'getNodeContent', array($nodeid));
         $node = $nodes[$nodeid];
         $contentType = $typelist[$node['contenttypeid']];
         if (in_array($contentType, $contentTypes)) {
             $preview = vB5_Template_NodeText::instance()->fetchOneNodePreview($nodeid, $api);
         }
         $previewLength = vB5_Template_Options::instance()->get('options.threadpreview');
         if (strlen($preview) > $previewLength) {
             $preview = substr($preview, 0, $previewLength);
         }
     }
     return $preview;
 }
Esempio n. 3
0
 /** gets a single page title.
  */
 public function fetchArticlePaging($nodeid)
 {
     return vB5_Template_NodeText::instance()->fetchArticlePaging($nodeid);
 }
Esempio n. 4
0
 /**
  * Handle any delayed rendering. Currently delayed urls and node texts.
  *
  * @param	string
  * @param	boolean	true if we are rendering for a call to /ajax/render/ and we want CSS <link>s separate
  *
  * @return	string
  */
 protected function renderDelayed(&$final_rendered_orig, $isAjaxTemplateRender = false)
 {
     $javascript = vB5_Template_Javascript::instance();
     $javascript->insertJs($final_rendered_orig);
     $javascript->resetPending();
     $stylesheet = vB5_Template_Stylesheet::instance();
     $stylesheet->insertCss($final_rendered_orig, $isAjaxTemplateRender);
     $stylesheet->resetPending();
     $link = vB5_Template_Headlink::instance();
     $link->insertLinks($final_rendered_orig);
     $link->resetPending();
     $phrase = vB5_Template_Phrase::instance();
     $phrase->replacePlaceholders($final_rendered_orig);
     $phrase->resetPending();
     // we do not reset pending urls, since they may be required by nodetext
     vB5_Template_Url::instance()->replacePlaceholders($final_rendered_orig);
     $nodeText = vB5_Template_NodeText::instance();
     $nodeText->replacePlaceholders($final_rendered_orig);
     $nodeText->resetPending();
     $templateCache = vB5_Template_Cache::instance();
     $templateCache->replaceTextOnly($final_rendered_orig);
     //We should keep the debug info for truly last.
     if (vB5_Frontend_Controller_Bbcode::needDebug()) {
         $config = vB5_Config::instance();
         if (!$config->debug) {
             return $final_rendered_orig;
         }
         self::$renderedTemplateNames[] = 'debug_info';
         self::$renderedTemplates[] = array('templateName' => 'debug_info', 'isParentTemplate' => (bool) 0, 'indent' => str_repeat('|----', 2));
         $user = vB5_User::instance();
         $this->register('user', $user, true);
         extract(self::$globalRegistered, EXTR_SKIP | EXTR_REFS);
         extract($this->registered, EXTR_OVERWRITE | EXTR_REFS);
         $vboptions = vB5_Template_Options::instance()->getOptions();
         $vboptions = $vboptions['options'];
         $renderedTemplates = array('count' => count(self::$renderedTemplates), 'countUnique' => count(array_unique(self::$renderedTemplateNames)), 'templates' => self::$renderedTemplates, 'styleid' => vB5_Template_Stylevar::instance()->getPreferredStyleId());
         $cssDebugLog = vB5_Template_Stylesheet::getDebugLog();
         $jsDebugLog = vB5_Template_Javascript::instance()->getDebugLog();
         $templateCode = $templateCache->getTemplate('debug_info');
         if ($templateCache->isTemplateText()) {
             @eval($templateCode);
         } else {
             @(include $templateCode);
         }
         $phrase->replacePlaceholders($final_rendered);
         $phrase->resetPending();
         $final_rendered_orig = str_replace('<!-DebugInfo-->', $final_rendered, $final_rendered_orig);
     }
 }
Esempio n. 5
0
 /** This gets nodeText for a single node.
  **/
 public function actionfetchtext()
 {
     if (empty($_REQUEST['nodeid']) or !intval($_REQUEST['nodeid'])) {
         return '';
     }
     $api = Api_InterfaceAbstract::instance();
     $nodeHandler = vB5_Template_NodeText::instance();
     $nodeText = $nodeHandler->fetchOneNodeText(intval($_REQUEST['nodeid']), $api);
     if (empty($nodeText)) {
         return '';
     }
     $this->sendAsJson(array('nodeText' => $nodeText));
 }