Exemplo n.º 1
0
 public function parseOptionsInput(XenForo_Input $input, array $widget)
 {
     $options = parent::parseOptionsInput($input, $widget);
     $options['html'] = null;
     $options['_text'] = $input->filterSingle(self::getNamePrefix() . 'text', XenForo_Input::STRING);
     return $options;
 }
Exemplo n.º 2
0
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title'])) {
         return new XenForo_Phrase('tinhte_xentag_tag_cloud');
     }
     return parent::extraPrepareTitle($widget);
 }
Exemplo n.º 3
0
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title'])) {
         return new XenForo_Phrase('staff_online_now');
     }
     return parent::extraPrepareTitle($widget);
 }
Exemplo n.º 4
0
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title'])) {
         return new XenForo_Phrase('share_this_page');
     }
     return parent::extraPrepareTitle($widget);
 }
 protected function _getExtraDataLink(array $widget)
 {
     if (XenForo_Application::$versionId > 1040000) {
         return XenForo_Link::buildPublicLink('find-new/profile-posts');
     }
     return parent::_getExtraDataLink($widget);
 }
Exemplo n.º 6
0
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title'])) {
         return new XenForo_Phrase('xengallery_recent_albums');
     }
     return parent::extraPrepareTitle($widget);
 }
Exemplo n.º 7
0
 public function renderOptions(XenForo_ViewRenderer_Abstract $viewRenderer, array &$templateParams)
 {
     $response = parent::renderOptions($viewRenderer, $templateParams);
     // hide the expression field
     $templateParams['options_loaded'] = '';
     return $response;
 }
Exemplo n.º 8
0
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title'])) {
         return new XenForo_Phrase('wf_users_find');
     }
     return parent::extraPrepareTitle($widget);
 }
Exemplo n.º 9
0
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title'])) {
         return new XenForo_Phrase('forum_statistics');
     }
     return parent::extraPrepareTitle($widget);
 }
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title'])) {
         return new XenForo_Phrase('xengallery_top_contributors');
     }
     return parent::extraPrepareTitle($widget);
 }
Exemplo n.º 11
0
 public function parseOptionsInput(XenForo_Input $input, array $widget)
 {
     //        $options = XenForo_Application::get('options');
     //        $found = $options->EWRmedio_mediacount;
     if (!($addon = XenForo_Model::create('XenForo_Model_AddOn')->getAddOnById('EWRmedio')) || empty($addon['active'])) {
         throw new XenForo_Exception(new XenForo_Phrase('wf_x_not_installed', array('target' => 'EWRmedio')), true);
     }
     return parent::parseOptionsInput($input, $widget);
 }
Exemplo n.º 12
0
 public function useUserCache(array $widget)
 {
     if (!empty($widget['options']['as_guest'])) {
         // using guest permission
         // there is no reason to use the user cache
         return false;
     }
     return parent::useUserCache($widget);
 }
Exemplo n.º 13
0
 public function prepare()
 {
     if ($this->_prepared === false) {
         if (!empty($this->_renderer)) {
             $this->_prepared = $this->_renderer->extraPrepareTitle($this->_widget);
         } else {
             $this->_prepared = new XenForo_Phrase('wf_unknown_renderer', array('class' => $this->_widget['class']));
         }
     }
 }
Exemplo n.º 14
0
 public function parseOptionsInput(XenForo_Input $input, array $widget)
 {
     $options = parent::parseOptionsInput($input, $widget);
     $class = $options['callback_class'];
     $method = $options['callback_method'];
     if (!XenForo_Application::autoload($class) || !method_exists($class, $method)) {
         throw new XenForo_Exception(new XenForo_Phrase('please_enter_valid_callback_method'), true);
     }
     return $options;
 }
Exemplo n.º 15
0
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title']) and isset(self::$_extraContainerDatas[$widget['widget_id']])) {
         $extraContainerData = self::$_extraContainerDatas[$widget['widget_id']];
         if (isset($extraContainerData['title'])) {
             return $extraContainerData['title'];
         }
     }
     return parent::extraPrepareTitle($widget);
 }
