コード例 #1
0
ファイル: MediaCloudWidget.php プロジェクト: Sywooch/forums
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
 {
     $mediaCloudModel = XenForo_Model::create('EWRmedio_Model_Keywords');
     //		$model = XenForo_Model::create('EWRporta_Model_Options');
     //		$option = $model->getOptionById('MediaCloud');
     $options = XenForo_Application::get('options');
     $sidebar['keywords'] = $mediaCloudModel->getKeywordCloud($options->EWRmedio_cloudcount, $options->EWRmedio_mincloud, $options->EWRmedio_maxcloud);
     if ($options->EWRmedio_animatedcloud && $sidebar['keywords']) {
         $sidebar['animated'] = $mediaCloudModel->getAnimatedCloud($sidebar['keywords']);
     }
     /*		$limit = $option['limit'];
     		$mincloud = $option['mincloud'];
     		$maxcloud = $option['maxcloud'];
     		$animated = $option['animated'];
     		
     		$cloud['keywords'] = $mediaCloudModel->getKeywordCloud($limit, $mincloud, $maxcloud);
     
     		if ($animated && $cloud['keywords'])
     		{
     			$cloud['animated'] = $mediaCloudModel->getAnimatedCloud($cloud['keywords']);
     		}*/
     $viewParams = array('MediaCloud' => $sidebar);
     $renderTemplateObject->setParams($viewParams);
     return $renderTemplateObject->render();
 }
コード例 #2
0
ファイル: ShareThisPage.php プロジェクト: Sywooch/forums
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
 {
     $renderTemplateObject->setParams($params);
     if (!isset($params['url'])) {
         // try to detect the correct url for different templates
         $autoDetectedUrl = false;
         switch ($positionCode) {
             case 'forum_list':
                 $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:forums');
                 break;
             case 'forum_view':
                 $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:forums', $params['forum']);
                 break;
             case 'member_view':
                 // this widget on member_view, seriously?
                 $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:members', $params['user']);
                 break;
             case 'resource_author_view':
                 $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:resources/authors', $params['user']);
                 break;
             case 'resource_view':
                 $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:resources', $params['resource']);
                 break;
             case 'thread_view':
                 $autoDetectedUrl = XenForo_Link::buildPublicLink('canonical:threads', $params['thread']);
                 break;
         }
         if ($autoDetectedUrl !== false) {
             $renderTemplateObject->setParam('url', $autoDetectedUrl);
         }
     }
     return $renderTemplateObject->render();
 }
コード例 #3
0
ファイル: Alt.php プロジェクト: VoDongMy/xenforo-laravel5.1
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
 {
     $params = $renderTemplateObject->getParams();
     $params['taigachat']['alt'] = true;
     $params['taigachat_alt'] = true;
     $renderTemplateObject->setParams($params);
     return $renderTemplateObject->render();
 }
コード例 #4
0
ファイル: Photo.php プロジェクト: Sywooch/forums
 /**
  * @param array $widget
  * @param string $positionCode
  * @param array $params
  * @param XenForo_Template_Abstract $template
  * @return string
  */
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $template)
 {
     if (!$this->_canViewGallery()) {
         return;
     }
     $photoModel = $this->_getPhotoModel();
     $conditions = array('content_type' => sonnb_XenGallery_Model_Photo::$contentType, 'content_state' => 'visible');
     $this->_prepareConditions($widget, $conditions, $fetchOptions);
     $photos = $photoModel->getContents($conditions, $fetchOptions);
     $photos = $photoModel->prepareContents($photos, $fetchOptions);
     $this->_prepareContents($widget, $photos, $photoModel);
     if (empty($photos)) {
         return;
     }
     $template->setParam('photos', null);
     $template->setParams(array('widget' => $widget, 'contents' => $photos));
     if (method_exists('WidgetFramework_Template_Trojan', 'WidgetFramework_setRequiredExternals')) {
         $externalRequires = array('css' => array('sonnb_xengallery_widget_photo'));
         WidgetFramework_Template_Trojan::WidgetFramework_setRequiredExternals($externalRequires);
     }
     return $template->render();
 }
コード例 #5
0
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $renderTemplateObject)
 {
     $renderTemplateObject->setParams($params);
     return $renderTemplateObject->render();
 }
