PageRenderTime 49ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_flexicontent/views/filemanager/view.html.php

http://flexicontent.googlecode.com/
PHP | 221 lines | 110 code | 33 blank | 78 comment | 16 complexity | 945ab8d5be0bed9692daf5c704389559 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 1869 2014-03-12 12:18:40Z 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. // no direct access
  19. defined( '_JEXEC' ) or die( 'Restricted access' );
  20. jimport('joomla.application.component.view');
  21. /**
  22. * HTML View class for the Filemanager View
  23. *
  24. * @package Joomla
  25. * @subpackage FLEXIcontent
  26. * @since 1.0
  27. */
  28. class FlexicontentViewFilemanager extends JViewLegacy
  29. {
  30. /**
  31. * Creates the Filemanagerview
  32. *
  33. * @since 1.0
  34. */
  35. function display( $tpl = null )
  36. {
  37. JHTML::_('behavior.tooltip');
  38. // Load the form validation behavior
  39. JHTML::_('behavior.formvalidation');
  40. //initialise variables
  41. $app = JFactory::getApplication();
  42. $option = JRequest::getVar('option');
  43. $document = JFactory::getDocument();
  44. $db = JFactory::getDBO();
  45. $user = JFactory::getUser();
  46. $params = JComponentHelper::getParams('com_flexicontent');
  47. //$authorparams = flexicontent_db::getUserConfig($user->id);
  48. $langs = FLEXIUtilities::getLanguages('code');
  49. //get vars
  50. $filter_order = $app->getUserStateFromRequest( $option.'.filemanager.filter_order', 'filter_order', 'f.filename', 'cmd' );
  51. $filter_order_Dir = $app->getUserStateFromRequest( $option.'.filemanager.filter_order_Dir', 'filter_order_Dir', '', 'word' );
  52. $filter = $app->getUserStateFromRequest( $option.'.filemanager.filter', 'filter', 1, 'int' );
  53. $filter_lang = $app->getUserStateFromRequest( $option.'.filemanager.filter_lang', 'filter_lang', '', 'string' );
  54. $filter_uploader= $app->getUserStateFromRequest( $option.'.filemanager.filter_uploader','filter_uploader',0, 'int' );
  55. $filter_url = $app->getUserStateFromRequest( $option.'.filemanager.filter_url', 'filter_url', '', 'word' );
  56. $filter_secure = $app->getUserStateFromRequest( $option.'.filemanager.filter_secure', 'filter_secure', '', 'word' );
  57. $filter_ext = $app->getUserStateFromRequest( $option.'.filemanager.filter_ext', 'filter_ext', '', 'alnum' );
  58. $search = $app->getUserStateFromRequest( $option.'.filemanager.search', 'search', '', 'string' );
  59. $filter_item = $app->getUserStateFromRequest( $option.'.filemanager.item_id', 'item_id', 0, 'int' );
  60. $folder_mode = 0;
  61. $search = FLEXI_J16GE ? $db->escape( trim(JString::strtolower( $search ) ) ) : $db->getEscaped( trim(JString::strtolower( $search ) ) );
  62. //add css and submenu to document
  63. $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/flexicontentbackend.css');
  64. if (FLEXI_J30GE) $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/j3x.css');
  65. else if (FLEXI_J16GE) $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/j25.css');
  66. else $document->addStyleSheet(JURI::base().'components/com_flexicontent/assets/css/j15.css');
  67. // Get User's Global Permissions
  68. $perms = FlexicontentHelperPerm::getPerm();
  69. // **************************
  70. // Create Submenu and toolbar
  71. // **************************
  72. FLEXISubmenu('CanFiles');
  73. JToolBarHelper::title( JText::_( 'FLEXI_FILEMANAGER' ), 'files' );
  74. if (FLEXI_J16GE) {
  75. JToolBarHelper::deleteList('Are you sure?', 'filemanager.remove');
  76. } else {
  77. JToolBarHelper::deleteList();
  78. }
  79. if ($perms->CanConfig) {
  80. JToolBarHelper::divider(); JToolBarHelper::spacer();
  81. $session = JFactory::getSession();
  82. $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent');
  83. $_width = ($fc_screen_width && $fc_screen_width-84 > 940 ) ? ($fc_screen_width-84 > 1400 ? 1400 : $fc_screen_width-84 ) : 940;
  84. $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent');
  85. $_height = ($fc_screen_height && $fc_screen_height-128 > 550 ) ? ($fc_screen_height-128 > 1000 ? 1000 : $fc_screen_height-128 ) : 550;
  86. JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration');
  87. }
  88. // ***********************
  89. // Get data from the model
  90. // ***********************
  91. $model = $this->getModel();
  92. if ( !$folder_mode ) {
  93. $rows = $this->get('Data');
  94. } else {
  95. // TODO MORE ...
  96. }
  97. $pagination = $this->get('Pagination');
  98. //$users = $this->get('Users');
  99. // Get item using at least one file (-of- the currently listed files)
  100. /*$items_single = $model->getItemsSingleprop( array('file','minigallery') );
  101. $items_multi = $model->getItemsMultiprop ( $field_props=array('image'=>'originalname'), $value_props=array('image'=>'filename') );
  102. $items = array();
  103. foreach ($items_single as $item_id => $_item) $items[$item_id] = $_item;
  104. foreach ($items_multi as $item_id => $_item) $items[$item_id] = $_item;
  105. ksort($items);*/
  106. $assigned_fields_labels = array('image'=>'image/gallery', 'file'=>'file', 'minigallery'=>'minigallery');
  107. $assigned_fields_icons = array('image'=>'picture_link', 'file'=>'page_link', 'minigallery'=>'film_link');
  108. /*****************
  109. ** BUILD LISTS **
  110. *****************/
  111. $lists = array();
  112. // ** FILE UPLOAD FORM **
  113. // Build languages list
  114. //$allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed',null);
  115. //$allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs);
  116. $allowed_langs = null;
  117. if (FLEXI_FISH || FLEXI_J16GE) {
  118. $lists['file-lang'] = flexicontent_html::buildlanguageslist('file-lang', '', '*', 3, $allowed_langs, $published_only=false);
  119. } else {
  120. $lists['file-lang'] = flexicontent_html::getSiteDefaultLang() . '<input type="hidden" name="file-lang" value="'.flexicontent_html::getSiteDefaultLang().'" />';
  121. }
  122. /*************
  123. ** FILTERS **
  124. *************/
  125. // language filter
  126. $lists['language'] = flexicontent_html::buildlanguageslist('filter_lang', 'class="inputbox" onchange="submitform();" size="1" ', $filter_lang, 2);
  127. // search
  128. $lists['search'] = $search;
  129. //search filter
  130. $filters = array();
  131. $filters[] = JHTML::_('select.option', '1', JText::_( 'FLEXI_FILENAME' ) );
  132. $filters[] = JHTML::_('select.option', '2', JText::_( 'FLEXI_FILE_TITLE' ) );
  133. $lists['filter'] = JHTML::_('select.genericlist', $filters, 'filter', 'size="1" class="inputbox"', 'value', 'text', $filter );
  134. //build url/file filterlist
  135. $url = array();
  136. $url[] = JHTML::_('select.option', '', '- '. JText::_( 'FLEXI_ALL_FILES' ) .' -' );
  137. $url[] = JHTML::_('select.option', 'F', JText::_( 'FLEXI_FILE' ) );
  138. $url[] = JHTML::_('select.option', 'U', JText::_( 'FLEXI_URL' ) );
  139. $lists['url'] = JHTML::_('select.genericlist', $url, 'filter_url', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_url );
  140. //item lists
  141. /*$items_list = array();
  142. $items_list[] = JHTML::_('select.option', '', '- '. JText::_( 'FLEXI_FILTER_BY_ITEM' ) .' -' );
  143. foreach($items as $item) {
  144. $items_list[] = JHTML::_('select.option', $item->id, JText::_( $item->title ) . ' (#' . $item->id . ')' );
  145. }
  146. $lists['item_id'] = JHTML::_('select.genericlist', $items_list, 'item_id', 'size="1" class="inputbox" onchange="submitform( );"', 'value', 'text', $filter_item );*/
  147. $lists['item_id'] = '<input type="text" name="item_id" size="1" class="inputbox" onchange="submitform( );" value="'.$filter_item.'" />';
  148. //build secure/media filterlist
  149. $secure = array();
  150. $secure[] = JHTML::_('select.option', '', '- '. JText::_( 'FLEXI_ALL_DIRECTORIES' ) .' -' );
  151. $secure[] = JHTML::_('select.option', 'S', JText::_( 'FLEXI_SECURE_DIR' ) );
  152. $secure[] = JHTML::_('select.option', 'M', JText::_( 'FLEXI_MEDIA_DIR' ) );
  153. $lists['secure'] = JHTML::_('select.genericlist', $secure, 'filter_secure', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_secure );
  154. //build ext filterlist
  155. $lists['ext'] = flexicontent_html::buildfilesextlist('filter_ext', 'class="inputbox" size="1" onchange="submitform( );"', $filter_ext);
  156. //build uploader filterlist
  157. $lists['uploader'] = flexicontent_html::builduploaderlist('filter_uploader', 'class="inputbox" size="1" onchange="submitform( );"', $filter_uploader);
  158. // table ordering
  159. $lists['order_Dir'] = $filter_order_Dir;
  160. $lists['order'] = $filter_order;
  161. // uploadstuff
  162. if ($params->get('enable_flash', 1)) {
  163. JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ window.location.reload(); }') );
  164. }
  165. jimport('joomla.client.helper');
  166. $ftp = !JClientHelper::hasCredentials('ftp');
  167. //assign data to template
  168. $this->assignRef('params' , $params);
  169. $this->assign('require_ftp' , $ftp);
  170. //Load pane behavior
  171. if (!FLEXI_J16GE) {
  172. jimport('joomla.html.pane');
  173. $pane = JPane::getInstance('Tabs');
  174. $this->assignRef('pane' , $pane);
  175. }
  176. $this->assignRef('lists' , $lists);
  177. $this->assignRef('rows' , $rows);
  178. $this->assignRef('pagination' , $pagination);
  179. $this->assignRef('CanFiles' , $perms->CanFiles);
  180. $this->assignRef('CanUpload' , $perms->CanUpload);
  181. $this->assignRef('CanViewAllFiles' , $perms->CanViewAllFiles);
  182. $this->assignRef('assigned_fields_labels' , $assigned_fields_labels);
  183. $this->assignRef('assigned_fields_icons' , $assigned_fields_icons);
  184. $this->assignRef('langs', $langs);
  185. parent::display($tpl);
  186. }
  187. }
  188. ?>