Exemplo n.º 16
0
 protected function _validateOptionValue($optionKey, &$optionValue)
 {
     switch ($optionKey) {
         case 'limit':
             if (empty($optionValue)) {
                 $optionValue = 0;
             }
             break;
     }
     return parent::_validateOptionValue($optionKey, $optionValue);
 }
Exemplo n.º 17
0
 public static function template_post_render($templateName, &$output, array &$containerData, XenForo_Template_Abstract $template)
 {
     if (defined('WIDGET_FRAMEWORK_LOADED')) {
         if ($templateName != 'wf_widget_wrapper') {
             $rendered = WidgetFramework_Core::getInstance()->renderWidgetsFor($templateName, $template->getParams(), $template, $containerData);
             if ($rendered) {
                 // get a copy of container data for widget rendered
                 $positionCode = $template->getParam(WidgetFramework_Core::PARAM_POSITION_CODE);
                 if ($positionCode !== null) {
                     WidgetFramework_WidgetRenderer::setContainerData($template->getParam('widget'), $containerData);
                 }
                 if (!isset($containerData[WidgetFramework_Core::PARAM_TEMPLATE_OBJECTS])) {
                     $containerData[WidgetFramework_Core::PARAM_TEMPLATE_OBJECTS] = array();
                 }
                 $containerData[WidgetFramework_Core::PARAM_TEMPLATE_OBJECTS][$templateName] = $template;
             }
         }
         if (self::$_saveLayoutEditorRendered) {
             switch ($templateName) {
                 case 'wf_widget_wrapper':
                 case 'wf_layout_editor_widget_wrapper':
                     $normalizedGroupId = $template->getParam('normalizedGroupId');
                     if (!empty($normalizedGroupId)) {
                         self::$_layoutEditorRendered[$normalizedGroupId] = $output;
                     }
                     $tabs = $template->getParam('tabs');
                     foreach ($tabs as $tab) {
                         if (!empty($normalizedGroupId)) {
                             self::$_layoutEditorRendered[$tab['widget_id']] = array('normalizedGroupId' => $normalizedGroupId);
                         } else {
                             self::$_layoutEditorRendered[$tab['widget_id']] = $output;
                         }
                     }
                     break;
                 case 'wf_layout_editor_widget':
                     $widget = $template->getParam('widget');
                     self::$_layoutEditorRendered[$widget['widget_id']] = $output;
                     break;
             }
         }
         if ($templateName === 'PAGE_CONTAINER') {
             WidgetFramework_Template_Extended::WidgetFramework_processLateExtraData($output, $containerData, $template);
             if (!empty(self::$_navigationTabsForums)) {
                 $output = str_replace('<!-- navigation_tabs_forums for wf_home_navtab_links -->', self::$_navigationTabsForums, $output);
             }
         }
     }
 }
Exemplo n.º 18
0
 public function render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $template, &$output)
 {
     $rendered = parent::render($widget, $positionCode, $params, $template, $output);
     if ($rendered === self::RENDERED) {
         // only work if the normal rendering routine runs throughly
         // this is done to make sure conditional is tested properly
         // since 1.2.1
         $rendered = $output = '';
         if (!empty($widget['options']['noVisitorPanel'])) {
             if (!defined(WidgetFramework_Core::NO_VISITOR_PANEL_FLAG)) {
                 define(WidgetFramework_Core::NO_VISITOR_PANEL_FLAG, true);
             }
             $output .= WidgetFramework_Core::NO_VISITOR_PANEL_MARKUP;
         }
     }
     return $rendered;
 }
Exemplo n.º 19
0
 protected function _renderOptions(XenForo_Template_Abstract $template)
 {
     $existingCategoryIds = array();
     $existingOptions = $template->getParam('options');
     if (!empty($existingOptions['categoryIds'])) {
         $existingCategoryIds = $existingOptions['categoryIds'];
     }
     /** @var XenGallery_Model_Category $categoryModel */
     $categoryModel = WidgetFramework_Core::getInstance()->getModelFromCache('XenGallery_Model_Category');
     $rows = $categoryModel->getCategoryStructure();
     $categories = array();
     foreach ($rows as $category) {
         $categories[] = array('value' => $category['category_id'], 'label' => $category['category_title'], 'depth' => $category['depth'], 'selected' => in_array($category['category_id'], $existingCategoryIds));
     }
     $template->setParam('categories', $categories);
     return parent::_renderOptions($template);
 }
