function display($tpl = null) { $app = JFactory::getApplication(); $active = $app->getMenu()->getActive(); $cache = JFactory::getCache(); $user = JFactory::getUser(); $model = $this->getModel(); $articles_model = $this->getModel('articles'); /********************************** PARAMS *****************************/ $appparams = JComponentHelper::getParams(CJBLOG); $menuParams = new JRegistry(); if ($active) { $menuParams->loadString($active->params); } $this->params = clone $menuParams; $this->params->merge($appparams); /********************************** PARAMS *****************************/ $id = $app->input->getInt('id', 0); if (!$id) { if (!$user->guest) { $id = $user->id; } else { if ($this->params->get('blogUserId', 0) > 0) { $id = $this->params->get('blogUserId'); } else { CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403); return; } } } $limitstart = $app->input->getInt('start', 0); $limitstart = floor($limitstart / 5) * 5; $profile = $cache->call(array('CjBlogApi', 'get_user_profile'), $id); $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => 5, 'order' => 'a.created', 'order_dir' => 'desc', 'user_id' => $id)); $this->assignRef('user', $profile); $this->assignRef('articles', $articles->articles); $this->assignRef('pagination', $articles->pagination); $document = JFactory::getDocument(); $title = JText::sprintf('TXT_USERS_BLOG', addslashes($profile['name'])); $title = CjBlogHelper::get_page_title($title); $document->setTitle($title); if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $active = $app->getMenu()->getActive(); $cache = JFactory::getCache(); $user = JFactory::getUser(); $document = JFactory::getDocument(); $model = $this->getModel(); $articles_model = $this->getModel('articles'); /********************************** PARAMS *****************************/ $appparams = JComponentHelper::getParams(CJBLOG); $menuParams = new JRegistry(); if ($active) { $menuParams->loadString($active->params); } $this->params = clone $menuParams; $this->params->merge($appparams); /********************************** PARAMS *****************************/ $document->addScript(CJBLOG_MEDIA_URI . 'js/jquery.form.js'); $document->addScript(CJBLOG_MEDIA_URI . 'js/jquery.Jcrop.min.js'); $id = $app->input->getInt('id', 0); if (!$id) { if (!$user->guest) { $id = $user->id; } else { CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403); return; } } if ($user->id != $id) { $model->hit($id); } $profile = $cache->call(array('CjBlogApi', 'get_user_profile'), $id); // $badges = $cache->call(array('CjBlogApi', 'get_user_badges'), $id); // $articles = $cache->call(array($articles_model, 'get_articles'), array('published'=>1, 'pagination'=>false, 'limitstart'=>0, 'limit'=>5, 'user_id'=>$id)); if (!$profile) { CJFunctions::throw_error(JText::_('MSG_NO_USER_FOUND'), 403); } $this->assignRef('profile', $profile); $document->setTitle(CjBlogHelper::get_page_title($profile['name'])); if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $active = $app->getMenu()->getActive(); $model = $this->getModel(); $articles_model = $this->getModel('badges'); $page_heading = ''; /********************************** PARAMS *****************************/ $appparams = JComponentHelper::getParams(CJBLOG); $menuParams = new JRegistry(); if ($active) { $menuParams->loadString($active->params); } $this->params = clone $menuParams; $this->params->merge($appparams); /********************************** PARAMS *****************************/ switch ($this->action) { case 'badges_home': $badges = $model->get_badges(); $this->assignRef('badgegroups', $badges); $page_heading = JText::_('LBL_BADGES'); break; case 'user_badges': $id = $app->input->getInt('id', null); $my = JFactory::getUser($id); $badges = $model->get_user_badges($my->id); $this->assignRef('badgegroups', $badges); $page_heading = JText::sprintf('TXT_BADGES_OWNED_BY', $my->name, array('jsSafe' => true)); $document->setMetaData('robots', 'noindex,follow'); break; } $this->params->set('page_heading', $this->params->get('page_heading', $page_heading)); $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $page_heading; } $document->setTitle(CjBlogHelper::get_page_title($title)); if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $model = $this->getModel(); $document = JFactory::getDocument(); $active = $app->getMenu()->getActive(); $parent_id = $app->input->getInt('id', 0); /********************************** PARAMS *****************************/ $appparams = JComponentHelper::getParams(CJBLOG); $menuParams = new JRegistry(); $page_heading = JText::_('LBL_CATEGORIES'); if ($active) { $menuParams->loadString($active->params); } $this->params = clone $menuParams; $this->params->merge($appparams); /********************************** PARAMS *****************************/ $parent_id = $parent_id == 0 ? 'root' : $parent_id; $categories = $model->get_categories($parent_id, false); // $categories = $cache->call(array($model, 'get_categories'), $parent_id == 0 ? 'root' : $parent_id, false); $this->assignRef('categories', $categories); $this->assign('brand', $app->getCfg('sitename')); $this->params->set('page_heading', $this->params->get('page_heading', $page_heading)); $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $page_heading; } $document->setTitle(CjBlogHelper::get_page_title($title)); if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $active = $app->getMenu()->getActive(); $model = $this->getModel(); $cache = JFactory::getCache(); $document = JFactory::getDocument(); /********************************** PARAMS *****************************/ $appparams = JComponentHelper::getParams(CJBLOG); $menuParams = new JRegistry(); if ($active) { $menuParams->loadString($active->params); } $this->params = clone $menuParams; $this->params->merge($appparams); /********************************** PARAMS *****************************/ $id = $app->input->getInt('id', 0); $result = new stdClass(); $page_heading = ''; $page_url = 'index.php?option=' . CJBLOG . '&view=users'; switch ($this->action) { case 'top_bloggers': $result = $model->get_users(2); $page_heading = JText::_('LBL_TOP_BLOGGERS'); $page_url = $page_url . '&task=top'; break; case 'search': $query = $app->input->getString('search', ''); $result = $model->get_users(4, array('query' => $query)); $page_heading = JText::_('LBL_SEARCH'); break; case 'badge_owners': $result = $model->get_users(3, array('badge_id' => $id)); $badge = CjBlogApi::get_badge_details($id); $page_heading = JText::sprintf('TXT_USERS_WHO_WON_BADGE', $badge['title'], array('jsSafe' => true)); $page_url = $page_url . '&task=badge&id=' . $id . ':' . $badge['alias']; break; case 'new_bloggers': default: $result = $model->get_users(1); $page_heading = JText::_('LBL_NEW_BLOGGERS'); break; } if (!empty($result->users)) { $userIds = array_keys($result->users); if (!empty($userIds)) { $api = new CjLibApi(); $avatarApp = $this->params->get('avatar_component', 'cjforum'); $profileApp = $this->params->get('profile_component', 'cjforum'); $api->prefetchUserProfiles($avatarApp, $userIds); if ($avatarApp != $profileApp) { $api->prefetchUserProfiles($profileApp, $userIds); } } } $this->params->set('page_heading', $this->params->get('page_heading', $page_heading)); $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $page_heading; } $document->setTitle(CjBlogHelper::get_page_title($title)); $this->assign('brand', $app->getCfg('sitename')); if (!empty($result)) { $this->assignRef('users', $result->users); $this->assignRef('pagination', $result->pagination); $this->assignRef('state', $result->state); } $this->assignRef('page_url', $page_url); if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $cache = JFactory::getCache(); $active = $app->getMenu()->getActive(); $user = JFactory::getUser(); $document = JFactory::getDocument(); $pathway = $app->getPathway(); $model = $this->getModel(); $category_model = $this->getModel('categories'); $limit = $app->getCfg('list_limit', 20); $limitstart = $app->input->getInt('limitstart', 0); $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0; $this->print = $app->input->getBool('print'); $catid = $app->input->getInt('id', 0); $this->category = $category = null; $max_cat_levels = 0; $page_heading = ''; $page_url = 'index.php?option=' . CJBLOG . '&view=articles'; /********************************** PARAMS *****************************/ $appparams = JComponentHelper::getParams(CJBLOG); $menuParams = new JRegistry(); if ($active) { $menuParams->loadString($active->params); $active_menu_catid = (int) $menuParams->get('catid', 0); if ($catid == 0 && $active_menu_catid > 0) { $catid = $active_menu_catid; } } $this->params = clone $menuParams; $this->params->merge($appparams); /********************************** PARAMS *****************************/ if ($this->action != 'tagged_articles' && $catid > 0) { $max_cat_levels = intval($this->params->get('max_category_levels', -1)); $category = $category_model->get_category($catid); $groups = $user->getAuthorisedViewLevels(); if (!$category || !in_array($category->access, $groups)) { CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $this->assignRef('category', $category); $app->input->set('cjblogcatid', $catid); } switch ($this->action) { case 'latest_articles': $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => $limit, 'catid' => $catid, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.created', 'order_dir' => 'desc')); $this->assignRef('articles', $articles->articles); $this->assignRef('pagination', $articles->pagination); $this->assign('active_id', 3); $page_heading = JText::_('LBL_LATEST_ARTICLES'); $page_url = $page_url . '&task=latest'; break; case 'trending_articles': $trending_days = 30; $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'day_limit' => $trending_days, 'limitstart' => $limitstart, 'limit' => $limit, 'catid' => $catid, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.hits', 'order_dir' => 'desc')); $this->assignRef('articles', $articles->articles); $this->assignRef('pagination', $articles->pagination); $this->assign('active_id', 3); $page_heading = JText::_('LBL_TRENDING_ARTICLES') . ' ( ' . JText::sprintf('TXT_IN_LAST_X_DAYS', $trending_days) . ' )'; $page_url = $page_url . '&task=trending'; break; case 'popular_articles': $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => $limit, 'catid' => $catid, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.hits', 'order_dir' => 'desc')); $this->assignRef('articles', $articles->articles); $this->assignRef('pagination', $articles->pagination); $this->assign('active_id', 3); $page_heading = JText::_('LBL_MOST_POPULAR_ARTICLES'); $page_url = $page_url . '&task=popular'; break; case 'favorite_articles': $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => $limit, 'catid' => $catid, 'favorites' => true, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.hits', 'order_dir' => 'desc')); $this->assignRef('articles', $articles->articles); $this->assignRef('pagination', $articles->pagination); $this->assign('active_id', 6); $page_heading = JText::_('LBL_MY_FAVORITE_ARTICLES'); $page_url = $page_url . '&task=favorites'; break; case 'tagged_articles': $id = $app->input->getInt('id', 0); if (!$id) { return CJFunctions::throw_error(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $articles = $model->get_articles(array('tag_id' => $id, 'published' => 1, 'pagination' => true, 'limitstart' => $limitstart, 'limit' => $limit, 'max_cat_levels' => $max_cat_levels, 'order' => 'a.created', 'order_dir' => 'desc')); $tag = $model->get_tag_details($id); $this->assignRef('articles', $articles->articles); $this->assignRef('pagination', $articles->pagination); $this->assign('page_description', $tag->description); $this->assign('active_id', 3); $page_heading = JText::sprintf('TXT_TAGGED_ARTICLES', $this->escape($tag->tag_text)); $page_url = $page_url . '&task=tag&id=' . $tag->id . ':' . $tag->alias; break; } // set breadcrumbs $path = array(array('title' => $this->params->get('page_heading'), 'link' => '')); if ($category) { $temp = $category; $page_heading = $page_heading . ': ' . $category->title; $page_url = $page_url . '&id=' . $category->id . (!empty($category->alias) ? ':' . $category->alias : ''); while ($temp && ($active->query['option'] != CJBLOG || $active->query['view'] == 'articles') && $temp->id > 1) { $path[] = array('title' => $category->title, 'link' => ContentHelperRoute::getCategoryRoute($temp->id)); $temp = $temp->getParent(); } } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } // set browser title $this->params->set('page_heading', $this->params->get('page_heading', $page_heading)); $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $page_heading; } $document->setTitle(CjBlogHelper::get_page_title($title)); // set meta description if ($this->params->get('menu-meta_description')) { $document->setDescription($this->params->get('menu-meta_description')); } // set meta keywords if ($this->params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } // set robots if ($this->params->get('robots')) { $document->setMetadata('robots', $this->params->get('robots')); } // set nofollow if it is print if ($this->print) { $document->setMetaData('robots', 'noindex, nofollow'); } $this->assignRef('page_url', $page_url); // display parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $active = $app->getMenu()->getActive(); $model = $this->getModel(); $cache = JFactory::getCache(); $user = JFactory::getUser(); /********************************** PARAMS *****************************/ $appparams = JComponentHelper::getParams(CJBLOG); $menuParams = new JRegistry(); $page_heading = ''; if ($active) { $menuParams->loadString($active->params); } $this->params = clone $menuParams; $this->params->merge($appparams); /********************************** PARAMS *****************************/ $result = new stdClass(); switch ($this->action) { case 'user_points': $id = $app->input->getInt('id', 0); if (!$id) { $id = $user->id; } $order = $app->getUserStateFromRequest("cjbloguserpoints.order", 'order', 'a.created', 'cmd'); $order_Dir = $app->getUserStateFromRequest("cjbloguserpoints.order_Dir", 'order_Dir', 'DESC', 'word'); $profile = $cache->call(array('CjBlogApi', 'get_user_profile'), $id); $result = $model->get_user_point_details($id, array('order' => $order, 'order_dir' => $order_Dir)); $points = !empty($result->points) ? $result->points : array(); $this->assignRef('profile', $profile); $this->assignRef('points', $points); $this->assignRef('pagination', $result->pagination); $this->assignRef('state', $result->state); $page_heading = JText::sprintf('COM_CJBLOG_MY_POINTS_DETAILS', $profile['points']); break; case 'user_articles': $id = $app->input->getInt('id', 0); $my = null; if (!$id) { $id = $user->id; $my = $user; } else { $my = JFactory::getUser($id); } $limit = $app->getCfg('list_limit', 20); $limitstart = $app->input->getInt('start', 0); $limitstart = $limit != 0 ? floor($limitstart / $limit) * $limit : 0; $username = $this->params->get('user_display_name', 'name'); $articles = $model->get_articles(array('published' => 1, 'pagination' => true, 'user_id' => $my->id, 'limitstart' => $limitstart, 'limit' => $limit, 'order' => 'a.created', 'order_dir' => 'desc')); $page_heading = JText::sprintf('TXT_USER_ARTICLES', $my->{$username}, array('jsSafe' => true)); $page_url = 'index.php?option=' . CJBLOG . '&view=user&task=articles&id=' . $my->id . ':' . $my->username; $this->assignRef('articles', $articles->articles); $this->assignRef('pagination', $articles->pagination); $this->assignRef('page_url', $page_url); $tpl = 'articles'; break; default: break; } $this->params->set('page_heading', $this->params->get('page_heading', $page_heading)); $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $page_heading; } JFactory::getDocument()->setTitle(CjBlogHelper::get_page_title($title)); parent::display($tpl); }