Files
@ f43d1a4680a9
Branch filter:
Location: hot67beta/administrator/components/com_media/models/manager.php
f43d1a4680a9
3.7 KiB
text/x-php
menubar 0 to 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | <?php
/**
* @version $Id: manager.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Joomla
* @subpackage Content
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.application.component.model');
/**
* Weblinks Component Weblink Model
*
* @package Joomla
* @subpackage Content
* @since 1.5
*/
class MediaModelManager extends JModel
{
function getState($property = null)
{
static $set;
if (!$set) {
$folder = JRequest::getVar( 'folder', '', '', 'path' );
$this->setState('folder', $folder);
$parent = str_replace("\\", "/", dirname($folder));
$parent = ($parent == '.') ? null : $parent;
$this->setState('parent', $parent);
$set = true;
}
return parent::getState($property);
}
/**
* Image Manager Popup
*
* @param string $listFolder The image directory to display
* @since 1.5
*/
function getFolderList($base = null)
{
global $mainframe;
// Get some paths from the request
if (empty($base)) {
$base = COM_MEDIA_BASE;
}
// Get the list of folders
jimport('joomla.filesystem.folder');
$folders = JFolder::folders($base, '.', true, true);
// Load appropriate language files
$lang = & JFactory::getLanguage();
$lang->load('', JPATH_ADMINISTRATOR);
$lang->load(JRequest::getCmd( 'option' ), JPATH_ADMINISTRATOR);
$document =& JFactory::getDocument();
$document->setTitle(JText::_('Insert Image'));
// Build the array of select options for the folder list
$options[] = JHTML::_('select.option', "","/");
foreach ($folders as $folder) {
$folder = str_replace(COM_MEDIA_BASE, "", $folder);
$value = substr($folder, 1);
$text = str_replace(DS, "/", $folder);
$options[] = JHTML::_('select.option', $value, $text);
}
// Sort the folder list array
if (is_array($options)) {
sort($options);
}
// Create the drop-down folder select list
$list = JHTML::_('select.genericlist', $options, 'folderlist', "class=\"inputbox\" size=\"1\" onchange=\"ImageManager.setFolder(this.options[this.selectedIndex].value)\" ", 'value', 'text', $base);
return $list;
}
function getFolderTree($base = null)
{
// Get some paths from the request
if (empty($base)) {
$base = COM_MEDIA_BASE;
}
$mediaBase = str_replace(DS, '/', COM_MEDIA_BASE.'/');
// Get the list of folders
jimport('joomla.filesystem.folder');
$folders = JFolder::folders($base, '.', true, true);
$tree = array();
foreach ($folders as $folder)
{
$folder = str_replace(DS, '/', $folder);
$name = substr($folder, strrpos($folder, '/') + 1);
$relative = str_replace($mediaBase, '', $folder);
$absolute = $folder;
$path = explode('/', $relative);
$node = (object) array('name' => $name, 'relative' => $relative, 'absolute' => $absolute);
$tmp = &$tree;
for ($i=0,$n=count($path); $i<$n; $i++)
{
if (!isset($tmp['children'])) {
$tmp['children'] = array();
}
if ($i == $n-1) {
// We need to place the node
$tmp['children'][$relative] = array('data' =>$node, 'children' => array());
break;
}
if (array_key_exists($key = implode('/', array_slice($path, 0, $i+1)), $tmp['children'])) {
$tmp = &$tmp['children'][$key];
}
}
}
$tree['data'] = (object) array('name' => JText::_('Media'), 'relative' => '', 'absolute' => $base);
return $tree;
}
}
|