Esempio n. 1
0
 /**
  * Execute a request
  */
 public function execute($task = '')
 {
     global $mainframe;
     $document =& JFactory::getDocument();
     $my =& JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $menus =& JSite::getMenu();
     $menuitem =& $menus->getActive();
     $userId = JRequest::getInt('userid', '', 'GET');
     $tmpl = JRequest::getVar('tmpl', '', 'REQUEST');
     $format = JRequest::getVar('format', '', 'REQUEST');
     $nohtml = JRequest::getVar('no_html', '', 'REQUEST');
     if ($tmpl != 'component' && $format != 'feed' && $format != 'ical' && $nohtml != 1 && $format != 'raw') {
         // This is to fix MSIE that has incorrect user agent because jquery doesn't detect correctly.
         $ieFix = "<!--[if IE 6]><script type=\"text/javascript\">var jomsIE6 = true;</script><![endif]-->";
         $document->addCustomTag($ieFix);
     }
     // Add custom css for the specific view if needed.
     $config = CFactory::getConfig();
     $viewName = JString::strtolower(JRequest::getVar('view', '', 'REQUEST'));
     jimport('joomla.filesystem.file');
     if ($config->get('enablecustomviewcss')) {
         CTemplate::addStylesheet($viewName);
     }
     $env = CTemplate::getTemplateEnvironment();
     $html = '<div id="community-wrap" class="on-' . $env->joomlaTemplate . ' ' . $document->direction . '">';
     // Build the component menu module
     ob_start();
     CTemplate::renderModules('js_top');
     $moduleHTML = ob_get_contents();
     ob_end_clean();
     $html .= $moduleHTML;
     // Build the content HTML
     CFactory::load('helpers', 'azrul');
     $inbox =& $this->getModel('inbox');
     $unread = $inbox->countUnRead(array('user_id' => $my->id));
     $param = array('inbox' => $unread);
     if (!empty($task) && method_exists($this, $task)) {
         ob_start();
         if (method_exists($this, '_viewEnabled') && !$this->_viewEnabled()) {
             echo property_exists($this, '_disabledMessage') ? $this->_disabledMessage : JText::_('Function is disabled');
         } else {
             $this->{$task}();
         }
         $output = ob_get_contents();
         ob_end_clean();
     } else {
         ob_start();
         $this->display();
         $output = ob_get_contents();
         ob_end_clean();
     }
     // Build toolbar HTML
     ob_start();
     $view =& $this->getView(JRequest::getCmd('view', 'frontpage'));
     $view->showToolbar($param);
     // Header title will use view->title. If not specified, we will
     // use current page title
     $headerTitle = !empty($view->title) ? $view->title : $document->getTitle();
     $view->showHeader($headerTitle, $this->_icon);
     $header = ob_get_contents();
     ob_end_clean();
     $html .= $header;
     // @rule: Super admin should always be allowed regardless of their block status
     // block member to access profile owner details
     CFactory::load('helpers', 'owner');
     CFactory::load('libraries', 'block');
     $getBlockStatus = new blockUser();
     $blocked = $getBlockStatus->isUserBlocked($userId, $viewName);
     if ($blocked) {
         if (COwnerHelper::isCommunityAdmin()) {
             $mainframe =& JFactory::getApplication();
             $mainframe->enqueueMessage(JText::_('CC YOU ARE BLOCKED BY USER', 'error'));
         } else {
             $tmpl = new CTemplate();
             $output .= $tmpl->fetch('block.denied');
         }
     }
     // Build the component bottom module
     ob_start();
     CTemplate::renderModules('js_bottom');
     $moduleHTML = ob_get_contents();
     ob_end_clean();
     $html .= $output . $moduleHTML . '</div>';
     CFactory::load('helpers', 'string');
     $html = CStringHelper::replaceThumbnails($html);
     $html = JString::str_ireplace(array('{error}', '{warning}', '{info}'), '', $html);
     // Trigger onModuleDisplay()
     CFactory::load('libraries', 'apps');
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $moduleHTML = $appsLib->triggerEvent('onModuleRender');
     $mods = array();
     foreach ($moduleHTML as $modules) {
         foreach ($modules as $position => $content) {
             if (empty($mods[$position])) {
                 $mods[$position] = '';
             }
             $mods[$position] .= $content;
         }
     }
     foreach ($mods as $position => $module) {
         $html = str_replace('<!-- ' . $position . ' -->', $module, $html);
     }
     // Display viewType switcher
     // $browser = CBrowser::getInstance();
     // if( $browser->_mobile )
     // {
     // 	CFactory::load('libraries', 'mobile');
     // 	ob_start();
     // 		CMobile::showSwitcher();
     // 		$switcherHTML = ob_get_contents();
     // 	ob_end_clean();
     // 	$html .= $switcherHTML;
     // }
     echo $html;
 }
