public function render() { $template = new CTemplateHelper(); $file = $template->getTemplateFile('mobile.document'); ob_start(); require $file; $data = ob_get_contents(); ob_end_clean(); $data = $this->_parseTemplate($data); return $data; }
public function getThumbnail($obj) { $config = CFactory::getConfig(); $file = $obj->thumb; // Site origin if (JString::substr($file, 0, 4) == 'http') { $uri = $file; return $uri; } // Remote storage if ($obj->storage != 'file') { $storage = CStorage::getStorage($obj->storage); $uri = $storage->getURI($file); return $uri; } // Default thumbnail if (empty($file) || !JFile::exists(JPATH_ROOT . '/' . $file)) { $template = new CTemplateHelper(); $asset = $template->getTemplateAsset('video_thumb.png', 'images'); $uri = $asset->url; return $uri; } // Strip cdn path if exists. // Note: At one point, cdn path was stored along with the thumbnail path // in the db which is the mistake we are trying to rectify here. $file = str_ireplace($config->get('videocdnpath'), '', $file); // CDN or local $baseUrl = $config->get('videobaseurl') or $baseUrl = JURI::root(); $uri = str_replace('\\', '/', rtrim($baseUrl, '/') . '/' . ltrim($file, '/')); return $uri; }
function showToolbar($data = null) { $mySQLVer = 0; if (JFile::exists(JPATH_COMPONENT . DS . 'libraries' . DS . 'advancesearch.php')) { require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'advancesearch.php'; $mySQLVer = CAdvanceSearch::getMySQLVersion(); } require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'toolbar.php'; require_once JPATH_COMPONENT . DS . 'libraries' . DS . 'miniheader.php'; $format = JRequest::getVar('format', 'html', 'get'); if ($format == 'json') { return; } $mainframe =& JFactory::getApplication(); $document =& JFactory::getDocument(); $my = CFactory::getUser(); $userid = JRequest::getInt('userid', ''); $user = CFactory::getUser($userid); // Get the configuration object. $config = CFactory::getConfig(); //JHTML::_('behavior.tooltip'); $js = 'assets/window-1.0'; $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js'; CAssets::attach($js, 'js'); $js = 'assets/script-1.2'; $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js'; CAssets::attach($js, 'js'); $js = '<script type=\'text/javascript\'>'; $js .= '/*<![CDATA[*/'; $js .= 'var js_viewerId = ' . $my->id . '; '; $js .= 'var js_profileId = ' . $user->id . ';'; $js .= '/*]]>*/'; $js .= '</script>'; $mainframe->addCustomHeadTag($js); CFactory::load('libraries', 'template'); CTemplate::addStylesheet('style'); // Load rtl stylesheet if ($document->direction == 'rtl') { CTemplate::addStylesheet('style.rtl'); } // FOr iPhone, we need to add the stylesheet AFTER the main stylesheet has been loaded // if(JRequest::getVar('screen')=='mobile') // { // $document->addStylesheet( JURI::root() . 'components/com_community/templates/default/css/style.mobile.css' ); // } // This need to be loaded in main messaging library CFactory::load('libraries', 'window'); CWindow::load(); $template = new CTemplateHelper(); $styleIE7 = $template->getTemplateAsset('styleIE7', 'css'); $styleIE6 = $template->getTemplateAsset('styleIE6', 'css'); $css = '<!-- Jom Social --> <!--[if IE 7.0]> <link rel="stylesheet" href="' . $styleIE7->url . '" type="text/css" /> <![endif]--> <!--[if lte IE 6]> <link rel="stylesheet" href="' . $styleIE6->url . '" type="text/css" /> <![endif]-->'; $mainframe->addCustomHeadTag($css); $css = 'assets/autocomplete.css'; CAssets::attach($css, 'css'); // Load joms.ajax CTemplate::addScript('joms.ajax'); $task = JRequest::getVar('task', '', 'GET'); $groupId = JRequest::getInt('groupid', '', 'GET'); // Hide the toolbar from unregistered user // but still show the mini header if (empty($my->id)) { if (!empty($groupId) && $task != 'viewgroup') { CFactory::load('libraries', 'miniheader'); echo CMiniHeader::showGroupMiniHeader($groupId); return; } echo CMiniHeader::showMiniHeader($this->_showMiniHeaderUser); return; } /** * Inbox unread count */ $inboxUnread = 0; if (!empty($data['inbox'])) { $inboxUnread = $data['inbox']; } /** * Notification alert */ $notiAlert = 0; $notiAlert = $this->_newNotification(); if (!empty($notiAlert) && $notiAlert > 0) { CFactory::load('libraries', 'window'); CWindow::load(); } $config = CFactory::getConfig(); $logoutLink = CRoute::_('index.php?option=com_community&view=' . $config->get('redirect_logout'), false); $logoutLink = base64_encode($logoutLink); $isFacebookUser = false; if ($config->get('fbconnectkey') && $config->get('fbconnectsecret')) { CFactory::load('libraries', 'facebook'); CFactory::load('models', 'connect'); // Once they reach here, we assume that they are already logged into facebook. // Since CFacebook library handles the security we don't need to worry about any intercepts here. $facebook = new CFacebook(); $connectTable =& JTable::getInstance('Connect', 'CTable'); $fbUser = $facebook->getUser(); $connectTable->load($fbUser); $isFacebookUser = $connectTable->userid == $my->id; } $groupMiniHeader = ''; // Show miniheader if ($task != 'viewgroup') { CFactory::load('libraries', 'miniheader'); $groupMiniHeader = CMiniHeader::showGroupMiniHeader($groupId); } $tmpl = new CTemplate(); $tmpl->set('my', $my); $tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id)); $tmpl->set('config', $config); $tmpl->set('inboxUnread', $inboxUnread); $tmpl->set('notiAlert', $notiAlert); $tmpl->set('miniheader', CMiniHeader::showMiniHeader($this->_showMiniHeaderUser)); $tmpl->set('groupMiniHeader', $groupMiniHeader); $tmpl->set('showAdvanceSearch', $mySQLVer > 4.1 ? 1 : 0); $tmpl->set('logoutLink', $logoutLink); $tmpl->set('isFacebookUser', $isFacebookUser); $toolbar = CFactory::getToolbar(); $tmpl->set('customToolbar', $toolbar); echo $tmpl->fetch('toolbar.index'); }
private function _getTemplateFullpath($file) { $template = new CTemplateHelper(); $file = $template->getFile($file); return $file; }
/** * Attach necessary scripts and stylesheets for the toolbar to operate correctly on 3rd party * environments. **/ private function attachHeaders() { $document =& JFactory::getDocument(); $config = CFactory::getConfig(); if ($document->getType() != 'html') { return; } $js = 'assets/window-1.0'; $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js'; CAssets::attach($js, 'js'); $js = 'assets/script-1.2'; $js .= $config->getBool('usepackedjavascript') ? '.pack.js' : '.js'; CAssets::attach($js, 'js'); CFactory::load('libraries', 'template'); CTemplate::addStylesheet('style'); $templateParams = CTemplate::getTemplateParams(); CTemplate::addStylesheet('style.' . $templateParams->get('colorTheme')); // Load rtl stylesheet if ($document->direction == 'rtl') { CTemplate::addStylesheet('style.rtl'); } // This need to be loaded so the popups will work correctly in notification window CFactory::load('libraries', 'window'); CWindow::load(); $template = new CTemplateHelper(); $styleIE7 = $template->getTemplateAsset('styleIE7', 'css'); $styleIE6 = $template->getTemplateAsset('styleIE6', 'css'); $css = '<!-- Jom Social --> <!--[if IE 7.0]> <link rel="stylesheet" href="' . $styleIE7->url . '" type="text/css" /> <![endif]--> <!--[if lte IE 6]> <link rel="stylesheet" href="' . $styleIE6->url . '" type="text/css" /> <![endif]-->'; $document->addCustomTag($css); $css = 'assets/autocomplete.css'; CAssets::attach($css, 'css'); // Load joms.ajax CTemplate::addScript('joms.ajax'); }
/** * * @return \CParameter */ public static function getTemplateParams() { $template = new CTemplateHelper(); $defaultParam = $template->getTemplatePath('params.ini', 'default'); $templateParam = $template->getTemplatePath('params.ini'); $overrideParam = $template->getOverrideTemplatePath('params.ini'); $params = new CParameter(''); if (JFile::exists($defaultParam)) { $params->bind(JFile::read($defaultParam)); } if (JFile::exists($templateParam)) { $params->bind(JFile::read($templateParam)); } if (JFile::exists($overrideParam)) { $params->bind(JFile::read($overrideParam)); } return $params; }
/** Method to get avatar's uri * */ public static function avatarURI($file = '', $default = '') { $config = CFactory::getConfig(); // Default avatar if (empty($file) || !JFile::exists(JPATH_ROOT . DS . $file)) { CFactory::load('helpers', 'template'); $template = new CTemplateHelper(); $asset = $template->getTemplateAsset($default, 'images'); $uri = $asset->url; return $uri; } // Strip cdn path if exists. // Note: At one point, cdn path was stored along with the avatar path // in the db which is the mistake we are trying to rectify here. $file = str_ireplace($config->get('imagecdnpath'), '', $file); // CDN or local $baseUrl = $config->get('imagebaseurl') or $baseUrl = JURI::root(); $uri = str_replace('\\', '/', rtrim($baseUrl, '/') . '/' . ltrim($file, '/')); return $uri; }
public function attachHeaders() { $document = JFactory::getDocument(); $config = CFactory::getConfig(); $my = CFactory::getUser(); $userid = JRequest::getVar('userid', ''); $user = CFactory::getUser($userid); if ($document->getType() != 'html') { return; } $document = JFactory::getDocument(); $js = '<script type=\'text/javascript\'>'; $js .= '/*<![CDATA[*/'; $js .= 'var js_viewerId = ' . $my->id . '; '; $js .= 'var js_profileId = ' . $user->id . ';'; $js .= '/*]]>*/'; $js .= '</script>'; $document->addCustomTag($js); // This need to be loaded so the popups will work correctly in notification window CFactory::load('libraries', 'window'); CWindow::load(); CFactory::load('libraries', 'minitip'); CMinitip::load(); CFactory::load('libraries', 'template'); CTemplate::addStylesheet('style'); $templateParams = CTemplate::getTemplateParams(); CTemplate::addStylesheet('style.' . $templateParams->get('colorTheme')); // Load rtl stylesheet if ($document->direction == 'rtl') { CTemplate::addStylesheet('style.rtl'); } $template = new CTemplateHelper(); $styleIE7 = $template->getTemplateAsset('styleIE7', 'css'); $styleIE6 = $template->getTemplateAsset('styleIE6', 'css'); $css = '<!-- Jom Social --> <!--[if IE 7.0]> <link rel="stylesheet" href="' . $styleIE7->url . '" type="text/css" /> <![endif]--> <!--[if lte IE 6]> <link rel="stylesheet" href="' . $styleIE6->url . '" type="text/css" /> <![endif]-->'; $document->addCustomTag($css); $css = 'assets/autocomplete.css'; CAssets::attach($css, 'css'); // Required, but added in default template //$css = 'assets/tipsy-0.1.7/src/stylesheets/tipsy.css'; //CAssets::attach($css, 'css'); // Load joms.ajax CTemplate::addScript('joms.ajax'); }
/** * @todo get coverUri and avatarUri should use same function to prevent duplicate code * @param type $file * @param type $default * @return string */ public static function coverURI($file = '', $default = '') { $config = CFactory::getConfig(); $storage = CStorage::getStorage($config->get('photostorage')); /* Default cover */ if (empty($file) || !$storage->exists($file)) { $template = new CTemplateHelper(); $asset = $template->getTemplateAsset($default, 'images'); $uri = $asset->url; return $uri; } if ($config->get('photostorage') == 'file') { $file = str_ireplace($config->get('imagecdnpath'), '', $file); // CDN or local $baseUrl = $config->get('imagebaseurl') or $baseUrl = JURI::root(); $uri = str_replace('\\', '/', rtrim($baseUrl, '/') . '/' . ltrim($file, '/')); return $uri; } else { return $storage->getURI($file); } }
/** * Return the exact URL */ public function getThumbURI() { // CDN or local $config = CFactory::getConfig(); $file = $this->thumbnail; // Remote storage if ($this->storage != 'file') { CFactory::load('libraries', 'storage'); $storage = CStorage::getStorage($this->storage); $uri = $storage->getURI($file); return $uri; } // Default avatar if (empty($file) || !JFile::exists(JPATH_ROOT . DS . $file)) { CFactory::load('helpers', 'template'); $template = new CTemplateHelper(); $asset = $template->getTemplateAsset('photo_thumb.png', 'images'); $uri = $asset->url; return $uri; } // Strip cdn path if exists. // Note: At one point, cdn path was stored along with the avatar path // in the db which is the mistake we are trying to rectify here. $file = str_ireplace($config->get('photocdnpath'), '', $file); // CDN or local $baseUrl = $config->get('photobaseurl') or $baseUrl = JURI::root(); $uri = str_replace('\\', '/', rtrim($baseUrl, '/') . '/' . ltrim($file, '/')); return $uri; }
/** * Get user cover Url * @return string */ public function getCover() { $config = CFactory::getConfig(); $storage = CStorage::getStorage($config->get('user_avatar_storage')); $storages['file'] = 'file'; $storages['s3'] = 's3'; if (!$storage->exists($this->_cover)) { unset($storages[$config->get('user_avatar_storage')]); $storages = array_pop($storages); $storage = CStorage::getStorage($storages); } if (empty($this->_cover) || !$storage->exists($this->_cover)) { $profileModel = CFactory::getModel('Profile'); $gender = $profileModel->getGender($this->id); $tGender = strtoupper($gender); /* Not use translate string yet */ if (strpos($tGender, 'COM_COMMUNITY_') === false) { /* But it must be default English string */ $tGender = 'COM_COMMUNITY_' . $tGender; /* Adding prefix translate string */ } /* Now we have translate string already. Let's determine gender ( No shemale here ) */ // theme designer files first switch ($tGender) { case 'COM_COMMUNITY_MALE': $gender = 'male-default'; $td_cover = 'default-cover-male'; break; case 'COM_COMMUNITY_FEMALE': $gender = 'female-default'; $td_cover = 'default-cover-female'; break; default: $gender = 'undefined-default'; $td_cover = 'default-cover'; break; } $template = new CTemplateHelper(); // Theme designer cover if (file_exists(COMMUNITY_PATH_ASSETS . $td_cover . '.png')) { return JUri::root() . str_replace(JPATH_ROOT, '', COMMUNITY_PATH_ASSETS) . "{$td_cover}.png"; } if (file_exists(COMMUNITY_PATH_ASSETS . $td_cover . '.jpg')) { return JUri::root() . str_replace(JPATH_ROOT, '', COMMUNITY_PATH_ASSETS) . "{$td_cover}.jpg"; } // Default cover if (file_exists(COMMUNITY_PATH_ASSETS . 'cover-' . $gender . '.png')) { return JUri::root() . str_replace(JPATH_ROOT, '', COMMUNITY_PATH_ASSETS) . 'cover-' . $gender . '.png'; } if (file_exists(COMMUNITY_PATH_ASSETS . 'cover-' . $gender . '.jpg')) { return JUri::root() . str_replace(JPATH_ROOT, '', COMMUNITY_PATH_ASSETS) . 'cover-' . $gender . '.jpg'; } // Template cover $asset = $template->getTemplateAsset('cover-' . $gender . '.jpg', 'images'); $uri = $asset->url; if (strlen($uri)) { return $uri; } $asset = $template->getTemplateAsset('cover-' . $gender . '.png', 'images'); $uri = $asset->url; if (strlen($uri)) { return $uri; } } else { /* if not local storage than get remote storage */ $storage = CStorage::getStorage($this->_storage); return $storage->getURI($this->_cover); } $avatar = CUrlHelper::coverURI($this->_cover, ''); return $avatar; }
/** * Centralized location to attach asset to any page. It avoids duplicate * attachement */ static function attach($path, $type, $assetPath = '') { $document =& JFactory::getDocument(); if ($document->getType() != 'html') { return; } CFactory::load('helpers', 'template'); CFactory::load('libraries', 'template'); $template = new CTemplateHelper(); $config = CFactory::getConfig(); // (Temporary) // Quick fix to prevent loading of unwanted stuff // on mobile view because it'll take a bit of work // to identify where they came from // (Temporary) // if (CTemplate::mobileTemplate()) // { // if (strstr($path, 'window-1.0') || strstr($path, 'style.css') || strstr($path, 'script-1.2') || strstr($path, 'window.css') ) // return; // } if (!defined('C_ASSET_JQUERY')) { $jQuery = $template->getTemplateAsset('joms.jquery', 'js'); $document->addScript($jQuery->url); define('C_ASSET_JQUERY', 1); } static $added = false; if (!$added) { // Ensure our script is loaded before anything else. // if (CTemplate::mobileTemplate()) // { // $script = $template->getTemplateAsset('script.mobile-1.0', 'js'); // } // else // { // $script = $template->getTemplateAsset('script-1.2', 'js'); // } $script = $template->getTemplateAsset('script-1.2', 'js'); $document->addScript($script->url); $signature = md5($script->url); define('C_ASSET_' . $signature, 1); $added = true; } if (!empty($assetPath)) { $path = $assetPath . $path; } else { $path = JURI::root() . 'components/com_community/' . JString::ltrim($path, '/'); } if (!defined('C_ASSET_' . md5($path))) { define('C_ASSET_' . md5($path), 1); switch ($type) { case 'js': $document->addScript($path); break; case 'css': $document->addStyleSheet($path); } } }