Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

com_content helper optimalisation (work in progress)

general code optimalisation

git-svn-id: http://joomlacode.org/svn/joomla/development/trunk@7200 6f6e1ebd-4c2b-0410-823f-f34bde69bce9
  • Loading branch information...
commit d8b62657b1875c843e6b8cb2b0684cfc2b2524ff 1 parent 6a151e4
@johanjanssens johanjanssens authored
Showing with 564 additions and 776 deletions.
  1. +5 −5 administrator/components/com_content/controller.php
  2. +1 −1  administrator/components/com_content/helper.php
  3. +1 −1  administrator/components/com_content/views/element/view.php
  4. +0 −1  administrator/includes/framework.php
  5. +2 −0  administrator/index.php
  6. +3 −0  components/com_content/content.php
  7. +10 −17 components/com_content/controller.php
  8. +3 −304 components/com_content/helpers/content.php
  9. +52 −0 components/com_content/helpers/controller.php
  10. +156 −0 components/com_content/helpers/html.php
  11. +236 −0 components/com_content/helpers/model.php
  12. +2 −2 components/com_content/models/archive.php
  13. +3 −3 components/com_content/models/article.php
  14. +4 −4 components/com_content/models/category.php
  15. +3 −3 components/com_content/models/frontpage.php
  16. +5 −5 components/com_content/models/section.php
  17. +5 −5 components/com_content/views/article/tmpl/default.php
  18. +4 −119 components/com_content/views/article/view.html.php
  19. +4 −4 components/com_content/views/category/tmpl/blog_item.php
  20. +1 −1  components/com_content/views/category/tmpl/default.php
  21. +1 −1  components/com_content/views/category/tmpl/default_items.php
  22. +9 −125 components/com_content/views/category/view.html.php
  23. +4 −4 components/com_content/views/frontpage/tmpl/default_item.php
  24. +6 −105 components/com_content/views/frontpage/view.html.php
  25. +2 −2 components/com_search/search.php
  26. +0 −2  includes/framework.php
  27. +3 −0  index.php
  28. +6 −6 libraries/joomla/application/application.php
  29. +3 −38 libraries/joomla/database/database.php
  30. +2 −2 libraries/joomla/factory.php
  31. +6 −8 libraries/joomla/html/pane.php
  32. +2 −0  libraries/joomla/session/storage/database.php
  33. +3 −0  libraries/joomla/session/storage/memcache.php
  34. +1 −1  modules/mod_latestnews/helper.php
  35. +1 −1  modules/mod_mostread/helper.php
  36. +1 −1  modules/mod_newsflash/helper.php
  37. +1 −1  modules/mod_related_items/helper.php
  38. +10 −3 plugins/system/debug.php
  39. +3 −1 templates/rhuk_milkyway/css/template.css
