Source for file GBFilePicker.module.php
Documentation is available at GBFilePicker.module.php
#-------------------------------------------------------------------------------
# Module : GBFilePicker (c) 2010-2012 by Georg Busch (georg.busch@gmx.net)
# a file picker tool for CMS Made Simple
# The projects homepage is: dev.cmsmadesimple.org/projects/gbfilepicker
# CMS Made Simple is (c) 2004-2012 by Ted Kulp
# The projects homepage is: cmsmadesimple.org
# File : GBFilePicker.module.php
# Purpose: main module class
#-------------------------------------------------------------------------------
* Class definition and methods for GBFilePicker
* Main class of the GBFilePicker Module
* @author Georg Busch (NaN)
* @copyright 2010 Georg Busch (NaN)
protected $_pp =
'<div style="float:right"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="FA2D3FPLSTAKJ" />
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online." />
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1" />
global $CMS_ADMIN_PAGE, $config;
if(isset
($CMS_ADMIN_PAGE) &&
$CMS_ADMIN_PAGE ==
1)
if(!file_exists(cms_join_path($config['previews_path'] , 'GBFilePickerThumbs')))
@mkdir(cms_join_path($config['previews_path'] , 'GBFilePickerThumbs'), 0755);
$userops =
& cmsms()->GetUserOperations();
$this->_isAdmin =
$userops->UserInGroup(get_userid(false),1);
if($user =
& $userops->LoadUserById(get_userid(false)))
$this->_username =
$user->username;
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetName
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetFriendlyName
function GetFriendlyName()
return $this->Lang('GBFilePicker');
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetVersion
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetHelp
$path =
dirname(__FILE__
) .
DIRECTORY_SEPARATOR .
'doc' .
DIRECTORY_SEPARATOR;
if(file_exists($path .
'help_' .
$this->curlang .
'.html'))
return $this->_pp.
$this->lang('help');
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetAuthor
return 'Georg Busch (NaN)';
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetChangeLog
$path =
dirname(__FILE__
) .
DIRECTORY_SEPARATOR .
'doc' .
DIRECTORY_SEPARATOR;
if(file_exists($path .
'changelog_' .
$this->curlang .
'.html'))
return $this->_pp.
file_get_contents($path .
'changelog_' .
$this->curlang .
'.html');
return $this->_pp.
$this->lang('changelog');
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#HasAdmin
return $this->CheckPermission('Manage GBFilePicker');
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetAdminSection
function GetAdminSection()
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetAdminDescription
function GetAdminDescription()
return $this->lang('admindescription');
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#VisibleToAdminUser
function VisibleToAdminUser()
return $this->CheckPermission('Manage GBFilePicker');
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#MinimumCMSVersion
function MinimumCMSVersion()
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#MaximumCMSVersion
function MaximumCMSVersion()
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#InstallPostMessage
function InstallPostMessage()
return $this->Lang('post_install', $this->GetVersion());
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#UninstallPostMessage
function UninstallPostMessage()
return $this->Lang('post_uninstall', $this->GetVersion());
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#UninstallPreMessage
function UninstallPreMessage()
return $this->Lang('confirm_uninstall');
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#HandlesEvents
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#IsPluginModule
function IsPluginModule()
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#DoAction
function DoAction($action, $id, $params, $returnid =
'')
parent::DoAction($action, $id, $params, $returnid);
unset
($params['action']);
parent::DoAction('fileBrowser', $id, $params, $returnid);
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#SetParameters
* @todo create list of allowed parameters!
#$this->RestrictUnknownParams();
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#HasCapability
function HasCapability($capability,$params =
array())
case 'content_attributes':
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetContentBlockInput
function GetContentBlockInput($blockname,$value,$params,$adding =
false)
if($this->CheckPermission('Use GBFilePicker'))
if(isset
($params['smarty']) &&
$this->IsTrue($params['smarty']))
foreach($params as $k=>
$v)
$params[$k] =
$this->DoSmarty($v);
* @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetHeaderHTML
$this->smarty->assign('gbfp_reload_dir_text', $this->lang('reload_dir'));
$this->smarty->assign('gbfp_clear_cache_text', $this->lang('clear_cache'));
$this->smarty->assign('gbfp_close_text', $this->lang('close'));
$this->smarty->assign('thumb_width', get_site_preference('thumbnail_width',96));
$this->smarty->assign('thumb_height', get_site_preference('thumbnail_height',96));
$this->smarty->assign('gbfp_title', $this->Lang('browser_title'));
$this->smarty->assign('gbfp_id', '');
return $this->ProcessTemplate('themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_admin_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'header.tpl');
#-------------------------------------------------------------------------------
# Not part of the CMSms module API
#-------------------------------------------------------------------------------
* Creates the filepicker input.
* @param object &$module - the module instance that calls the filepicker (this is only needed if you want to process own templates; pass the filepicker instance itself or leave it empty if you don't need this)
* @param string $id - the id of the moduleinstance that creates the filepicker input
* @param string $name - the name of the input field
* @param string $value - the preselected value
* @param array $params - the input params (param_name => param_value):<br /><ul>
* <li>(string) 'feu_access' => a csv of group ids of the frontend users module,</li>
* <li>(boolean) 'restrict_users_diraccess' => set to true if user may only access a dir of his username (notice: this has no effect if you are admin; in frontend this will always be true),</li>
* <li>(string) 'header_template' => specify wich template should be used to create the html output that will be placed in the <head> section (default is header.tpl of the selected theme of GBFilePickers preferences),</li>
* <li>(string) 'input_template' => specify wich template should be used to create the input elements (default is input.tpl of the selected theme of GBFilePickers preferences),</li>
* <li>(string) 'upload_template' => specify wich template should be used to create the upload form of mode dropdown (default is upload.tpl of the selected theme of GBFilePickers preferences),</li>
* <li>(string) 'filebrowser_template' => specify wich template should be used to create the filebrowser output (default is fileBrowser.tpl of the selected theme of GBFilePickers preferences),</li>
* <li>(string) 'prompt' => the prompt of the input field,</li>
* <li>(string) 'media_type' => the media type (at the moment only image / file are supported),</li>
* <li>(mixed) 'file_extensions' => an array or a csv of allowed file extensions,</li>
* <li>(mixed) 'exclude_prefix' => an array or a csv of file prefixes that will be excluded,</li>
* <li>(mixed) 'exclude_sufix' => an array or a csv of file suffixes that will be excluded,</li>
* <li>(mixed) 'include_prefix' => an array or a csv of file prefixes that will be included,</li>
* <li>(mixed) 'include_sufix' => an array or a csv of file suffixes that will be included,</li>
* <li>(boolean) 'show_subdirs' => set to true if user may browse subdirs (notice: this has no effect if you are admin)</li>
* <li>(string) 'mode' => dropdown/browser,</li>
* <li>(boolean) 'allow_none' => set to false if the option "none" should not be shown (notice: this has no effect if you are admin),</li>
* <li>(boolean) 'lock_input' => set to false if user may enter the path in the inputfield ('mode'=>'browser', 'media_type' => 'file') (notice: this has no effect if you are admin),</li>
* <li>(boolean) 'upload' => set to true if user may upload files (notice: this has no effect if you are admin or have permission to modify files),</li>
* <li>(boolean) 'delete' => set to true if user may delete files/dirs (notice: this has no effect if you are admin or have permission to modify files),</li>
* <li>(boolean) 'create_dirs' => set to true if user may create dirs (notice: this has no effect if you are admin or have permission to modify files),</li>
* <li>(string) 'add_txt' => any additional text that will be added to the html input when tag is rendered,</li>
* <li>(integer) 'size' => the size of the textinput ('mode' => 'browser', 'media_type' => 'file' only),</li>
* <li>(integer) 'maxlength' => the max length of the textinput ('mode' => 'browser', 'media_type' => 'file' only),</li>
* <li>(integer) 'scaling_width' => the default width of images when allow_scaling is true,</li>
* <li>(integer) 'scaling_height' => the default height of images when allow_scaling is true,</li>
* <li>(boolean) 'show_thumbfiles' => set to true if thumbs should also be shown as regular files,</li>
* <li>(boolean) 'allow_scaling' => set to false if user may not scale the images on upload,</li>
* <li>(boolean) 'create_thumbs' => set to false if the module may not create thumbs for the input,</li>
* <li>(boolean) 'allow_upscaling' => set to true if user may enlarge the images</li>
* <li>(boolean) 'force_scaling' => set to true to force resizing of image to a given size if user may not resize images</li>
* <li>(boolean) 'keep_aspectratio' => set to false to change aspect ratio to that one of the scaling size on resizing images</li></ul>
* @param integer $returnid - the page id to return to and to print out the result after module has finished its task;<br />usually this has nothing to say but is required for frontend usage (must be an existing content id)
* @return string - the HTML output of the filepicker
public function CreateFilePickerInput(&$module, $id, $name, $value =
'', $params =
array(), $returnid =
'')
if(class_exists('cms_utils') &&
cms_utils::get_current_pageid() &&
$returnid ==
'')
$returnid =
cms_utils::get_current_pageid();
if(!$params =
& $this->SetInputParams($module, $id, $name, $params))
$value =
$this->CleanUrl($value, false);
$module->smarty->assign('thumb_width', get_site_preference('thumbnail_width',96));
$module->smarty->assign('thumb_height', get_site_preference('thumbnail_height',96));
if($params['media_type'] ==
'image')
$module->smarty->assign('gbfp_thumb_width', $thumbnail_size[0]);
$module->smarty->assign('gbfp_thumb_height', $thumbnail_size[1]);
$module->smarty->assign('gbfp_thumburl', $this->GetThumbnail($value, $params['create_thumbs'],true));
$module->smarty->assign('gbfp_value', $value);
$module->smarty->assign('gbfp_loaded', $this->_loaded);
foreach($headers_list as $header)
$filebrowser_url =
str_replace('&','&',$this->CreateLink(($id ==
'' ?
'm1_' :
$id), 'fileBrowser', $returnid, '',array('name' =>
$name,'dir'=>
($this->_isAdmin?
$params['dir']:
'')),'', true));
if($params['mode'] ==
'dropdown')
$params['exclude_prefix'],
$params['include_prefix'],
$params['exclude_sufix'],
$params['include_sufix'],
$params['file_extensions'],
$upload_url =
str_replace('&','&',$this->CreateLink(($id ==
'' ?
'm1_' :
$id), 'upload', $returnid, $this->lang('upload'),array('name' =>
$name,'dir'=>
($this->_isAdmin?
$params['dir']:
'')),'', true));
$upload_link =
$this->CreateLink(($id ==
'' ?
'm1_' :
$id), 'upload', $returnid, $this->lang('upload'), array('name' =>
$name), '', false, false, 'id="'.
$id.
$name.
'_GBFP_upload" class="GBFP_link GBFP_upload"');
$reload_url =
str_replace('&','&',$this->CreateLink(($id ==
'' ?
'm1_' :
$id),'reloadDropdown',$returnid,$this->lang('reload_dropdown'),array('name' =>
$name,'dir'=>
($this->_isAdmin?
$params['dir']:
'')),'',true));
$reload_link =
$this->CreateLink(($id ==
'' ?
'm1_' :
$id), 'reloadDropdown', $returnid, $this->lang('reload_dropdown'), array('name' =>
$name), '', false, false, 'id="'.
$id.
$name.
'_GBFP_reload_dropdown" class="GBFP_link GBFP_reload_dropdown"');
else if($params['mode'] ==
'browser')
if($params['media_type'] ==
'image')
$input =
'<input id="'.
$id.
$name.
'" type="hidden" name="'.
$id.
$name.
'" value="' .
$value .
'" />';
else if($params['media_type'] ==
'file')
$input =
'<input id="'.
$id.
$name.
'" class="GBFP_input GBFP_textinput" type="text"' .
($params['lock_input']?
' disabled="disabled"':
'') .
($params['add_txt'] !=
''?
' '.
$params['add_txt'].
' ':
'') .
($params['size'] !=
''?
' size="' .
$params['size'] .
'"':
'') .
($params['maxlength'] !=
''?
' maxlength="' .
$params['maxlength'] .
'"':
'') .
' name="' .
$id.
$name .
'" value="' .
$value .
'" />';
$browse_url =
str_replace('&','&',$this->CreateLink(($id ==
'' ?
'm1_' :
$id), 'fileBrowser', $returnid, $this->lang('browse_'.
$params['media_type']),array('name' =>
$name,'dir'=>
($this->_isAdmin?
$params['dir']:
'')),'', true));
$browse_link =
$this->CreateLink(($id ==
'' ?
'm1_' :
$id), 'fileBrowser', $returnid, $this->lang('browse_'.
$params['media_type']), array('name' =>
$name,'dir'=>
($this->_isAdmin?
$params['dir']:
'')), '', false, false, 'id="'.
$id.
$name.
'_GBFP_browse" class="GBFP_link GBFP_browse"');
if($params['allow_none'])
$clear_link =
'<a href="#" onclick="document.getElementById(\''.
$id.
$name.
'\').value = \'\';return false;" id="'.
$id.
$name.
'_GBFP_clear" class="GBFP_link GBFP_clear">'.
$this->lang('none').
'</a>';
debug_buffer($params,'GBFilePicker input params; input = "'.
$id.
$name.
'"; function CreateFilePickerInput() FINAL');
$module->smarty->assign('gbfp_filebrowser_url', $filebrowser_url);
$module->smarty->assign('gbfp_input', $input);
$module->smarty->assign('gbfp_upload_url', $upload_url);
$module->smarty->assign('gbfp_upload_link', $upload_link);
$module->smarty->assign('gbfp_reload_dropdown_url', $reload_url);
$module->smarty->assign('gbfp_reload_dropdown_link', $reload_link);
$module->smarty->assign('gbfp_browse_url', $browse_url);
$module->smarty->assign('gbfp_browse_link', $browse_link);
$module->smarty->assign('gbfp_clear_link', $clear_link);
$module->smarty->assign('gbfp_name', $name);
$module->smarty->assign('gbfp_inputid', $id.
$name);
$module->smarty->assign('gbfp_title', $this->Lang('browser_title'));
foreach($params as $k =>
$v)
$module->smarty->assign('gbfp_'.
$k,$v);
$module->smarty->assign('gbfp_id', ($id ==
'' ?
'm1_' :
$id));
$module->smarty->assign('gbfp_reload_dir_text', $this->lang('reload_dir'));
$module->smarty->assign('gbfp_clear_cache_text', $this->lang('clear_cache'));
$module->smarty->assign('gbfp_close_text', $this->lang('close'));
if(endswith($params['input_template'],'.tpl'))
return $module->ProcessTemplate($params['input_template']);
return $module->ProcessTemplateFromDatabase($params['input_template']);
private function &SetInputParams(&$module, $id, $name, $params =
array())
global $CMS_ADMIN_PAGE, $config;
$_SESSION['GPFP_' .
($id ==
'' ?
'm1_' :
$id).
$name] =
array();
if(!$session_params =
& $this->GetInputParams($id, $name))
if(isset
($params['prompt']))
$session_params['prompt'] =
$params['prompt'];
if(isset
($params['header_template']))
$session_params['header_template'] =
$params['header_template'];
if(isset
($params['input_template']))
$session_params['input_template'] =
$params['input_template'];
if(isset
($params['upload_template']))
$session_params['upload_template'] =
$params['upload_template'];
if(isset
($params['filebrowser_template']))
$session_params['filebrowser_template'] =
$params['filebrowser_template'];
$session_params['module'] =
$module->GetName();
if(isset
($params['feu_access']))
$session_params['feu_access'] =
$this->CleanArray(explode(',',$params['feu_access']));
$session_params['feu_access'] =
$this->CleanArray($params['feu_access']);
if(isset
($params['restrict_users_diraccess']) &&
$this->IsFalse($params['restrict_users_diraccess']))
$session_params['restrict_users_diraccess'] =
false;
$dir =
$session_params['start_dir'];
if(isset
($params['dir']) &&
$params['dir'] !=
'')
$dir =
$this->CleanUrl($params['dir'],false);
$session_params['start_dir'] =
$dir;
if(isset
($CMS_ADMIN_PAGE) &&
$CMS_ADMIN_PAGE ==
1)
if(!$this->CheckPermission('Use GBFilePicker'))
$username =
$this->_username;
if( !$feusers =
& $this->GetModuleInstance('FrontEndUsers' ) )
if(!$userid =
$feusers->LoggedInId())
if(!$groups =
$feusers->GetMemberGroupsArray($userid))
foreach($groups as $_group)
if(in_array($_group['groupid'],$session_params['feu_access']))
$username =
$feusers->GetUserName($userid);
$params['media_type'] =
'image';
$params['restrict_users_diraccess'] =
true;
if(!$this->_isAdmin &&
$session_params['restrict_users_diraccess'])
$session_params['start_dir'] .=
'/' .
$dir;
$session_params['start_dir'] =
$dir;
$_dir =
$this->CleanPath($session_params['start_dir']);
if(isset
($params['media_type']))
$session_params['media_type'] =
strtolower($params['media_type']);
if($session_params['media_type'] ==
'file')
$session_params['file_extensions'] =
array();
if(isset
($params['file_extensions']) &&
$params['file_extensions'] !=
'')
if($session_params['media_type'] ==
'image')
$_file_ext =
$session_params['file_extensions'];
$session_params['file_extensions'] =
$_file_ext;
if(isset
($params['exclude_prefix']))
$session_params['exclude_prefix'] =
trim($params['exclude_prefix']);
if(isset
($params['exclude_sufix']))
$session_params['exclude_sufix'] =
trim($params['exclude_sufix']);
if(isset
($params['include_prefix']))
$session_params['include_prefix'] =
trim($params['include_prefix']);
if(isset
($params['include_sufix']))
$session_params['include_sufix'] =
trim($params['include_sufix']);
if(isset
($params['show_subdirs']) &&
$this->IsTrue($params['show_subdirs']))
$session_params['show_subdirs'] =
true;
else if(isset
($params['show_subdirs']) &&
$this->IsFalse($params['show_subdirs']) &&
!$this->_isAdmin)
$session_params['show_subdirs'] =
false;
if(isset
($params['mode']))
$session_params['mode'] =
strtolower($params['mode']);
if(isset
($params['allow_none']) &&
$this->IsFalse($params['allow_none']) &&
!$this->_isAdmin)
$session_params['allow_none'] =
false;
if(isset
($params['lock_input']) &&
$this->IsFalse($params['lock_input']))
$session_params['lock_input'] =
false;
else if(isset
($params['lock_input']) &&
$this->IsTrue($params['lock_input']) &&
!$this->_isAdmin)
$session_params['lock_input'] =
true;
if(isset
($params['upload']) &&
$this->IsTrue($params['upload']) &&
$this->GetPreference('show_filemanagement'))
$session_params['upload'] =
true;
else if(isset
($params['upload']) &&
$this->IsFalse($params['upload']) &&
!$this->_isAdmin)
$session_params['upload'] =
false;
if(isset
($params['delete']) &&
$this->IsTrue($params['delete']) &&
$this->GetPreference('show_filemanagement'))
$session_params['delete'] =
true;
else if(isset
($params['delete']) &&
$this->IsFalse($params['delete']) &&
!$this->_isAdmin)
$session_params['delete'] =
false;
if(isset
($params['create_dirs']) &&
$this->IsTrue($params['create_dirs']) &&
$this->GetPreference('show_filemanagement'))
$session_params['create_dirs'] =
true;
else if(isset
($params['create_dirs']) &&
$this->IsFalse($params['create_dirs']) &&
!$this->_isAdmin)
$session_params['create_dirs'] =
false;
if(isset
($params['add_txt']))
$session_params['add_txt'] =
trim($params['add_txt']);
if(isset
($params['size']))
$session_params['size'] =
intval($params['size']);
if(isset
($params['maxlength']))
$session_params['maxlength'] =
intval($params['maxlength']);
if(isset
($params['scaling_width']))
$session_params['scaling_width'] =
intval($params['scaling_width']);
if(isset
($params['scaling_height']))
$session_params['scaling_height'] =
intval($params['scaling_height']);
if(isset
($params['show_thumbfiles']))
$session_params['show_thumbfiles'] =
intval($params['show_thumbfiles']);
if(isset
($params['allow_scaling']))
$session_params['allow_scaling'] =
intval($params['allow_scaling']);
if(isset
($params['create_thumbs']))
$session_params['create_thumbs'] =
intval($params['create_thumbs']);
if(isset
($params['allow_upscaling']))
$session_params['allow_upscaling'] =
intval($params['allow_upscaling']);
if(isset
($params['force_scaling']))
$session_params['force_scaling'] =
intval($params['force_scaling']);
if(isset
($params['keep_aspect_ratio']))
$session_params['keep_aspect_ratio'] =
intval($params['keep_aspect_ratio']);
if($session_params['mode'] ==
'dropdown')
$session_params['dir'] =
$dir;
$session_params['start_dir'] =
$dir;
$_SESSION['GBFP_id_'.
$name] =
($id ==
'' ?
'm1_' :
$id);
$_SESSION['GPFP_' .
($id ==
'' ?
'm1_' :
$id).
$name] =
$session_params;
#debug_buffer($session_params,'GBFilePicker session vars; input = "'.$id.$name.'"; function SetInputParams()');
$session_params['dir'] =
$dir;
protected function &GetInputParams($id, $name)
'module' =>
$this->GetName(),
'restrict_users_diraccess' =>
intval($this->GetPreference('restrict_users_diraccess', false)),
'file_extensions' =>
array('jpg','jpeg','gif','png'),
'show_subdirs' =>
intval($this->_isAdmin),
'lock_input' =>
intval(!$this->_isAdmin),
'upload' =>
intval($this->_isAdmin ||
($this->GetPreference('show_filemanagement', false) &&
$this->CheckPermission('Modify Files'))),
'delete' =>
intval($this->_isAdmin ||
($this->GetPreference('show_filemanagement', false) &&
$this->CheckPermission('Modify Files'))),
'create_dirs' =>
intval($this->_isAdmin ||
($this->GetPreference('show_filemanagement', false) &&
$this->CheckPermission('Modify Files'))),
'scaling_width' =>
intval($this->GetPreference('scaling_width', '')),
'scaling_height' =>
intval($this->GetPreference('scaling_height', '')),
'show_thumbfiles' =>
intval($this->GetPreference('show_thumbfiles', false)),
'allow_scaling' =>
intval($this->GetPreference('allow_scaling', false) ||
$this->_isAdmin),
'create_thumbs' =>
intval($this->GetPreference('create_thumbs', true)),
'allow_upscaling' =>
intval($this->GetPreference('allow_upscaling', false) ||
$this->_isAdmin),
'force_scaling' =>
intval($this->GetPreference('force_scaling',false)),
'keep_aspect_ratio' =>
intval($this->GetPreference('keep_aspectratio',true)));
global $CMS_ADMIN_PAGE, $config;
if(isset
($CMS_ADMIN_PAGE) &&
$CMS_ADMIN_PAGE ==
1)
if(!$this->CheckPermission('Use GBFilePicker'))
if(!$this->_isAdmin &&
$params['restrict_users_diraccess'])
$params['start_dir'] =
$this->_username;
$params['input_template'] =
'themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_admin_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'input.tpl';
$params['filebrowser_template'] =
'themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_admin_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'fileBrowser.tpl';
$params['upload_template'] =
'themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_admin_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'upload.tpl';
$params['header_template'] =
'themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_admin_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'header.tpl';
if( !$feusers =
& $this->GetModuleInstance('FrontEndUsers' ) )
if(!$userid =
$feusers->LoggedInId())
if(!$groups =
$feusers->GetMemberGroupsArray($userid))
foreach($groups as $_group)
if(in_array($_group['groupid'],$params['feu_access']))
$params['input_template'] =
'themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_frontend_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'input.tpl';
$params['filebrowser_template'] =
'themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_frontend_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'fileBrowser.tpl';
$params['upload_template'] =
'themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_frontend_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'upload.tpl';
$params['header_template'] =
'themes'.
DIRECTORY_SEPARATOR.
$this->GetPreference('default_frontend_theme','Default (AJAX)').
DIRECTORY_SEPARATOR.
'header.tpl';
$params['restrict_users_diraccess'] =
true;
$params['start_dir'] =
$feusers->GetPreference('image_destination_path', 'feusers') .
'/' .
$feusers->GetUserName($userid);
#debug_buffer($params,'GBFilePicker input params; input = "'.$id.$name.'"; function GetInputParams()');
if(isset
($_SESSION['GPFP_' .
($id ==
'' ?
'm1_' :
$id).
$name]))
$params =
array_merge($params, $_SESSION['GPFP_' .
($id ==
'' ?
'm1_' :
$id).
$name]);
* Gets the file type of a file.
* @param string $file - the path to a file
* @param string $use_mime - set to true to detect file type by mime type
* @return string - the mime-type or file extension
if(isset
($fileinfo['extension']))
* Create a dropdown form element containing a list of files that match certain conditions
* @param string $id - the id of the moduleinstance that creates the filepicker input
* @param string $name - the name of the input field
* @param string $dir - the directory to list the files of (may be relative to uploads dir or absolute path)
* @param string $selected - the preselected value
* @param array|string$excl_prefix - fileprefixes to exclude (array('foo','bar',...) or csv)
* @param array|string$incl_prefix - fileprefixes to include (array('foo','bar',...) or csv)
* @param array|string$excl_sufix - filesufixes to exclude (array('foo','bar',...) or csv)
* @param array|string$incl_sufix - filesufixes to include (array('foo','bar',...) or csv)
* @param array|string$file_ext - filesufixes to include (array('foo','bar',...) or csv)
* @param string $media_type - file or image
* @param boolean $allow_none - set to false to hide the option 'none'
* @param string $add_txt - any additional text that will be added to the html input when tag is rendered
* @return string - the HTML output of a select element with options
public function CreateFileDropdown($id, $name, $dir =
'', $selected =
'', $excl_prefix =
'', $incl_prefix =
'',
$excl_sufix =
'', $incl_sufix =
'', $file_ext =
'', $media_type =
'', $allow_none =
true, $add_txt =
'')
if(empty($files) &&
!$allow_none)
return $this->lang('dir_empty');
$dropdown =
'<select class="GBFP_input GBFP_dropdown GBFP_'.
$media_type.
'" name="'.
$id.
$name.
'" id="'.
$id.
$name.
'"';
$dropdown .=
' '.
$add_txt;
$dropdown .=
'<option value=""';
$dropdown .=
' selected="selected"';
$dropdown .=
' thumbnail="">--- '.
lang('none').
' ---</option>';
foreach( $files as $file )
$dropdown .=
'<option value="'.
$file->relurl.
'"';
if($file->relurl ==
$selected)
$dropdown .=
' selected="selected"';
if($file->is_image &&
$media_type ==
'image')
$dropdown .=
' thumbnail="'.
(isset
($file->thumburl) &&
$file->thumburl!=
''?
$file->thumburl:
$file->fullurl).
'"';
$dropdown .=
'>'.
$file->basename.
'</option>';
$dropdown .=
"</select>";
* Return an array containing a list of files in a directory related to a certain input.<br />
* Performs a non recursive search.
* @param string $id - the id of the moduleinstance that creates the filepicker input
* @param string $name - the name of the input field
* @param string $dir - the directory to list the files of (may be relative to uploads dir or absolute path)
$params =
& $this->GetInputParams($id, $name);
return $this->GetFiles($dir, $params['exclude_prefix'],
$params['include_prefix'], $params['exclude_sufix'],
$params['include_sufix'], $params['file_extensions'],
$params['media_type'], ($params['mode'] ==
'dropdown' ?
true :
!$params['show_subdirs']), $params['show_thumbfiles'],
$params['create_thumbs']);
* Return an array containing a list of files in a directory.<br />
* Performs a non recursive search.
* @param string $dir - the directory to list the files of (may be relative to uploads dir or absolute path)
* @param array|string$excl_prefix - fileprefixes to exclude (array('foo','bar',...) or csv)
* @param array|string$incl_prefix - fileprefixes to include (array('foo','bar',...) or csv)
* @param array|string$excl_sufix - filesufixes to exclude (array('foo','bar',...) or csv)
* @param array|string$incl_sufix - filesufixes to include (array('foo','bar',...) or csv)
* @param array|string$file_ext - filesufixes to include (array('foo','bar',...) or csv)
* @param string $media_type - file or image
* @param boolean $excl_dirs - set to true to exclude directories
* @param boolean $show_thumbfiles
* @param boolean $create_thumbs = true
public function &GetFiles($dir =
'', $excl_prefix =
'', $incl_prefix =
'', $excl_sufix =
'',
$incl_sufix =
'', $file_ext =
'', $media_type =
'image', $excl_dirs =
false, $show_thumbfiles =
false, $create_thumbs =
true)
$_file_ext =
array('jpg','jpeg','gif','png');
if($media_type ==
'image')
while ($entry =
$d->read())
if ($entry[0] ==
'.' ||
(is_dir($dir.
$entry) &&
$excl_dirs))
$file->is_dir =
is_dir($dir.
$entry);
foreach($fileinfo as $k=>
$v)
foreach($excl_prefix as $str)
if(startswith($file->filename,$str))
foreach($incl_prefix as $str)
if(startswith($str,'thumb_'))
if(!startswith($file->filename,$str))
foreach($excl_sufix as $str)
if(endswith($file->filename,$str))
foreach($incl_sufix as $str)
if(!endswith($file->filename,$str))
if(startswith($entry,'thumb_') &&
!$show_thumbfiles &&
!$incl_thumbs)
$filetype =
$this->GetFileType($dir.
$entry,$this->GetPreference('use_mimetype',false));
if (!$file->is_dir &&
$media_type ==
'image' &&
!in_array(str_replace('image/','',$filetype),$file_ext))
else if(!$file->is_dir &&
$media_type !=
'image' &&
!in_array($file->extension,$file_ext) &&
!empty($file_ext))
$file->fullurl =
$url.
$entry;
$file->relurl =
trim(str_replace($config['uploads_url'],'',$file->fullurl),'/');
$file->id =
munge_string_to_url($file->relurl);
$file->last_modifed =
filemtime($dir.
$entry);
if (!$file->is_dir &&
in_array(str_replace('image/','',$filetype),array('jpg','jpeg','gif','png')))
$file->filetype =
$filetype;
if ($show_thumbfiles ||
$incl_thumbs)
$file->thumbnail =
$this->GetThumbnail($dir.
$entry, $create_thumbs);
$file->thumburl =
$this->GetThumbnail($dir.
$entry, $create_thumbs,true);
$file->imgsize =
$imgsize[0] .
' x ' .
$imgsize[1];
$file->imgsize =
' ';
$info =
@stat($dir.
$entry);
$file->filesize =
$info['size'];
$file->fileicon =
$this->GetFileIcon($file->extension,false,true);
usort($files, array($this, 'SortFiles'));
* Replaces all multiple DIRECTORY_SEPARATOR, dots and (multiple) slashes with one single DIRECTORY_SEPARATOR to make a clean secure path parameter
* @param string $path - the path to clean
* @param string $full_path - true to prepend uploads path on return, false to return only the cleaned $path
* @return string - the clean path
public function CleanPath($path, $full_path =
true)
$path =
trim(str_replace(array($config['uploads_path'],$config['uploads_url']), '', $path),'/'.
DIRECTORY_SEPARATOR);
$path =
preg_replace('/[\\/]+/',DIRECTORY_SEPARATOR, '/' .
$path .
'/');
$path =
$config['uploads_path'] .
$path;
return trim(preg_replace('/[\\/]+/',DIRECTORY_SEPARATOR, $path) , DIRECTORY_SEPARATOR);
* Replaces all multiple slashes, dots and (multiple) backslashes with one single slash to make a clean secure url parameter
* @param string $url - the url to clean
* @param string $full_url - true to prepend uploads url on return, false to return only the cleaned $url
* @return string - the clean url
public function CleanURL($url, $full_url =
true)
$url =
trim(str_replace(array($config['uploads_path'],$config['uploads_url']), '', $url),'/'.
DIRECTORY_SEPARATOR);
$url =
$config['uploads_url'] .
$url;
* Returns the thumbnail of a given image file.
* @param string $path - the path of the file to create a thumbnail of (can be relative to the uploads dir or absolute)
* @param string $create_thumb - set to false if thumbnail may not be created if not exists
* @param string $urlonly - set to true to get only the url to the thumbnail
* @return string - HTML img element or url
public function GetThumbnail($path, $create_thumb =
true, $urlonly =
false)
$url =
$this->CleanUrl(str_replace($filename,'',$path));
$thumbnail=
cms_join_path($config['previews_path'] , 'GBFilePickerThumbs' , 'thumb_' .
munge_string_to_url(str_replace($config['uploads_path'], '', $path)) .
'_' .
$filename);
$this->HandleFileResizing($path .
$filename, $thumbnail, get_site_preference('thumbnail_width', 96), get_site_preference('thumbnail_height',96),true,false,60,false);
$thumbUrl =
$config['root_url'] .
'/' .
$this->CleanUrl(str_replace($config['root_path'], '', $thumbnail), false);
$thumbUrl =
$url .
$filename;
return '<img class="GBFP_thumbnail"' .
(isset
($thumbnail_size) &&
is_array($thumbnail_size) ?
' width="'.
$thumbnail_size[0].
'" height="'.
$thumbnail_size[1].
'"' :
'') .
' id="' .
munge_string_to_url($filename) .
'_GBFP_thumbnail" src="' .
$thumbUrl .
'" alt="' .
str_replace($config['uploads_url'],'',$url) .
$filename .
'" title="' .
str_replace($config['uploads_url'],'',$url) .
$filename .
'" />';
* Creates the thumbnail of a given image file.
* @param string $path - the path of the file to create a thumbnail from (can be relative to the uploads dir or absolute)
* @return string - absolute path of the thumbnail
$thumbnail=
cms_join_path($config['previews_path'] , 'GBFilePickerThumbs' , 'thumb_' .
munge_string_to_url(str_replace($config['uploads_path'], '', $path)) .
'_' .
$filename);
if(!$this->HandleFileResizing($path .
$filename, $thumbnail, get_site_preference('thumbnail_width', 96), get_site_preference('thumbnail_height',96),true,false,60,false))
* Gets the icon for a file.<br />
* If FileManager is installed it uses FileManager icons.<br />
* Otherwise it uses own icons.
* @param string $ext - the file extension
* @return string - the HTML ouput of an image
public function GetFileIcon($ext =
'', $is_dir =
false, $is_image =
false)
if($fm =
& $this->GetModuleInstance('FileManager'))
return $fm->GetFileIcon($ext, $is_dir);
return '<img class="GBFP_fileicon" src="'.
$config['root_url'].
'/modules/GBFilePicker/images/dir.gif" alt="" />';
return '<img class="GBFP_fileicon" src="'.
$config['root_url'].
'/modules/GBFilePicker/images/images.gif" alt="" />';
return '<img class="GBFP_fileicon" src="'.
$config['root_url'].
'/modules/GBFilePicker/images/fileicon.gif" alt="" />';
* Gets the icon for the file operation. <br />
* If FileManager is installed it uses FileManager icons. <br />
* Otherwise it uses own icons<br />
* @param string $action - the file operation (e.g. 'delete')
* @return string - the HTML ouput of an image
if($fm =
& $this->GetModuleInstance('FileManager'))
return $fm->GetActionIcon($action);
return '<img class="GBFP_actionicon" src="'.
$config['root_url'].
'/modules/GBFilePicker/images/'.
$action.
'.gif" title="'.
$action.
'" alt="'.
$action.
'" />';
* Checks if a directory is empty<br />
* Taken from TinyMCE Module (extracted from filepicker).
* @param string $dir - the path to a directory
while ($entry =
$d->read())
* Sorts the files by filename; shows directories first<br />
* this function is meant to be called from the php usort() function: usort($array,array($this,'SortFiles')<br />
* Taken from TinyMCE filepicker.
* @param object $file1 - one file to compare <br />a php stdClass with properties (boolean) $is_dir - a flag that specifys if it is a dir or a file;<br />(string) $basename - the basename of the file;
* @param object $file2 - the other file to compare <br />a php stdClass with properties (boolean) $is_dir - a flag that specifys if it is a dir or a file;<br />(string) $basename - the basename of the file;
* @return integer -1 or 1
if ($file1->is_dir &&
!$file2->is_dir) return -
1;
if (!$file1->is_dir &&
$file2->is_dir) return 1;
* Adapted from TinyMCE filepicker.
* @param string $source - the source path of the image
* @param string $output - the destination path of the resized image
* @param integer $new_width - the new wdth to scale the image to (if $keep_aspectratio is set to true this will be just some kind of max value)
* @param integer $new_height - the new height to scale the image to (if $keep_aspectratio is set to true this will be just some kind of max value)
* @param boolean $keep_aspectratio - set to false if image aspect ratio may be changed
* @param boolean $allow_upscaling - set to true if user may enlarge the image
* @param integer $quality - the quality of the new image (jpg only)
* @param boolean $clean_path - set to false if source is the upload_tmp_dir
* @todo enable format change?
$keep_aspectratio =
true, $allow_upscaling =
false, $quality =
100, $clean_path =
true)
if(@ini_get("upload_tmp_dir") &&
!startswith($source,@ini_get("upload_tmp_dir")) &&
$clean_path)
switch($img_data['mime'])
$orig_width =
@imagesx($orig_image);
$orig_height =
@imagesy($orig_image);
$aspectratio =
$orig_width /
$orig_height;
$new_width =
floor($new_width);
$new_height =
floor($new_height);
if($new_width <=
0 &&
$new_height >
0) { // force height
$new_width =
$orig_width;
if($new_height >
$orig_height &&
!$allow_upscaling)
$new_height =
$orig_height;
$new_width =
floor($new_height *
$aspectratio);
else if($new_height <=
0 &&
$new_width >
0) { // force width
$new_height =
$orig_height;
if($new_width >
$orig_width &&
!$allow_upscaling)
$new_width =
$orig_width;
$new_height =
floor($new_width /
$aspectratio);
else if($new_height >
0 &&
$new_width >
0) { // both
if($new_width >
$orig_width &&
!$allow_upscaling)
$new_width =
$orig_width;
if($new_height >
$orig_height &&
!$allow_upscaling)
$new_height =
$orig_height;
$new_aspectratio =
$new_width /
$new_height;
if($aspectratio >
1 &&
$new_aspectratio <
1)
{ // landscape to portrait
$_tmp =
floor($new_width /
$aspectratio);
if($_tmp >
0 &&
$_tmp <=
$new_height)
else if($aspectratio <
1 &&
$new_aspectratio >
1)
{ // portrait to landscape
$_tmp =
floor($new_height *
$aspectratio);
if($_tmp >
0 &&
$_tmp <=
$new_width)
if($new_aspectratio <
$aspectratio)
$_tmp =
floor($new_width /
$aspectratio);
if($_tmp >
0 &&
$_tmp <=
$new_height)
else if($new_aspectratio >
$aspectratio)
$_tmp =
floor($new_height *
$aspectratio);
if($_tmp >
0 &&
$_tmp <=
$new_width)
$new_height =
$orig_height;
$new_width =
$orig_width;
// handle transparency (adapted from supersizer plugin)
if($img_data['mime'] ==
'image/gif')
else if ($img_data['mime'] ==
'image/png')
@imagecopyresampled($new_image, $orig_image, 0, 0, 0, 0, $new_width, $new_height, $orig_width, $orig_height);
switch($img_data['mime'])
case 'image/jpeg':
return @imagejpeg($new_image, $output, $quality);
case 'image/gif' :
return @imagegif($new_image, $output);
case 'image/png' :
return @imagepng($new_image, $output);
if ($format=='unchanged')
switch($img_data['mime'])
case 'image/jpeg': return @imagejpeg($newImage, $output, $quality);
case 'image/gif' : return @imagegif($newImage, $output);
case 'image/png' : return @imagepng($newImage, $output);
case 'jpg': return @imagejpeg($newImage, $output, $quality);
case 'gif': return @imagegif($newImage, $output);
case 'png': return @imagepng($newImage, $output);
* returns the calculated size of the thumbnail<br />
* @param string $path - the source path of the image
* @return array - array(width,height)
$orig_width =
$img_data[0];
$orig_height =
$img_data[1];
$aspectratio =
$orig_width /
$orig_height;
$new_width =
floor(get_site_preference('thumbnail_width', 96));
$new_height =
floor(get_site_preference('thumbnail_height', 96));
if($new_width >
$orig_width)
$new_width =
$orig_width;
if($new_height >
$orig_height)
$new_height =
$orig_height;
$new_aspectratio =
$new_width /
$new_height;
if($aspectratio >
1 &&
$new_aspectratio <
1)
{ // landscape to portrait
$_tmp =
floor($new_width /
$aspectratio);
if($_tmp >
0 &&
$_tmp <=
$new_height)
else if($aspectratio <
1 &&
$new_aspectratio >
1)
{ // portrait to landscape
$_tmp =
floor($new_height *
$aspectratio);
if($_tmp >
0 &&
$_tmp <=
$new_width)
if($new_aspectratio <
$aspectratio)
$_tmp =
floor($new_width /
$aspectratio);
if($_tmp >
0 &&
$_tmp <=
$new_height)
else if($new_aspectratio >
$aspectratio)
$_tmp =
floor($new_height *
$aspectratio);
if($_tmp >
0 &&
$_tmp <=
$new_width)
return array($new_width, $new_height);
* Checks if a filename contains illegal chars<br />
* Taken from TinyMCE Module.
* @param string $filename - the filename to check
if (strpos($filename, '\'') !==
false) return true;
if (strpos($filename, '"' ) !==
false) return true;
if (strpos($filename, '/' ) !==
false) return true;
if (strpos($filename, '\\') !==
false) return true;
if (strpos($filename, '&' ) !==
false) return true;
if (strpos($filename, '\$') !==
false) return true;
if (strpos($filename, '+' ) !==
false) return true;
* Checks if a var is empty. <br />
* If $var is an array it recursivley checks all elements.
* @param mixed &$var - the var to check for empty value(s)
* @param boolean $trim - true to trim off spaces
* @param boolean $unset_empty_indexes - true to delete empty elements from array
* @return boolean - true if empty, false if not
public function IsVarEmpty(&$var, $trim =
true, $unset_empty_indexes =
false)
else if($trim &&
trim($var) ==
'')
* Removes empty elements from an array. <br />
* (can be useful when using function explode to create the array from a csv)
* @param array $array - the array to clean up
* @return array - an array without empty elements or an empty array
foreach ($array as $k=>
$v)
* Checks if a value is really meant to be "true". <br />
* Can be usefull when checking smarty params for the value true
* @param mixed $value - the value to check
public function IsTrue($value)
return (strtolower($value) ===
'true' ||
$value ===
1 ||
$value ===
'1' ||
$value ===
true);
* Checks if a value is really meant to be "false". <br />
* Can be usefull when checking smarty params for the value false
* @param mixed $value - the value to check
return (strtolower($value) ===
'false' ||
$value ===
'0' ||
$value ===
0 ||
$value ===
false ||
$value ===
'');
* Indicates if GBFilePicker output is already done<br />
* can be useful to avoid ouput of javascript and css twice
* @return bool - true if output done; false if not
* Processes given value using smarty
* @param string $tpl - the value to process by smarty
* @return string - the processed value
public function DoSmarty($tpl)
if(isset
($_GET['content_id']))
$manager =
& cmsms()->GetHierarchyManager();
$node =
$manager->sureGetNodeByAlias($_GET['content_id']);
$content =
& $node->GetContent();
if(isset
($content) &&
is_object($content) &&
$content->Type() !=
'content2')
if(version_compare(CMS_VERSION, '1.9') <
0 &&
!isset
(cmsms()->variables['pageinfo']->content_id))
// fake frontend rendering
cmsms()->variables['pageinfo'] =
new stdClass();
cmsms()->variables['pageinfo']->content_id =
$content->mId;
cmsms()->variables['pageinfo']->content_title =
$content->mName;
cmsms()->variables['pageinfo']->content_alias =
$content->mAlias;
cmsms()->variables['pageinfo']->content_menutext =
$content->mMenuText;
cmsms()->variables['pageinfo']->content_titleattribute =
$content->mTitleAttribute;
cmsms()->variables['pageinfo']->content_hierarchy =
$content->mHierarchy;
cmsms()->variables['pageinfo']->content_id_hierarchy =
$content->mIdHierarchy;
cmsms()->variables['pageinfo']->content_type =
$content->mType;
cmsms()->variables['pageinfo']->content_props =
$content->mProperties->mPropertyNames;
cmsms()->variables['pageinfo']->content_metadata =
$content->mMetadata;
cmsms()->variables['pageinfo']->content_modified_date =
$content->mModifiedDate;
cmsms()->variables['pageinfo']->content_created_date =
$content->mCreationDate;
cmsms()->variables['pageinfo']->content_last_modified_date =
$content->mModifiedDate;
cmsms()->variables['pageinfo']->content_last_modified_by_id =
$content->mOwner;
cmsms()->variables['pageinfo']->template_id =
$content->mTemplateId;
cmsms()->variables['pageinfo']->template_encoding =
get_encoding('');
cmsms()->variables['pageinfo']->template_modified_date =
time(); // ???
cmsms()->variables['pageinfo']->cachable =
$content->mCachable;
cmsms()->variables['pageinfo']->content_hierarchy_path =
$content->mHierarchyPath;
cmsms()->variables['content_id'] =
$content->mId;
cmsms()->variables['page'] =
$content->mAlias;
cmsms()->variables['page_id'] =
$content->mAlias;
cmsms()->variables['page_alias'] =
$content->mAlias;
cmsms()->variables['content_alias'] =
$content->mAlias;
cmsms()->variables['page_name'] =
$content->mAlias;
cmsms()->variables['position'] =
$content->mHierarchy;
cmsms()->variables['friendly_position'] =
cmsms()->GetContentOperations()->CreateFriendlyHierarchyPosition($content->mHierarchy);
$this->smarty->assign_by_ref('content_obj', $content);
$this->smarty->assign('content_id', $content->Id());
$this->smarty->assign('content_alias', $content->Alias());
$this->smarty->assign('page', $content->Alias());
$this->smarty->assign('page_id', $content->Alias());
$this->smarty->assign('page_alias', $content->Alias());
$this->smarty->assign('page_name', $content->Alias());
$this->smarty->assign('position', $content->Hierarchy());
$this->smarty->assign('friendly_position', cmsms()->GetContentOperations()->CreateFriendlyHierarchyPosition($content->Hierarchy()));
$tpl =
$this->ProcessTemplateFromData(preg_replace('/:::([^:]+):::/', '{$1}', $tpl));
* Returns a list of available themes
* @return array - the themes
$dir =
cms_join_path(dirname(__FILE__
), 'templates', 'themes') .
DIRECTORY_SEPARATOR;
$default_themes =
array();
while ($entry =
$d->read())
||
!file_exists(cms_join_path($dir.
$entry,'input.tpl'))
||
!file_exists(cms_join_path($dir.
$entry,'fileBrowser.tpl'))
||
!file_exists(cms_join_path($dir.
$entry,'header.tpl')))
$default_themes[$entry] =
$entry;
//$dir = cms_join_path($config['root_path'],'module_custom','GBFilePicker','templates','themes') . DIRECTORY_SEPARATOR;
//$custom_themes = array();
//if(file_exists($dir) && is_dir($dir))
// while ($entry = $d->read())
// || !is_dir($dir.$entry)
// || !file_exists(cms_join_path($dir.$entry,'input.tpl'))
// || !file_exists(cms_join_path($dir.$entry,'fileBrowser.tpl'))
// || !file_exists(cms_join_path($dir.$entry,'header.tpl')))
// $custom_themes[$entry] = $entry;
//$themes = $this->CleanArray(array_merge($default_themes,$custom_themes));
Documentation generated on Wed, 23 Feb 2011 21:38:09 +0100 by phpDocumentor 1.4.0a2