Willkommen bei WordPress. Dies ist dein erster Beitrag. Bearbeite oder lösche ihn und beginne mit dem Schreiben!
Hallo Welt!
von raredesign | Dez 3, 2019 | Allgemein | 0 Kommentare
Cokiee Shell
Current Path : /var/www/web236/html/components/com_xmovie/models/ |
Current File : //var/www/web236/html/components/com_xmovie/models/category.php |
<?php /* * @package Joomla 3.0 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * * @component XMovie Component * @copyright Copyright (C) Dana Harris optikool.com * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL */ defined('_JEXEC') or die('Restricted access'); jimport('joomla.application.component.modellist'); if (!class_exists('JModelListLegacy')) { class_alias('JModelList', 'JModelListLegacy'); } /** * * @author optikool * Model for the category view * */ class XMovieModelCategory extends JModelListLegacy { protected $_items = null; protected $_item = null; protected $_articles = null; protected $_siblings = null; protected $_children = null; protected $_parent = null; protected $_active = null; protected $_rightsibling = null; protected $_leftsibling = null; protected $_mainItemId = null; protected $_total = null; protected $_categoryids = null; protected $_pagination = null; /** * The category that applies. * * @access protected * @var object */ protected $_category = null; /** * The list of other newfeed categories. * * @access protected * @var array */ protected $_categories = null; /** * Constructor * * @since 1.5 */ function __construct() { parent::__construct(); } /** * 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) { // Initialise variables. $app = JFactory::getApplication(); $input = JFactory::getApplication() -> input; $menuitemid = $input -> getInt('Itemid'); $menu = JFactory::getApplication() -> getMenu(); $params = $menu -> getParams($menuitemid); $cfgParams = $this -> getConfigParams(); $db = $this -> getDbo(); // List state information $value = JRequest::getUInt('limit', $params -> get('single_cat_mov_per_page', $cfgParams -> get('cview_movs_per_page'))); $this -> setState('list.limit', $value); $value = JRequest::getUInt('limitstart', 0); $this -> setState('list.start', $value); // Get list ordering default from the parameters $menuParams = new JRegistry(); if ($menu = $app -> getMenu() -> getActive()) { $menuParams -> loadString($menu -> params); } $mergedParams = clone $params; $mergedParams -> merge($menuParams); $orderCol = JRequest::getCmd('filter_order', $params -> get('single_cat_mov_sort_order', $cfgParams -> get('cview_cat_sort_order'))); $this -> setState('list.ordering', $orderCol); $listOrder = JRequest::getCmd('filter_order_Dir', $params -> get('single_cat_mov_sort_order_dir', $cfgParams -> get('cview_sort_order_dir'))); $this -> setState('list.direction', $listOrder); $id = JRequest::getVar('id', 0, '', 'int'); $this -> setState('category.id', $id); $user = JFactory::getUser(); if ((!$user -> authorise('core.edit.state', 'com_xmovie')) && (!$user -> authorise('core.edit', 'com_xmovie'))) { // limit to published for people who can't edit or edit.state. $this -> setState('filter.published', 1); // Filter by start and end dates. $this -> setState('filter.publish_date', true); } $this -> setState('filter.language', $app -> getLanguageFilter()); // Load the parameters. $this -> setState('params', $params); } public function getItems() { // Invoke the parent getItems method to get the main list $items = parent::getItems(); $this -> _total = $this -> getTotal(); $categories = MovieHelper::getItemIds(); $subcategories = $this -> getSubCategories(); $itemId = JRequest::getInt('Itemid'); $id = JRequest::getVar('id', 0, '', 'int'); $menu = JFactory::getApplication() -> getMenu() -> getActive(); $cat = MovieHelper::getTopLevel('category', $id, $menu -> menutype); if (!isset($cat[$id])) { $cat[$id] = new stdClass(); $cat[$id] -> menuid = $itemId; $cat[$id] -> alias = $this -> _category -> alias; } // Convert the params field into an object, saving original in _params for ($i = 0, $n = count($items); $i < $n; $i++) { $item = &$items[$i]; $cid = $item -> catid; $user = JFactory::getUser($item -> user_id); $item -> submitter = $user -> username; if (isset($categories[$cid]['itemId']) && $categories[$cid]['itemId'] != '') { $item -> itemId = $categories[$cid]['itemId']; } else { $item -> itemId = $itemId; } if (isset($cat[$item -> catid])) { $item -> catido = $cat[$item -> catid] -> menuid; $item -> catidoa = $cat[$item -> catid] -> alias; } if (isset($subcategories[$item -> catid])) { $item -> catalias = $subcategories[$item -> catid]['alias']; } else { $item -> catalias = $categories[$item -> catid]['alias']; } if (!isset($this -> _params)) { $params = new JRegistry(); $item -> params = $params; $params -> loadString($item -> params); } } $this -> _items = $items; return $this -> _items; } /** * Method to build an SQL query to load the list data. * * @return string An SQL query * @since 1.6 */ protected function getListQuery() { $user = JFactory::getUser(); $groups = implode(',', $user -> getAuthorisedViewLevels()); // Create a new query object. $db = $this -> getDbo(); $query = $db -> getQuery(true); $category = $this -> getCategoryInfo(); // Select required fields from the categories. $query -> select($this -> getState('list.select', 'a.*')); $query -> from($db -> quoteName('#__xmovie_movies') . ' AS a'); $query -> where('a.access IN (' . $groups . ')'); if ($category) { $catQuery = 'a.catid = ANY (SELECT `id` FROM ' . $db -> quoteName('#__categories') . ' WHERE lft >= ' . $category -> lft . ' AND rgt <= ' . $category -> rgt . " AND extension = 'com_xmovie' AND access IN (" . $groups . "))"; $query -> where($catQuery); } $query -> where('a.published = 1'); // Filter by start and end dates. $nullDate = $db -> Quote($db -> getNullDate()); $date = JFactory::getDate(); $nowDate = $db -> Quote($date -> format($db -> getDateFormat())); if ($this -> getState('filter.publish_date')) { $query -> where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')'); $query -> where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); } // 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($db -> escape($this -> getState('list.ordering', 'a.ordering')) . ' ' . $db -> escape($this -> getState('list.direction', 'ASC'))); return $query; } public function getCategoryInfo() { if (!$this -> _category) { $cat_id = JRequest::getInt('id'); $db = $this -> getDbo(); $query = $db -> getQuery(true); $query -> select('*'); $query -> from('#__categories'); $query -> where("id = '{$cat_id}' AND extension = 'com_xmovie' AND published = '1'"); $db -> setQuery($query); $this -> _category = $db -> loadObject(); } return $this -> _category; } public function getConfigParams() { $cfgParams = JComponentHelper::getParams('com_xmovie'); return $cfgParams; } public function getSubCategories() { if (count($this -> _categories) > 0 || $this -> _categories != NULL) { return $this -> _categories; } if ($this -> _category == null) { $this -> getCategoryInfo(); } $cfgParams = $this -> getConfigParams(); $this -> _categoryids = array(); $tmpId = 0; $alias = ''; $cat_id = JRequest::getInt('id'); $p_id = 0; $this -> _categoryids = array(); $db = $this -> getDbo(); $query = $db -> getQuery(true); $app = JFactory::getApplication(); $params = $app -> getParams(); $user = JFactory::getUser(); $groups = implode(',', $user -> getAuthorisedViewLevels()); $query -> select('*'); $query -> from('#__categories'); $query -> where("parent_id = {$cat_id} AND extension = 'com_xmovie' AND published = '1'"); switch ($params->get('single_cat_sort_order', $cfgParams->get('cview_cat_sort_order'))) { case 'title' : $sort_method = "title"; break; case 'date' : $sort_method = "created_time"; break; case 'random' : $sort_method = "RAND()"; break; case 'popular' : default : $sort_method = "hits"; } if ($params -> get('single_cat_sort_order_dir', $cfgParams -> get('cview_cat_sort_order_dir')) == 'desc') { $listOrder = "DESC"; } else { $listOrder = "ASC"; } $query -> where('access IN (' . $groups . ') ORDER BY ' . $sort_method . ' ' . $listOrder); $db -> setQuery($query); $rows = $db -> loadAssocList('id'); $itemids = MovieHelper::getItemIds(); foreach ($rows as $key => $value) { $p_id = $rows[$key]['parent_id']; $this -> _categoryids[$key] = MovieHelper::getTopId($key); if (isset($itemids[$key])) { $itemid = $itemids[$key]['itemId']; $alias = $rows[$key]['alias']; $catid = $rows[$key]['parent_id']; $rows[$key]['itemId'] = $itemid; $rows[$key]['link'] = "index.php?view=category&id={$key}:{$alias}&Itemid={$itemid}"; } elseif (isset($itemids[$p_id])) { $itemid = $itemids[$p_id]['itemId']; $alias = $rows[$key]['alias']; $rows[$key]['itemId'] = $itemids[$p_id]['itemId']; $rows[$key]['link'] = "index.php?view=category&id={$key}:{$alias}&Itemid={$itemid}"; } else { $itemid = $itemids[0]['itemId']; $alias = $rows[$key]['alias']; $rows[$key]['itemId'] = $itemids[0]['itemId']; $rows[$key]['link'] = "index.php?view=category&id={$key}:{$alias}&Itemid={$itemid}"; } } $this -> _categories = $rows; return $rows; } /** * Method to get category data for the current category * * @param int An optional ID * * @return object * @since 1.5 */ public function getCategory() { if (!$this -> _category) { $cid = JRequest::getInt('id', ''); $db = $this -> getDbo(); $query = $db -> getQuery(true); $query -> select('*'); $query -> from('#__categories'); $query -> where("`id` = '{$cid}'"); $query -> where("`extension` = 'com_xmovie'"); $query -> where("published = '1'"); $db -> setQuery($query); $this -> _category = $db -> loadObject(); } return $this -> _category; } public function getMainItemId() { return $this -> _mainItemId; } public function getActive() { if ($this -> _active) { return $this -> _active; } else { $app = JFactory::getApplication(); $input = JFactory::getApplication() -> input; $menuitemid = $input -> getInt('Itemid'); $this -> _active = JFactory::getApplication() -> getMenu() -> getActive(); return $this -> _active; } } /** * Get the parent category. * * @param int 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. */ public function getParent() { if (!is_object($this -> _item)) { $this -> getCategory(); } return $this -> _parent; } /** * Get the sibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. */ function & getLeftSibling() { if (!is_object($this -> _item)) { $this -> getCategory(); } return $this -> _leftsibling; } function & getRightSibling() { if (!is_object($this -> _item)) { $this -> getCategory(); } return $this -> _rightsibling; } /** * Get the child categories. * * @param int 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. */ function & getChildren() { if (!is_object($this -> _item)) { $this -> getCategory(); } return $this -> _children; } public function getStart() { return $this -> getState('list.start'); } /** * Method to get a pagination object of the weblink items for the category * * @access public * @return integer */ function getPagination() { // Lets load the content if it doesn't already exist if (empty($this -> _pagination)) { jimport('joomla.html.pagination'); $this -> _pagination = new JPagination($this -> _total, $this -> getState('list.start'), $this -> getState('list.limit')); } return $this -> _pagination; } } ?>
Cokiee Shell Web 1.0, Coded By Razor
Neueste Kommentare