View
10 administrator/components/com_content/controller.php
@@ -157,7 +157,7 @@ function viewContent()
' FROM #__categories AS cc' .
' INNER JOIN #__sections AS s ON s.id = cc.section '.$filter .
' ORDER BY s.ordering, cc.ordering';
- $lists['catid'] = JContentHelper::filterCategory($query, $catid);
+ $lists['catid'] = ContentHelper::filterCategory($query, $catid);
// get list of sections for dropdown filter
$javascript = 'onchange="document.adminForm.submit();"';
@@ -291,7 +291,7 @@ function viewArchive()
$query = 'SELECT c.id AS value, c.title AS text' .
' FROM #__categories AS c'.$filter .
' ORDER BY c.ordering';
- $lists['catid'] = JContentHelper::filterCategory($query, $catid);
+ $lists['catid'] = ContentHelper::filterCategory($query, $catid);
// get list of sections for dropdown filter
$javascript = 'onchange="document.adminForm.submit();"';
@@ -674,7 +674,7 @@ function saveContent()
}
// Prepare the content for saving to the database
- JContentHelper::saveContentPrep( $row );
+ ContentHelper::saveContentPrep( $row );
// Make sure the data is valid
if (!$row->check()) {
@@ -745,11 +745,11 @@ function saveContent()
break;
case 'menulink' :
- JContentHelper::menuLink($redirect, $row->id);
+ ContentHelper::menuLink($redirect, $row->id);
break;
case 'resethits' :
- JContentHelper::resetHits($redirect, $row->id);
+ ContentHelper::resetHits($redirect, $row->id);
break;
case 'apply' :
View
2  administrator/components/com_content/helper.php
@@ -21,7 +21,7 @@
* @subpackage Content
* @since 1.5
*/
-class JContentHelper
+class ContentHelper
{
function saveContentPrep( &$row )
{
View
2  administrator/components/com_content/views/element/view.php
@@ -191,7 +191,7 @@ function _getLists()
$query = 'SELECT cc.id AS value, cc.title AS text, section FROM #__categories AS cc' .
' INNER JOIN #__sections AS s ON s.id = cc.section '.$filter .
' ORDER BY s.ordering, cc.ordering';
- $lists['catid'] = JContentHelper::filterCategory($query, $catid);
+ $lists['catid'] = ContentHelper::filterCategory($query, $catid);
// get list of sections for dropdown filter
$javascript = 'onchange="document.adminForm.submit();"';
View
1  administrator/includes/framework.php
@@ -83,5 +83,4 @@
jimport( 'joomla.utilities.string' );
jimport( 'joomla.version' );
-JDEBUG ? $_PROFILER->mark( 'afterLoadFramework' ) : null;
?>
View
2  administrator/index.php
@@ -24,6 +24,8 @@
require_once( JPATH_BASE .DS.'includes'.DS.'helper.php' );
require_once( JPATH_BASE .DS.'includes'.DS.'toolbar.php' );
+JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;
+
/**
* CREATE THE APPLICATION
*
View
3  components/com_content/content.php
@@ -17,7 +17,10 @@
// Require the com_content helper library
require_once(JPATH_COMPONENT.DS.'controller.php');
+require_once(JPATH_COMPONENT.DS.'helpers'.DS.'controller.php');
require_once(JPATH_COMPONENT.DS.'helpers'.DS.'content.php');
+require_once(JPATH_COMPONENT.DS.'helpers'.DS.'model.php');
+require_once(JPATH_COMPONENT.DS.'helpers'.DS.'html.php');
// Component Helper
jimport('joomla.application.component.helper');
View
27 components/com_content/controller.php
@@ -96,13 +96,12 @@ function save()
* Create a user access object for the user
*/
$access = new stdClass();
- $access->canEdit = $user->authorize('action', 'edit', 'content', 'all');
+ $access->canEdit = $user->authorize('action', 'edit', 'content', 'all');
$access->canEditOwn = $user->authorize('action', 'edit', 'content', 'own');
$access->canPublish = $user->authorize('action', 'publish', 'content', 'all');
$row = & JTable::getInstance('content');
- if (!$row->bind(JRequest::get('post')))
- {
+ if (!$row->bind(JRequest::get('post'))) {
JError::raiseError( 500, $row->getError());
}
@@ -113,8 +112,7 @@ function save()
if ($isNew)
{
// new record
- if (!($access->canEdit || $access->canEditOwn))
- {
+ if (!($access->canEdit || $access->canEditOwn)) {
JError::raiseError( 403, JText::_("ALERTNOTAUTH") );
}
$row->created = gmdate('Y-m-d H:i:s');
@@ -123,8 +121,7 @@ function save()
else
{
// existing record
- if (!($access->canEdit || ($access->canEditOwn && $row->created_by == $user->get('id'))))
- {
+ if (!($access->canEdit || ($access->canEditOwn && $row->created_by == $user->get('id')))) {
JError::raiseError( 403, JText::_("ALERTNOTAUTH") );
}
$row->modified = gmdate('Y-m-d H:i:s');
@@ -189,15 +186,13 @@ function save()
}
// Prepare content for save
- JContentHelper::saveContentPrep($row);
+ ContentHelperController::saveContentPrep($row);
- if (!$row->check())
- {
+ if (!$row->check()) {
JError::raiseError( 500, $row->getError());
}
$row->version++;
- if (!$row->store())
- {
+ if (!$row->store()) {
JError::raiseError( 500, $row->getError());
}
@@ -215,8 +210,7 @@ function save()
$query = 'INSERT INTO #__content_frontpage' .
' VALUES ( '.$row->id.', 1 )';
$db->setQuery($query);
- if (!$db->query())
- {
+ if (!$db->query()) {
JError::raiseError( 500, $db->stderror());
}
$fp->ordering = 1;
@@ -317,7 +311,7 @@ function cancel()
$user = & JFactory::getUser();
// At some point in the future these will be in a request object
- $Itemid = JRequest::getVar('Returnid', '0', 'post', 'int');
+ $Itemid = JRequest::getVar('Returnid', '0', 'post', 'int');
// Get an article table object and bind post variabes to it [We don't need a full model here]
$article = & JTable::getInstance('content');
@@ -382,8 +376,7 @@ function findkey()
$keyref = $db->getEscaped($keyref);
// If no keyref left, throw 404
- if( empty($keyref) === true )
- {
+ if( empty($keyref) === true ) {
JError::raiseError( 404, JText::_("Key Not Found") );
}
View
307 components/com_content/helpers/content.php
@@ -19,321 +19,21 @@
jimport('joomla.application.component.helper');
/**
- * Content Component Helper
+ * Content Component Helper Content
*
* @static
* @package Joomla
* @subpackage Content
* @since 1.5
*/
-class JContentHelper
+class ContentHelper
{
- function saveContentPrep(& $row)
- {
- //Get submitted text from the request variables
- $text = JRequest::getVar('text', '', 'post', 'string', JREQUEST_ALLOWRAW);
-
- //Clean text for xhtml transitional compliance
- jimport('joomla.filter.output');
- $text = str_replace('<br>', '<br />', $text);
- $row->title = JOutputFilter::ampReplace($row->title);
-
- // Search for the {readmore} tag and split the text up accordingly.
- $tagPos = JString::strpos($text, '<hr id="system-readmore" />');
-
- if ($tagPos === false) {
- $row->introtext = $text;
- } else {
- $row->introtext = JString::substr($text, 0, $tagPos);
- $row->fulltext = JString::substr($text, $tagPos +27);
- }
-
- return true;
- }
-
- function orderbyPrimary($orderby)
- {
- switch ($orderby)
- {
- case 'alpha' :
- $orderby = 'cc.title, ';
- break;
-
- case 'ralpha' :
- $orderby = 'cc.title DESC, ';
- break;
-
- case 'order' :
- $orderby = 'cc.ordering, ';
- break;
-
- default :
- $orderby = '';
- break;
- }
-
- return $orderby;
- }
-
- function orderbySecondary($orderby)
- {
- switch ($orderby)
- {
- case 'date' :
- $orderby = 'a.created';
- break;
-
- case 'rdate' :
- $orderby = 'a.created DESC';
- break;
-
- case 'alpha' :
- $orderby = 'a.title';
- break;
-
- case 'ralpha' :
- $orderby = 'a.title DESC';
- break;
-
- case 'hits' :
- $orderby = 'a.hits DESC';
- break;
-
- case 'rhits' :
- $orderby = 'a.hits';
- break;
-
- case 'order' :
- $orderby = 'a.ordering';
- break;
-
- case 'author' :
- $orderby = 'a.created_by_alias, u.name';
- break;
-
- case 'rauthor' :
- $orderby = 'a.created_by_alias DESC, u.name DESC';
- break;
-
- case 'front' :
- $orderby = 'f.ordering';
- break;
-
- default :
- $orderby = 'a.ordering';
- break;
- }
-
- return $orderby;
- }
-
- /*
- * @param int 0 = Archives, 1 = Section, 2 = Category
- */
- function buildWhere($type = 1, & $access, & $noauth, $gid, $id, $now = NULL, $year = NULL, $month = NULL)
- {
- global $mainframe;
-
- $db =& JFactory::getDBO();
- $params = &JComponentHelper::getParams( 'com_content' );
- $noauth = !$params->get('shownoauth');
- $nullDate = $db->getNullDate();
- $where = array ();
-
- // normal
- if ($type > 0) {
- $where[] = "a.state = 1";
- if (!$access->canEdit) {
- $where[] = "( a.publish_up = '$nullDate' OR a.publish_up <= '$now' )";
- $where[] = "( a.publish_down = '$nullDate' OR a.publish_down >= '$now' )";
- }
- if ($id > 0) {
- if ($type == 1) {
- $where[] = "a.sectionid IN ( $id ) ";
- } else
- if ($type == 2) {
- $where[] = "a.catid IN ( $id ) ";
- }
- }
- }
-
- // archive
- if ($type < 0)
- {
- $where[] = "a.state='-1'";
- if ($year) {
- $where[] = "YEAR( a.created ) = '$year'";
- }
- if ($month) {
- $where[] = "MONTH( a.created ) = '$month'";
- }
- if ($id > 0) {
- if ($type == -1) {
- $where[] = "a.sectionid = $id";
- } else
- if ($type == -2) {
- $where[] = "a.catid = $id";
- }
- }
- }
-
- if ($id == 0) {
- $where[] = "s.published = 1";
- $where[] = "cc.published = 1";
- if ($noauth) {
- $where[] = "a.access <= $gid";
- $where[] = "s.access <= $gid";
- $where[] = "cc.access <= $gid";
- }
- }
-
- return $where;
- }
-
- function buildVotingQuery()
- {
- $params = &JComponentHelper::getParams( 'com_content' );
- $voting = $params->get('vote');
-
- if ($voting) {
- // calculate voting count
- $select = ' , ROUND( v.rating_sum / v.rating_count ) AS rating, v.rating_count';
- $join = ' LEFT JOIN #__content_rating AS v ON a.id = v.content_id';
- } else {
- $select = '';
- $join = '';
- }
-
- $results = array ('select' => $select, 'join' => $join);
-
- return $results;
- }
-
- function getSectionLink(& $row)
- {
- $db =& JFactory::getDBO();
- static $links;
-
- if (!isset ($links)) {
- $links = array ();
- }
-
- if (empty ($links[$row->sectionid])) {
- $query = 'SELECT id, link' .
- ' FROM #__menu' .
- ' WHERE published = 1' .
- ' AND (type = "content_section" OR type = "content_blog_section" )' .
- ' AND componentid = '. $row->sectionid .
- ' ORDER BY type DESC, ordering';
- $db->setQuery($query);
- //$secLinkID = $db->loadResult();
- $result = $db->loadRow();
-
- $secLinkID = $result[0];
- $secLinkURL = $result[1];
-
- /*
- * Did we find an Itemid for the section?
- */
- $Itemid = null;
- if ($secLinkID) {
- $Itemid = '&Itemid='.(int) $secLinkID;
-
- if ($secLinkURL) {
- $link = JRoute::_($secLinkURL.$Itemid);
- } else {
- $link = JRoute::_('index.php?option=com_content&task=section&id='.$row->sectionid.$Itemid);
- }
- /*
- * We found one.. and built the link, so lets set it
- */
- $links[$row->sectionid] = '<a href="'.$link.'">'.$row->section.'</a>';
- } else {
- /*
- * Didn't find an Itemid.. set the section name as the link
- */
- $links[$row->sectionid] = $row->section;
- }
- }
-
- return $links[$row->sectionid];
- }
-
- function getCategoryLink(& $row)
- {
- $db =& JFactory::getDBO();
- static $links;
-
- if (!isset ($links)) {
- $links = array ();
- }
-
- if (empty ($links[$row->catid])) {
-
- $query = 'SELECT id, link' .
- ' FROM #__menu' .
- ' WHERE published = 1' .
- ' AND (type = "content_category" OR type = "content_blog_category" )' .
- ' AND componentid = ' . (int) $row->catid .
- ' ORDER BY type DESC, ordering';
- $db->setQuery($query);
- $result = $db->loadRow();
-
- $catLinkID = $result[0];
- $catLinkURL = $result[1];
-
- // Did we find an Itemid for the category?
- $Itemid = null;
- if ($catLinkID)
- {
- $Itemid = '&amp;Itemid='.(int) $catLinkID;
- }
- else
- {
- // Nope, lets try to find it by section...
- $query = 'SELECT id, link' .
- ' FROM #__menu' .
- ' WHERE published = 1' .
- ' AND (type = "content_section" OR type = "content_blog_section" )' .
- ' AND componentid = '. $row->sectionid .
- ' ORDER BY type DESC, ordering';
- $db->setQuery($query);
- $secLinkID = $db->loadResult();
-
- // Find it by section?
- if ($secLinkID) {
- $Itemid = '&amp;Itemid='.$secLinkID;
- }
- }
-
- if ($Itemid !== null)
- {
- if ($catLinkURL) {
- $link = JRoute::_($catLinkURL.$Itemid);
- } else {
- $link = JRoute::_('index.php?option=com_content&task=category&sectionid='.$row->sectionid.'&id='.$row->catid.$Itemid);
- }
-
- // We found an Itemid... build the link
- $links[$row->catid] = '<a href="'.$link.'">'.$row->category.'</a>';
- }
- else
- {
- // Didn't find an Itemid.. set the section name as the link
- $links[$row->catid] = $row->category;
- }
- }
-
- return $links[$row->catid];
- }
-
-
/**
* @param int The route of the content item
*/
function getArticleRoute($id, $catid = 0, $sectionid = 0)
{
- $item = JContentHelper::_getArticleMenuInfo((int)$id, (int)$catid, (int)$sectionid);
+ $item = ContentHelper::_getArticleMenuInfo((int)$id, (int)$catid, (int)$sectionid);
$link = 'index.php?option=com_content&view=article';
if(@$item->link_parts['view'] == 'article') {
@@ -356,7 +56,6 @@ function getArticleRoute($id, $catid = 0, $sectionid = 0)
*/
function _getArticleMenuInfo($id, $catid = 0, $sectionid = 0)
{
- $db =& JFactory::getDBO();
$component =& JComponentHelper::getInfo('com_content');
$menus =& JMenu::getInstance();
View
52 components/com_content/helpers/controller.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * @version $Id: content.php 7054 2007-03-28 23:54:44Z louis $
+ * @package Joomla
+ * @subpackage Content
+ * @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
+ * @license GNU/GPL, see LICENSE.php
+ * Joomla! is free software. This version may have been modified pursuant to the
+ * GNU General Public License, and as distributed it includes or is derivative
+ * of works licensed under the GNU General Public License or other free or open
+ * source software licenses. See COPYRIGHT.php for copyright notices and
+ * details.
+ */
+
+// no direct access
+defined('_JEXEC') or die('Restricted access');
+
+/**
+ * Content Component Helper Controller
+ *
+ * @static
+ * @package Joomla
+ * @subpackage Content
+ * @since 1.5
+ */
+class ContentHelperController
+{
+ //TODO :: Move this function in the JTableContent class ??
+ function saveContentPrep(& $row)
+ {
+ //Get submitted text from the request variables
+ $text = JRequest::getVar('text', '', 'post', 'string', JREQUEST_ALLOWRAW);
+
+ //Clean text for xhtml transitional compliance
+ jimport('joomla.filter.output');
+ $text = str_replace('<br>', '<br />', $text);
+ $row->title = JOutputFilter::ampReplace($row->title);
+
+ // Search for the {readmore} tag and split the text up accordingly.
+ $tagPos = JString::strpos($text, '<hr id="system-readmore" />');
+
+ if ($tagPos === false) {
+ $row->introtext = $text;
+ } else {
+ $row->introtext = JString::substr($text, 0, $tagPos);
+ $row->fulltext = JString::substr($text, $tagPos +27);
+ }
+
+ return true;
+ }
+}
+?>
View
156 components/com_content/helpers/html.php
@@ -0,0 +1,156 @@
+<?php
+/**
+ * @version $Id: content.php 7054 2007-03-28 23:54:44Z louis $
+ * @package Joomla
+ * @subpackage Content
+ * @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
+ * @license GNU/GPL, see LICENSE.php
+ * Joomla! is free software. This version may have been modified pursuant to the
+ * GNU General Public License, and as distributed it includes or is derivative
+ * of works licensed under the GNU General Public License or other free or open
+ * source software licenses. See COPYRIGHT.php for copyright notices and
+ * details.
+ */
+
+// no direct access
+defined('_JEXEC') or die('Restricted access');
+
+/**
+ * Content Component Helper View
+ *
+ * @static
+ * @package Joomla
+ * @subpackage Content
+ * @since 1.5
+ */
+class ContentHelperHTML
+{
+ function Icon($type, $article, $params, $access, $attribs = array())
+ {
+ global $Itemid;
+
+ $user =& JFactory::getUser();
+
+ $url = '';
+ $text = '';
+
+ switch($type)
+ {
+ case 'new' :
+ {
+ $url = 'index.php?task=new&id=0&sectionid='.$article->sectionid;
+
+ if ($params->get('icons')) {
+ $text = JAdminMenus::ImageCheck('new.png', '/images/M_images/', NULL, NULL, JText::_('New'), JText::_('New'). $article->id );
+ } else {
+ $text = JText::_('New').'&nbsp;';
+ }
+
+ $attribs = array( 'title' => '"'.JText::_( 'New' ).'"');
+ $output = JHTML::Link($url, $text, $attribs);
+ } break;
+
+ case 'pdf' :
+ {
+ $url = 'index.php?view=article&id='.$article->id.'&format=pdf';
+ $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
+
+ // checks template image directory for image, if non found default are loaded
+ if ($params->get('icons')) {
+ $text = JAdminMenus::ImageCheck('pdf_button.png', '/images/M_images/', NULL, NULL, JText::_('PDF'), JText::_('PDF'));
+ } else {
+ $text = JText::_('PDF').'&nbsp;';
+ }
+
+ $attribs['title'] = '"'.JText::_( 'PDF' ).'"';
+ $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
+
+ $output = JHTML::Link($url, $text, $attribs);
+ } break;
+
+ case 'print' :
+ {
+ $url = 'index.php?view=article&id='.$article->id.'&tmpl=component&print=1&page='.@ $request->limitstart;
+ $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
+
+ // checks template image directory for image, if non found default are loaded
+ if ( $params->get( 'icons' ) ) {
+ $text = JAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, JText::_( 'Print' ), JText::_( 'Print' ) );
+ } else {
+ $text = JText::_( 'ICON_SEP' ) .'&nbsp;'. JText::_( 'Print' ) .'&nbsp;'. JText::_( 'ICON_SEP' );
+ }
+
+ $attribs['title'] = '"'.JText::_( 'Print' ).'"';
+ $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
+
+ $output = JHTML::Link($url, $text, $attribs);
+ } break;
+
+ case 'email' :
+ {
+ $url = 'index.php?option=com_mailto&tmpl=component&link='.base64_encode( JRequest::getURI());
+ $status = 'width=400,height=300,menubar=yes,resizable=yes';
+
+ if ($params->get('icons')) {
+ $text = JAdminMenus::ImageCheck('emailButton.png', '/images/M_images/', NULL, NULL, JText::_('Email'), JText::_('Email'));
+ } else {
+ $text = '&nbsp;'.JText::_('Email');
+ }
+
+ $attribs['title'] = '"'.JText::_( 'Email ' ).'"';
+ $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
+
+ $output = JHTML::Link($url, $text, $attribs);
+ } break;
+
+ case 'edit' :
+ {
+ if ($params->get('popup')) {
+ return;
+ }
+ if ($article->state < 0) {
+ return;
+ }
+ if (!$access->canEdit && !($access->canEditOwn && $article->created_by == $user->get('id'))) {
+ return;
+ }
+ jimport('joomla.html.tooltips');
+ $url = 'index.php?view=article&&id='.$article->id.'&task=edit&Returnid='.$Itemid;
+ $text = JAdminMenus::ImageCheck('edit.png', '/images/M_images/', NULL, NULL, JText::_('Edit'), JText::_('Edit'). $article->id );
+
+ if ($article->state == 0) {
+ $overlib = JText::_('Unpublished');
+ } else {
+ $overlib = JText::_('Published');
+ }
+ $date = JHTML::Date($article->created);
+ $author = $article->created_by_alias ? $article->created_by_alias : $article->author;
+
+ $overlib .= '<br />';
+ $overlib .= $article->groups;
+ $overlib .= '<br />';
+ $overlib .= $date;
+ $overlib .= '<br />';
+ $overlib .= $author;
+
+ $button = JHTML::Link($url, $text);
+
+ $output = '<span class="hasTip" title="'.JText::_( 'Edit Item' ).' :: '.$overlib.'">'.$button.'</span>';
+ } break;
+
+ case 'print_screen' :
+ {
+ // checks template image directory for image, if non found default are loaded
+ if ( $params->get( 'icons' ) ) {
+ $text = JAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, JText::_( 'Print' ), JText::_( 'Print' ) );
+ } else {
+ $text = JText::_( 'ICON_SEP' ) .'&nbsp;'. JText::_( 'Print' ) .'&nbsp;'. JText::_( 'ICON_SEP' );
+ }
+ $output = '<a href="#" onclick="window.print();return false;">'.$text.'</a>';
+ }
+ }
+
+ return $output;
+ }
+}
+?>
View
236 components/com_content/helpers/model.php
@@ -0,0 +1,236 @@
+<?php
+/**
+ * @version $Id: content.php 7054 2007-03-28 23:54:44Z louis $
+ * @package Joomla
+ * @subpackage Content
+ * @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
+ * @license GNU/GPL, see LICENSE.php
+ * Joomla! is free software. This version may have been modified pursuant to the
+ * GNU General Public License, and as distributed it includes or is derivative
+ * of works licensed under the GNU General Public License or other free or open
+ * source software licenses. See COPYRIGHT.php for copyright notices and
+ * details.
+ */
+
+// no direct access
+defined('_JEXEC') or die('Restricted access');
+
+/**
+ * Content Component Helper Model
+ *
+ * @static
+ * @package Joomla
+ * @subpackage Content
+ * @since 1.5
+ */
+class ContentHelperModel
+{
+ function orderbyPrimary($orderby)
+ {
+ switch ($orderby)
+ {
+ case 'alpha' :
+ $orderby = 'cc.title, ';
+ break;
+
+ case 'ralpha' :
+ $orderby = 'cc.title DESC, ';
+ break;
+
+ case 'order' :
+ $orderby = 'cc.ordering, ';
+ break;
+
+ default :
+ $orderby = '';
+ break;
+ }
+
+ return $orderby;
+ }
+
+ function orderbySecondary($orderby)
+ {
+ switch ($orderby)
+ {
+ case 'date' :
+ $orderby = 'a.created';
+ break;
+
+ case 'rdate' :
+ $orderby = 'a.created DESC';
+ break;
+
+ case 'alpha' :
+ $orderby = 'a.title';
+ break;
+
+ case 'ralpha' :
+ $orderby = 'a.title DESC';
+ break;
+
+ case 'hits' :
+ $orderby = 'a.hits DESC';
+ break;
+
+ case 'rhits' :
+ $orderby = 'a.hits';
+ break;
+
+ case 'order' :
+ $orderby = 'a.ordering';
+ break;
+
+ case 'author' :
+ $orderby = 'a.created_by_alias, u.name';
+ break;
+
+ case 'rauthor' :
+ $orderby = 'a.created_by_alias DESC, u.name DESC';
+ break;
+
+ case 'front' :
+ $orderby = 'f.ordering';
+ break;
+
+ default :
+ $orderby = 'a.ordering';
+ break;
+ }
+
+ return $orderby;
+ }
+
+ function buildVotingQuery()
+ {
+ $params = &JComponentHelper::getParams( 'com_content' );
+ $voting = $params->get('vote');
+
+ if ($voting) {
+ // calculate voting count
+ $select = ' , ROUND( v.rating_sum / v.rating_count ) AS rating, v.rating_count';
+ $join = ' LEFT JOIN #__content_rating AS v ON a.id = v.content_id';
+ } else {
+ $select = '';
+ $join = '';
+ }
+
+ $results = array ('select' => $select, 'join' => $join);
+
+ return $results;
+ }
+
+ function getSectionLink(& $row)
+ {
+ $db =& JFactory::getDBO();
+ static $links;
+
+ if (!isset ($links)) {
+ $links = array ();
+ }
+
+ if (empty ($links[$row->sectionid]))
+ {
+ $query = 'SELECT id, link' .
+ ' FROM #__menu' .
+ ' WHERE published = 1' .
+ ' AND (type = "content_section" OR type = "content_blog_section" )' .
+ ' AND componentid = '. $row->sectionid .
+ ' ORDER BY type DESC, ordering';
+ $db->setQuery($query);
+ $result = $db->loadRow();
+
+ $secLinkID = $result[0];
+ $secLinkURL = $result[1];
+
+ $Itemid = null;
+ if ($secLinkID)
+ {
+ $Itemid = '&Itemid='.(int) $secLinkID;
+
+ if ($secLinkURL) {
+ $link = JRoute::_($secLinkURL.$Itemid);
+ } else {
+ $link = JRoute::_('index.php?option=com_content&task=section&id='.$row->sectionid.$Itemid);
+ }
+
+ $links[$row->sectionid] = '<a href="'.$link.'">'.$row->section.'</a>';
+ }
+ else
+ {
+ $links[$row->sectionid] = $row->section;
+ }
+ }
+
+ return $links[$row->sectionid];
+ }
+
+ function getCategoryLink(& $row)
+ {
+ $db =& JFactory::getDBO();
+ static $links;
+
+ if (!isset ($links)) {
+ $links = array ();
+ }
+
+ if (empty ($links[$row->catid])) {
+
+ $query = 'SELECT id, link' .
+ ' FROM #__menu' .
+ ' WHERE published = 1' .
+ ' AND (type = "content_category" OR type = "content_blog_category" )' .
+ ' AND componentid = ' . (int) $row->catid .
+ ' ORDER BY type DESC, ordering';
+ $db->setQuery($query);
+ $result = $db->loadRow();
+
+ $catLinkID = $result[0];
+ $catLinkURL = $result[1];
+
+ // Did we find an Itemid for the category?
+ $Itemid = null;
+ if ($catLinkID)
+ {
+ $Itemid = '&amp;Itemid='.(int) $catLinkID;
+ }
+ else
+ {
+ // Nope, lets try to find it by section...
+ $query = 'SELECT id, link' .
+ ' FROM #__menu' .
+ ' WHERE published = 1' .
+ ' AND (type = "content_section" OR type = "content_blog_section" )' .
+ ' AND componentid = '. $row->sectionid .
+ ' ORDER BY type DESC, ordering';
+ $db->setQuery($query);
+ $secLinkID = $db->loadResult();
+
+ // Find it by section?
+ if ($secLinkID) {
+ $Itemid = '&amp;Itemid='.$secLinkID;
+ }
+ }
+
+ if ($Itemid !== null)
+ {
+ if ($catLinkURL) {
+ $link = JRoute::_($catLinkURL.$Itemid);
+ } else {
+ $link = JRoute::_('index.php?option=com_content&task=category&sectionid='.$row->sectionid.'&id='.$row->catid.$Itemid);
+ }
+
+ // We found an Itemid... build the link
+ $links[$row->catid] = '<a href="'.$link.'">'.$row->category.'</a>';
+ }
+ else
+ {
+ // Didn't find an Itemid.. set the section name as the link
+ $links[$row->catid] = $row->category;
+ }
+ }
+
+ return $links[$row->catid];
+ }
+}
+?>
View
4 components/com_content/models/archive.php
@@ -90,7 +90,7 @@ function getTotal()
function _buildQuery()
{
// If voting is turned on, get voting data as well for the content items
- $voting = JContentHelper::buildVotingQuery();
+ $voting = ContentHelperModel::buildVotingQuery();
// Get the WHERE and ORDER BY clauses for the query
$where = $this->_buildContentWhere();
@@ -129,7 +129,7 @@ function _buildContentOrderBy()
// Special ordering for archive articles
$orderby_sec = $params->def('orderby', 'rdate');
- $primary = JContentHelper::orderbySecondary($orderby_sec);
+ $primary = ContentHelperModel::orderbySecondary($orderby_sec);
$orderby .= $primary;
return $orderby;
View
6 components/com_content/models/article.php
@@ -322,7 +322,7 @@ function _loadArticle()
if (empty($this->_article))
{
// If voting is turned on, get voting data as well for the article
- $voting = JContentHelper::buildVotingQuery();
+ $voting = ContentHelperModel::buildVotingQuery();
// Get the WHERE clause
$where = $this->_buildContentWhere();
@@ -411,12 +411,12 @@ function _loadArticleParams()
// Set the Section name as a link if needed
if ($params->get('section_link') && $this->_article->sectionid) {
- $this->_article->section = JContentHelper::getSectionLink($this->_article);
+ $this->_article->section = ContentHelperModel::getSectionLink($this->_article);
}
// Set the Category name as a link if needed
if ($params->get('category_link') && $this->_article->catid) {
- $this->_article->category = JContentHelper::getCategoryLink($this->_article);
+ $this->_article->category = ContentHelpeModel::getCategoryLink($this->_article);
}
// Show or Hide the introtext column
View
8 components/com_content/models/category.php
@@ -329,7 +329,7 @@ function _loadData($state = 1)
function _buildQuery($state = 1)
{
// If voting is turned on, get voting data as well for the content items
- $voting = JContentHelper::buildVotingQuery();
+ $voting = ContentHelperModel::buildVotingQuery();
// Get the WHERE and ORDER BY clauses for the query
$where = $this->_buildContentWhere($state);
@@ -375,15 +375,15 @@ function _buildContentOrderBy($state = 1)
case -1:
// Special ordering for archive articles
$orderby_sec = $params->def('orderby', 'rdate');
- $order_sec = JContentHelper::orderbySecondary($orderby_sec);
+ $order_sec = ContentHelperModel::orderbySecondary($orderby_sec);
break;
case 1:
default:
$orderby_sec = $params->def('orderby_sec', 'rdate');
$orderby_sec = ($orderby_sec == 'front') ? '' : $orderby_sec;
$orderby_pri = $params->def('orderby_pri', '');
- $secondary = JContentHelper::orderbySecondary($orderby_sec).', ';
- $primary = JContentHelper::orderbyPrimary($orderby_pri);
+ $secondary = ContentHelperModel::orderbySecondary($orderby_sec).', ';
+ $primary = ContentHelperModel::orderbyPrimary($orderby_pri);
break;
}
$orderby .= $primary .' '. $secondary .' a.created DESC';
View
6 components/com_content/models/frontpage.php
@@ -116,7 +116,7 @@ function _loadData()
function _buildQuery()
{
// Voting is turned on, get voting data as well for the content items
- $voting = JContentHelper::buildVotingQuery();
+ $voting = ContentHelperModel::buildVotingQuery();
// Get the WHERE and ORDER BY clauses for the query
$where = $this->_buildContentWhere();
@@ -149,8 +149,8 @@ function _buildContentOrderBy()
$orderby_sec = $params->def('orderby_sec', '');
$orderby_pri = $params->def('orderby_pri', '');
- $secondary = JContentHelper::orderbySecondary($orderby_sec);
- $primary = JContentHelper::orderbyPrimary($orderby_pri);
+ $secondary = ContentHelperModel::orderbySecondary($orderby_sec);
+ $primary = ContentHelperModel::orderbyPrimary($orderby_pri);
$orderby = ' ORDER BY '.$primary.' '.$secondary;
View
10 components/com_content/models/section.php
@@ -271,7 +271,7 @@ function _loadCategories()
// Ordering control
$orderby = $params->get('orderby', '');
- $orderby = JContentHelper::orderbySecondary($orderby);
+ $orderby = ContentHelperModel::orderbySecondary($orderby);
// Handle the access permissions part of the main database query
if ($user->authorize('action', 'edit', 'content', 'all')) {
@@ -387,7 +387,7 @@ function _loadTree()
function _buildQuery($state = 1)
{
// If voting is turned on, get voting data as well for the content items
- $voting = JContentHelper::buildVotingQuery();
+ $voting = ContentHelperModel::buildVotingQuery();
// Get the WHERE and ORDER BY clauses for the query
$where = $this->_buildContentWhere($state);
@@ -429,15 +429,15 @@ function _buildContentOrderBy($state = 1)
case -1:
// Special ordering for archive articles
$orderby_sec = $params->def('orderby', 'rdate');
- $order_sec = JContentHelper::orderbySecondary($orderby_sec);
+ $order_sec = ContentHelperModel::orderbySecondary($orderby_sec);
break;
case 1:
default:
$orderby_sec = $params->def('orderby_sec', 'rdate');
$orderby_sec = ($orderby_sec == 'front') ? '' : $orderby_sec;
$orderby_pri = $params->def('orderby_pri', '');
- $secondary = JContentHelper::orderbySecondary($orderby_sec);
- $primary = JContentHelper::orderbyPrimary($orderby_pri);
+ $secondary = ContentHelperModel::orderbySecondary($orderby_sec);
+ $primary = ContentHelperModel::orderbyPrimary($orderby_pri);
break;
}
$orderby .= "$primary $secondary";
View
10 components/com_content/views/article/tmpl/default.php
@@ -2,7 +2,7 @@
defined('_JEXEC') or die('Restricted access'); ?>
<?php if ($this->user->authorize('action', 'edit', 'content', 'all') && !$this->print) : ?>
<div class="contentpaneopen_edit<?php echo $this->params->get( 'pageclass_sfx' ); ?>" style="float: left;">
- <?php echo $this->getIcon('edit'); ?>
+ <?php echo ContentHelperHTML::Icon('edit', $this->article, $this->params, $this->access); ?>
</div>
<?php endif; ?>
@@ -23,24 +23,24 @@
<?php if (!$this->print) : ?>
<?php if ($this->params->get('pdf')) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('pdf'); ?>
+ <?php echo ContentHelperHTML::Icon('pdf', $this->article, $this->params, $this->access); ?>
</td>
<?php endif; ?>
<?php if ( $this->params->get( 'print' )) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('print'); ?>
+ <?php echo ContentHelperHTML::Icon('print', $this->article, $this->params, $this->access); ?>
</td>
<?php endif; ?>
<?php if ($this->params->get('email')) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('email'); ?>
+ <?php echo ContentHelperHTML::Icon('email', $this->article, $this->params, $this->access); ?>
</td>
<?php endif; ?>
<?php else : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('print_screen'); ?>
+ <?php echo ContentHelperHTML::Icon('print_screen', $this->article, $this->params, $this->access); ?>
</td>
<?php endif; ?>
</tr>
View
123 components/com_content/views/article/view.html.php
@@ -33,12 +33,12 @@ function display($tpl = null)
$user =& JFactory::getUser();
$document =& JFactory::getDocument();
$dispatcher =& JEventDispatcher::getInstance();
- $pathway =& $mainframe->getPathWay();
+ $pathway =& $mainframe->getPathWay();
$contentConfig = &JComponentHelper::getParams( 'com_content' );
// Initialize variables
$article =& $this->get('Article');
- $params =& $article->parameters;
+ $params =& $article->parameters;
// Get the menu object of the active menu item
$menu =& JMenu::getInstance();
@@ -67,7 +67,7 @@ function display($tpl = null)
$linkText = null;
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
-
+
//set breadcrumbs
if($item->query['view'] != 'article')
{
@@ -105,7 +105,7 @@ function display($tpl = null)
// Create a user access object for the current user
$access = new stdClass();
- $access->canEdit = $user->authorize('action', 'edit', 'content', 'all');
+ $access->canEdit = $user->authorize('action', 'edit', 'content', 'all');
$access->canEditOwn = $user->authorize('action', 'edit', 'content', 'own');
$access->canPublish = $user->authorize('action', 'publish', 'content', 'all');
@@ -171,121 +171,6 @@ function display($tpl = null)
parent::display($tpl);
}
- function getIcon($type, $attribs = array())
- {
- global $mainframe, $Itemid;
-
- $url = '';
- $text = '';
-
- $article = &$this->article;
-
- switch($type)
- {
- case 'pdf' :
- {
- $url = 'index.php?option=com_content&view=article&id='.$article->id.'&format=pdf';
- $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
-
- // checks template image directory for image, if non found default are loaded
- if ($this->params->get('icons')) {
- $text = JAdminMenus::ImageCheck('pdf_button.png', '/images/M_images/', NULL, NULL, JText::_('PDF'), JText::_('PDF'));
- } else {
- $text = JText::_('PDF').'&nbsp;';
- }
-
- $attribs['title'] = '"'.JText::_( 'PDF' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
-
- $output = JHTML::Link($url, $text, $attribs);
- } break;
-
- case 'print' :
- {
- $url = 'index.php?option=com_content&view=article&id='.$article->id.'&tmpl=component&print=1&page='.@ $this->request->limitstart;
- $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
-
- // checks template image directory for image, if non found default are loaded
- if ( $this->params->get( 'icons' ) ) {
- $text = JAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, JText::_( 'Print' ), JText::_( 'Print' ) );
- } else {
- $text = JText::_( 'ICON_SEP' ) .'&nbsp;'. JText::_( 'Print' ) .'&nbsp;'. JText::_( 'ICON_SEP' );
- }
-
- $attribs['title'] = '"'.JText::_( 'Print' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
-
- $output = JHTML::Link($url, $text, $attribs);
- } break;
-
- case 'email' :
- {
- $url = 'index.php?option=com_mailto&tmpl=component&link='.base64_encode( JRequest::getURI());
- $status = 'width=400,height=300,menubar=yes,resizable=yes';
-
- if ($this->params->get('icons')) {
- $text = JAdminMenus::ImageCheck('emailButton.png', '/images/M_images/', NULL, NULL, JText::_('Email'), JText::_('Email'));
- } else {
- $text = '&nbsp;'.JText::_('Email');
- }
-
- $attribs['title'] = '"'.JText::_( 'Email ' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
-
- $output = JHTML::Link($url, $text, $attribs);
- } break;
-
- case 'edit' :
- {
- if ($this->params->get('popup')) {
- return;
- }
- if ($article->state < 0) {
- return;
- }
- if (!$this->access->canEdit && !($this->access->canEditOwn && $article->created_by == $this->user->get('id'))) {
- return;
- }
- jimport('joomla.html.tooltips');
- $url = 'index.php?option=com_content&view=article&layout=form&id='.$article->id.'&Returnid='.$Itemid;
- $text = JAdminMenus::ImageCheck('edit.png', '/images/M_images/', NULL, NULL, JText::_('Edit'), JText::_('Edit'). $article->id );
-
- if ($article->state == 0) {
- $overlib = JText::_('Unpublished');
- } else {
- $overlib = JText::_('Published');
- }
- $date = JHTML::Date($article->created);
- $author = $article->created_by_alias ? $article->created_by_alias : $article->author;
-
- $overlib .= '<br />';
- $overlib .= $article->groups;
- $overlib .= '<br />';
- $overlib .= $date;
- $overlib .= '<br />';
- $overlib .= $author;
-
- $button = JHTML::Link($url, $text);
-
- $output = '<span class="hasTip" title="'.JText::_( 'Edit Item' ).' :: '.$overlib.'">'.$button.'</span>';
- } break;
-
- case 'print_screen' :
- {
- // checks template image directory for image, if non found default are loaded
- if ( $this->params->get( 'icons' ) ) {
- $text = JAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, JText::_( 'Print' ), JText::_( 'Print' ) );
- } else {
- $text = JText::_( 'ICON_SEP' ) .'&nbsp;'. JText::_( 'Print' ) .'&nbsp;'. JText::_( 'ICON_SEP' );
- }
- $output = '<a href="#" onclick="window.print();return false;">'.$text.'</a>';
- }
- }
-
-
- return $output;
- }
-
function _displayForm($tpl)
{
global $mainframe, $Itemid;
View
8 components/com_content/views/category/tmpl/blog_item.php
@@ -2,7 +2,7 @@
defined('_JEXEC') or die('Restricted access'); ?>
<?php if ($this->user->authorize('action', 'edit', 'content', 'all')) : ?>
<div class="contentpaneopen_edit<?php echo $this->params->get( 'pageclass_sfx' ); ?>" style="float: left;">
- <?php echo $this->getIcon('edit'); ?>
+ <?php echo ContentHelperHTML::Icon('edit', $this->item, $this->params, $this->access); ?>
</div>
<?php endif; ?>
@@ -23,19 +23,19 @@
<?php if ($this->params->get('pdf')) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('pdf'); ?>
+ <?php echo ContentHelperHTML::Icon('pdf', $this->item, $this->params, $this->access); ?>
</td>
<?php endif; ?>
<?php if ( $this->params->get( 'print' )) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('print'); ?>
+ <?php echo ContentHelperHTML::Icon('print', $this->item, $this->params, $this->access); ?>
</td>
<?php endif; ?>
<?php if ($this->params->get('email')) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('email'); ?>
+ <?php echo ContentHelperHTML::Icon('email', $this->item, $this->params, $this->access); ?>
</td>
<?php endif; ?>
</tr>
View
2  components/com_content/views/category/tmpl/default.php
@@ -22,7 +22,7 @@
?>
<?php if ($this->access->canEdit || $this->access->canEditOwn) :
- echo $this->getIcon('new');
+ echo ContentHelperHTML::Icon('new', $this->category , $this->params, $this->access);
endif; ?>
</td>
</tr>
View
2  components/com_content/views/category/tmpl/default_items.php
@@ -74,7 +74,7 @@ function tableOrdering( order, dir, task )
<td>
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?></a>
- <?php $this->item = $item; echo $this->getIcon('edit') ?>
+ <?php $this->item = $item; echo ContentHelperHTML::Icon('edit', $item, $this->params, $this->access) ?>
</td>
<?php else : ?>
<td>
View
134 components/com_content/views/category/view.html.php
@@ -74,8 +74,7 @@ function display($tpl = null)
$access->canPublish = $user->authorize('action', 'publish', 'content', 'all');
//set breadcrumbs
- if($item->query['view'] != 'category')
- {
+ if($item->query['view'] != 'category') {
$pathway->addItem($category->title, '');
}
@@ -84,20 +83,20 @@ function display($tpl = null)
$contentConfig = &JComponentHelper::getParams( 'com_content' );
$params->def('title', 1);
$params->def('hits', $contentConfig->get('hits'));
- $params->def('showAuthor', $contentConfig->get('showAuthor'));
+ $params->def('showAuthor', $contentConfig->get('showAuthor'));
$params->def('date', $contentConfig->get('showCreateDate'));
- $params->def('date_format', JText::_('DATE_FORMAT_LC'));
- $params->def('navigation', 2);
- $params->def('display', 1);
- $params->def('display_num', $mainframe->getCfg('list_limit'));
+ $params->def('date_format', JText::_('DATE_FORMAT_LC'));
+ $params->def('navigation', 2);
+ $params->def('display', 1);
+ $params->def('display_num', $mainframe->getCfg('list_limit'));
$params->def('empty_cat', 0);
$params->def('cat_items', 1);
$params->def('cat_description',0);
$params->def('pageclass_sfx', '');
$params->def('headings', 1);
- $params->def('filter', 1);
- $params->def('filter_type', 'title');
- $params->set('intro_only', 1);
+ $params->def('filter', 1);
+ $params->def('filter_type', 'title');
+ $params->set('intro_only', 1);
if ($params->def('page_title', 1)) {
$params->def('header', $item->name);
@@ -119,121 +118,6 @@ function display($tpl = null)
parent::display($tpl);
}
- function getIcon($type, $attribs = array())
- {
- global $mainframe, $Itemid;
-
- $url = '';
- $text = '';
- $output = '';
-
- $article = $this->item;
-
- switch($type)
- {
- case 'new' :
- {
- $url = 'index.php?task=new&id=0&sectionid='.$article->sectionid;
-
- if ($this->params->get('icons')) {
- $text = JAdminMenus::ImageCheck('new.png', '/images/M_images/', NULL, NULL, JText::_('New'), JText::_('New'). $article->id );
- } else {
- $text = JText::_('New').'&nbsp;';
- }
-
- $attribs = array( 'title' => '"'.JText::_( 'New' ).'"');
- $output = JHTML::Link($url, $text, $attribs);
- } break;
-
- case 'edit' :
- {
- if ($this->params->get('popup')) {
- return;
- }
- if ($article->state < 0) {
- return;
- }
- if (!$this->access->canEdit && !($this->access->canEditOwn && $article->created_by == $this->user->get('id'))) {
- return;
- }
-
-
- $url = 'index.php?view=article&id='.$article->id.'&task=edit&Returnid='.$Itemid;
- jimport('joomla.html.tooltips');
- $text = JAdminMenus::ImageCheck('edit.png', '/images/M_images/', NULL, NULL, JText::_('Edit'), JText::_('Edit'). $article->id );
-
- if ($article->state == 0) {
- $overlib = JText::_('Unpublished');
- } else {
- $overlib = JText::_('Published');
- }
- $date = JHTML::Date($article->created);
- $author = $article->created_by_alias ? $article->created_by_alias : $article->author;
-
- $overlib .= '<br />'.$article->groups.'<br />'.$date.'<br />'.$author;
-
- $button = JHTML::Link($url, $text);
-
- $output = '<span class="hasTip" title="'.JText::_( 'Edit Item' ).' :: '.$overlib.'">'.$button.'</span>';
- } break;
-
- case 'pdf' :
- {
- $url = 'index.php?view=article&id='.$article->id.'&format=pdf';
- $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
-
- // checks template image directory for image, if non found default are loaded
- if ($this->params->get('icons')) {
- $text = JAdminMenus::ImageCheck('pdf_button.png', '/images/M_images/', NULL, NULL, JText::_('PDF'), JText::_('PDF'));
- } else {
- $text = JText::_('PDF').'&nbsp;';
- }
-
- $attribs['title'] = '"'.JText::_( 'PDF' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
- $output = JHTML::Link($url, $text, $attribs);
-
- } break;
-
- case 'print' :
- {
- $url = 'index.php?view=article&id='.$article->id.'&tmpl=component&print=1&page='.@ $this->request->limitstart;
- $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
-
- // checks template image directory for image, if non found default are loaded
- if ( $this->params->get( 'icons' ) ) {
- $text = JAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, JText::_( 'Print' ), JText::_( 'Print' ) );
- } else {
- $text = JText::_( 'ICON_SEP' ) .'&nbsp;'. JText::_( 'Print' ) .'&nbsp;'. JText::_( 'ICON_SEP' );
- }
-
- $attribs['title'] = '"'.JText::_( 'Print' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
- $output = JHTML::Link($url, $text, $attribs);
-
- } break;
-
- case 'email' :
- {
- $url = 'index.php?option=com_mailto&tmpl=component&link='.base64_encode( JRequest::getURI());
- $status = 'width=400,height=300,menubar=yes,resizable=yes';
-
- if ($this->params->get('icons')) {
- $text = JAdminMenus::ImageCheck('emailButton.png', '/images/M_images/', NULL, NULL, JText::_('Email'), JText::_('Email'));
- } else {
- $text = '&nbsp;'.JText::_('Email');
- }
-
- $attribs['title'] = '"'.JText::_( 'Email ' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
- $output = JHTML::Link($url, $text, $attribs);
-
- } break;
- }
-
- return $output;
- }
-
function &getItems()
{
global $mainframe;
View
8 components/com_content/views/frontpage/tmpl/default_item.php
@@ -2,7 +2,7 @@
defined('_JEXEC') or die('Restricted access'); ?>
<?php if ($this->user->authorize('action', 'edit', 'content', 'all')) : ?>
<div class="contentpaneopen_edit<?php echo $this->params->get( 'pageclass_sfx' ); ?>" style="float: left;">
- <?php echo $this->getIcon('edit'); ?>
+ <?php echo ContentHelperHTML::Icon('edit', $this->item, $this->params, $this->access); ?>
</div>
<?php endif; ?>
@@ -23,19 +23,19 @@
<?php if ($this->params->get('pdf')) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('pdf'); ?>
+ <?php echo ContentHelperHTML::Icon('pdf', $this->item, $this->params, $this->access); ?>
</td>
<?php endif; ?>
<?php if ( $this->params->get( 'print' )) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('print'); ?>
+ <?php echo ContentHelperHTML::Icon('print', $this->item, $this->params, $this->access); ?>
</td>
<?php endif; ?>
<?php if ($this->params->get('email')) : ?>
<td align="right" width="100%" class="buttonheading">
- <?php echo $this->getIcon('email'); ?>
+ <?php echo ContentHelperHTML::Icon('email', $this->item, $this->params, $this->access); ?>
</td>
<?php endif; ?>
</tr>
View
111 components/com_content/views/frontpage/view.html.php
@@ -49,9 +49,9 @@ function display($tpl = null)
// parameters
$title = $params->def('title', $menu->name);
$intro = $params->def('intro', 4);
- $leading = $params->def('leading', 1);
- $links = $params->def('link', 4);
- $descrip = $params->def('description', 1);
+ $leading = $params->def('leading', 1);
+ $links = $params->def('link', 4);
+ $descrip = $params->def('description', 1);
$descrip_image = $params->def('description_image', 1);
$params->def('pageclass_sfx', '');
@@ -70,10 +70,10 @@ function display($tpl = null)
$total =& $this->get('total');
// Create a user access object for the user
- $access = new stdClass();
+ $access = new stdClass();
$access->canEdit = $user->authorize('action', 'edit', 'content', 'all');
- $access->canEditOwn = $user->authorize('action', 'edit', 'content', 'own');
- $access->canPublish = $user->authorize('action', 'publish', 'content', 'all');
+ $access->canEditOwn = $user->authorize('action', 'edit', 'content', 'own');
+ $access->canPublish = $user->authorize('action', 'publish', 'content', 'all');
//add alternate feed link
$link = JRoute::_('index.php?option=com_content&view=frontpage&format=feed');
@@ -130,105 +130,6 @@ function display($tpl = null)
parent::display($tpl);
}
- function getIcon($type, $attribs = array())
- {
- global $mainframe, $Itemid;
-
- $url = '';
- $text = '';
-
- $article = $this->item;
-
- switch($type)
- {
- case 'pdf' :
- {
- $url = 'index.php?view=article&id='.$article->id.'&format=pdf';
- $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
-
- // checks template image directory for image, if non found default are loaded
- if ($this->params->get('icons')) {
- $text = JAdminMenus::ImageCheck('pdf_button.png', '/images/M_images/', NULL, NULL, JText::_('PDF'), JText::_('PDF'));
- } else {
- $text = JText::_('PDF').'&nbsp;';
- }
-
- $attribs['title'] = '"'.JText::_( 'PDF' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
- $output = JHTML::Link($url, $text, $attribs);
-
- } break;
-
- case 'print' :
- {
- $url = 'index.php?view=article&id='.$article->id.'&tmpl=component&print=1&page='.@ $this->request->limitstart;
- $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
-
- // checks template image directory for image, if non found default are loaded
- if ( $this->params->get( 'icons' ) ) {
- $text = JAdminMenus::ImageCheck( 'printButton.png', '/images/M_images/', NULL, NULL, JText::_( 'Print' ), JText::_( 'Print' ) );
- } else {
- $text = JText::_( 'ICON_SEP' ) .'&nbsp;'. JText::_( 'Print' ) .'&nbsp;'. JText::_( 'ICON_SEP' );
- }
-
- $attribs['title'] = '"'.JText::_( 'Print' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
- $output = JHTML::Link($url, $text, $attribs);
-
- } break;
-
- case 'email' :
- {
- $url = 'index.php?option=com_mailto&tmpl=component&link='.base64_encode( JRequest::getURI());
- $status = 'width=400,height=300,menubar=yes,resizable=yes';
-
- if ($this->params->get('icons')) {
- $text = JAdminMenus::ImageCheck('emailButton.png', '/images/M_images/', NULL, NULL, JText::_('Email'), JText::_('Email'));
- } else {
- $text = '&nbsp;'.JText::_('Email');
- }
-
- $attribs['title'] = '"'.JText::_( 'Email ' ).'"';
- $attribs['onclick'] = "\"window.open(this.href,'win2','".$status."'); return false;\"";
- $output = JHTML::Link($url, $text, $attribs);
-
- } break;
-
- case 'edit' :
- {
- if ($this->params->get('popup')) {
- return;
- }
- if ($article->state < 0) {
- return;
- }
- if (!$this->access->canEdit && !($this->access->canEditOwn && $article->created_by == $this->user->get('id'))) {
- return;
- }
- jimport('joomla.html.tooltips');
- $url = 'index.php?view=article&layout=form&id='.$article->id.'&Returnid='.$Itemid;
- $text = JAdminMenus::ImageCheck('edit.png', '/images/M_images/', NULL, NULL, JText::_('Edit'), JText::_('Edit'). $article->id );
-
- if ($article->state == 0) {
- $overlib = JText::_('Unpublished');
- } else {
- $overlib = JText::_('Published');
- }
- $date = JHTML::Date($article->created);
- $author = $article->created_by_alias ? $article->created_by_alias : $article->author;
-
- $overlib .= '<br />'.$article->groups.'<br />'.$date.'<br />'.$author;
-
- $button = JHTML::Link($url, $text);
-
- $output = '<span class="hasTip" title="'.JText::_( 'Edit Item' ).' :: '.$overlib.'">'.$button.'</span>';
- } break;
- }
-
-
- return $output;
- }
-
function &getItem($index = 0, &$params)
{
global $mainframe;
View
4 components/com_search/search.php
@@ -210,8 +210,8 @@ function getResults($searchword, $phrase, $ordering, $areas)
// determines Itemid for articles where itemid has not been included
if ( !empty($link) && @$link['task'] == 'view' && isset($link['id']) && !isset($link['Itemid']) ) {
$itemid = '';
- if (JContentHelper::getItemid( $link['id'] )) {
- $itemid = '&Itemid='. JContentHelper::getItemid( $link['id'] );
+ if (ContentHelper::getItemid( $link['id'] )) {
+ $itemid = '&Itemid='. ContentHelper::getItemid( $link['id'] );
}
$rows[$i]->href = $rows[$i]->href . $itemid;
}
View
2  includes/framework.php
@@ -83,6 +83,4 @@
jimport( 'joomla.utilities.string' ); //needs to be loaded later
jimport( 'joomla.version' ); //needs to be loaded later
-
-JDEBUG ? $_PROFILER->mark( 'afterLoadFramework' ) : null;
?>
View
3  index.php
@@ -15,12 +15,15 @@
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
+
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'application.php' );
+JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;
+
/**
* CREATE THE APPLICATION
*
View
12 libraries/joomla/application/application.php
@@ -417,7 +417,7 @@ function login($username, $password, $remember)
if (!in_array(false, $results, true)) {
// Set the remember me cookie if enabled
- if ($remember)
+ if ($remember)
{
jimport('joomla.utilities.simplecrypt');
jimport('joomla.utilities.utility');
@@ -624,11 +624,11 @@ function &_createRouter()
if($this->getCfg('sef_rewrite')) {
$options['mode'] = 2;
}
-
+
// Set default router parameters
$menu =& JMenu::getInstance();
$item = $menu->getDefault();
-
+
$options['vars'] = $item->query;
$options['vars']['Itemid'] = $item->id;
@@ -889,11 +889,11 @@ function &getUser()
}
/**
- * Deprecated, use JContentHelper::getItemid instead.
+ * Deprecated, use ContentHelper::getItemid instead.
*
* @since 1.0
* @deprecated As of version 1.5
- * @see JContentHelper::getItemid()
+ * @see ContentHelper::getItemid()
*/
function getItemid( $id )
{
@@ -903,7 +903,7 @@ function getItemid( $id )
$article =& JTable::getInstance('content');
$article->load($id);
- $info = JContentHelper::_getArticleMenuInfo($id, $article->catid, $article->sectionid);
+ $info = ContentHelper::_getArticleMenuInfo($id, $article->catid, $article->sectionid);
return $info->id;
}
}
View
41 libraries/joomla/database/database.php