コード例 #6
0
ファイル: Album.php プロジェクト: Sywooch/forums
 /**
  * @param array $widget
  * @param string $positionCode
  * @param array $params
  * @param XenForo_Template_Abstract $template
  * @return string
  */
 protected function _render(array $widget, $positionCode, array $params, XenForo_Template_Abstract $template)
 {
     $core = WidgetFramework_Core::getInstance();
     /* @var $albumModel sonnb_XenGallery_Model_Album */
     $albumModel = $core->getModelFromCache('sonnb_XenGallery_Model_Album');
     /* @var $galleryModel sonnb_XenGallery_Model_Gallery */
     $galleryModel = $core->getModelFromCache('sonnb_XenGallery_Model_Gallery');
     if (!$galleryModel->canViewGallery()) {
         return;
     }
     $conditions = array('album_state' => 'visible', 'content_count' => array('>', 0), 'cover_content_id' => array('>', 0));
     $fetchOptions = array('orderDirection' => 'desc', 'limit' => $widget['options']['limit'] * 3, 'join' => sonnb_XenGallery_Model_Album::FETCH_USER | sonnb_XenGallery_Model_Album::FETCH_COVER_PHOTO, 'followingUserId' => XenForo_Visitor::getUserId());
     switch ($widget['options']['type']) {
         case 'new':
             $fetchOptions['order'] = 'album_date';
             break;
         case 'lastUpdate':
             $fetchOptions['order'] = 'album_updated_date';
             break;
         case 'mostViewed':
             $fetchOptions['order'] = 'view_count';
             break;
         case 'mostCommented':
             $fetchOptions['order'] = 'comment_count';
             break;
         case 'random':
             $fetchOptions['order'] = 'random';
             break;
         case 'recentlyLiked':
             $fetchOptions['order'] = 'recently_liked';
             break;
         case 'mostLiked':
         default:
             $fetchOptions['order'] = 'likes';
             break;
     }
     if ($widget['options']['category_id']) {
         $conditions['category_id'] = $widget['options']['category_id'];
     }
     if ($widget['options']['collection_id']) {
         $fetchOptions['fetchCollectionDate'] = true;
         $fetchOptions['order'] = 'collection_date';
         $conditions['collection_id'] = $widget['options']['collection_id'];
     }
     if ($widget['options']['likes']) {
         $conditions['likes'] = array('>', $widget['options']['likes']);
     }
     if ($widget['options']['view_count']) {
         $conditions['view_count'] = array('>', $widget['options']['view_count']);
     }
     if ($widget['options']['comment_count']) {
         $conditions['comment_count'] = array('>', $widget['options']['comment_count']);
     }
     $userIds = explode(',', $widget['options']['user_id']);
     $userIds = array_filter($userIds);
     array_walk($userIds, create_function('&$userId, $key', '$userId = trim($userId);'));
     if ($userIds) {
         $conditions['user_id'] = $userIds;
     }
     $albums = $albumModel->getAlbums($conditions, $fetchOptions);
     $albums = $albumModel->prepareAlbums($albums, $fetchOptions);
     if ($albums) {
         foreach ($albums as $albumId => $album) {
             if (!$albumModel->canViewAlbum($album)) {
                 unset($albums[$albumId]);
                 continue;
             }
         }
     }
     if (empty($albums)) {
         return;
     }
     $albums = array_slice($albums, 0, $widget['options']['limit']);
     $albums = $albumModel->attachCoversToAlbums($albums, $fetchOptions);
     if ($widget['options']['thumbnail_width'] && $widget['options']['thumbnail_height']) {
         foreach ($albums as &$album) {
             if (!empty($album['cover']['medium_height']) && !empty($album['cover']['medium_width'])) {
                 $widthRatio = $album['cover']['medium_width'] / $widget['options']['thumbnail_width'];
                 $heightRatio = $album['cover']['medium_height'] / $widget['options']['thumbnail_height'];
                 if ($widthRatio == $heightRatio) {
                     $album['cover']['medium_width'] = $widget['options']['thumbnail_width'];
                     $album['cover']['medium_height'] = $widget['options']['thumbnail_height'];
                     $album['cover']['style'] = '';
                 } elseif ($widthRatio < $heightRatio) {
                     $album['cover']['medium_height'] = $album['cover']['medium_height'] / ($album['cover']['medium_width'] / $widget['options']['thumbnail_width']);
                     $album['cover']['medium_width'] = $widget['options']['thumbnail_width'];
                     $album['cover']['style'] = 'top: -' . ($album['cover']['medium_height'] - $widget['options']['thumbnail_height']) / 2 . 'px;';
                 } else {
                     $album['cover']['medium_width'] = $album['cover']['medium_width'] / ($album['cover']['medium_height'] / $widget['options']['thumbnail_height']);
                     $album['cover']['medium_height'] = $widget['options']['thumbnail_height'];
                     $album['cover']['style'] = 'left: -' . ($album['cover']['medium_width'] - $widget['options']['thumbnail_width']) / 2 . 'px;';
                 }
             }
         }
     }
     $template->setParam('albums', null);
     $template->setParams(array('widget' => $widget, 'albums' => $albums));
     if (method_exists('WidgetFramework_Template_Trojan', 'WidgetFramework_setRequiredExternals')) {
         $externalRequires = array('css' => array('sonnb_xengallery_widget_album'));
         WidgetFramework_Template_Trojan::WidgetFramework_setRequiredExternals($externalRequires);
     }
     return $template->render();
 }