?
Path : /home/admin/public_html/old/administrator/components/com_xijc/models/ |
Current File : /home/admin/public_html/old/administrator/components/com_xijc/models/manager.php |
<?php // Disallow direct access to this file defined('_JEXEC') or die('Restricted access'); jimport( 'joomla.application.component.model' ); class XiJCModelManager extends JModel { var $_pagination; /** * Constructor */ function __construct() { global $mainframe; // Call the parents constructor parent::__construct(); // Get the pagination request variables $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); $limitstart = $mainframe->getUserStateFromRequest( 'com_XiJC.limitstart', 'limitstart', 0, 'int' ); // In case limit has been changed, adjust limitstart accordingly $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); $this->setState('limit', $limit); $this->setState('limitstart', $limitstart); } /* * Retrieves the JPagination object * * @return object JPagination object */ function &getPagination() { if ($this->_pagination == null) $this->getComponents(); return $this->_pagination; } /** * Returns the Fields * * @return object JParameter object **/ function &getComponents() { global $mainframe; static $components; if( isset( $components ) ) return $components; // Initialize variables $db =& JFactory::getDBO(); // Get the limit / limitstart $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); $limitstart = $mainframe->getUserStateFromRequest('com_XiJClimitstart', 'limitstart', 0, 'int'); // In case limit has been changed, adjust limitstart accordingly $limitstart = ($limit != 0) ? ($limitstart / $limit ) * $limit : 0; /* * Get the total number of records for pagination * In #__component table, for all top level components, parent value is 0. */ $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote( '#__components' ).' ' .'where '.$db->nameQuote('parent').'='.$db->Quote(0); $db->setQuery( $query ); $total = $db->loadResult(); jimport('joomla.html.pagination'); // Get the pagination object $this->_pagination = new JPagination( $total , $limitstart , $limit ); $query = 'SELECT * FROM ' . $db->nameQuote( '#__components' ).' ' .'where '.$db->nameQuote('parent').'='.$db->Quote(0); $db->setQuery( $query , $this->_pagination->limitstart , $this->_pagination->limit ); $components = $db->loadObjectList(); return $components; } function updateEnable($option,$value) { global $mainframe; $db =& JFactory::getDBO(); //check if row already exist for component $query = 'SELECT COUNT(*) FROM ' . $db->nameQuote( '#__xijc_manager' ).' ' .'where '.$db->nameQuote('option').'='.$db->Quote($option); $db->setQuery( $query ); $count = $db->loadResult(); if($count) { $query = 'UPDATE #__xijc_manager' . ' SET '.$db->nameQuote('enable').'='.$db->Quote($value).'' . ' WHERE '.$db->nameQuote('option').'='. $db->Quote($option); $db->setQuery( $query ); if (!$db->query()) { return JError::raiseWarning( 500, $db->getError() ); } } else { //insert row for component JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $row =& JTable::getInstance( 'manager' , 'XiJCTable' ); $row->option = $option; $row->enable = $value; if (!$row->store()) { return JError::raiseWarning( 500, $db->getError() ); } } return true; } function getManagerInfo($filter='',$join='AND') { return XiJCUtils::getManagerInfo($filter); } }