PageRenderTime 27ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/com_flexicontent_v2.x/admin/views/categories/view.html.php

http://flexicontent.googlecode.com/
PHP | 275 lines | 187 code | 37 blank | 51 comment | 50 complexity | 37dbbb630f1bad7c39a44934a0ab7333 MD5 | raw file
Possible License(s): MIT, GPL-2.0, Apache-2.0
  1. <?php
  2. /**
  3. * @version 1.5 stable $Id: view.html.php 1577 2012-12-02 15:10:44Z ggppdk $
  4. * @package Joomla
  5. * @subpackage FLEXIcontent
  6. * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
  7. * @license GNU/GPL v2
  8. *
  9. * FLEXIcontent is a derivative work of the excellent QuickFAQ component
  10. * @copyright (C) 2008 Christoph Lukes
  11. * see www.schlu.net for more information
  12. *
  13. * FLEXIcontent is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. defined( '_JEXEC' ) or die( 'Restricted access' );
  19. jimport('joomla.application.component.view');
  20. /**
  21. * View class for the FLEXIcontent categories screen
  22. *
  23. * @package Joomla
  24. * @subpackage FLEXIcontent
  25. * @since 1.0
  26. */
  27. class FlexicontentViewCategories extends JViewLegacy
  28. {
  29. function display($tpl = null)
  30. {
  31. //initialise variables
  32. global $globalcats;
  33. $app = JFactory::getApplication();
  34. $option = JRequest::getVar('option');
  35. $view = JRequest::getVar('view');
  36. $user = JFactory::getUser();
  37. $db = JFactory::getDBO();
  38. $document = JFactory::getDocument();
  39. JHTML::_('behavior.tooltip');
  40. //get vars
  41. $order_property = !FLEXI_J16GE ? 'c.ordering' : 'c.lft';
  42. $filter_order = $app->getUserStateFromRequest( $option.'.'.$view.'.filter_order', 'filter_order', $order_property, 'cmd' );
  43. $filter_order_Dir = $app->getUserStateFromRequest( $option.'.'.$view.'.filter_order_Dir', 'filter_order_Dir', '', 'word' );
  44. $filter_state = $app->getUserStateFromRequest( $option.'.'.$view.'.filter_state', 'filter_state', '', 'string' );
  45. $filter_cats = $app->getUserStateFromRequest( $option.'.'.$view.'.filter_cats', 'filter_cats', '', 'int' );
  46. $filter_level = $app->getUserStateFromRequest( $option.'.'.$view.'.filter_level', 'filter_level', '', 'string' );
  47. $filter_access = $app->getUserStateFromRequest( $option.'.'.$view.'.filter_access', 'filter_access', '', 'string' );
  48. if (FLEXI_J16GE) {
  49. $filter_language = $app->getUserStateFromRequest( $option.'.'.$view.'.filter_language', 'filter_language', '', 'string' );
  50. }
  51. $search = $app->getUserStateFromRequest( $option.'.'.$view.'.search', 'search', '', 'string' );
  52. $search = FLEXI_J16GE ? $db->escape( trim(JString::strtolower( $search ) ) ) : $db->getEscaped( trim(JString::strtolower( $search ) ) );
  53. // Prepare the document: add css files, etc
  54. $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/flexicontentbackend.css');
  55. if (FLEXI_J30GE) $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/j3x.css');
  56. else if (FLEXI_J16GE) $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/j25.css');
  57. else $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/j15.css');
  58. // Get User's Global Permissions
  59. $perms = FlexicontentHelperPerm::getPerm();
  60. // Create Submenu (and also check access to current view)
  61. FLEXISubmenu('CanCats');
  62. // ******************
  63. // Create the toolbar
  64. // ******************
  65. $js = "window.addEvent('domready', function(){";
  66. $contrl = FLEXI_J16GE ? "categories." : "";
  67. $contrl_singular = FLEXI_J16GE ? "category." : "";
  68. JToolBarHelper::title( JText::_( 'FLEXI_CATEGORIES' ), 'fc_categories' );
  69. $toolbar = JToolBar::getInstance('toolbar');
  70. // Copy Parameters
  71. $btn_task = '';
  72. $popup_load_url = JURI::base().'index.php?option=com_flexicontent&view=categories&layout=params&tmpl=component';
  73. if (FLEXI_J16GE) {
  74. $js .= "
  75. $$('li#toolbar-params a.toolbar, #toolbar-params button')
  76. .set('onclick', 'javascript:;')
  77. .set('href', '".$popup_load_url."')
  78. .set('rel', '{handler: \'iframe\', size: {x: 600, y: 440}, onClose: function() {}}');
  79. ";
  80. JToolBarHelper::custom( $btn_task, 'params.png', 'params_f2.png', 'FLEXI_COPY_PARAMS', false );
  81. JHtml::_('behavior.modal', 'li#toolbar-params a.toolbar, #toolbar-params button');
  82. } else {
  83. $toolbar->appendButton('Popup', 'params', JText::_('FLEXI_COPY_PARAMS'), $popup_load_url, 600, 440);
  84. }
  85. //if (FLEXI_J16GE)
  86. // $toolbar->appendButton('Popup', 'move', JText::_('FLEXI_COPY_MOVE'), JURI::base().'index.php?option=com_flexicontent&amp;view=categories&amp;layout=batch&amp;tmpl=component', 800, 440);
  87. JToolBarHelper::divider();
  88. $add_divider = false;
  89. if ( !FLEXI_J16GE || $user->authorise('core.create', 'com_flexicontent') ) {
  90. $cancreate_cat = true;
  91. } else {
  92. $usercats = FlexicontentHelperPerm::getAllowedCats($user, $actions_allowed = array('core.create')
  93. , $require_all = true, $check_published = true, $specific_catids = false, $find_first = true
  94. );
  95. $cancreate_cat = count($usercats) > 0;
  96. }
  97. if ( $cancreate_cat ) {
  98. JToolBarHelper::addNew($contrl_singular.'add');
  99. $add_divider = true;
  100. }
  101. if ( !FLEXI_J16GE || ( $user->authorise('core.edit', 'com_flexicontent') || $user->authorise('core.edit.own', 'com_flexicontent') ) ) {
  102. JToolBarHelper::editList($contrl_singular.'edit');
  103. $add_divider = true;
  104. }
  105. if ( FLEXI_J16GE && $user->authorise('core.admin', 'checkin') )
  106. {
  107. JToolBarHelper::checkin($contrl.'checkin');
  108. $add_divider = true;
  109. }
  110. if ($add_divider) JToolBarHelper::divider();
  111. $add_divider = false;
  112. if ( !FLEXI_J16GE || ( $user->authorise('core.edit.state', 'com_flexicontent') || $user->authorise('core.edit.state.own', 'com_flexicontent') ) ) {
  113. JToolBarHelper::publishList($contrl.'publish');
  114. JToolBarHelper::unpublishList($contrl.'unpublish');
  115. JToolBarHelper::divider();
  116. if (FLEXI_J16GE) JToolBarHelper::archiveList($contrl.'archive');
  117. }
  118. $add_divider = false;
  119. if ( !FLEXI_J16GE || ( $filter_state == -2 && $user->authorise('core.delete', 'com_flexicontent') ) ) {
  120. JToolBarHelper::deleteList('Are you sure?', $contrl.'remove');
  121. //JToolBarHelper::deleteList('', $contrl.'delete', 'JTOOLBAR_EMPTY_TRASH');
  122. $add_divider = true;
  123. }
  124. elseif ( $user->authorise('core.edit.state', 'com_flexicontent') ) {
  125. JToolBarHelper::trash($contrl.'trash');
  126. $add_divider = true;
  127. }
  128. if ($add_divider) JToolBarHelper::divider();
  129. if ($perms->CanConfig) {
  130. //JToolBarHelper::custom($contrl.'rebuild', 'refresh.png', 'refresh_f2.png', 'JTOOLBAR_REBUILD', false);
  131. $session = JFactory::getSession();
  132. $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent');
  133. $_width = ($fc_screen_width && $fc_screen_width-84 > 940 ) ? ($fc_screen_width-84 > 1400 ? 1400 : $fc_screen_width-84 ) : 940;
  134. $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent');
  135. $_height = ($fc_screen_height && $fc_screen_height-128 > 550 ) ? ($fc_screen_height-128 > 1000 ? 1000 : $fc_screen_height-128 ) : 550;
  136. JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration');
  137. }
  138. $js .= "});";
  139. $document->addScriptDeclaration($js);
  140. //Get data from the model
  141. if (FLEXI_J16GE) {
  142. $rows = $this->get( 'Items');
  143. } else {
  144. $rows = $this->get( 'Data');
  145. }
  146. // Parse configuration for every category
  147. foreach ($rows as $cat) $cat->config = FLEXI_J16GE ? new JRegistry($cat->config) : new JParameter($cat->config);
  148. if (FLEXI_J16GE) {
  149. $this->state = $this->get('State');
  150. // Preprocess the list of items to find ordering divisions.
  151. foreach ($rows as &$item) {
  152. $this->ordering[$item->parent_id][] = $item->id;
  153. }
  154. }
  155. $pagination = $this->get( 'Pagination' );
  156. $categories = & $globalcats;
  157. if (FLEXI_J16GE) {
  158. $lists['copyid'] = flexicontent_cats::buildcatselect($categories, 'copycid', '', 2, 'class="inputbox"', false, true, $actions_allowed=array('core.edit'));
  159. $lists['destid'] = flexicontent_cats::buildcatselect($categories, 'destcid[]', '', false, 'class="inputbox" size="15" multiple="true"', false, true, $actions_allowed=array('core.edit'));
  160. } else if (FLEXI_ACCESS && ($user->gid < 25)) {
  161. if ((FAccess::checkAllContentAccess('com_content','add','users',$user->gmid,'content','all')) || (FAccess::checkAllContentAccess('com_content','edit','users',$user->gmid,'content','all')) || (FAccess::checkAllContentAccess('com_content','editown','users',$user->gmid,'content','all')) || $CanCats) {
  162. $lists['copyid'] = flexicontent_cats::buildcatselect($categories, 'copycid', '', 2, 'class="inputbox"', false, false);
  163. $lists['destid'] = flexicontent_cats::buildcatselect($categories, 'destcid[]', '', false, 'class="inputbox" size="15" multiple="true"', false, false);
  164. } else {
  165. $lists['copyid'] = flexicontent_cats::buildcatselect($categories, 'copycid', '', 2, 'class="inputbox"');
  166. $lists['destid'] = flexicontent_cats::buildcatselect($categories, 'destcid[]', '', false, 'class="inputbox" size="15" multiple="true"');
  167. }
  168. } else {
  169. $lists['copyid'] = flexicontent_cats::buildcatselect($categories, 'copycid', '', 2, 'class="inputbox"');
  170. $lists['destid'] = flexicontent_cats::buildcatselect($categories, 'destcid[]', '', false, 'class="inputbox" size="15" multiple="true"');
  171. }
  172. // *******************
  173. // Create Form Filters
  174. // *******************
  175. // filter by a category (it's subtree will be displayed)
  176. $categories = $globalcats;
  177. $lists['cats'] = flexicontent_cats::buildcatselect($categories, 'filter_cats', $filter_cats, 2, 'class="inputbox" size="1" onchange="this.form.submit();"', $check_published=true, $check_perms=false);
  178. // filter depth level
  179. $options = array();
  180. $options[] = JHtml::_('select.option', '', JText::_( 'FLEXI_SELECT_MAX_DEPTH' ));
  181. for($i=1; $i<=10; $i++) $options[] = JHtml::_('select.option', $i, $i);
  182. $fieldname = $elementid = 'filter_level';
  183. $attribs = ' size="1" class="inputbox" onchange="this.form.submit();" ';
  184. $lists['level'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_level, $elementid, $translate=true );
  185. // filter publication state
  186. if (FLEXI_J16GE)
  187. {
  188. $options = JHtml::_('jgrid.publishedOptions');
  189. array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_PUBLISHED')) );
  190. $fieldname = $elementid = 'filter_state';
  191. $attribs = ' size="1" class="inputbox" onchange="Joomla.submitform()" ';
  192. $lists['state'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_state, $elementid, $translate=true );
  193. } else {
  194. $lists['state'] = JHTML::_('grid.state', $filter_state );
  195. }
  196. if (FLEXI_J16GE)
  197. {
  198. // filter access level
  199. $options = JHtml::_('access.assetgroups');
  200. array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_SELECT_ACCESS')) );
  201. $fieldname = $elementid = 'filter_access';
  202. $attribs = ' size="1" class="inputbox" onchange="Joomla.submitform()" ';
  203. $lists['access'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate=true );
  204. // filter language
  205. $lists['language'] = flexicontent_html::buildlanguageslist('filter_language', 'size="1" class="inputbox" onchange="submitform();"', $filter_language, 2);
  206. } else {
  207. // filter access level
  208. $options = array();
  209. $options[] = JHtml::_('select.option', '', JText::_('FLEXI_SELECT_ACCESS_LEVEL'));
  210. $options[] = JHtml::_('select.option', '0', JText::_('Public'));
  211. $options[] = JHtml::_('select.option', '1', JText::_('Registered'));
  212. $options[] = JHtml::_('select.option', '2', JText::_('SPECIAL'));
  213. $fieldname = $elementid = 'filter_access';
  214. $attribs = ' size="1" class="inputbox" onchange="this.form.submit()" ';
  215. $lists['access'] = JHTML::_('select.genericlist', $options, $fieldname, $attribs, 'value', 'text', $filter_access, $elementid, $translate=true );
  216. }
  217. // filter search word
  218. $lists['search']= $search;
  219. // table ordering
  220. $lists['order_Dir'] = $filter_order_Dir;
  221. $lists['order'] = $filter_order;
  222. $ordering = ($lists['order'] == $order_property) ? $order_property : '';
  223. //assign data to template
  224. $this->assignRef('lists' , $lists);
  225. $this->assignRef('rows' , $rows);
  226. if (FLEXI_J16GE) {
  227. $this->assignRef('permission' , $perms);
  228. $this->assignRef('orderingx' , $ordering);
  229. } else {
  230. $this->assignRef('CanRights' , $CanRights);
  231. $this->assignRef('ordering' , $ordering);
  232. }
  233. $this->assignRef('pagination' , $pagination);
  234. $this->assignRef('user' , $user);
  235. parent::display($tpl);
  236. }
  237. }
  238. ?>