getPathway(); $params =& $mainframe->getParams('com_content'); // Initialize variables $article =& $this->get('Article'); $aparams =& $article->parameters; $params->merge($aparams); if($this->getLayout() == 'pagebreak') { $this->_displayPagebreak($tpl); return; } if($this->getLayout() == 'form') { $this->_displayForm($tpl); return; } if (($article->id == 0)) { $id = JRequest::getVar( 'id', '', 'default', 'int' ); return JError::raiseError( 404, JText::sprintf( 'Article # not found', $id ) ); } $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); if (!$params->get('intro_only') && ($this->getLayout() == 'default') && ($limitstart == 0)) { $model =& $this->getModel(); $model->hit(); } // Create a user access object for the current user $access = new stdClass(); $access->canEdit = $user->authorize('com_content', 'edit', 'content', 'all'); $access->canEditOwn = $user->authorize('com_content', 'edit', 'content', 'own'); $access->canPublish = $user->authorize('com_content', 'publish', 'content', 'all'); // Check to see if the user has access to view the full article $aid = $user->get('aid'); if ($article->access <= $aid) { $article->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));; } else { if ( ! $aid ) { // Redirect to login $uri = JFactory::getURI(); $return = $uri->toString(); $url = 'index.php?option=com_user&view=login'; $url .= '&return='.base64_encode($return);; //$url = JRoute::_($url, false); $mainframe->redirect($url, JText::_('You must login first') ); } else{ JError::raiseWarning( 403, JText::_('ALERTNOTAUTH') ); return; } } /* * Process the prepare content plugins */ JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onPrepareContent', array (& $article, & $params, $limitstart)); /* * Handle the metadata */ // because the application sets a default page title, we need to get it // right from the menu item itself // Get the menu item object $menus = &JSite::getMenu(); $menu = $menus->getActive(); if (is_object( $menu ) && isset($menu->query['view']) && $menu->query['view'] == 'article' && isset($menu->query['id']) && $menu->query['id'] == $article->id) { $menu_params = new JParameter( $menu->params ); if (!$menu_params->get( 'page_title')) { $params->set('page_title', $article->title); } } else { $params->set('page_title', $article->title); } $document->setTitle( $params->get( 'page_title' ) ); if ($article->metadesc) { $document->setDescription( $article->metadesc ); } if ($article->metakey) { $document->setMetadata('keywords', $article->metakey); } if ($mainframe->getCfg('MetaTitle') == '1') { $mainframe->addMetaTag('title', $article->title); } if ($mainframe->getCfg('MetaAuthor') == '1') { $mainframe->addMetaTag('author', $article->author); } $mdata = new JParameter($article->metadata); $mdata = $mdata->toArray(); foreach ($mdata as $k => $v) { if ($v) { $document->setMetadata($k, $v); } } // If there is a pagebreak heading or title, add it to the page title if (!empty($article->page_title)) { $article->title = $article->title .' - '. $article->page_title; $document->setTitle($article->page_title.' - '.JText::sprintf('Page %s', $limitstart + 1)); } /* * Handle the breadcrumbs */ if($menu && $menu->query['view'] != 'article') { switch ($menu->query['view']) { case 'section': $pathway->addItem($article->category, 'index.php?view=category&id='.$article->catslug); $pathway->addItem($article->title, ''); break; case 'category': $pathway->addItem($article->title, ''); break; } } /* * Handle display events */ $article->event = new stdClass(); $results = $dispatcher->trigger('onAfterDisplayTitle', array ($article, &$params, $limitstart)); $article->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onBeforeDisplayContent', array (& $article, & $params, $limitstart)); $article->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onAfterDisplayContent', array (& $article, & $params, $limitstart)); $article->event->afterDisplayContent = trim(implode("\n", $results)); $print = JRequest::getBool('print'); if ($print) { $document->setMetaData('robots', 'noindex, nofollow'); } $this->assignRef('article', $article); $this->assignRef('params' , $params); $this->assignRef('user' , $user); $this->assignRef('access' , $access); $this->assignRef('print', $print); parent::display($tpl); } function _displayForm($tpl) { global $mainframe; // Initialize variables $document =& JFactory::getDocument(); $user =& JFactory::getUser(); $uri =& JFactory::getURI(); $params =& $mainframe->getParams('com_content'); // Make sure you are logged in and have the necessary access rights if ($user->get('gid') < 19) { JResponse::setHeader('HTTP/1.0 403',true); JError::raiseWarning( 403, JText::_('ALERTNOTAUTH') ); return; } // Initialize variables $article =& $this->get('Article'); $aparams =& $article->parameters; $isNew = ($article->id < 1); $params->merge($aparams); // At some point in the future this will come from a request object $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); // Add the Calendar includes to the document
section JHTML::_('behavior.calendar'); if ($isNew) { // TODO: Do we allow non-sectioned articles from the frontend?? $article->sectionid = JRequest::getVar('sectionid', 0, '', 'int'); $db = JFactory::getDBO(); $db->setQuery('SELECT title FROM #__sections WHERE id = '.(int) $article->sectionid); $article->section = $db->loadResult(); } // Get the lists $lists = $this->_buildEditLists(); // Load the JEditor object $editor =& JFactory::getEditor(); // Build the page title string $title = $article->id ? JText::_('Edit') : JText::_('New'); // Set page title // because the application sets a default page title, we need to get it // right from the menu item itself // Get the menu item object $menus = &JSite::getMenu(); $menu = $menus->getActive(); $params->set( 'page_title', $params->get( 'page_title' ) ); if (is_object( $menu )) { $menu_params = new JParameter( $menu->params ); if (!$menu_params->get( 'page_title')) { $params->set('page_title', JText::_( 'Submit an Article' )); } } else { $params->set('page_title', JText::_( 'Submit an Article' )); } $document->setTitle( $params->get( 'page_title' ) ); // get pathway $pathway =& $mainframe->getPathWay(); $pathway->addItem($title, ''); // Unify the introtext and fulltext fields and separated the fields by the {readmore} tag if (JString::strlen($article->fulltext) > 1) { $article->text = $article->introtext."