Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
PK PLZ[f> > metadata.xmlnu W+A
PK PLZ[+q' q'
router.phpnu W+A getMenu();
$params = JComponentHelper::getParams('com_content');
$advanced = $params->get('sef_advanced_link', 0);
// We need a menu item. Either the one specified in the query, or the current active one if none specified
if (empty($query['Itemid']))
{
$menuItem = $menu->getActive();
$menuItemGiven = false;
}
else
{
$menuItem = $menu->getItem($query['Itemid']);
$menuItemGiven = true;
}
// Check again
if ($menuItemGiven && isset($menuItem) && $menuItem->component != 'com_content')
{
$menuItemGiven = false;
unset($query['Itemid']);
}
if (isset($query['view']))
{
$view = $query['view'];
}
else
{
// We need to have a view in the query or it is an invalid URL
return $segments;
}
// Are we dealing with an article or category that is attached to a menu item?
if (($menuItem instanceof stdClass) && $menuItem->query['view'] == $query['view'] && isset($query['id']) && $menuItem->query['id'] == (int) $query['id'])
{
unset($query['view']);
if (isset($query['catid']))
{
unset($query['catid']);
}
if (isset($query['layout']))
{
unset($query['layout']);
}
unset($query['id']);
return $segments;
}
if ($view == 'category' || $view == 'article')
{
if (!$menuItemGiven)
{
$segments[] = $view;
}
unset($query['view']);
if ($view == 'article')
{
if (isset($query['id']) && isset($query['catid']) && $query['catid'])
{
$catid = $query['catid'];
// Make sure we have the id and the alias
if (strpos($query['id'], ':') === false)
{
$db = JFactory::getDbo();
$dbQuery = $db->getQuery(true)
->select('alias')
->from('#__content')
->where('id=' . (int) $query['id']);
$db->setQuery($dbQuery);
$alias = $db->loadResult();
$query['id'] = $query['id'] . ':' . $alias;
}
}
else
{
// We should have these two set for this view. If we don't, it is an error
return $segments;
}
}
else
{
if (isset($query['id']))
{
$catid = $query['id'];
}
else
{
// We should have id set for this view. If we don't, it is an error
return $segments;
}
}
if ($menuItemGiven && isset($menuItem->query['id']))
{
$mCatid = $menuItem->query['id'];
}
else
{
$mCatid = 0;
}
$categories = JCategories::getInstance('Content');
$category = $categories->get($catid);
if (!$category)
{
// We couldn't find the category we were given. Bail.
return $segments;
}
$path = array_reverse($category->getPath());
$array = array();
foreach ($path as $id)
{
if ((int) $id == (int) $mCatid)
{
break;
}
list($tmp, $id) = explode(':', $id, 2);
$array[] = $id;
}
$array = array_reverse($array);
if (!$advanced && count($array))
{
$array[0] = (int) $catid . ':' . $array[0];
}
$segments = array_merge($segments, $array);
if ($view == 'article')
{
if ($advanced)
{
list($tmp, $id) = explode(':', $query['id'], 2);
}
else
{
$id = $query['id'];
}
$segments[] = $id;
}
unset($query['id']);
unset($query['catid']);
}
if ($view == 'archive')
{
if (!$menuItemGiven)
{
$segments[] = $view;
unset($query['view']);
}
if (isset($query['year']))
{
if ($menuItemGiven)
{
$segments[] = $query['year'];
unset($query['year']);
}
}
if (isset($query['year']) && isset($query['month']))
{
if ($menuItemGiven)
{
$segments[] = $query['month'];
unset($query['month']);
}
}
}
if ($view == 'featured')
{
if (!$menuItemGiven)
{
$segments[] = $view;
}
unset($query['view']);
}
/*
* If the layout is specified and it is the same as the layout in the menu item, we
* unset it so it doesn't go into the query string.
*/
if (isset($query['layout']))
{
if ($menuItemGiven && isset($menuItem->query['layout']))
{
if ($query['layout'] == $menuItem->query['layout'])
{
unset($query['layout']);
}
}
else
{
if ($query['layout'] == 'default')
{
unset($query['layout']);
}
}
}
$total = count($segments);
for ($i = 0; $i < $total; $i++)
{
$segments[$i] = str_replace(':', '-', $segments[$i]);
}
return $segments;
}
/**
* Parse the segments of a URL.
*
* @param array &$segments The segments of the URL to parse.
*
* @return array The URL attributes to be used by the application.
*
* @since 3.3
*/
public function parse(&$segments)
{
$total = count($segments);
$vars = array();
for ($i = 0; $i < $total; $i++)
{
$segments[$i] = preg_replace('/-/', ':', $segments[$i], 1);
}
// Get the active menu item.
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
$params = JComponentHelper::getParams('com_content');
$advanced = $params->get('sef_advanced_link', 0);
$db = JFactory::getDbo();
// Count route segments
$count = count($segments);
/*
* Standard routing for articles. If we don't pick up an Itemid then we get the view from the segments
* the first segment is the view and the last segment is the id of the article or category.
*/
if (!isset($item))
{
$vars['view'] = $segments[0];
$vars['id'] = $segments[$count - 1];
return $vars;
}
/*
* If there is only one segment, then it points to either an article or a category.
* We test it first to see if it is a category. If the id and alias match a category,
* then we assume it is a category. If they don't we assume it is an article
*/
if ($count == 1)
{
// We check to see if an alias is given. If not, we assume it is an article
if (strpos($segments[0], ':') === false)
{
$vars['view'] = 'article';
$vars['id'] = (int) $segments[0];
return $vars;
}
list($id, $alias) = explode(':', $segments[0], 2);
// First we check if it is a category
$category = JCategories::getInstance('Content')->get($id);
if ($category && $category->alias == $alias)
{
$vars['view'] = 'category';
$vars['id'] = $id;
return $vars;
}
else
{
$query = $db->getQuery(true)
->select($db->quoteName(array('alias', 'catid')))
->from($db->quoteName('#__content'))
->where($db->quoteName('id') . ' = ' . (int) $id);
$db->setQuery($query);
$article = $db->loadObject();
if ($article)
{
if ($article->alias == $alias)
{
$vars['view'] = 'article';
$vars['catid'] = (int) $article->catid;
$vars['id'] = (int) $id;
return $vars;
}
}
}
}
/*
* If there was more than one segment, then we can determine where the URL points to
* because the first segment will have the target category id prepended to it. If the
* last segment has a number prepended, it is an article, otherwise, it is a category.
*/
if (!$advanced)
{
$cat_id = (int) $segments[0];
$article_id = (int) $segments[$count - 1];
if ($article_id > 0)
{
$vars['view'] = 'article';
$vars['catid'] = $cat_id;
$vars['id'] = $article_id;
}
else
{
$vars['view'] = 'category';
$vars['id'] = $cat_id;
}
return $vars;
}
// We get the category id from the menu item and search from there
$id = $item->query['id'];
$category = JCategories::getInstance('Content')->get($id);
if (!$category)
{
JError::raiseError(404, JText::_('COM_CONTENT_ERROR_PARENT_CATEGORY_NOT_FOUND'));
return $vars;
}
$categories = $category->getChildren();
$vars['catid'] = $id;
$vars['id'] = $id;
$found = 0;
foreach ($segments as $segment)
{
$segment = str_replace(':', '-', $segment);
foreach ($categories as $category)
{
if ($category->alias == $segment)
{
$vars['id'] = $category->id;
$vars['catid'] = $category->id;
$vars['view'] = 'category';
$categories = $category->getChildren();
$found = 1;
break;
}
}
if ($found == 0)
{
if ($advanced)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__content')
->where($db->quoteName('catid') . ' = ' . (int) $vars['catid'])
->where($db->quoteName('alias') . ' = ' . $db->quote($db->quote($segment)));
$db->setQuery($query);
$cid = $db->loadResult();
}
else
{
$cid = $segment;
}
$vars['id'] = $cid;
if ($item->query['view'] == 'archive' && $count != 1)
{
$vars['year'] = $count >= 2 ? $segments[$count - 2] : null;
$vars['month'] = $segments[$count - 1];
$vars['view'] = 'archive';
}
else
{
$vars['view'] = 'article';
}
}
$found = 0;
}
return $vars;
}
}
/**
* Content router functions
*
* These functions are proxys for the new router interface
* for old SEF extensions.
*
* @deprecated 4.0 Use Class based routers instead
*/
function ContentBuildRoute(&$query)
{
$router = new ContentRouter;
return $router->build($query);
}
function ContentParseRoute($segments)
{
$router = new ContentRouter;
return $router->parse($segments);
}
PK PLZ[RC views/archive/view.html.phpnu W+A get('State');
$items = $this->get('Items');
$pagination = $this->get('Pagination');
// Get the page/component configuration
$params = &$state->params;
foreach ($items as $item)
{
$item->catslug = ($item->category_alias) ? ($item->catid . ':' . $item->category_alias) : $item->catid;
$item->parent_slug = ($item->parent_alias) ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
// No link for ROOT category
if ($item->parent_alias == 'root')
{
$item->parent_slug = null;
}
}
$form = new stdClass;
// Month Field
$months = array(
'' => JText::_('COM_CONTENT_MONTH'),
'01' => JText::_('JANUARY_SHORT'),
'02' => JText::_('FEBRUARY_SHORT'),
'03' => JText::_('MARCH_SHORT'),
'04' => JText::_('APRIL_SHORT'),
'05' => JText::_('MAY_SHORT'),
'06' => JText::_('JUNE_SHORT'),
'07' => JText::_('JULY_SHORT'),
'08' => JText::_('AUGUST_SHORT'),
'09' => JText::_('SEPTEMBER_SHORT'),
'10' => JText::_('OCTOBER_SHORT'),
'11' => JText::_('NOVEMBER_SHORT'),
'12' => JText::_('DECEMBER_SHORT')
);
$form->monthField = JHtml::_(
'select.genericlist',
$months,
'month',
array(
'list.attr' => 'size="1" class="inputbox"',
'list.select' => $state->get('filter.month'),
'option.key' => null
)
);
// Year Field
$years = array();
$years[] = JHtml::_('select.option', null, JText::_('JYEAR'));
for ($year = date('Y'), $i = $year - 10; $i <= $year; $i++)
{
$years[] = JHtml::_('select.option', $i, $i);
}
$form->yearField = JHtml::_(
'select.genericlist',
$years,
'year',
array('list.attr' => 'size="1" class="inputbox"', 'list.select' => $state->get('filter.year'))
);
$form->limitField = $pagination->getLimitBox();
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->filter = $state->get('list.filter');
$this->form = &$form;
$this->items = &$items;
$this->params = &$params;
$this->user = &$user;
$this->pagination = &$pagination;
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('JGLOBAL_ARTICLES'));
}
$title = $this->params->get('page_title', '');
if (empty($title))
{
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
$this->document->setTitle($title);
if ($this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
}
}
PK PLZ[S views/archive/tmpl/default.phpnu W+A
PK PLZ[3ߖ views/categories/metadata.xmlnu W+A
PK PLZ[V views/categories/index.htmlnu W+A
PK PLZ[1]# # views/article/view.html.phpnu W+A item = $this->get('Item');
$this->print = $app->input->getBool('print');
$this->state = $this->get('State');
$this->user = $user;
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
// Create a shortcut for $item.
$item = $this->item;
$item->tagLayout = new JLayoutFile('joomla.content.tags');
// Add router helpers.
$item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id;
$item->catslug = $item->category_alias ? ($item->catid.':'.$item->category_alias) : $item->catid;
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
// No link for ROOT category
if ($item->parent_alias == 'root')
{
$item->parent_slug = null;
}
// TODO: Change based on shownoauth
$item->readmore_link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
// Merge article params. If this is single-article view, menu params override article params
// Otherwise, article params override menu item params
$this->params = $this->state->get('params');
$active = $app->getMenu()->getActive();
$temp = clone ($this->params);
// Check to see which parameters should take priority
if ($active)
{
$currentLink = $active->link;
// If the current view is the active item and an article view for this article, then the menu item params take priority
if (strpos($currentLink, 'view=article') && (strpos($currentLink, '&id='.(string) $item->id)))
{
// Load layout from active query (in case it is an alternative menu item)
if (isset($active->query['layout']))
{
$this->setLayout($active->query['layout']);
}
// Check for alternative layout of article
elseif ($layout = $item->params->get('article_layout'))
{
$this->setLayout($layout);
}
// $item->params are the article params, $temp are the menu item params
// Merge so that the menu item params take priority
$item->params->merge($temp);
}
else
{
// Current view is not a single article, so the article params take priority here
// Merge the menu item params with the article params so that the article params take priority
$temp->merge($item->params);
$item->params = $temp;
// Check for alternative layouts (since we are not in a single-article menu item)
// Single-article menu item layout takes priority over alt layout for an article
if ($layout = $item->params->get('article_layout'))
{
$this->setLayout($layout);
}
}
}
else
{
// Merge so that article params take priority
$temp->merge($item->params);
$item->params = $temp;
// Check for alternative layouts (since we are not in a single-article menu item)
// Single-article menu item layout takes priority over alt layout for an article
if ($layout = $item->params->get('article_layout'))
{
$this->setLayout($layout);
}
}
$offset = $this->state->get('list.offset');
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true && $user->get('guest') )))
{
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
if ($item->params->get('show_intro', '1') == '1')
{
$item->text = $item->introtext.' '.$item->fulltext;
}
elseif ($item->fulltext)
{
$item->text = $item->fulltext;
}
else
{
$item->text = $item->introtext;
}
$item->tags = new JHelperTags;
$item->tags->getItemTags('com_content.article', $this->item->id);
// Process the content plugins.
JPluginHelper::importPlugin('content');
$dispatcher->trigger('onContentPrepare', array ('com_content.article', &$item, &$this->params, $offset));
$item->event = new stdClass;
$results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$this->params, $offset));
$item->event->afterDisplayTitle = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$this->params, $offset));
$item->event->beforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$this->params, $offset));
$item->event->afterDisplayContent = trim(implode("\n", $results));
// Increment the hit counter of the article.
if (!$this->params->get('intro_only') && $offset == 0)
{
$model = $this->getModel();
$model->hit();
}
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($this->item->params->get('pageclass_sfx'));
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('JGLOBAL_ARTICLES'));
}
$title = $this->params->get('page_title', '');
$id = (int) @$menu->query['id'];
// if the menu item does not concern this article
if ($menu && ($menu->query['option'] != 'com_content' || $menu->query['view'] != 'article' || $id != $this->item->id))
{
// If this is not a single article menu item, set the page title to the article title
if ($this->item->title)
{
$title = $this->item->title;
}
$path = array(array('title' => $this->item->title, 'link' => ''));
$category = JCategories::getInstance('Content')->get($this->item->catid);
while ($category && ($menu->query['option'] != 'com_content' || $menu->query['view'] == 'article' || $id != $category->id) && $category->id > 1)
{
$path[] = array('title' => $category->title, 'link' => ContentHelperRoute::getCategoryRoute($category->id));
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item)
{
$pathway->addItem($item['title'], $item['link']);
}
}
// Check for empty title and add site name if param is set
if (empty($title))
{
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
if (empty($title))
{
$title = $this->item->title;
}
$this->document->setTitle($title);
if ($this->item->metadesc)
{
$this->document->setDescription($this->item->metadesc);
}
elseif (!$this->item->metadesc && $this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->item->metakey)
{
$this->document->setMetadata('keywords', $this->item->metakey);
}
elseif (!$this->item->metakey && $this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
if ($app->getCfg('MetaAuthor') == '1')
{
$this->document->setMetaData('author', $this->item->author);
}
$mdata = $this->item->metadata->toArray();
foreach ($mdata as $k => $v)
{
if ($v)
{
$this->document->setMetadata($k, $v);
}
}
// If there is a pagebreak heading or title, add it to the page title
if (!empty($this->item->page_title))
{
$this->item->title = $this->item->title . ' - ' . $this->item->page_title;
$this->document->setTitle($this->item->page_title . ' - ' . JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $this->state->get('list.offset') + 1));
}
if ($this->print)
{
$this->document->setMetaData('robots', 'noindex, nofollow');
}
}
}
PK PLZ[ff; ; views/article/tmpl/default.phpnu W+A item->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
$canEdit = $params->get('access-edit');
$user = JFactory::getUser();
$info = $params->get('info_block_position', 0);
JHtml::_('behavior.caption');
$useDefList = ($params->get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_create_date')
|| $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author'));
?>
';
}
$item->author = $item->created_by_alias ? $item->created_by_alias : $item->author;
}
}
PK PLZ[V
index.htmlnu W+A
PK PLZ[l)
controller.phpnu W+A input = JFactory::getApplication()->input;
// Article frontpage Editor pagebreak proxying:
if ($this->input->get('view') === 'article' && $this->input->get('layout') === 'pagebreak')
{
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
}
// Article frontpage Editor article proxying:
elseif ($this->input->get('view') === 'articles' && $this->input->get('layout') === 'modal')
{
JHtml::_('stylesheet', 'system/adminlist.css', array(), true);
$config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
}
parent::__construct($config);
}
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
$cachable = true;
// Set the default view name and format from the Request.
// Note we are using a_id to avoid collisions with the router and the return page.
// Frontend is a bit messier than the backend.
$id = $this->input->getInt('a_id');
$vName = $this->input->getCmd('view', 'categories');
$this->input->set('view', $vName);
$user = JFactory::getUser();
if ($user->get('id') ||
($this->input->getMethod() == 'POST' &&
(($vName == 'category' && $this->input->get('layout') != 'blog') || $vName == 'archive' )))
{
$cachable = false;
}
$safeurlparams = array('catid' => 'INT', 'id' => 'INT', 'cid' => 'ARRAY', 'year' => 'INT', 'month' => 'INT', 'limit' => 'UINT', 'limitstart' => 'UINT',
'showall' => 'INT', 'return' => 'BASE64', 'filter' => 'STRING', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'filter-search' => 'STRING', 'print' => 'BOOLEAN', 'lang' => 'CMD', 'Itemid' => 'INT');
// Check for edit form.
if ($vName == 'form' && !$this->checkEditId('com_content.edit.article', $id))
{
// Somehow the person just went to the form - we don't allow that.
return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
}
parent::display($cachable, $safeurlparams);
return $this;
}
}
PK PLZ[V controllers/index.htmlnu W+A
PK PLZ[ϳ controllers/article.phpnu W+A setRedirect($this->getReturnPage());
}
}
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = array())
{
$user = JFactory::getUser();
$categoryId = JArrayHelper::getValue($data, 'catid', $this->input->getInt('catid'), 'int');
$allow = null;
if ($categoryId)
{
// If the category has been passed in the data or URL check it.
$allow = $user->authorise('core.create', 'com_content.category.'.$categoryId);
}
if ($allow === null)
{
// In the absense of better information, revert to the component permissions.
return parent::allowAdd();
}
else
{
return $allow;
}
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key; default is id.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = JFactory::getUser();
$userId = $user->get('id');
$asset = 'com_content.article.' . $recordId;
// Check general edit permission first.
if ($user->authorise('core.edit', $asset))
{
return true;
}
// Fallback on edit.own.
// First test if the permission is available.
if ($user->authorise('core.edit.own', $asset))
{
// Now test the owner is the user.
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
if (empty($ownerId) && $recordId)
{
// Need to do a lookup from the model.
$record = $this->getModel()->getItem($recordId);
if (empty($record))
{
return false;
}
$ownerId = $record->created_by;
}
// If the owner matches 'me' then do the test.
if ($ownerId == $userId)
{
return true;
}
}
// Since there is no asset tracking, revert to the component permissions.
return parent::allowEdit($data, $key);
}
/**
* Method to cancel an edit.
*
* @param string $key The name of the primary key of the URL variable.
*
* @return boolean True if access level checks pass, false otherwise.
*
* @since 1.6
*/
public function cancel($key = 'a_id')
{
parent::cancel($key);
// Redirect to the return page.
$this->setRedirect($this->getReturnPage());
}
/**
* Method to edit an existing record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key
* (sometimes required to avoid router collisions).
*
* @return boolean True if access level check and checkout passes, false otherwise.
*
* @since 1.6
*/
public function edit($key = null, $urlVar = 'a_id')
{
$result = parent::edit($key, $urlVar);
return $result;
}
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.5
*/
public function getModel($name = 'form', $prefix = '', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* Gets the URL arguments to append to an item redirect.
*
* @param integer $recordId The primary key id for the item.
* @param string $urlVar The name of the URL variable for the id.
*
* @return string The arguments to append to the redirect URL.
*
* @since 1.6
*/
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'a_id')
{
// Need to override the parent method completely.
$tmpl = $this->input->get('tmpl');
// $layout = $this->input->get('layout', 'edit');
$append = '';
// Setup redirect info.
if ($tmpl)
{
$append .= '&tmpl='.$tmpl;
}
// TODO This is a bandaid, not a long term solution.
// if ($layout)
// {
// $append .= '&layout=' . $layout;
// }
$append .= '&layout=edit';
if ($recordId)
{
$append .= '&'.$urlVar.'='.$recordId;
}
$itemId = $this->input->getInt('Itemid');
$return = $this->getReturnPage();
$catId = $this->input->getInt('catid', null, 'get');
if ($itemId)
{
$append .= '&Itemid='.$itemId;
}
if ($catId)
{
$append .= '&catid='.$catId;
}
if ($return)
{
$append .= '&return='.base64_encode($return);
}
return $append;
}
/**
* Get the return URL.
*
* If a "return" variable has been passed in the request
*
* @return string The return URL.
*
* @since 1.6
*/
protected function getReturnPage()
{
$return = $this->input->get('return', null, 'base64');
if (empty($return) || !JUri::isInternal(base64_decode($return)))
{
return JUri::base();
}
else
{
return base64_decode($return);
}
}
/**
* Function that allows child controller access to model data after the data has been saved.
*
* @param JModelLegacy $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since 1.6
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
{
return;
}
/**
* Method to save a record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return boolean True if successful, false otherwise.
*
* @since 1.6
*/
public function save($key = null, $urlVar = 'a_id')
{
$result = parent::save($key, $urlVar);
// If ok, redirect to the return page.
if ($result)
{
$this->setRedirect($this->getReturnPage());
}
return $result;
}
/**
* Method to save a vote.
*
* @return void
*
* @since 1.6
*/
public function vote()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$user_rating = $this->input->getInt('user_rating', -1);
if ($user_rating > -1)
{
$url = $this->input->getString('url', '');
$id = $this->input->getInt('id', 0);
$viewName = $this->input->getString('view', $this->default_view);
$model = $this->getModel($viewName);
if ($model->storeVote($id, $user_rating))
{
$this->setRedirect($url, JText::_('COM_CONTENT_ARTICLE_VOTE_SUCCESS'));
}
else
{
$this->setRedirect($url, JText::_('COM_CONTENT_ARTICLE_VOTE_FAILURE'));
}
}
}
}
PK PLZ[%* helpers/association.phpnu W+A input;
$view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view == 'article')
{
if ($id)
{
$associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $id);
$return = array();
foreach ($associations as $tag => $item)
{
$return[$tag] = ContentHelperRoute::getArticleRoute($item->id, $item->catid, $item->language);
}
return $return;
}
}
if ($view == 'category' || $view == 'categories')
{
return self::getCategoryAssociations($id, 'com_content');
}
return array();
}
}
PK PLZ[V helpers/index.htmlnu W+A
PK PLZ[dy$ $ helpers/icon.phpnu W+A id;
if ($params->get('show_icons'))
{
if ($legacy)
{
$text = JHtml::_('image', 'system/new.png', JText::_('JNEW'), null, true);
}
else
{
$text = ' ' . JText::_('JNEW') . ' ';
}
}
else
{
$text = JText::_('JNEW') . ' ';
}
// Add the button classes to the attribs array
if (isset($attribs['class']))
{
$attribs['class'] = $attribs['class'] . ' btn btn-primary';
}
else
{
$attribs['class'] = 'btn btn-primary';
}
$button = JHtml::_('link', JRoute::_($url), $text, $attribs);
$output = '' . $button . '';
return $output;
}
/**
* Method to generate a link to the email item page for the given article
*
* @param object $article The article information
* @param JRegistry $params The item parameters
* @param array $attribs Optional attributes for the link
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
*
* @return string The HTML markup for the email item link
*/
public static function email($article, $params, $attribs = array(), $legacy = false)
{
require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php';
$uri = JUri::getInstance();
$base = $uri->toString(array('scheme', 'host', 'port'));
$template = JFactory::getApplication()->getTemplate();
$link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid), false);
$url = 'index.php?option=com_mailto&tmpl=component&template=' . $template . '&link=' . MailToHelper::addLink($link);
$status = 'width=400,height=350,menubar=yes,resizable=yes';
if ($params->get('show_icons'))
{
if ($legacy)
{
$text = JHtml::_('image', 'system/emailButton.png', JText::_('JGLOBAL_EMAIL'), null, true);
}
else
{
$text = ' ' . JText::_('JGLOBAL_EMAIL');
}
}
else
{
$text = JText::_('JGLOBAL_EMAIL');
}
$attribs['title'] = JText::_('JGLOBAL_EMAIL');
$attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";
$output = JHtml::_('link', JRoute::_($url), $text, $attribs);
return $output;
}
/**
* Display an edit icon for the article.
*
* This icon will not display in a popup window, nor if the article is trashed.
* Edit access checks must be performed in the calling code.
*
* @param object $article The article information
* @param JRegistry $params The item parameters
* @param array $attribs Optional attributes for the link
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
*
* @return string The HTML for the article edit icon.
* @since 1.6
*/
public static function edit($article, $params, $attribs = array(), $legacy = false)
{
$user = JFactory::getUser();
$uri = JUri::getInstance();
// Ignore if in a popup window.
if ($params && $params->get('popup'))
{
return;
}
// Ignore if the state is negative (trashed).
if ($article->state < 0)
{
return;
}
JHtml::_('bootstrap.tooltip');
// Show checked_out icon if the article is checked out by a different user
if (property_exists($article, 'checked_out') && property_exists($article, 'checked_out_time') && $article->checked_out > 0 && $article->checked_out != $user->get('id'))
{
$checkoutUser = JFactory::getUser($article->checked_out);
$button = JHtml::_('image', 'system/checked_out.png', null, null, true);
$date = JHtml::_('date', $article->checked_out_time);
$tooltip = JText::_('JLIB_HTML_CHECKED_OUT') . ' :: ' . JText::sprintf('COM_CONTENT_CHECKED_OUT_BY', $checkoutUser->name) . ' ' . $date;
return '' . $button . '';
}
$url = 'index.php?option=com_content&task=article.edit&a_id=' . $article->id . '&return=' . base64_encode($uri);
if ($article->state == 0)
{
$overlib = JText::_('JUNPUBLISHED');
}
else
{
$overlib = JText::_('JPUBLISHED');
}
$date = JHtml::_('date', $article->created);
$author = $article->created_by_alias ? $article->created_by_alias : $article->author;
$overlib .= '<br />';
$overlib .= $date;
$overlib .= '<br />';
$overlib .= JText::sprintf('COM_CONTENT_WRITTEN_BY', htmlspecialchars($author, ENT_COMPAT, 'UTF-8'));
if ($legacy)
{
$icon = $article->state ? 'edit.png' : 'edit_unpublished.png';
if (strtotime($article->publish_up) > strtotime(JFactory::getDate())
|| ((strtotime($article->publish_down) < strtotime(JFactory::getDate())) && $article->publish_down != '0000-00-00 00:00:00'))
{
$icon = 'edit_unpublished.png';
}
$text = JHtml::_('image', 'system/' . $icon, JText::_('JGLOBAL_EDIT'), null, true);
}
else
{
$icon = $article->state ? 'edit' : 'eye-close';
if (strtotime($article->publish_up) > strtotime(JFactory::getDate())
|| ((strtotime($article->publish_down) < strtotime(JFactory::getDate())) && $article->publish_down != '0000-00-00 00:00:00'))
{
$icon = 'eye-close';
}
$text = ' ' . JText::_('JGLOBAL_EDIT') . ' ';
}
$output = JHtml::_('link', JRoute::_($url), $text, $attribs);
return $output;
}
/**
* Method to generate a popup link to print an article
*
* @param object $article The article information
* @param JRegistry $params The item parameters
* @param array $attribs Optional attributes for the link
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
*
* @return string The HTML markup for the popup link
*/
public static function print_popup($article, $params, $attribs = array(), $legacy = false)
{
$app = JFactory::getApplication();
$input = $app->input;
$request = $input->request;
$url = ContentHelperRoute::getArticleRoute($article->slug, $article->catid);
$url .= '&tmpl=component&print=1&layout=default&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('show_icons'))
{
if ($legacy)
{
$text = JHtml::_('image', 'system/printButton.png', JText::_('JGLOBAL_PRINT'), null, true);
}
else
{
$text = ' ' . JText::_('JGLOBAL_PRINT') . ' ';
}
}
else
{
$text = JText::_('JGLOBAL_PRINT');
}
$attribs['title'] = JText::_('JGLOBAL_PRINT');
$attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";
$attribs['rel'] = 'nofollow';
return JHtml::_('link', JRoute::_($url), $text, $attribs);
}
/**
* Method to generate a link to print an article
*
* @param object $article Not used, @deprecated for 4.0
* @param JRegistry $params The item parameters
* @param array $attribs Not used, @deprecated for 4.0
* @param boolean $legacy True to use legacy images, false to use icomoon based graphic
*
* @return string The HTML markup for the popup link
*/
public static function print_screen($article, $params, $attribs = array(), $legacy = false)
{
// Checks template image directory for image, if none found default are loaded
if ($params->get('show_icons'))
{
if ($legacy)
{
$text = JHtml::_('image', 'system/printButton.png', JText::_('JGLOBAL_PRINT'), null, true);
}
else
{
$text = ' ' . JText::_('JGLOBAL_PRINT') . ' ';
}
}
else
{
$text = JText::_('JGLOBAL_PRINT');
}
return '' . $text . '';
}
}
PK PLZ[fF] ] helpers/category.phpnu W+A array((int) $id)
);
//Create the link
$link = 'index.php?option=com_content&view=article&id='. $id;
if ((int) $catid > 1)
{
$categories = JCategories::getInstance('Content');
$category = $categories->get((int) $catid);
if ($category)
{
$needles['category'] = array_reverse($category->getPath());
$needles['categories'] = $needles['category'];
$link .= '&catid='.$catid;
}
}
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
self::buildLanguageLookup();
if (isset(self::$lang_lookup[$language]))
{
$link .= '&lang=' . self::$lang_lookup[$language];
$needles['language'] = $language;
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
return $link;
}
public static function getCategoryRoute($catid, $language = 0)
{
if ($catid instanceof JCategoryNode)
{
$id = $catid->id;
$category = $catid;
}
else
{
$id = (int) $catid;
$category = JCategories::getInstance('Content')->get($id);
}
if ($id < 1 || !($category instanceof JCategoryNode))
{
$link = '';
}
else
{
$needles = array();
$link = 'index.php?option=com_content&view=category&id='.$id;
$catids = array_reverse($category->getPath());
$needles['category'] = $catids;
$needles['categories'] = $catids;
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
self::buildLanguageLookup();
if(isset(self::$lang_lookup[$language]))
{
$link .= '&lang=' . self::$lang_lookup[$language];
$needles['language'] = $language;
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
}
return $link;
}
public static function getFormRoute($id)
{
//Create the link
if ($id)
{
$link = 'index.php?option=com_content&task=article.edit&a_id='. $id;
}
else
{
$link = 'index.php?option=com_content&task=article.edit&a_id=0';
}
return $link;
}
protected static function buildLanguageLookup()
{
if (count(self::$lang_lookup) == 0)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.sef AS sef')
->select('a.lang_code AS lang_code')
->from('#__languages AS a');
$db->setQuery($query);
$langs = $db->loadObjectList();
foreach ($langs as $lang)
{
self::$lang_lookup[$lang->lang_code] = $lang->sef;
}
}
}
protected static function _findItem($needles = null)
{
$app = JFactory::getApplication();
$menus = $app->getMenu('site');
$language = isset($needles['language']) ? $needles['language'] : '*';
// Prepare the reverse lookup array.
if (!isset(self::$lookup[$language]))
{
self::$lookup[$language] = array();
$component = JComponentHelper::getComponent('com_content');
$attributes = array('component_id');
$values = array($component->id);
if ($language != '*')
{
$attributes[] = 'language';
$values[] = array($needles['language'], '*');
}
$items = $menus->getItems($attributes, $values);
foreach ($items as $item)
{
if (isset($item->query) && isset($item->query['view']))
{
$view = $item->query['view'];
if (!isset(self::$lookup[$language][$view]))
{
self::$lookup[$language][$view] = array();
}
if (isset($item->query['id'])) {
// here it will become a bit tricky
// language != * can override existing entries
// language == * cannot override existing entries
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
{
self::$lookup[$language][$view][$item->query['id']] = $item->id;
}
}
}
}
}
if ($needles)
{
foreach ($needles as $view => $ids)
{
if (isset(self::$lookup[$language][$view]))
{
foreach ($ids as $id)
{
if (isset(self::$lookup[$language][$view][(int) $id]))
{
return self::$lookup[$language][$view][(int) $id];
}
}
}
}
}
// Check if the active menuitem matches the requested language
$active = $menus->getActive();
if ($active && $active->component == 'com_content' && ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled()))
{
return $active->id;
}
// If not found, return language specific home link
$default = $menus->getDefault($language);
return !empty($default->id) ? $default->id : null;
}
}
PK PLZ[pF F helpers/query.phpnu W+A quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END';
break;
// use created if publish_up is not set
case 'published' :
$queryDate = ' CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END ';
break;
case 'created' :
default :
$queryDate = ' a.created ';
break;
}
return $queryDate;
}
/**
* Get join information for the voting query.
*
* @param JRegistry $param An options object for the article.
*
* @return array A named array with "select" and "join" keys.
* @since 1.5
*/
public static function buildVotingQuery($params=null)
{
if (!$params)
{
$params = JComponentHelper::getParams('com_content');
}
$voting = $params->get('show_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;
}
/**
* Method to order the intro articles array for ordering
* down the columns instead of across.
* The layout always lays the introtext articles out across columns.
* Array is reordered so that, when articles are displayed in index order
* across columns in the layout, the result is that the
* desired article ordering is achieved down the columns.
*
* @param array $articles Array of intro text articles
* @param integer $numColumns Number of columns in the layout
*
* @return array Reordered array to achieve desired ordering down columns
* @since 1.6
*/
public static function orderDownColumns(&$articles, $numColumns = 1)
{
$count = count($articles);
// just return the same array if there is nothing to change
if ($numColumns == 1 || !is_array($articles) || $count <= $numColumns)
{
$return = $articles;
}
// we need to re-order the intro articles array
else {
// we need to preserve the original array keys
$keys = array_keys($articles);
$maxRows = ceil($count / $numColumns);
$numCells = $maxRows * $numColumns;
$numEmpty = $numCells - $count;
$index = array();
// calculate number of empty cells in the array
// fill in all cells of the array
// put -1 in empty cells so we can skip later
for ($row = 1, $i = 1; $row <= $maxRows; $row++)
{
for ($col = 1; $col <= $numColumns; $col++)
{
if ($numEmpty > ($numCells - $i))
{
// put -1 in empty cells
$index[$row][$col] = -1;
}
else {
// put in zero as placeholder
$index[$row][$col] = 0;
}
$i++;
}
}
// layout the articles in column order, skipping empty cells
$i = 0;
for ($col = 1; ($col <= $numColumns) && ($i < $count); $col++)
{
for ($row = 1; ($row <= $maxRows) && ($i < $count); $row++)
{
if ($index[$row][$col] != - 1)
{
$index[$row][$col] = $keys[$i];
$i++;
}
}
}
// now read the $index back row by row to get articles in right row/col
// so that they will actually be ordered down the columns (when read by row in the layout)
$return = array();
$i = 0;
for ($row = 1; ($row <= $maxRows) && ($i < $count); $row++)
{
for ($col = 1; ($col <= $numColumns) && ($i < $count); $col++)
{
$return[$keys[$i]] = $articles[$index[$row][$col]];
$i++;
}
}
}
return $return;
}
}
PK PLZ[ 5# models/archive.phpnu W+A state->params;
// Filter on archived articles
$this->setState('filter.published', 2);
// Filter on month, year
$this->setState('filter.month', $app->input->getInt('month'));
$this->setState('filter.year', $app->input->getInt('year'));
// Optional filter text
$this->setState('list.filter', $app->input->getString('filter-search'));
// Get list limit
$itemid = $app->input->get('Itemid', 0, 'int');
$limit = $app->getUserStateFromRequest('com_content.archive.list' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint');
$this->setState('list.limit', $limit);
}
/**
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Set the archive ordering
$params = $this->state->params;
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
// No category ordering
$categoryOrderby = '';
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby = $primary . ' ' . $secondary . ' a.created DESC ';
$this->setState('list.ordering', $orderby);
$this->setState('list.direction', '');
// Create a new query object.
$query = parent::getListQuery();
// Add routing for archive
//sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id.' END as slug';
$query->select($case_when);
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('c.alias', '!=', '0');
$case_when .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $c_id.' END as catslug';
$query->select($case_when);
// Filter on month, year
// First, get the date field
$queryDate = ContentHelperQuery::getQueryDate($articleOrderDate);
if ($month = $this->getState('filter.month'))
{
$query->where('MONTH('. $queryDate . ') = ' . $month);
}
if ($year = $this->getState('filter.year'))
{
$query->where('YEAR('. $queryDate . ') = ' . $year);
}
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
/**
* Method to get the archived article list
*
* @access public
* @return array
*/
public function getData()
{
$app = JFactory::getApplication();
// Lets load the content if it doesn't already exist
if (empty($this->_data))
{
// Get the page/component configuration
$params = $app->getParams();
// Get the pagination request variables
$limit = $app->input->get('limit', $params->get('display_num', 20), 'uint');
$limitstart = $app->input->get('limitstart', 0, 'uint');
$query = $this->_buildQuery();
$this->_data = $this->_getList($query, $limitstart, $limit);
}
return $this->_data;
}
// JModelLegacy override to add alternating value for $odd
protected function _getList($query, $limitstart=0, $limit=0)
{
$result = parent::_getList($query, $limitstart, $limit);
$odd = 1;
foreach ($result as $k => $row)
{
$result[$k]->odd = $odd;
$odd = 1 - $odd;
}
return $result;
}
}
PK PLZ[V models/index.htmlnu W+A
PK PLZ[,T3 3 models/form.phpnu W+A input->getInt('a_id');
$this->setState('article.id', $pk);
$this->setState('article.catid', $app->input->getInt('catid'));
$return = $app->input->get('return', null, 'base64');
$this->setState('return_page', base64_decode($return));
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('layout', $app->input->getString('layout'));
}
/**
* Method to get article data.
*
* @param integer $itemId The id of the article.
*
* @return mixed Content item data object on success, false on failure.
*/
public function getItem($itemId = null)
{
$itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('article.id');
// Get a row instance.
$table = $this->getTable();
// Attempt to load the row.
$return = $table->load($itemId);
// Check for a table object error.
if ($return === false && $table->getError())
{
$this->setError($table->getError());
return false;
}
$properties = $table->getProperties(1);
$value = JArrayHelper::toObject($properties, 'JObject');
// Convert attrib field to Registry.
$value->params = new JRegistry;
$value->params->loadString($value->attribs);
// Compute selected asset permissions.
$user = JFactory::getUser();
$userId = $user->get('id');
$asset = 'com_content.article.' . $value->id;
// Check general edit permission first.
if ($user->authorise('core.edit', $asset))
{
$value->params->set('access-edit', true);
}
// Now check if edit.own is available.
elseif (!empty($userId) && $user->authorise('core.edit.own', $asset))
{
// Check for a valid user and that they are the owner.
if ($userId == $value->created_by)
{
$value->params->set('access-edit', true);
}
}
// Check edit state permission.
if ($itemId)
{
// Existing item
$value->params->set('access-change', $user->authorise('core.edit.state', $asset));
}
else
{
// New item.
$catId = (int) $this->getState('article.catid');
if ($catId)
{
$value->params->set('access-change', $user->authorise('core.edit.state', 'com_content.category.' . $catId));
$value->catid = $catId;
}
else
{
$value->params->set('access-change', $user->authorise('core.edit.state', 'com_content'));
}
}
$value->articletext = $value->introtext;
if (!empty($value->fulltext))
{
$value->articletext .= '' . $value->fulltext;
}
// Convert the metadata field to an array.
$registry = new JRegistry;
$registry->loadString($value->metadata);
$value->metadata = $registry->toArray();
if ($itemId)
{
$value->tags = new JHelperTags;
$value->tags->getTagIds($value->id, 'com_content.article');
$value->metadata['tags'] = $value->tags;
}
return $value;
}
/**
* Get the return URL.
*
* @return string The return URL.
*
* @since 1.6
*/
public function getReturnPage()
{
return base64_encode($this->getState('return_page'));
}
/**
* Method to save the form data.
*
* @param array $data The form data.
*
* @return boolean True on success.
*
* @since 3.2
*/
public function save($data)
{
// Associations are not edited in frontend ATM so we have to inherit them
if (JLanguageAssociations::isEnabled() && !empty($data['id']))
{
if ($associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $data['id']))
{
foreach ($associations as $tag => $associated)
{
$associations[$tag] = (int) $associated->id;
}
$data['associations'] = $associations;
}
}
return parent::save($data);
}
}
PK PLZ[2֦ models/featured.phpnu W+A input;
$user = JFactory::getUser();
// List state information
$limitstart = $input->getUInt('limitstart', 0);
$this->setState('list.start', $limitstart);
$params = $this->state->params;
$limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
$this->setState('list.limit', $limit);
$this->setState('list.links', $params->get('num_links'));
$this->setState('filter.frontpage', true);
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))){
// filter on published for those who do not have edit or edit.state rights.
$this->setState('filter.published', 1);
}
else
{
$this->setState('filter.published', array(0, 1, 2));
}
// check for category selection
if ($params->get('featured_categories') && implode(',', $params->get('featured_categories')) == true)
{
$featuredCategories = $params->get('featured_categories');
$this->setState('filter.frontpage.categories', $featuredCategories);
}
}
/**
* Method to get a list of articles.
*
* @return mixed An array of objects on success, false on failure.
*/
public function getItems()
{
$params = clone $this->getState('params');
$limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
if ($limit > 0)
{
$this->setState('list.limit', $limit);
return parent::getItems();
}
return array();
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= $this->getState('filter.frontpage');
return parent::getStoreId($id);
}
/**
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Set the blog ordering
$params = $this->state->params;
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
$categoryOrderby = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby = $primary . ' ' . $secondary . ' a.created DESC ';
$this->setState('list.ordering', $orderby);
$this->setState('list.direction', '');
// Create a new query object.
$query = parent::getListQuery();
// Filter by frontpage.
if ($this->getState('filter.frontpage'))
{
$query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id');
}
// Filter by categories
$featuredCategories = $this->getState('filter.frontpage.categories');
if (is_array($featuredCategories) && !in_array('', $featuredCategories))
{
$query->where('a.catid IN (' . implode(',', $featuredCategories) . ')');
}
return $query;
}
}
PK PLZ[%< models/forms/article.xmlnu W+A
PK PLZ[V models/forms/index.htmlnu W+A
PK PLZ[ Qh h models/forms/filter_articles.xmlnu W+A
PK PLZ[d d models/categories.phpnu W+A setState('filter.extension', $this->_extension);
// Get the parent id if defined.
$parentId = $app->input->getInt('id');
$this->setState('filter.parentId', $parentId);
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('filter.published', 1);
$this->setState('filter.access', true);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':'.$this->getState('filter.extension');
$id .= ':'.$this->getState('filter.published');
$id .= ':'.$this->getState('filter.access');
$id .= ':'.$this->getState('filter.parentId');
return parent::getStoreId($id);
}
/**
* Redefine the function an add some properties to make the styling more easy
*
* @param bool $recursive True if you want to return children recursively.
*
* @return mixed An array of data items on success, false on failure.
* @since 1.6
*/
public function getItems($recursive = false)
{
if (!count($this->_items))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new JRegistry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_num_articles_cat', 1) || !$params->get('show_empty_categories_cat', 0);
$categories = JCategories::getInstance('Content', $options);
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));
if (is_object($this->_parent))
{
$this->_items = $this->_parent->getChildren($recursive);
}
else {
$this->_items = false;
}
}
return $this->_items;
}
public function getParent()
{
if (!is_object($this->_parent))
{
$this->getItems();
}
return $this->_parent;
}
}
PK PLZ[EK)0 )0 models/category.phpnu W+A input->getInt('id');
$this->setState('category.id', $pk);
// Load the parameters. Merge Global and Menu Item params into new object
$params = $app->getParams();
$menuParams = new JRegistry;
if ($menu = $app->getMenu()->getActive())
{
$menuParams->loadString($menu->params);
}
$mergedParams = clone $menuParams;
$mergedParams->merge($params);
$this->setState('params', $mergedParams);
$user = JFactory::getUser();
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))){
// limit to published for people who can't edit or edit.state.
$this->setState('filter.published', 1);
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(JFactory::getDate()->toSQL());
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
else
{
$this->setState('filter.published', array(0, 1, 2));
}
// process show_noauth parameter
if (!$params->get('show_noauth'))
{
$this->setState('filter.access', true);
}
else
{
$this->setState('filter.access', false);
}
// Optional filter text
$this->setState('list.filter', $app->input->getString('filter-search'));
// filter.order
$itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int');
$orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'a.ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir',
'filter_order_Dir', '', 'cmd');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$this->setState('list.start', $app->input->get('limitstart', 0, 'uint'));
// set limit for query. If list, use parameter. If blog, add blog parameters for limit.
if (($app->input->get('layout') == 'blog') || $params->get('layout_type') == 'blog')
{
$limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
$this->setState('list.links', $params->get('num_links'));
}
else
{
$limit = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint');
}
$this->setState('list.limit', $limit);
// set the depth of the category query based on parameter
$showSubcategories = $params->get('show_subcategory_content', '0');
if ($showSubcategories)
{
$this->setState('filter.max_category_levels', $params->get('show_subcategory_content', '1'));
$this->setState('filter.subcategories', true);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
$this->setState('layout', $app->input->getString('layout'));
}
/**
* Get the articles in the category
*
* @return mixed An array of articles or false if an error occurs.
* @since 1.5
*/
function getItems()
{
$limit = $this->getState('list.limit');
if ($this->_articles === null && $category = $this->getCategory())
{
$model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
$model->setState('params', JFactory::getApplication()->getParams());
$model->setState('filter.category_id', $category->id);
$model->setState('filter.published', $this->getState('filter.published'));
$model->setState('filter.access', $this->getState('filter.access'));
$model->setState('filter.language', $this->getState('filter.language'));
$model->setState('list.ordering', $this->_buildContentOrderBy());
$model->setState('list.start', $this->getState('list.start'));
$model->setState('list.limit', $limit);
$model->setState('list.direction', $this->getState('list.direction'));
$model->setState('list.filter', $this->getState('list.filter'));
// filter.subcategories indicates whether to include articles from subcategories in the list or blog
$model->setState('filter.subcategories', $this->getState('filter.subcategories'));
$model->setState('filter.max_category_levels', $this->getState('filter.max_category_levels'));
$model->setState('list.links', $this->getState('list.links'));
if ($limit >= 0)
{
$this->_articles = $model->getItems();
if ($this->_articles === false)
{
$this->setError($model->getError());
}
}
else
{
$this->_articles = array();
}
$this->_pagination = $model->getPagination();
}
return $this->_articles;
}
/**
* Build the orderby for the query
*
* @return string $orderby portion of query
* @since 1.5
*/
protected function _buildContentOrderBy()
{
$app = JFactory::getApplication('site');
$db = $this->getDbo();
$params = $this->state->params;
$itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int');
$orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
$orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
$orderby = ' ';
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = null;
}
if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', '')))
{
$orderDirn = 'ASC';
}
if ($orderCol && $orderDirn)
{
$orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
}
$articleOrderby = $params->get('orderby_sec', 'rdate');
$articleOrderDate = $params->get('order_date');
$categoryOrderby = $params->def('orderby_pri', '');
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
$orderby .= $primary . ' ' . $secondary . ' a.created ';
return $orderby;
}
public function getPagination()
{
if (empty($this->_pagination))
{
return null;
}
return $this->_pagination;
}
/**
* Method to get category data for the current category
*
* @param integer An optional ID
*
* @return object
* @since 1.5
*/
public function getCategory()
{
if (!is_object($this->_item))
{
if ( isset( $this->state->params ) )
{
$params = $this->state->params;
$options = array();
$options['countItems'] = $params->get('show_cat_num_articles', 1) || !$params->get('show_empty_categories_cat', 0);
}
else {
$options['countItems'] = 0;
}
$categories = JCategories::getInstance('Content', $options);
$this->_item = $categories->get($this->getState('category.id', 'root'));
// Compute selected asset permissions.
if (is_object($this->_item))
{
$user = JFactory::getUser();
$asset = 'com_content.category.'.$this->_item->id;
// Check general create permission.
if ($user->authorise('core.create', $asset))
{
$this->_item->getParams()->set('access-create', true);
}
// TODO: Why aren't we lazy loading the children and siblings?
$this->_children = $this->_item->getChildren();
$this->_parent = false;
if ($this->_item->getParent())
{
$this->_parent = $this->_item->getParent();
}
$this->_rightsibling = $this->_item->getSibling();
$this->_leftsibling = $this->_item->getSibling(false);
}
else {
$this->_children = false;
$this->_parent = false;
}
}
return $this->_item;
}
/**
* Get the parent category.
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
* @since 1.6
*/
public function getParent()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_parent;
}
/**
* Get the left sibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
* @since 1.6
*/
function &getLeftSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_leftsibling;
}
/**
* Get the right sibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
* @since 1.6
*/
function &getRightSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_rightsibling;
}
/**
* Get the child categories.
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
* @since 1.6
*/
function &getChildren()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
// Order subcategories
if (count($this->_children))
{
$params = $this->getState()->get('params');
if ($params->get('orderby_pri') == 'alpha' || $params->get('orderby_pri') == 'ralpha')
{
jimport('joomla.utilities.arrayhelper');
JArrayHelper::sortObjects($this->_children, 'title', ($params->get('orderby_pri') == 'alpha') ? 1 : -1);
}
}
return $this->_children;
}
/**
* Increment the hit counter for the category.
*
* @param int $pk Optional primary key of the category to increment.
*
* @return boolean True if successful; false otherwise and internal error set.
*/
public function hit($pk = 0)
{
$input = JFactory::getApplication()->input;
$hitcount = $input->getInt('hitcount', 1);
if ($hitcount)
{
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
$table = JTable::getInstance('Category', 'JTable');
$table->load($pk);
$table->hit($pk);
}
return true;
}
}
PK PLZ[2* 2* models/article.phpnu W+A input->getInt('id');
$this->setState('article.id', $pk);
$offset = $app->input->getUInt('limitstart');
$this->setState('list.offset', $offset);
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
// TODO: Tune these values based on other permissions.
$user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content')))
{
$this->setState('filter.published', 1);
$this->setState('filter.archived', 2);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
}
/**
* Method to get article data.
*
* @param integer $pk The id of the article.
*
* @return mixed Menu item data object on success, false on failure.
*/
public function getItem($pk = null)
{
$user = JFactory::getUser();
$pk = (!empty($pk)) ? $pk : (int) $this->getState('article.id');
if ($this->_item === null)
{
$this->_item = array();
}
if (!isset($this->_item[$pk]))
{
try
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select(
$this->getState(
'item.select', 'a.id, a.asset_id, a.title, a.alias, a.introtext, a.fulltext, ' .
// If badcats is not null, this means that the article is inside an unpublished category
// In this case, the state is set to 0 to indicate Unpublished (even if the article state is Published)
'CASE WHEN badcats.id is null THEN a.state ELSE 0 END AS state, ' .
'a.catid, a.created, a.created_by, a.created_by_alias, ' .
// Use created if modified is 0
'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' .
'a.modified_by, a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, ' .
'a.images, a.urls, a.attribs, a.version, a.ordering, ' .
'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language, a.xreference'
)
);
$query->from('#__content AS a');
// Join on category table.
$query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access')
->join('LEFT', '#__categories AS c on c.id = a.catid');
// Join on user table.
$query->select('u.name AS author')
->join('LEFT', '#__users AS u on u.id = a.created_by');
// Filter by language
if ($this->getState('filter.language'))
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
// Join over the categories to get parent category titles
$query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
// Join on voting table
$query->select('ROUND(v.rating_sum / v.rating_count, 0) AS rating, v.rating_count as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id = v.content_id')
->where('a.id = ' . (int) $pk);
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) {
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$date = JFactory::getDate();
$nowDate = $db->quote($date->toSql());
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
// Join to check for category published state in parent categories up the tree
// If all categories are published, badcats.id will be null, and we just use the article state
$subquery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ';
$subquery .= 'ON cat.lft BETWEEN parent.lft AND parent.rgt ';
$subquery .= 'WHERE parent.extension = ' . $db->quote('com_content');
$subquery .= ' AND parent.published <= 0 GROUP BY cat.id)';
$query->join('LEFT OUTER', $subquery . ' AS badcats ON badcats.id = c.id');
// Filter by published state.
$published = $this->getState('filter.published');
$archived = $this->getState('filter.archived');
if (is_numeric($published))
{
$query->where('(a.state = ' . (int) $published . ' OR a.state =' . (int) $archived . ')');
}
$db->setQuery($query);
$data = $db->loadObject();
if (empty($data))
{
return JError::raiseError(404, JText::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'));
}
// Check for published state if filter set.
if (((is_numeric($published)) || (is_numeric($archived))) && (($data->state != $published) && ($data->state != $archived)))
{
return JError::raiseError(404, JText::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'));
}
// Convert parameter fields to objects.
$registry = new JRegistry;
$registry->loadString($data->attribs);
$data->params = clone $this->getState('params');
$data->params->merge($registry);
$registry = new JRegistry;
$registry->loadString($data->metadata);
$data->metadata = $registry;
// Technically guest could edit an article, but lets not check that to improve performance a little.
if (!$user->get('guest'))
{
$userId = $user->get('id');
$asset = 'com_content.article.' . $data->id;
// Check general edit permission first.
if ($user->authorise('core.edit', $asset))
{
$data->params->set('access-edit', true);
}
// Now check if edit.own is available.
elseif (!empty($userId) && $user->authorise('core.edit.own', $asset))
{
// Check for a valid user and that they are the owner.
if ($userId == $data->created_by)
{
$data->params->set('access-edit', true);
}
}
}
// Compute view access permissions.
if ($access = $this->getState('filter.access'))
{
// If the access filter has been set, we already know this user can view.
$data->params->set('access-view', true);
}
else
{
// If no access filter is set, the layout takes some responsibility for display of limited information.
$user = JFactory::getUser();
$groups = $user->getAuthorisedViewLevels();
if ($data->catid == 0 || $data->category_access === null)
{
$data->params->set('access-view', in_array($data->access, $groups));
}
else
{
$data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups));
}
}
$this->_item[$pk] = $data;
}
catch (Exception $e)
{
if ($e->getCode() == 404)
{
// Need to go thru the error handler to allow Redirect to work.
JError::raiseError(404, $e->getMessage());
}
else
{
$this->setError($e);
$this->_item[$pk] = false;
}
}
}
return $this->_item[$pk];
}
/**
* Increment the hit counter for the article.
*
* @param integer $pk Optional primary key of the article to increment.
*
* @return boolean True if successful; false otherwise and internal error set.
*/
public function hit($pk = 0)
{
$input = JFactory::getApplication()->input;
$hitcount = $input->getInt('hitcount', 1);
if ($hitcount)
{
$pk = (!empty($pk)) ? $pk : (int) $this->getState('article.id');
$table = JTable::getInstance('Content', 'JTable');
$table->load($pk);
$table->hit($pk);
}
return true;
}
/**
* Save user vote on article
*
* @param integer $pk Joomla Article Id
* @param integer $rate Voting rate
*
* @return boolean Return true on success
*/
public function storeVote($pk = 0, $rate = 0)
{
if ($rate >= 1 && $rate <= 5 && $pk > 0)
{
$userIP = $_SERVER['REMOTE_ADDR'];
// Initialize variables.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Create the base select statement.
$query->select('*')
->from($db->quoteName('#__content_rating'))
->where($db->quoteName('content_id') . ' = ' . (int) $pk);
// Set the query and load the result.
$db->setQuery($query);
$rating = $db->loadObject();
// Check for a database error.
if ($db->getErrorNum())
{
JError::raiseWarning(500, $db->getErrorMsg());
return false;
}
// There are no ratings yet, so lets insert our rating
if (!$rating)
{
$query = $db->getQuery(true);
// Create the base insert statement.
$query->insert($db->quoteName('#__content_rating'))
->columns(array($db->quoteName('content_id'), $db->quoteName('lastip'), $db->quoteName('rating_sum'), $db->quoteName('rating_count')))
->values((int) $pk . ', ' . $db->quote($userIP) . ',' . (int) $rate . ', 1');
// Set the query and execute the insert.
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
}
else
{
if ($userIP != ($rating->lastip))
{
$query = $db->getQuery(true);
// Create the base update statement.
$query->update($db->quoteName('#__content_rating'))
->set($db->quoteName('rating_count') . ' = rating_count + 1')
->set($db->quoteName('rating_sum') . ' = rating_sum + ' . (int) $rate)
->set($db->quoteName('lastip') . ' = ' . $db->quote($userIP))
->where($db->quoteName('content_id') . ' = ' . (int) $pk);
// Set the query and execute the update.
$db->setQuery($query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
}
else
{
return false;
}
}
return true;
}
JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_CONTENT_INVALID_RATING', $rate), "JModelArticle::storeVote($rate)");
return false;
}
}
PK PLZ[E:Q Q models/articles.phpnu W+A input->get('limit', $app->getCfg('list_limit', 0), 'uint');
$this->setState('list.limit', $value);
$value = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $value);
$orderCol = $app->input->get('filter_order', 'a.ordering');
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'a.ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$params = $app->getParams();
$this->setState('params', $params);
$user = JFactory::getUser();
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content')))
{
// Filter on published for those who do not have edit or edit.state rights.
$this->setState('filter.published', 1);
}
$this->setState('filter.language', JLanguageMultilang::isEnabled());
// Process show_noauth parameter
if (!$params->get('show_noauth'))
{
$this->setState('filter.access', true);
}
else
{
$this->setState('filter.access', false);
}
$this->setState('layout', $app->input->getString('layout'));
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . serialize($this->getState('filter.published'));
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.featured');
$id .= ':' . $this->getState('filter.article_id');
$id .= ':' . $this->getState('filter.article_id.include');
$id .= ':' . serialize($this->getState('filter.category_id'));
$id .= ':' . $this->getState('filter.category_id.include');
$id .= ':' . serialize($this->getState('filter.author_id'));
$id .= ':' . $this->getState('filter.author_id.include');
$id .= ':' . serialize($this->getState('filter.author_alias'));
$id .= ':' . $this->getState('filter.author_alias.include');
$id .= ':' . $this->getState('filter.date_filtering');
$id .= ':' . $this->getState('filter.date_field');
$id .= ':' . $this->getState('filter.start_date_range');
$id .= ':' . $this->getState('filter.end_date_range');
$id .= ':' . $this->getState('filter.relative_date');
return parent::getStoreId($id);
}
/**
* Get the master query for retrieving a list of articles subject to the model state.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Get the current user for authorisation checks
$user = JFactory::getUser();
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.introtext, a.fulltext, ' .
'a.checked_out, a.checked_out_time, ' .
'a.catid, a.created, a.created_by, a.created_by_alias, ' .
// Use created if modified is 0
'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' .
'a.modified_by, uam.name as modified_by_name,' .
// Use created if publish_up is 0
'CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END as publish_up,' .
'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' .
'a.hits, a.xreference, a.featured,' . ' ' . $query->length('a.fulltext') . ' AS readmore'
)
);
// Process an Archived Article layout
if ($this->getState('filter.published') == 2)
{
// If badcats is not null, this means that the article is inside an archived category
// In this case, the state is set to 2 to indicate Archived (even if the article state is Published)
$query->select($this->getState('list.select', 'CASE WHEN badcats.id is null THEN a.state ELSE 2 END AS state'));
}
else
{
/*
Process non-archived layout
If badcats is not null, this means that the article is inside an unpublished category
In this case, the state is set to 0 to indicate Unpublished (even if the article state is Published)
*/
$query->select($this->getState('list.select', 'CASE WHEN badcats.id is not null THEN 0 ELSE a.state END AS state'));
}
$query->from('#__content AS a');
// Join over the frontpage articles.
if ($this->context != 'com_content.featured')
{
$query->join('LEFT', '#__content_frontpage AS fp ON fp.content_id = a.id');
}
// Join over the categories.
$query->select('c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias')
->join('LEFT', '#__categories AS c ON c.id = a.catid');
// Join over the users for the author and modified_by names.
$query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author")
->select("ua.email AS author_email")
->join('LEFT', '#__users AS ua ON ua.id = a.created_by')
->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
// Join over the categories to get parent category titles
$query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
// Join on voting table
$query->select('ROUND(v.rating_sum / v.rating_count, 0) AS rating, v.rating_count as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
// Join to check for category published state in parent categories up the tree
$query->select('c.published, CASE WHEN badcats.id is null THEN c.published ELSE 0 END AS parents_published');
$subquery = 'SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ';
$subquery .= 'ON cat.lft BETWEEN parent.lft AND parent.rgt ';
$subquery .= 'WHERE parent.extension = ' . $db->quote('com_content');
if ($this->getState('filter.published') == 2)
{
// Find any up-path categories that are archived
// If any up-path categories are archived, include all children in archived layout
$subquery .= ' AND parent.published = 2 GROUP BY cat.id ';
// Set effective state to archived if up-path category is archived
$publishedWhere = 'CASE WHEN badcats.id is null THEN a.state ELSE 2 END';
}
else
{
// Find any up-path categories that are not published
// If all categories are published, badcats.id will be null, and we just use the article state
$subquery .= ' AND parent.published != 1 GROUP BY cat.id ';
// Select state to unpublished if up-path category is unpublished
$publishedWhere = 'CASE WHEN badcats.id is null THEN a.state ELSE 0 END';
}
$query->join('LEFT OUTER', '(' . $subquery . ') AS badcats ON badcats.id = c.id');
// Filter by access level.
if ($access = $this->getState('filter.access'))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')')
->where('c.access IN (' . $groups . ')');
}
// Filter by published state
$published = $this->getState('filter.published');
if (is_numeric($published))
{
// Use article state if badcats.id is null, otherwise, force 0 for unpublished
$query->where($publishedWhere . ' = ' . (int) $published);
}
elseif (is_array($published))
{
JArrayHelper::toInteger($published);
$published = implode(',', $published);
// Use article state if badcats.id is null, otherwise, force 0 for unpublished
$query->where($publishedWhere . ' IN (' . $published . ')');
}
// Filter by featured state
$featured = $this->getState('filter.featured');
switch ($featured)
{
case 'hide':
$query->where('a.featured = 0');
break;
case 'only':
$query->where('a.featured = 1');
break;
case 'show':
default:
// Normally we do not discriminate
// between featured/unfeatured items.
break;
}
// Filter by a single or group of articles.
$articleId = $this->getState('filter.article_id');
if (is_numeric($articleId))
{
$type = $this->getState('filter.article_id.include', true) ? '= ' : '<> ';
$query->where('a.id ' . $type . (int) $articleId);
}
elseif (is_array($articleId))
{
JArrayHelper::toInteger($articleId);
$articleId = implode(',', $articleId);
$type = $this->getState('filter.article_id.include', true) ? 'IN' : 'NOT IN';
$query->where('a.id ' . $type . ' (' . $articleId . ')');
}
// Filter by a single or group of categories
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
$type = $this->getState('filter.category_id.include', true) ? '= ' : '<> ';
// Add subcategory check
$includeSubcategories = $this->getState('filter.subcategories', false);
$categoryEquals = 'a.catid ' . $type . (int) $categoryId;
if ($includeSubcategories)
{
$levels = (int) $this->getState('filter.max_category_levels', '1');
// Create a subquery for the subcategory list
$subQuery = $db->getQuery(true)
->select('sub.id')
->from('#__categories as sub')
->join('INNER', '#__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt')
->where('this.id = ' . (int) $categoryId);
if ($levels >= 0)
{
$subQuery->where('sub.level <= this.level + ' . $levels);
}
// Add the subquery to the main query
$query->where('(' . $categoryEquals . ' OR a.catid IN (' . $subQuery->__toString() . '))');
}
else
{
$query->where($categoryEquals);
}
}
elseif (is_array($categoryId) && (count($categoryId) > 0))
{
JArrayHelper::toInteger($categoryId);
$categoryId = implode(',', $categoryId);
if (!empty($categoryId))
{
$type = $this->getState('filter.category_id.include', true) ? 'IN' : 'NOT IN';
$query->where('a.catid ' . $type . ' (' . $categoryId . ')');
}
}
// Filter by author
$authorId = $this->getState('filter.author_id');
$authorWhere = '';
if (is_numeric($authorId))
{
$type = $this->getState('filter.author_id.include', true) ? '= ' : '<> ';
$authorWhere = 'a.created_by ' . $type . (int) $authorId;
}
elseif (is_array($authorId))
{
JArrayHelper::toInteger($authorId);
$authorId = implode(',', $authorId);
if ($authorId)
{
$type = $this->getState('filter.author_id.include', true) ? 'IN' : 'NOT IN';
$authorWhere = 'a.created_by ' . $type . ' (' . $authorId . ')';
}
}
// Filter by author alias
$authorAlias = $this->getState('filter.author_alias');
$authorAliasWhere = '';
if (is_string($authorAlias))
{
$type = $this->getState('filter.author_alias.include', true) ? '= ' : '<> ';
$authorAliasWhere = 'a.created_by_alias ' . $type . $db->quote($authorAlias);
}
elseif (is_array($authorAlias))
{
$first = current($authorAlias);
if (!empty($first))
{
JArrayHelper::toString($authorAlias);
foreach ($authorAlias as $key => $alias)
{
$authorAlias[$key] = $db->quote($alias);
}
$authorAlias = implode(',', $authorAlias);
if ($authorAlias)
{
$type = $this->getState('filter.author_alias.include', true) ? 'IN' : 'NOT IN';
$authorAliasWhere = 'a.created_by_alias ' . $type . ' (' . $authorAlias .
')';
}
}
}
if (!empty($authorWhere) && !empty($authorAliasWhere))
{
$query->where('(' . $authorWhere . ' OR ' . $authorAliasWhere . ')');
}
elseif (empty($authorWhere) && empty($authorAliasWhere))
{
// If both are empty we don't want to add to the query
}
else
{
// One of these is empty, the other is not so we just add both
$query->where($authorWhere . $authorAliasWhere);
}
// Define null and now dates
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(JFactory::getDate()->toSql());
// Filter by start and end dates.
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content')))
{
$query ->where('(a.publish_up = '.$nullDate.' OR a.publish_up <= '.$nowDate.')')
->where('(a.publish_down = '.$nullDate.' OR a.publish_down >= '.$nowDate.')');
}
// Filter by Date Range or Relative Date
$dateFiltering = $this->getState('filter.date_filtering', 'off');
$dateField = $this->getState('filter.date_field', 'a.created');
switch ($dateFiltering)
{
case 'range':
$startDateRange = $db->quote($this->getState('filter.start_date_range', $nullDate));
$endDateRange = $db->quote($this->getState('filter.end_date_range', $nullDate));
$query->where(
'(' . $dateField . ' >= ' . $startDateRange . ' AND ' . $dateField .
' <= ' . $endDateRange . ')'
);
break;
case 'relative':
$relativeDate = (int) $this->getState('filter.relative_date', 0);
$query->where(
$dateField . ' >= DATE_SUB(' . $nowDate . ', INTERVAL ' .
$relativeDate . ' DAY)'
);
break;
case 'off':
default:
break;
}
// Process the filter for list views with user-entered filters
$params = $this->getState('params');
if ((is_object($params)) && ($params->get('filter_field') != 'hide') && ($filter = $this->getState('list.filter')))
{
// Clean filter variable
$filter = JString::strtolower($filter);
$hitsFilter = (int) $filter;
$filter = $db->quote('%' . $db->escape($filter, true) . '%', false);
switch ($params->get('filter_field'))
{
case 'author':
$query->where(
'LOWER( CASE WHEN a.created_by_alias > ' . $db->quote(' ') .
' THEN a.created_by_alias ELSE ua.name END ) LIKE ' . $filter . ' '
);
break;
case 'hits':
$query->where('a.hits >= ' . $hitsFilter . ' ');
break;
case 'title':
default:
// Default to 'title' if parameter is not valid
$query->where('LOWER( a.title ) LIKE ' . $filter);
break;
}
}
// Filter by language
if ($this->getState('filter.language'))
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
// Add the list ordering clause.
$query->order($this->getState('list.ordering', 'a.ordering') . ' ' . $this->getState('list.direction', 'ASC'));
return $query;
}
/**
* Method to get a list of articles.
*
* Overriden to inject convert the attribs field into a JParameter object.
*
* @return mixed An array of objects on success, false on failure.
*
* @since 1.6
*/
public function getItems()
{
$items = parent::getItems();
$user = JFactory::getUser();
$userId = $user->get('id');
$guest = $user->get('guest');
$groups = $user->getAuthorisedViewLevels();
$input = JFactory::getApplication()->input;
// Get the global params
$globalParams = JComponentHelper::getParams('com_content', true);
// Convert the parameter fields into objects.
foreach ($items as &$item)
{
$articleParams = new JRegistry;
$articleParams->loadString($item->attribs);
// Unpack readmore and layout params
$item->alternative_readmore = $articleParams->get('alternative_readmore');
$item->layout = $articleParams->get('layout');
$item->params = clone $this->getState('params');
/*For blogs, article params override menu item params only if menu param = 'use_article'
Otherwise, menu item params control the layout
If menu item is 'use_article' and there is no article param, use global*/
if (($input->getString('layout') == 'blog') || ($input->getString('view') == 'featured')
|| ($this->getState('params')->get('layout_type') == 'blog'))
{
// Create an array of just the params set to 'use_article'
$menuParamsArray = $this->getState('params')->toArray();
$articleArray = array();
foreach ($menuParamsArray as $key => $value)
{
if ($value === 'use_article')
{
// If the article has a value, use it
if ($articleParams->get($key) != '')
{
// Get the value from the article
$articleArray[$key] = $articleParams->get($key);
}
else
{
// Otherwise, use the global value
$articleArray[$key] = $globalParams->get($key);
}
}
}
// Merge the selected article params
if (count($articleArray) > 0)
{
$articleParams = new JRegistry;
$articleParams->loadArray($articleArray);
$item->params->merge($articleParams);
}
}
else
{
// For non-blog layouts, merge all of the article params
$item->params->merge($articleParams);
}
// Get display date
switch ($item->params->get('list_show_date'))
{
case 'modified':
$item->displayDate = $item->modified;
break;
case 'published':
$item->displayDate = ($item->publish_up == 0) ? $item->created : $item->publish_up;
break;
default:
case 'created':
$item->displayDate = $item->created;
break;
}
// Compute the asset access permissions.
// Technically guest could edit an article, but lets not check that to improve performance a little.
if (!$guest)
{
$asset = 'com_content.article.' . $item->id;
// Check general edit permission first.
if ($user->authorise('core.edit', $asset))
{
$item->params->set('access-edit', true);
}
// Now check if edit.own is available.
elseif (!empty($userId) && $user->authorise('core.edit.own', $asset))
{
// Check for a valid user and that they are the owner.
if ($userId == $item->created_by)
{
$item->params->set('access-edit', true);
}
}
}
$access = $this->getState('filter.access');
if ($access)
{
// If the access filter has been set, we already have only the articles this user can view.
$item->params->set('access-view', true);
}
else
{
// If no access filter is set, the layout takes some responsibility for display of limited information.
if ($item->catid == 0 || $item->category_access === null)
{
$item->params->set('access-view', in_array($item->access, $groups));
}
else
{
$item->params->set('access-view', in_array($item->access, $groups) && in_array($item->category_access, $groups));
}
}
// Get the tags
$item->tags = new JHelperTags;
$item->tags->getItemTags('com_content.article', $item->id);
}
return $items;
}
/**
* Method to get the starting number of items for the data set.
*
* @return integer The starting number of items available in the data set.
*
* @since 12.2
*/
public function getStart()
{
return $this->getState('list.start');
}
}
PK PLZ[%Ɖ content.phpnu W+A execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
PK PLZ[f> > metadata.xmlnu W+A PK PLZ[+q' q'
z router.phpnu W+A PK PLZ[RC %( views/archive/view.html.phpnu W+A PK PLZ[S 8 views/archive/tmpl/default.phpnu W+A PK PLZ[dY Y ? views/archive/tmpl/default.xmlnu W+A PK PLZ[V Z views/archive/tmpl/index.htmlnu W+A PK PLZ[# # $ [ views/archive/tmpl/default_items.phpnu W+A PK PLZ[$N n~ views/archive/metadata.xmlnu W+A PK PLZ[V G views/archive/index.htmlnu W+A PK PLZ[+ views/featured/view.html.phpnu W+A PK PLZ['I; views/featured/tmpl/default.phpnu W+A PK PLZ[5$h % views/featured/tmpl/default_links.phpnu W+A PK PLZ[>y3 y3 $ Y views/featured/tmpl/default_item.phpnu W+A PK PLZ[1 1 &