Exemple #1
0
 public static function template_hook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
 {
     switch ($hookName) {
         case 'page_container_content_top':
         case 'page_container_content_title_bar':
         case 'forum_list_nodes':
             // check to see if we should work on this hook
             $position = VietXfAdvStats_Option::get('position');
             if (strpos($position, $hookName) === 0) {
                 // our position is set to this hook position
                 // now we will check to see if it's "above" or "below"
                 $relativePosition = trim(substr($position, strlen($hookName)), '_');
                 switch ($relativePosition) {
                     case 'above':
                         $contents = self::POSITION_PLACE_HOLDER . $contents;
                         break;
                     default:
                         // if it's not above, it's definitely below!
                         $contents .= self::POSITION_PLACE_HOLDER;
                 }
                 define(self::POSITION_READY_FLAG, true);
             }
             break;
         case 'vietxf_advanced_forum_statistics':
             // this is our special hook
             // $contents = self::POSITION_PLACE_HOLDER; // should we use this instead?
             $contents .= self::POSITION_PLACE_HOLDER;
             define(self::POSITION_READY_FLAG, true);
             break;
     }
 }
Exemple #2
0
 protected static function _prepareSectionForWrapper(array $sectionRaw, array $autoRenderData = array())
 {
     $section = array();
     // prepare common info
     $typeEscaped = self::_escapeTypeString($sectionRaw['type']);
     // finished common info
     $section['section_id'] = self::_getUniqueId($typeEscaped);
     if (!empty($sectionRaw['title'])) {
         $section['section_title'] = $sectionRaw['title'];
     } else {
         $section['section_title'] = new XenForo_Phrase('VietXfAdvStats_section_' . $sectionRaw['type']);
     }
     // prepare link
     $routePrefix = VietXfAdvStats_Option::get('routePrefix');
     $linkAction = $typeEscaped;
     $linkParams = array();
     // prepare link detail
     $typeParts = explode('_', $sectionRaw['type']);
     $typeMajor = array_shift($typeParts);
     $section['section_type'] = $sectionRaw['type'];
     $section['section_type_major'] = $typeMajor;
     switch ($typeMajor) {
         case 'threads':
             $viewableNodes = self::getSharedData(self::SHARED_DATA_VIEWABLE_NODES);
             if (!empty($sectionRaw['forum_id'])) {
                 // this is a custom section, include selected node and its children only
                 $nodeIds = self::getNodeIds($viewableNodes, $sectionRaw['forum_id']);
                 $linkParams['node_ids'] = implode(',', $nodeIds);
                 $linkParams['section_forum_id'] = $sectionRaw['forum_id'];
                 if (!empty($nodeIds) && empty($sectionRaw['title']) && !is_array($sectionRaw['forum_id'])) {
                     $section['section_title'] = $viewableNodes[$sectionRaw['forum_id']]['title'];
                 }
             } else {
                 // include all nodes
                 $linkParams['node_ids'] = implode(',', array_keys($viewableNodes));
             }
             break;
     }
     if (!empty($linkParams['node_ids'])) {
         $linkParams['hash'] = self::calcHash(explode(',', $linkParams['node_ids']));
     }
     // finished link detail
     $section['section_link'] = XenForo_Link::buildPublicLink($routePrefix . '/' . $linkAction, array(), $linkParams);
     // finished link
     // try to render the section immediately
     if (!empty($autoRenderData['template'])) {
         $section['rendered'] = self::renderSection($section['section_type_major'], $section['section_type'], $linkAction, $linkParams, $autoRenderData['template']);
     }
     return $section;
 }