Server IP : 180.180.241.3 / Your IP : 216.73.216.252 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/AppServ/www/news/administrator/components/com_youtubegallery/views/categories/ |
Upload File : |
<?php /** * Extra Search Joomla! 1.5 Native Component * @version 3.8.3 * @author Design COmpass corp <support@joomlaboat.com> * @link http://www.joomlaboat.com * @GNU General Public License **/ // no direct access defined('_JEXEC') or die('Restricted access'); jimport( 'joomla.application.component.view'); class YouTubeGalleryViewCategories extends JView { var $_pagination; function display($tpl = null) { global $mainframe; JToolBarHelper::title(JText::_('YouTube Gallery - Categories'), 'generic.png'); JToolBarHelper::addNewX('newItem'); JToolBarHelper::customX( 'copyItem', 'copy.png', 'copy_f2.png', 'Copy', true); JToolBarHelper::deleteListX(); //$db = & JFactory::getDBO(); $context = 'com_youtubegallery.categories.'; $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 's.id', 'cmd' ); $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); $limit = $mainframe->getUserStateFromRequest( $context.'limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); // $where = array(); // if ($search) // { // $where[] = 'LOWER(s.categoryname) LIKE '.$db->Quote( '%'.$db->getEscaped($search,true).'%', false ); // } // $where = count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : ''; // $query = 'SELECT COUNT(*)' // . ' FROM #__youtubegallery_categories AS s ' // . $where // ; // $db->setQuery( $query ); // if (!$db->query()) echo ( $db->stderr()); // $total = $db->loadResult(); // $orderby = 'ORDER BY '. $filter_order .' '. $filter_order_Dir ; //$inner=array(); //$inner[]='LEFT JOIN `#__youtubegallery_categories` ON #__youtubegallery_categories.id=catid'; //$inner[]='LEFT JOIN `#__youtubegallery_videos` ON #__youtubegallery_videos.listid=s.id AND #__youtubegallery_videos.isvideo'; //. implode (' ', $inner).' ' //jimport('joomla.html.pagination'); //$pageNav = new JPagination( $total, $limitstart, $limit ); // $query = 'SELECT s.* FROM #__youtubegallery_categories AS s ' // . $where // . $orderby //; //$db->setQuery($query, $pageNav->limitstart, $pageNav->limit ); //if (!$db->query()) echo ( $db->stderr()); //$rows = $db->loadObjectList(); //if(!isset($rows)) //{ //$rows=array(); //} ///foreach($rows as $r) // $r->checked_out=''; $javascript = 'onchange="document.adminForm.submit();"'; $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // search filter $lists['search']= $search; $this->assignRef('items', $this->getItems()); $this->assignRef('pagination', $this->_pagination); $this->assignRef('lists', $lists); parent::display($tpl); } function getItems() { global $mainframe; static $items; if (isset($items)) { return $items; } $db = & JFactory::getDBO(); $context= 'com_youtubegallery.list.'; $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'm.id', 'int' );//'m.ordering' $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', 'ASC', 'word' ); $filter_rootparent = $mainframe->getUserStateFromRequest( $context.'filter_rootparent','filter_rootparent','','int' ); $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg( 'list_limit' ), 'int' ); $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); $levellimit = $mainframe->getUserStateFromRequest( $context.'levellimit', 'levellimit', 10, 'int' ); $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); $search = JString::strtolower( $search ); $where = array(); // just in case filter_order get's messed up if ($filter_order) { $orderby = ' ORDER BY '.$filter_order .' '. $filter_order_Dir .', m.parentid';//, m.ordering } else { $orderby = ' ORDER BY m.parentid';//, m.ordering } // select the records // note, since this is a tree we have to do the limits code-side if ($search) { $query = 'SELECT m.id' . ' FROM #__youtubegallery_categories AS m' . ' WHERE ' . ' LOWER( m.categoryname ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );// . //AND //$and; $db->setQuery( $query ); $search_rows = $db->loadResultArray(); } if($filter_rootparent) $where[]=' ( id='.$filter_rootparent.' OR parentid!=0 )'; $WhereStr=''; if(count($where)>0) { $WhereStr=' WHERE '.implode(' AND ',$where);//$WhereStr; } $query = 'SELECT m.* ' . ' FROM #__youtubegallery_categories AS m' . $WhereStr . $orderby; $db->setQuery( $query ); if (!$db->query()) die( $db->stderr()); $rows = $db->loadObjectList(); $children = array(); // first pass - collect children foreach ($rows as $v ) { $pt = $v->parentid; $list = @$children[$pt] ? $children[$pt] : array(); array_push( $list, $v ); $children[$pt] = $list; } // second pass - get an indent list of the items $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, max( 0, $levellimit-1 ) ); $list = $this->treerecurse(0, '', array(), $children, max( 0, $levellimit-1 ) ); // eventually only pick out the searched items. if ($search) { $list1 = array(); foreach ($search_rows as $sid ) { foreach ($list as $item) { if ($item->id == $sid) { $list1[] = $item; } } } // replace full list with found items $list = $list1; } $total = count( $list ); jimport('joomla.html.pagination'); $this->_pagination = new JPagination( $total, $limitstart, $limit ); // slice out elements based on limits $list = array_slice( $list, $this->_pagination->limitstart, $this->_pagination->limit ); return $list; } function treerecurse($id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1) { if (@$children[$id] && $level <= $maxlevel) { foreach ($children[$id] as $v) { $id = $v->id; if ($type) { $pre = '<sup>|_</sup> '; $spacer = ' '; } else { $pre = '- '; $spacer = ' '; } if ($v->parentid == 0) { $txt = $v->categoryname; } else { $txt = $pre . $v->categoryname; } $pt = $v->parentid; $list[$id] = $v; $list[$id]->treename = "$indent$txt"; $list[$id]->children = count(@$children[$id]); $list = $this->treerecurse($id, $indent . $spacer, $list, $children, $maxlevel, $level+1, $type); } } return $list; } } ?>