Exemplo n.º 20
0
 public function extraPrepareTitle(array $widget)
 {
     if (empty($widget['title'])) {
         return new XenForo_Phrase('wf_online_users');
     }
     $preparedTitle = parent::extraPrepareTitle($widget);
     if ($preparedTitle instanceof XenForo_Phrase) {
         $onlineUsers = $this->_getOnlineUsers();
         $params = $preparedTitle->getParams();
         foreach ($onlineUsers as $key => $value) {
             if (is_numeric($value)) {
                 $params[$key] = XenForo_Template_Helper_Core::numberFormat($value);
             }
         }
         $preparedTitle->setParams($params);
     }
     return $preparedTitle;
 }
Exemplo n.º 21
0
 protected function _validateOptionValue($optionKey, &$optionValue)
 {
     switch ($optionKey) {
         case 'limit':
             if (empty($optionValue)) {
                 $optionValue = 5;
             }
             break;
         case 'order':
             if (empty($optionValue)) {
                 $optionValue = 'register_date';
             }
             break;
         case 'direction':
             if (empty($optionValue)) {
                 $optionValue = 'DESC';
             }
             break;
     }
     return parent::_validateOptionValue($optionKey, $optionValue);
 }
Exemplo n.º 22
0
 protected function _validateOptionValue($optionKey, &$optionValue)
 {
     switch ($optionKey) {
         case 'thread_id':
             if (!empty($optionValue)) {
                 $optionValue = strtolower($optionValue);
                 if ($optionValue === 'random') {
                     // random mode
                 } else {
                     $threadModel = XenForo_Model::create('XenForo_Model_Thread');
                     $thread = $threadModel->getThreadById($optionValue);
                     if (empty($thread)) {
                         throw new XenForo_Exception(new XenForo_Phrase('requested_thread_not_found'), true);
                     } elseif (empty($thread['discussion_type']) or 'poll' != $thread['discussion_type']) {
                         throw new XenForo_Exception(new XenForo_Phrase('wf_requested_thread_does_not_have_poll'), true);
                     }
                 }
             }
             break;
     }
     return parent::_validateOptionValue($optionKey, $optionValue);
 }
 public static function getViewObject(array $params, XenForo_Template_Abstract $templateObj)
 {
     if (isset($params[WidgetFramework_Core::PARAM_VIEW_OBJECT])) {
         return $params[WidgetFramework_Core::PARAM_VIEW_OBJECT];
     }
     $viewObj = $templateObj->getParam(WidgetFramework_Core::PARAM_VIEW_OBJECT);
     if (!empty($viewObj)) {
         return $viewObj;
     }
     if (empty(self::$_pseudoViewObj)) {
         if (!empty(WidgetFramework_Listener::$fc) and !empty(WidgetFramework_Listener::$viewRenderer)) {
             if (WidgetFramework_Listener::$viewRenderer instanceof XenForo_ViewRenderer_HtmlPublic) {
                 self::$_pseudoViewObj = new XenForo_ViewPublic_Base(WidgetFramework_Listener::$viewRenderer, WidgetFramework_Listener::$fc->getResponse());
             }
         }
     }
     if (!empty(self::$_pseudoViewObj)) {
         return self::$_pseudoViewObj;
     }
     if (WidgetFramework_Core::debugMode()) {
         // log the exception for admin examination (in our debug mode only)
         XenForo_Error::logException(new XenForo_Exception(sprintf('Unable to get view object for %s', $templateObj->getTemplateName())), false, '[bd] Widget Framework');
     }
     return null;
 }
