0byt3m1n1-V2
Path:
/
home
/
a
/
c
/
a
/
academiac
/
www
/
[
Home
]
File: categories.php.tar
home/academiac/www/administrator/components/com_virtuemart/tables/categories.php 0000604 00000015500 15137216373 0024431 0 ustar 00 <?php /** * * Product table * * @package VirtueMart * @subpackage Category * @author jseros * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: categories.php 5573 2012-02-29 14:05:31Z alatak $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); if(!class_exists('VmTable'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmtable.php'); /** * Category table class * The class is is used to table-level abstraction for Categories. * * @package VirtueMart * @subpackage Category * @author jseros */ class TableCategories extends VmTable { /** @var int Primary key */ var $virtuemart_category_id = null; /** @var integer Product id */ var $virtuemart_vendor_id = 0; /** @var string Category name */ var $category_name = ''; var $slug = ''; /** @var string Category description */ var $category_description = ''; /** @var string Category browse page layout */ var $category_template = null; /** @var string Category browse page layout */ var $category_layout = null; /** @var int Category flypage */ var $category_product_layout = null; /** @var integer Products to show per row */ var $products_per_row = null; /** @var int Category order */ var $ordering = 0; var $shared = 0; /** @var int category limit step*/ var $limit_list_step = 0; /** @var int category limit initial */ var $limit_list_initial = 0; /** @var string Meta description */ var $metadesc = ''; /** @var string custom title */ var $customtitle = ''; /** @var string Meta keys */ var $metakey = ''; /** @var string Meta robot */ var $metarobot = ''; /** @var string Meta author */ var $metaauthor = ''; /** @var integer Category publish or not */ var $published = 0; /** * Class contructor * * @author Max Milbers * @param $db database connector object */ public function __construct($db) { parent::__construct('#__virtuemart_categories', 'virtuemart_category_id', $db); //In a VmTable the primary key is the same as the _tbl_key and therefore not needed // $this->setPrimaryKey('virtuemart_category_id'); $this->setObligatoryKeys('category_name'); $this->setLoggable(); $this->setTranslatable(array('category_name','category_description','metadesc','metakey','customtitle')); $this->setSlug('category_name'); $this->setTableShortCut('c'); } public function check(){ $csValue = $this->limit_list_step; if(!empty($csValue)){ $sequenceArray = explode(',', $csValue); foreach($sequenceArray as &$csV){ $csV = (int)trim($csV); } $this->limit_list_step = implode(',',$sequenceArray); vmdebug('my check',$this->limit_list_step); } return parent::check(); } /** * Overwrite method * * @author jseros * @param $dirn movement number * @param $parent_id category parent id * @param $where sql WHERE clausule */ public function move( $dirn, $parent_id = 0, $where='' ) { if (!in_array( 'ordering', array_keys($this->getProperties()))) { vmError( get_class( $this ).' does not support ordering' ); return false; } $k = $this->_tbl_key; $sql = "SELECT c.".$this->_tbl_key.", c.ordering FROM ".$this->_tbl." c LEFT JOIN #__virtuemart_category_categories cx ON c.virtuemart_category_id = cx.category_child_id"; $condition = 'cx.category_parent_id = '. $this->_db->Quote($parent_id); $where = ($where ? ' AND '.$condition : $condition); if ($dirn < 0) { $sql .= ' WHERE c.ordering < '.(int) $this->ordering; $sql .= ($where ? ' AND '.$where : ''); $sql .= ' ORDER BY c.ordering DESC'; } else if ($dirn > 0) { $sql .= ' WHERE c.ordering > '.(int) $this->ordering; $sql .= ($where ? ' AND '. $where : ''); $sql .= ' ORDER BY c.ordering'; } else { $sql .= ' WHERE c.ordering = '.(int) $this->ordering; $sql .= ($where ? ' AND '.$where : ''); $sql .= ' ORDER BY c.ordering'; } $this->_db->setQuery( $sql, 0, 1 ); $row = null; $row = $this->_db->loadObject(); if (isset($row)) { $query = 'UPDATE '. $this->_tbl . ' SET ordering = '. (int) $row->ordering . ' WHERE '. $this->_tbl_key .' = '. $this->_db->Quote($this->$k) ; $this->_db->setQuery( $query ); if (!$this->_db->query()) { $err = $this->_db->getErrorMsg(); JError::raiseError( 500, 'TableCategories move isset row this->k '.$err ); } $query = 'UPDATE '.$this->_tbl . ' SET ordering = '.(int) $this->ordering . ' WHERE '.$this->_tbl_key.' = '.$this->_db->Quote($row->$k) ; $this->_db->setQuery( $query ); if (!$this->_db->query()) { $err = $this->_db->getErrorMsg(); JError::raiseError( 500, 'TableCategories move isset row $row->$k '.$err ); } $this->ordering = $row->ordering; } else { $query = 'UPDATE '. $this->_tbl . ' SET ordering = '.(int) $this->ordering . ' WHERE '. $this->_tbl_key .' = '. $this->_db->Quote($this->$k) ; $this->_db->setQuery( $query ); if (!$this->_db->query()) { $err = $this->_db->getErrorMsg(); JError::raiseError( 500, 'TableCategories move update '.$err ); } } return true; } /** * Overwrite method * Compacts the ordering sequence of the selected records * @author jseros * * @param $parent_id category parent id * @param string Additional where query to limit ordering to a particular subset of records */ function reorder( $parent_id = 0, $where='' ) { $k = $this->_tbl_key; if (!in_array( 'ordering', array_keys($this->getProperties() ) )) { vmError( get_class( $this ).' does not support ordering'); return false; } $query = 'SELECT c.'.$this->_tbl_key.', c.ordering' . ' FROM '. $this->_tbl . ' c' . ' LEFT JOIN #__virtuemart_category_categories cx' . ' ON c.virtuemart_category_id = cx.category_child_id' . ' WHERE c.ordering >= 0' . ( $where ? ' AND '. $where : '' ) . ' AND cx.category_parent_id = '. $parent_id . ' ORDER BY c.ordering'.$order2; $this->_db->setQuery( $query ); if (!($orders = $this->_db->loadObjectList())) { vmError($this->_db->getErrorMsg()); return false; } // compact the ordering numbers for ($i=0, $n=count( $orders ); $i < $n; $i++) { if ($orders[$i]->ordering >= 0) { if ($orders[$i]->ordering != $i+1) { $orders[$i]->ordering = $i+1; $query = 'UPDATE '.$this->_tbl . ' SET ordering = '. (int) $orders[$i]->ordering . ' WHERE '. $k .' = '. $this->_db->Quote($orders[$i]->$k) ; $this->_db->setQuery( $query); $this->_db->query(); } } } return true; } } home/academiac/www/administrator/components/com_categories/categories.php 0000644 00000001125 15137225322 0023076 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_categories * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; // Access check. if (!JFactory::getUser()->authorise('core.manage', JRequest::getCmd('extension'))) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } // Execute the task. $controller = JControllerLegacy::getInstance('Categories'); $controller->execute(JRequest::getVar('task')); $controller->redirect(); home/academiac/www/administrator/components/com_categories/helpers/categories.php 0000644 00000004616 15137225540 0024552 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; /** * Categories helper. * * @package Joomla.Administrator * @subpackage com_categories * @since 1.6 */ class CategoriesHelper { /** * Configure the Submenu links. * * @param string The extension being used for the categories. * * @return void * @since 1.6 */ public static function addSubmenu($extension) { // Avoid nonsense situation. if ($extension == 'com_categories') { return; } $parts = explode('.', $extension); $component = $parts[0]; if (count($parts) > 1) { $section = $parts[1]; } // Try to find the component helper. $eName = str_replace('com_', '', $component); $file = JPath::clean(JPATH_ADMINISTRATOR.'/components/'.$component.'/helpers/'.$eName.'.php'); if (file_exists($file)) { require_once $file; $prefix = ucfirst(str_replace('com_', '', $component)); $cName = $prefix.'Helper'; if (class_exists($cName)) { if (is_callable(array($cName, 'addSubmenu'))) { $lang = JFactory::getLanguage(); // loading language file from the administrator/language directory then // loading language file from the administrator/components/*extension*/language directory $lang->load($component, JPATH_BASE, null, false, true) || $lang->load($component, JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component), null, false, true); call_user_func(array($cName, 'addSubmenu'), 'categories'.(isset($section)?'.'.$section:'')); } } } } /** * Gets a list of the actions that can be performed. * * @param string $extension The extension. * @param int $categoryId The category ID. * * @return JObject * @since 1.6 */ public static function getActions($extension, $categoryId = 0) { $user = JFactory::getUser(); $result = new JObject; $parts = explode('.', $extension); $component = $parts[0]; if (empty($categoryId)) { $assetName = $component; $level = 'component'; } else { $assetName = $component.'.category.'.(int) $categoryId; $level = 'category'; } $actions = JAccess::getActions($component, $level); foreach ($actions as $action) { $result->set($action->name, $user->authorise($action->name, $assetName)); } return $result; } } home/academiac/www/plugins/search/categories/categories.php 0000644 00000010767 15137265176 0020150 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // no direct access defined('_JEXEC') or die; require_once JPATH_SITE.'/components/com_content/helpers/route.php'; /** * Categories Search plugin * * @package Joomla.Plugin * @subpackage Search.categories * @since 1.6 */ class plgSearchCategories extends JPlugin { /** * Constructor * * @access protected * @param object $subject The object to observe * @param array $config An array that holds the plugin configuration * @since 1.5 */ public function __construct(& $subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); } /** * @return array An array of search areas */ function onContentSearchAreas() { static $areas = array( 'categories' => 'PLG_SEARCH_CATEGORIES_CATEGORIES' ); return $areas; } /** * Categories Search method * * The sql must return the following fields that are * used in a common display routine: href, title, section, created, text, * browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category * @param mixed An array if restricted to areas, null if search all */ function onContentSearch($text, $phrase='', $ordering='', $areas=null) { $db = JFactory::getDbo(); $user = JFactory::getUser(); $app = JFactory::getApplication(); $groups = implode(',', $user->getAuthorisedViewLevels()); $searchText = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sContent = $this->params->get('search_content', 1); $sArchived = $this->params->get('search_archived', 1); $limit = $this->params->def('search_limit', 50); $state = array(); if ($sContent) { $state[]=1; } if ($sArchived) { $state[]=2; } $text = trim($text); if ($text == '') { return array(); } switch($phrase) { case 'exact': $text = $db->Quote('%'.$db->escape($text, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE '.$text; $wheres2[] = 'a.description LIKE '.$text; $where = '(' . implode(') OR (', $wheres2) . ')'; break; case 'any': case 'all'; default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%'.$db->escape($word, true).'%', false); $wheres2 = array(); $wheres2[] = 'a.title LIKE '.$word; $wheres2[] = 'a.description LIKE '.$word; $wheres[] = implode(' OR ', $wheres2); } $where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')'; break; } switch ($ordering) { case 'alpha': $order = 'a.title ASC'; break; case 'category': case 'popular': case 'newest': case 'oldest': default: $order = 'a.title DESC'; } $text = $db->Quote('%'.$db->escape($text, true).'%', false); $query = $db->getQuery(true); $return = array(); if (!empty($state)) { //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias'); $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('a.title, a.description AS text, "" AS created, "2" AS browsernav, a.id AS catid, ' . $case_when); $query->from('#__categories AS a'); $query->where('(a.title LIKE '. $text .' OR a.description LIKE '. $text .') AND a.published IN ('.implode(',', $state).') AND a.extension = \'com_content\'' .'AND a.access IN ('. $groups .')' ); $query->group('a.id'); $query->order($order); if ($app->isSite() && $app->getLanguageFilter()) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); } $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList(); if ($rows) { $count = count($rows); for ($i = 0; $i < $count; $i++) { $rows[$i]->href = ContentHelperRoute::getCategoryRoute($rows[$i]->slug); $rows[$i]->section = JText::_('JCATEGORY'); } foreach($rows as $key => $category) { if (searchHelper::checkNoHTML($category, $searchText, array('name', 'title', 'text'))) { $return[] = $category; } } } } return $return; } } home/academiac/www/administrator/components/com_categories/models/categories.php 0000644 00000015165 15137376147 0024406 0 ustar 00 <?php /** * @package Joomla.Administrator * @subpackage com_categories * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * Categories Component Categories Model * * @package Joomla.Administrator * @subpackage com_categories * @since 1.6 */ class CategoriesModelCategories extends JModelList { /** * Constructor. * * @param array An optional associative array of configuration settings. * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'published', 'a.published', 'access', 'a.access', 'access_level', 'language', 'a.language', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'created_time', 'a.created_time', 'created_user_id', 'a.created_user_id', 'lft', 'a.lft', 'rgt', 'a.rgt', 'level', 'a.level', 'path', 'a.path', ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string An optional ordering field. * @param string An optional direction (asc|desc). * * @return void * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication(); $context = $this->context; $extension = $app->getUserStateFromRequest('com_categories.categories.filter.extension', 'extension', 'com_content', 'cmd'); $this->setState('filter.extension', $extension); $parts = explode('.', $extension); // extract the component name $this->setState('filter.component', $parts[0]); // extract the optional section name $this->setState('filter.section', (count($parts) > 1) ? $parts[1] : null); $search = $this->getUserStateFromRequest($context.'.search', 'filter_search'); $this->setState('filter.search', $search); $level = $this->getUserStateFromRequest($context.'.filter.level', 'filter_level', 0, 'int'); $this->setState('filter.level', $level); $access = $this->getUserStateFromRequest($context.'.filter.access', 'filter_access', 0, 'int'); $this->setState('filter.access', $access); $published = $this->getUserStateFromRequest($context.'.filter.published', 'filter_published', ''); $this->setState('filter.published', $published); $language = $this->getUserStateFromRequest($context.'.filter.language', 'filter_language', ''); $this->setState('filter.language', $language); // List state information. parent::populateState('a.lft', 'asc'); } /** * 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 .= ':'.$this->getState('filter.search'); $id .= ':'.$this->getState('filter.extension'); $id .= ':'.$this->getState('filter.published'); $id .= ':'.$this->getState('filter.language'); return parent::getStoreId($id); } /** * @return string * @since 1.6 */ function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.id, a.title, a.alias, a.note, a.published, a.access' . ', a.checked_out, a.checked_out_time, a.created_user_id' . ', a.path, a.parent_id, a.level, a.lft, a.rgt' . ', a.language' ) ); $query->from('#__categories AS a'); // Join over the language $query->select('l.title AS language_title'); $query->join('LEFT', $db->quoteName('#__languages').' AS l ON l.lang_code = a.language'); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the asset groups. $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the users for the author. $query->select('ua.name AS author_name'); $query->join('LEFT', '#__users AS ua ON ua.id = a.created_user_id'); // Filter by extension if ($extension = $this->getState('filter.extension')) { $query->where('a.extension = '.$db->quote($extension)); } // Filter on the level. if ($level = $this->getState('filter.level')) { $query->where('a.level <= '.(int) $level); } // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = ' . (int) $access); } // Implement View Level Access if (!$user->authorise('core.admin')) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN ('.$groups.')'); } // Filter by published state $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('a.published = ' . (int) $published); } elseif ($published === '') { $query->where('(a.published IN (0, 1))'); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = '.(int) substr($search, 3)); } elseif (stripos($search, 'author:') === 0) { $search = $db->Quote('%'.$db->escape(substr($search, 7), true).'%'); $query->where('(ua.name LIKE '.$search.' OR ua.username LIKE '.$search.')'); } else { $search = $db->Quote('%'.$db->escape($search, true).'%'); $query->where('(a.title LIKE '.$search.' OR a.alias LIKE '.$search.' OR a.note LIKE '.$search.')'); } } // Filter on the language. if ($language = $this->getState('filter.language')) { $query->where('a.language = '.$db->quote($language)); } // Add the list ordering clause $listOrdering = $this->getState('list.ordering', 'a.lft'); $listDirn = $db->escape($this->getState('list.direction', 'ASC')); if ($listOrdering == 'a.access') { $query->order('a.access '.$listDirn.', a.lft '.$listDirn); } else { $query->order($db->escape($listOrdering).' '.$listDirn); } //echo nl2br(str_replace('#__','jos_',$query)); return $query; } } home/academiac/www/libraries/joomla/application/categories.php 0000644 00000047042 15137416744 0020630 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Application * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * JCategories Class. * * @package Joomla.Platform * @subpackage Application * @since 11.1 */ class JCategories { /** * Array to hold the object instances * * @var array * @since 11.1 */ public static $instances = array(); /** * Array of category nodes * * @var mixed * @since 11.1 */ protected $_nodes; /** * Array of checked categories -- used to save values when _nodes are null * * @var array * @since 11.1 */ protected $_checkedCategories; /** * Name of the extension the categories belong to * * @var string * @since 11.1 */ protected $_extension = null; /** * Name of the linked content table to get category content count * * @var string * @since 11.1 */ protected $_table = null; /** * Name of the category field * * @var string * @since 11.1 */ protected $_field = null; /** * Name of the key field * * @var string * @since 11.1 */ protected $_key = null; /** * Name of the items state field * * @var string * @since 11.1 */ protected $_statefield = null; /** * Array of options * * @var array * @since 11.1 */ protected $_options = null; /** * Class constructor * * @param array $options Array of options * * @since 11.1 */ public function __construct($options) { $this->_extension = $options['extension']; $this->_table = $options['table']; $this->_field = (isset($options['field']) && $options['field']) ? $options['field'] : 'catid'; $this->_key = (isset($options['key']) && $options['key']) ? $options['key'] : 'id'; $this->_statefield = (isset($options['statefield'])) ? $options['statefield'] : 'state'; $options['access'] = (isset($options['access'])) ? $options['access'] : 'true'; $options['published'] = (isset($options['published'])) ? $options['published'] : 1; $this->_options = $options; return true; } /** * Returns a reference to a JCategories object * * @param string $extension Name of the categories extension * @param array $options An array of options * * @return JCategories JCategories object * * @since 11.1 */ public static function getInstance($extension, $options = array()) { $hash = md5($extension . serialize($options)); if (isset(self::$instances[$hash])) { return self::$instances[$hash]; } $parts = explode('.', $extension); $component = 'com_' . strtolower($parts[0]); $section = count($parts) > 1 ? $parts[1] : ''; $classname = ucfirst(substr($component, 4)) . ucfirst($section) . 'Categories'; if (!class_exists($classname)) { $path = JPATH_SITE . '/components/' . $component . '/helpers/category.php'; if (is_file($path)) { include_once $path; } else { return false; } } self::$instances[$hash] = new $classname($options); return self::$instances[$hash]; } /** * Loads a specific category and all its children in a JCategoryNode object * * @param mixed $id an optional id integer or equal to 'root' * @param boolean $forceload True to force the _load method to execute * * @return mixed JCategoryNode object or null if $id is not valid * * @since 11.1 */ public function get($id = 'root', $forceload = false) { if ($id !== 'root') { $id = (int) $id; if ($id == 0) { $id = 'root'; } } // If this $id has not been processed yet, execute the _load method if ((!isset($this->_nodes[$id]) && !isset($this->_checkedCategories[$id])) || $forceload) { $this->_load($id); } // If we already have a value in _nodes for this $id, then use it. if (isset($this->_nodes[$id])) { return $this->_nodes[$id]; } // If we processed this $id already and it was not valid, then return null. elseif (isset($this->_checkedCategories[$id])) { return null; } return false; } /** * Load method * * @param integer $id Id of category to load * * @return void * * @since 11.1 */ protected function _load($id) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $extension = $this->_extension; // Record that has this $id has been checked $this->_checkedCategories[$id] = true; $query = $db->getQuery(true); // Right join with c for category $query->select('c.*'); $case_when = ' CASE WHEN '; $case_when .= $query->charLength('c.alias'); $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 slug'; $query->select($case_when); $query->from('#__categories as c'); $query->where('(c.extension=' . $db->Quote($extension) . ' OR c.extension=' . $db->Quote('system') . ')'); if ($this->_options['access']) { $query->where('c.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')'); } if ($this->_options['published'] == 1) { $query->where('c.published = 1'); } $query->order('c.lft'); // s for selected id if ($id != 'root') { // Get the selected category $query->where('s.id=' . (int) $id); if ($app->isSite() && $app->getLanguageFilter()) { $query->leftJoin('#__categories AS s ON (s.lft < c.lft AND s.rgt > c.rgt AND c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')) OR (s.lft >= c.lft AND s.rgt <= c.rgt)'); } else { $query->leftJoin('#__categories AS s ON (s.lft <= c.lft AND s.rgt >= c.rgt) OR (s.lft > c.lft AND s.rgt < c.rgt)'); } } else { if ($app->isSite() && $app->getLanguageFilter()) { $query->where('c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); } } $subQuery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ' . 'ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = ' . $db->quote($extension) . ' AND parent.published != 1 GROUP BY cat.id) '; $query->leftJoin($subQuery . 'AS badcats ON badcats.id = c.id'); $query->where('badcats.id is null'); // i for item if (isset($this->_options['countItems']) && $this->_options['countItems'] == 1) { if ($this->_options['published'] == 1) { $query->leftJoin( $db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id AND i.' . $this->_statefield . ' = 1' ); } else { $query->leftJoin($db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id'); } $query->select('COUNT(i.' . $db->quoteName($this->_key) . ') AS numitems'); } // Group by $query->group('c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time, c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level, c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id, c.path, c.published, c.rgt, c.title, c.modified_user_id'); // Get the results $db->setQuery($query); $results = $db->loadObjectList('id'); $childrenLoaded = false; if (count($results)) { // Foreach categories foreach ($results as $result) { // Deal with root category if ($result->id == 1) { $result->id = 'root'; } // Deal with parent_id if ($result->parent_id == 1) { $result->parent_id = 'root'; } // Create the node if (!isset($this->_nodes[$result->id])) { // Create the JCategoryNode and add to _nodes $this->_nodes[$result->id] = new JCategoryNode($result, $this); // If this is not root and if the current node's parent is in the list or the current node parent is 0 if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id == 1)) { // Compute relationship between node and its parent - set the parent in the _nodes field $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]); } // If the node's parent id is not in the _nodes list and the node is not root (doesn't have parent_id == 0), // then remove the node from the list if (!(isset($this->_nodes[$result->parent_id]) || $result->parent_id == 0)) { unset($this->_nodes[$result->id]); continue; } if ($result->id == $id || $childrenLoaded) { $this->_nodes[$result->id]->setAllLoaded(); $childrenLoaded = true; } } elseif ($result->id == $id || $childrenLoaded) { // Create the JCategoryNode $this->_nodes[$result->id] = new JCategoryNode($result, $this); if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id)) { // Compute relationship between node and its parent $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]); } if (!isset($this->_nodes[$result->parent_id])) { unset($this->_nodes[$result->id]); continue; } if ($result->id == $id || $childrenLoaded) { $this->_nodes[$result->id]->setAllLoaded(); $childrenLoaded = true; } } } } else { $this->_nodes[$id] = null; } } } /** * Helper class to load Categorytree * * @package Joomla.Platform * @subpackage Application * @since 11.1 */ class JCategoryNode extends JObject { /** * Primary key * * @var integer * @since 11.1 */ public $id = null; /** * The id of the category in the asset table * * @var integer * @since 11.1 */ public $asset_id = null; /** * The id of the parent of category in the asset table, 0 for category root * * @var integer * @since 11.1 */ public $parent_id = null; /** * The lft value for this category in the category tree * * @var integer * @since 11.1 */ public $lft = null; /** * The rgt value for this category in the category tree * * @var integer * @since 11.1 */ public $rgt = null; /** * The depth of this category's position in the category tree * * @var integer * @since 11.1 */ public $level = null; /** * The extension this category is associated with * * @var integer * @since 11.1 */ public $extension = null; /** * The menu title for the category (a short name) * * @var string * @since 11.1 */ public $title = null; /** * The the alias for the category * * @var string * @since 11.1 */ public $alias = null; /** * Description of the category. * * @var string * @since 11.1 */ public $description = null; /** * The publication status of the category * * @var boolean * @since 11.1 */ public $published = null; /** * Whether the category is or is not checked out * * @var boolean * @since 11.1 */ public $checked_out = 0; /** * The time at which the category was checked out * * @var time * @since 11.1 */ public $checked_out_time = 0; /** * Access level for the category * * @var integer * @since 11.1 */ public $access = null; /** * JSON string of parameters * * @var string * @since 11.1 */ public $params = null; /** * Metadata description * * @var string * @since 11.1 */ public $metadesc = null; /** * Key words for meta data * * @var string * @since 11.1 */ public $metakey = null; /** * JSON string of other meta data * * @var string * @since 11.1 */ public $metadata = null; public $created_user_id = null; /** * The time at which the category was created * * @var time * @since 11.1 */ public $created_time = null; public $modified_user_id = null; /** * The time at which the category was modified * * @var time * @since 11.1 */ public $modified_time = null; /** * Nmber of times the category has been viewed * * @var integer * @since 11.1 */ public $hits = null; /** * The language for the category in xx-XX format * * @var time * @since 11.1 */ public $language = null; /** * Number of items in this category or descendants of this category * * @var integer * @since 11.1 */ public $numitems = null; /** * Number of children items * * @var * @since 11.1 */ public $childrennumitems = null; /** * Slug fo the category (used in URL) * * @var string * @since 11.1 */ public $slug = null; /** * Array of assets * * @var array * @since 11.1 */ public $assets = null; /** * Parent Category object * * @var object * @since 11.1 */ protected $_parent = null; /** * @var Array of Children * @since 11.1 */ protected $_children = array(); /** * Path from root to this category * * @var array * @since 11.1 */ protected $_path = array(); /** * Category left of this one * * @var integer * @since 11.1 */ protected $_leftSibling = null; /** * Category right of this one * * @var * @since 11.1 */ protected $_rightSibling = null; /** * true if all children have been loaded * * @var boolean * @since 11.1 */ protected $_allChildrenloaded = false; /** * Constructor of this tree * * @var * @since 11.1 */ protected $_constructor = null; /** * Class constructor * * @param array $category The category data. * @param JCategoryNode &$constructor The tree constructor. * * @since 11.1 */ public function __construct($category = null, &$constructor = null) { if ($category) { $this->setProperties($category); if ($constructor) { $this->_constructor = &$constructor; } return true; } return false; } /** * Set the parent of this category * * If the category already has a parent, the link is unset * * @param mixed &$parent JCategoryNode for the parent to be set or null * * @return void * * @since 11.1 */ public function setParent(&$parent) { if ($parent instanceof JCategoryNode || is_null($parent)) { if (!is_null($this->_parent)) { $key = array_search($this, $this->_parent->_children); unset($this->_parent->_children[$key]); } if (!is_null($parent)) { $parent->_children[] = & $this; } $this->_parent = & $parent; if ($this->id != 'root') { if ($this->parent_id != 1) { $this->_path = $parent->getPath(); } $this->_path[] = $this->id . ':' . $this->alias; } if (count($parent->_children) > 1) { end($parent->_children); $this->_leftSibling = prev($parent->_children); $this->_leftSibling->_rightsibling = &$this; } } } /** * Add child to this node * * If the child already has a parent, the link is unset * * @param JNode &$child The child to be added. * * @return void * * @since 11.1 */ public function addChild(&$child) { if ($child instanceof JCategoryNode) { $child->setParent($this); } } /** * Remove a specific child * * @param integer $id ID of a category * * @return void * * @since 11.1 */ public function removeChild($id) { $key = array_search($this, $this->_parent->_children); unset($this->_parent->_children[$key]); } /** * Get the children of this node * * @param boolean $recursive False by default * * @return array The children * * @since 11.1 */ public function &getChildren($recursive = false) { if (!$this->_allChildrenloaded) { $temp = $this->_constructor->get($this->id, true); if ($temp) { $this->_children = $temp->getChildren(); $this->_leftSibling = $temp->getSibling(false); $this->_rightSibling = $temp->getSibling(true); $this->setAllLoaded(); } } if ($recursive) { $items = array(); foreach ($this->_children as $child) { $items[] = $child; $items = array_merge($items, $child->getChildren(true)); } return $items; } return $this->_children; } /** * Get the parent of this node * * @return mixed JNode or null * * @since 11.1 */ public function &getParent() { return $this->_parent; } /** * Test if this node has children * * @return boolean True if there is a child * * @since 11.1 */ public function hasChildren() { return count($this->_children); } /** * Test if this node has a parent * * @return boolean True if there is a parent * * @since 11.1 */ public function hasParent() { return $this->getParent() != null; } /** * Function to set the left or right sibling of a category * * @param object $sibling JCategoryNode object for the sibling * @param boolean $right If set to false, the sibling is the left one * * @return void * * @since 11.1 */ public function setSibling($sibling, $right = true) { if ($right) { $this->_rightSibling = $sibling; } else { $this->_leftSibling = $sibling; } } /** * Returns the right or left sibling of a category * * @param boolean $right If set to false, returns the left sibling * * @return mixed JCategoryNode object with the sibling information or * NULL if there is no sibling on that side. * * @since 11.1 */ public function getSibling($right = true) { if (!$this->_allChildrenloaded) { $temp = $this->_constructor->get($this->id, true); $this->_children = $temp->getChildren(); $this->_leftSibling = $temp->getSibling(false); $this->_rightSibling = $temp->getSibling(true); $this->setAllLoaded(); } if ($right) { return $this->_rightSibling; } else { return $this->_leftSibling; } } /** * Returns the category parameters * * @return JRegistry * * @since 11.1 */ public function getParams() { if (!($this->params instanceof JRegistry)) { $temp = new JRegistry; $temp->loadString($this->params); $this->params = $temp; } return $this->params; } /** * Returns the category metadata * * @return JRegistry A JRegistry object containing the metadata * * @since 11.1 */ public function getMetadata() { if (!($this->metadata instanceof JRegistry)) { $temp = new JRegistry; $temp->loadString($this->metadata); $this->metadata = $temp; } return $this->metadata; } /** * Returns the category path to the root category * * @return array * * @since 11.1 */ public function getPath() { return $this->_path; } /** * Returns the user that created the category * * @param boolean $modified_user Returns the modified_user when set to true * * @return JUser A JUser object containing a userid * * @since 11.1 */ public function getAuthor($modified_user = false) { if ($modified_user) { return JFactory::getUser($this->modified_user_id); } return JFactory::getUser($this->created_user_id); } /** * Set to load all children * * @return void * * @since 11.1 */ public function setAllLoaded() { $this->_allChildrenloaded = true; foreach ($this->_children as $child) { $child->setAllLoaded(); } } /** * Returns the number of items. * * @param boolean $recursive If false number of children, if true number of descendants * * @return integer Number of children or descendants * * @since 11.1 */ public function getNumItems($recursive = false) { if ($recursive) { $count = $this->numitems; foreach ($this->getChildren() as $child) { $count = $count + $child->getNumItems(true); } return $count; } return $this->numitems; } } home/academiac/www/plugins/finder/categories/categories.php 0000644 00000025075 15137436353 0020145 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Finder.Categories * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_BASE') or die; jimport('joomla.application.component.helper'); jimport('joomla.filesystem.file'); // Load the base adapter. require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php'; /** * Finder adapter for Joomla Categories. * * @package Joomla.Plugin * @subpackage Finder.Categories * @since 2.5 */ class plgFinderCategories extends FinderIndexerAdapter { /** * The plugin identifier. * * @var string * @since 2.5 */ protected $context = 'Categories'; /** * The extension name. * * @var string * @since 2.5 */ protected $extension = 'com_categories'; /** * The sublayout to use when rendering the results. * * @var string * @since 2.5 */ protected $layout = 'category'; /** * The type of content that the adapter indexes. * * @var string * @since 2.5 */ protected $type_title = 'Category'; /** * The table name. * * @var string * @since 2.5 */ protected $table = '#__categories'; /** * The field the published state is stored in. * * @var string * @since 2.5 */ protected $state_field = 'published'; /** * Constructor * * @param object &$subject The object to observe * @param array $config An array that holds the plugin configuration * * @since 2.5 */ public function __construct(&$subject, $config) { parent::__construct($subject, $config); $this->loadLanguage(); } /** * Method to remove the link information for items that have been deleted. * * @param string $context The context of the action being performed. * @param JTable $table A JTable object containing the record to be deleted * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderDelete($context, $table) { if ($context == 'com_categories.category') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove the items. return $this->remove($id); } /** * Method to determine if the access level of an item changed. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content has just been created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle categories here if ($context == 'com_categories.category') { // Check if the access levels are different if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the item $this->reindex($row->id); } return true; } /** * Method to reindex the link information for an item that has been saved. * This event is fired before the data is actually saved so we are going * to queue the item to be indexed later. * * @param string $context The context of the content passed to the plugin. * @param JTable $row A JTable object * @param boolean $isNew If the content is just about to be created * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle categories here if ($context == 'com_categories.category') { // Query the database for the old access level if the item isn't new if (!$isNew) { $this->checkItemAccess($row); } } return true; } /** * Method to update the link information for items that have been changed * from outside the edit screen. This is fired when the item is published, * unpublished, archived, or unarchived from the list view. * * @param string $context The context for the content passed to the plugin. * @param array $pks A list of primary key ids of the content that has changed state. * @param integer $value The value of the state that the content has been changed to. * * @return void * * @since 2.5 */ public function onFinderChangeState($context, $pks, $value) { // We only want to handle categories here if ($context == 'com_categories.category') { // The category published state is tied to the parent category // published state so we need to look up all published states // before we change anything. foreach ($pks as $pk) { $sql = clone($this->getStateQuery()); $sql->where('a.id = ' . (int) $pk); // Get the published states. $this->db->setQuery($sql); $item = $this->db->loadObject(); // Translate the state. $temp = $this->translateState($value); // Update the item. $this->change($pk, 'state', $temp); // Reindex the item $this->reindex($pk); } } // Handle when the plugin is disabled if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } } /** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @since 2.5 * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Need to import component route helpers dynamically, hence the reason it's handled here if (JFile::exists(JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php')) { include_once JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php'; } $extension = ucfirst(substr($item->extension, 4)); // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = $registry; $registry = new JRegistry; $registry->loadString($item->metadata); $item->metadata = $registry; /* Add the meta-data processing instructions based on the categories * configuration parameters. */ // Add the meta-author. $item->metaauthor = $item->metadata->get('author'); // Handle the link to the meta-data. $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); //$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Trigger the onContentPrepare event. $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); // Build the necessary route and path information. $item->url = $this->getURL($item->id, $item->extension, $this->layout); if (class_exists($extension . 'HelperRoute') && method_exists($extension . 'HelperRoute', 'getCategoryRoute')) { $class = $extension . 'HelperRoute'; // This is necessary for PHP 5.2 compatibility $item->route = call_user_func(array($class, 'getCategoryRoute'), $item->id); // Use this when PHP 5.3 is minimum supported //$item->route = $class::getCategoryRoute($item->id); } else { $item->route = ContentHelperRoute::getCategoryRoute($item->slug, $item->catid); } $item->path = FinderIndexerHelper::getContentPath($item->route); // Get the menu title if it exists. $title = $this->getItemMenuTitle($item->url); // Adjust the title if necessary. if (!empty($title) && $this->params->get('use_menu_title', true)) { $item->title = $title; } // Translate the state. Categories should only be published if the parent category is published. $item->state = $this->translateState($item->state); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Category'); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); } /** * Method to setup the indexer to be run. * * @return boolean True on success. * * @since 2.5 */ protected function setup() { // Load com_content route helper as it is the fallback for routing in the indexer in this instance. include_once JPATH_SITE . '/components/com_content/helpers/route.php'; return true; } /** * Method to get the SQL query used to retrieve the list of content items. * * @param mixed $sql A JDatabaseQuery object or null. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getListQuery($sql = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $sql = $sql instanceof JDatabaseQuery ? $sql : $db->getQuery(true); $sql->select('a.id, a.title, a.alias, a.description AS summary, a.extension'); $sql->select('a.created_user_id AS created_by, a.modified_time AS modified, a.modified_user_id AS modified_by'); $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.lft, a.parent_id, a.level'); $sql->select('a.created_time AS start_date, a.published AS state, a.access, a.params'); // Handle the alias CASE WHEN portion of the query $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $sql->charLength('a.alias'); $case_when_item_alias .= ' THEN '; $a_id = $sql->castAsChar('a.id'); $case_when_item_alias .= $sql->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id.' END as slug'; $sql->select($case_when_item_alias); $sql->from('#__categories AS a'); $sql->where($db->quoteName('a.id') . ' > 1'); return $sql; } /** * Method to get a SQL query to load the published and access states for * a category and section. * * @return JDatabaseQuery A database object. * * @since 2.5 */ protected function getStateQuery() { $sql = $this->db->getQuery(true); $sql->select($this->db->quoteName('a.id')); $sql->select($this->db->quoteName('a.published') . ' AS cat_state'); $sql->select($this->db->quoteName('a.access') . ' AS cat_access'); $sql->from($this->db->quoteName('#__categories') . ' AS a'); return $sql; } } home/academiac/www/components/com_virtuemart/controllers/categories.php 0000604 00000002613 15137453727 0022654 0 ustar 00 <?php /** * * Description * * @package VirtueMart * @subpackage * @author Max Milbers * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: category.php 2641 2010-11-09 19:25:13Z milbo $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); // Load the controller framework jimport('joomla.application.component.controller'); /** * Class Description * * @package VirtueMart * @author Max Milbers */ class VirtueMartControllerCategories extends JController { public function display($cachable = false, $urlparams = false) { $safeurlparams = array('virtuemart_category_id'=>'INT','return'=>'BASE64','lang'=>'CMD'); parent::display(true, $safeurlparams); } public function json(){ $view = $this->getView('categories', 'json'); $layoutName = JRequest::getWord('layout', 'default'); $view->setLayout($layoutName); // Display it all $view->display(); } } // pure php no closing tag home/academiac/www/administrator/components/com_categories/controllers/categories.php 0000644 00000006156 15137454511 0025461 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; jimport('joomla.application.component.controlleradmin'); /** * The Categories List Controller * * @package Joomla.Administrator * @subpackage com_categories * @since 1.6 */ class CategoriesControllerCategories extends JControllerAdmin { /** * Proxy for getModel * * @param string $name The model name. Optional. * @param string $prefix The class prefix. Optional. * * @return object The model. * @since 1.6 */ function getModel($name = 'Category', $prefix = 'CategoriesModel', $config = array('ignore_request' => true)) { $model = parent::getModel($name, $prefix, $config); return $model; } /** * Rebuild the nested set tree. * * @return bool False on failure or error, true on success. * @since 1.6 */ public function rebuild() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $extension = JRequest::getCmd('extension'); $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension='.$extension, false)); // Initialise variables. $model = $this->getModel(); if ($model->rebuild()) { // Rebuild succeeded. $this->setMessage(JText::_('COM_CATEGORIES_REBUILD_SUCCESS')); return true; } else { // Rebuild failed. $this->setMessage(JText::_('COM_CATEGORIES_REBUILD_FAILURE')); return false; } } /** * Save the manual order inputs from the categories list page. * * @return void * @since 1.6 */ public function saveorder() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get the arrays from the Request $order = JRequest::getVar('order', null, 'post', 'array'); $originalOrder = explode(',', JRequest::getString('original_order_values')); // Make sure something has changed if (!($order === $originalOrder)) { parent::saveorder(); } else { // Nothing to reorder $this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list, false)); return true; } } /** Deletes and returns correctly. * * @return void * @since 2.5.12 */ public function delete() { JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); // Get items to remove from the request. $cid = JRequest::getVar('cid', array(), '', 'array'); $extension = JRequest::getVar('extension', null); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); } else { // Get the model. $model = $this->getModel(); // Make sure the item ids are integers jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); // Remove the items. if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&extension=' . $extension, false)); } } home/academiac/www/components/com_newsfeeds/models/categories.php 0000644 00000005701 15137455076 0021356 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * This models supports retrieving lists of newsfeed categories. * * @package Joomla.Site * @subpackage com_newsfeeds * @since 1.6 */ class NewsfeedsModelCategories extends JModelList { /** * Model context string. * * @var string */ public $_context = 'com_newsfeeds.categories'; /** * The category context (allows other extensions to derived from this model). * * @var string */ protected $_extension = 'com_newsfeeds'; private $_parent = null; private $_items = null; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $this->setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = JRequest::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 * * @return mixed An array of data items on success, false on failure. */ public function getItems() { 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_items_cat', 1) || !$params->get('show_empty_categories_cat', 0); $categories = JCategories::getInstance('Newsfeeds', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if(is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; } public function getParent() { if(!is_object($this->_parent)) { $this->getItems(); } return $this->_parent; } } home/academiac/www/components/com_weblinks/models/categories.php 0000644 00000005673 15137507215 0021212 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * This models supports retrieving lists of article categories. * * @package Joomla.Site * @subpackage com_weblinks * @since 1.6 */ class WeblinksModelCategories extends JModelList { /** * Model context string. * * @var string */ public $_context = 'com_weblinks.categories'; /** * The category context (allows other extensions to derived from this model). * * @var string */ protected $_extension = 'com_weblinks'; private $_parent = null; private $_items = null; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $this->setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = JRequest::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 * * @return mixed An array of data items on success, false on failure. */ public function getItems() { 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_links', 1) || !$params->get('show_empty_categories_cat', 0); $categories = JCategories::getInstance('Weblinks', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if(is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; } public function getParent() { if(!is_object($this->_parent)) { $this->getItems(); } return $this->_parent; } } home/academiac/www/components/com_content/models/categories.php 0000644 00000006071 15140017614 0021030 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * This models supports retrieving lists of article categories. * * @package Joomla.Site * @subpackage com_content * @since 1.6 */ class ContentModelCategories extends JModelList { /** * Model context string. * * @var string */ public $_context = 'com_content.categories'; /** * The category context (allows other extensions to derived from this model). * * @var string */ protected $_extension = 'com_content'; private $_parent = null; private $_items = null; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $this->setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = JRequest::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; } } home/academiac/www/components/com_contact/models/categories.php 0000644 00000005666 15140072022 0021014 0 ustar 00 <?php /** * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; jimport('joomla.application.component.modellist'); /** * This models supports retrieving lists of contact categories. * * @package Joomla.Site * @subpackage com_contact * @since 1.6 */ class ContactModelCategories extends JModelList { /** * Model context string. * * @var string */ public $_context = 'com_contact.categories'; /** * The category context (allows other extensions to derived from this model). * * @var string */ protected $_extension = 'com_contact'; private $_parent = null; private $_items = null; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $this->setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = JRequest::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 * * @return mixed An array of data items on success, false on failure. */ public function getItems() { 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_items_cat', 1) || !$params->get('show_empty_categories_cat', 0); $categories = JCategories::getInstance('Contact', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if(is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; } public function getParent() { if(!is_object($this->_parent)) { $this->getItems(); } return $this->_parent; } }
©
2018.