Esempio n. 2
0
 /**
  * Execute a request
  */
 public function execute($task)
 {
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $document = JFactory::getDocument();
     $my = CFactory::getUser();
     $pathway = $mainframe->getPathway();
     $menus = $mainframe->getMenu();
     $menuitem = $menus->getActive();
     $userId = $jinput->get->get('userid', '', 'INT');
     $tmpl = $jinput->request->get('tmpl', '', 'STRING');
     $format = $jinput->request->get('format', '', 'STRING');
     $nohtml = $jinput->request->get('no_html', '', 'STRING');
     if ($tmpl != 'component' && $format != 'feed' && $format != 'ical' && $nohtml != 1 && $format != 'raw') {
         // This is to fix MSIE that has incorrect user agent because jquery doesn't detect correctly.
         $ieFix = "<!--[if IE 6]><script type=\"text/javascript\">var jomsIE6 = true;</script><![endif]-->";
         $document->addCustomTag($ieFix);
     }
     // Add custom css for the specific view if needed.
     $config = CFactory::getConfig();
     $viewName = JString::strtolower($jinput->request->get('view', '', 'STRING'));
     jimport('joomla.filesystem.file');
     if ($config->get('enablecustomviewcss')) {
         CTemplate::addStylesheet($viewName);
     }
     $template = JFactory::getApplication()->getTemplate();
     // echo var_dump(CTemplate::addStylesheet('beez2'));
     if ($template == 'beez_20' && JVERSION > 2 && JVERSION < 3) {
         CTemplate::addStylesheet('beez2');
     }
     $env = CTemplate::getTemplateEnvironment();
     $svgFile = CFactory::getPath('template://assets/icon/joms-icon.svg');
     // non ajax-prefixed tasks that should avoid svg
     $excludeSvgList = array('changeAvatar', 'multiUpload', 'uploadvideo');
     // exclude svg file from ajax response
     if ($svgFile && substr($task, 0, 4) != 'ajax' && !in_array($task, $excludeSvgList)) {
         include_once $svgFile;
     }
     $html = '<div id="community-wrap" class="jomsocial-wrapper on-' . $env->joomlaTemplate . ' ' . $document->direction . ' c' . ucfirst($viewName) . '">';
     $html .= '<div class="jomsocial">';
     // Build the component menu module
     ob_start();
     $tmpl = new CTemplate();
     $tmpl->renderModules('js_top');
     $moduleHTML = ob_get_contents();
     ob_end_clean();
     $html .= $moduleHTML;
     // Build the content HTML
     //CFactory::load( 'helpers' , 'azrul' );
     if (!empty($task) && method_exists($this, $task)) {
         ob_start();
         if (method_exists($this, '_viewEnabled') && !$this->_viewEnabled()) {
             echo property_exists($this, '_disabledMessage') ? $this->_disabledMessage : JText::_('COM_COMMUNITY_CONTROLLER_FUNCTION_DISABLED_WARNING');
         } else {
             $this->{$task}();
         }
         $output = ob_get_contents();
         ob_end_clean();
     } else {
         ob_start();
         $this->display();
         $output = ob_get_contents();
         ob_end_clean();
     }
     // Build toolbar HTML
     ob_start();
     $view = $this->getView(JString::strtolower($jinput->get('view', 'frontpage', 'STRING')));
     // Do not rely on the toolbar to include necessary css or javascripts.
     $view->attachHeaders();
     // Display the site's toolbar.
     $view->showToolbar();
     // Header title will use view->title. If not specified, we will
     // use current page title
     $headerTitle = !empty($view->title) ? $view->title : $document->getTitle();
     $view->showHeader($headerTitle, $this->_icon);
     $header = ob_get_contents();
     ob_end_clean();
     $html .= $header;
     // @rule: Super admin should always be allowed regardless of their block status
     // block member to access profile owner details
     //CFactory::load( 'helpers' , 'owner' );
     //CFactory::load( 'libraries' , 'block' );
     $getBlockStatus = new blockUser();
     $blocked = $getBlockStatus->isUserBlocked($userId, $viewName);
     if ($blocked) {
         if (COwnerHelper::isCommunityAdmin()) {
             $mainframe = JFactory::getApplication();
             $mainframe->enqueueMessage(JText::_('COM_COMMUNITY_YOU_ARE_BLOCKED_BY_USER', 'error'));
         } else {
             $tmpl = new CTemplate();
             $view->showToolbar();
             echo $tmpl->fetch('block.denied');
             return;
             $block = true;
         }
     }
     // Build the component bottom module
     ob_start();
     $tmpl = new CTemplate();
     $tmpl->renderModules('js_bottom');
     $moduleHTML = ob_get_contents();
     ob_end_clean();
     $html .= $output . $moduleHTML . '</div></div>';
     //CFactory::load( 'helpers' , 'string' );
     $html = CStringHelper::replaceThumbnails($html);
     $html = CString::str_ireplace(array('{error}', '{warning}', '{info}'), '', $html);
     // Trigger onModuleDisplay()
     //CFactory::load( 'libraries' , 'apps' );
     $appsLib = CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $moduleHTML = $appsLib->triggerEvent('onModuleRender');
     $mods = array();
     if (is_array($moduleHTML)) {
         foreach ($moduleHTML as $modules) {
             if (is_array($modules)) {
                 foreach ($modules as $position => $content) {
                     if (empty($mods[$position])) {
                         $mods[$position] = '';
                     }
                     $mods[$position] .= $content;
                 }
             }
         }
     }
     foreach ($mods as $position => $module) {
         $html = str_replace('<!-- ' . $position . ' -->', $module, $html);
     }
     echo $html;
     // Fix UI quirks.
     echo PHP_EOL;
     echo '<script>window.joms && joms.fixUI && joms.fixUI();</script>';
     echo PHP_EOL;
 }