Exemplo n.º 24
0
 /**
  * @return WidgetFramework_WidgetRenderer
  */
 public static function getRenderer($class, $throw = true)
 {
     $instance = self::getInstance();
     try {
         if (in_array($class, $instance->_renderers)) {
             if (!isset(self::$_rendererInstances[$class])) {
                 self::$_rendererInstances[$class] = WidgetFramework_WidgetRenderer::create($class);
             }
             return self::$_rendererInstances[$class];
         } elseif ($class == 'WidgetFramework_WidgetRenderer_None') {
             return WidgetFramework_WidgetRenderer::create($class);
         } else {
             if ($throw) {
                 throw new XenForo_Exception(new XenForo_Phrase('wf_invalid_widget_renderer_x', array('renderer' => $class)), true);
             }
         }
     } catch (Exception $e) {
         if ($throw) {
             throw $e;
         } else {
             return false;
         }
     }
 }
Exemplo n.º 25
0
 protected function _getCacheId(array $widget, $positionCode, array $params, array $suffix = array())
 {
     if (isset($params['thread']) and !empty($params['thread']['thread_id'])) {
         $suffix[] = 't' . $params['thread']['thread_id'];
     } elseif (isset($params['page']) and !empty($params['page']['node_id'])) {
         $suffix[] = 'p' . $params['page']['node_id'];
     } elseif (isset($params['forum']) and !empty($params['forum']['node_id'])) {
         $suffix[] = 'f' . $params['forum']['node_id'];
     } elseif (isset($params['resource']) and !empty($params['resource']['resource_id'])) {
         $suffix[] = 'r' . $params['resource']['resource_id'];
     }
     return parent::_getCacheId($widget, $positionCode, $params, $suffix);
 }
Exemplo n.º 26
0
 protected function _getCacheId(array $widget, $positionCode, array $params, array $suffix = array())
 {
     if ($this->_helperDetectSpecialForums($widget['options']['forums'])) {
         // we have to use special cache id when special forum ids are used
         if (isset($params['forum'])) {
             $suffix[] = 'f' . $params['forum']['node_id'];
         }
     }
     return parent::_getCacheId($widget, $positionCode, $params, $suffix);
 }
Exemplo n.º 27
0
 protected function _getAjaxLoadParams(array $widget, $positionCode, array $params, XenForo_Template_Abstract $template)
 {
     $ajaxLoadParams = parent::_getAjaxLoadParams($widget, $positionCode, $params, $template);
     if ($this->_helperDetectSpecialForums($widget['options']['forums'])) {
         $forumIds = $this->_helperGetForumIdsFromOption($widget['options']['forums'], $params, empty($widget['options']['as_guest']) ? false : true);
         $ajaxLoadParams['forumIds'] = $forumIds;
     }
     return $ajaxLoadParams;
 }
Exemplo n.º 28
0
 public static function front_controller_pre_view(XenForo_FrontController $fc, XenForo_ControllerResponse_Abstract &$controllerResponse, XenForo_ViewRenderer_Abstract &$viewRenderer, array &$containerParams)
 {
     self::$fc = $fc;
     self::$viewRenderer = $viewRenderer;
     if ($viewRenderer instanceof XenForo_ViewRenderer_HtmlPublic) {
         WidgetFramework_Core::getInstance()->bootstrap();
     }
     if (defined('WIDGET_FRAMEWORK_LOADED')) {
         if ($controllerResponse instanceof XenForo_ControllerResponse_View) {
             WidgetFramework_WidgetRenderer::markTemplateToProcess($controllerResponse);
         }
     }
 }
 protected function _getCacheId(array $widget, $positionCode, array $params, array $suffix = array())
 {
     if (!empty($widget['options']['forums'])) {
         $forumIds = $this->_helperGetForumIdsFromOption($widget['options']['forums'], $params, true);
         if (!empty($forumIds)) {
             $suffix[] = md5(serialize($forumIds));
         }
     }
     return parent::_getCacheId($widget, $positionCode, $params, $suffix);
 }
Exemplo n.º 30
0
 /**
  * @param string $class
  * @param bool $throw
  * @throws Exception
  * @return WidgetFramework_WidgetRenderer
  */
 public static function getRenderer($class, $throw = true)
 {
     try {
         if (!isset(self::$_rendererInstances[$class])) {
             self::$_rendererInstances[$class] = WidgetFramework_WidgetRenderer::create($class);
         }
         return self::$_rendererInstances[$class];
     } catch (Exception $e) {
         if ($throw) {
             throw $e;
         }
     }
     return null;
 }