Source for file GBFilePicker.module.php

Documentation is available at GBFilePicker.module.php

  1. <?php
  2. #-------------------------------------------------------------------------------
  3. #
  4. # Module : GBFilePicker (c) 2010 by Georg Busch (georg.busch@gmx.net) is a file
  5. #          picker tool for CMS Made Simple
  6. #          The projects homepage is: dev.cmsmadesimple.org/projects/gbfilepicker
  7. #          CMS Made Simple is (c) 2004-2010 by Ted Kulp
  8. #          The projects homepage is: cmsmadesimple.org
  9. # Version: 1.2
  10. # File   : GBFilePicker.module.php
  11. # Purpose: main module class
  12. # License: GPL
  13. #
  14. #-------------------------------------------------------------------------------
  15.  
  16. /**
  17.  * Class definition and methods for GBFilePicker
  18.  *
  19.  * @package CMSModule
  20.  * @license GPL
  21.  */
  22.  
  23. /**
  24.  * Main class of the GBFilePicker Module
  25.  *
  26.  * @author Georg Busch (NaN)
  27.  * @copyright 2010 Georg Busch (NaN)
  28.  * @version 1.2
  29.  *
  30.  * @package CMSModule
  31.  * @license GPL
  32.  */
  33. class GBFilePicker extends CMSModule 
  34. {
  35.     /**
  36.      * @access protected
  37.      * @var boolean 
  38.      * @ignore
  39.      */
  40.     protected $_isAdmin;
  41.     
  42.     /**
  43.      * @access protected
  44.      * @var boolean 
  45.      * @ignore
  46.      */
  47.     protected $_loaded;
  48.     
  49.     /**
  50.      * @access protected
  51.      * @var string 
  52.      * @ignore
  53.      */
  54.     protected $_username;
  55.     
  56.     /**
  57.      * Constructor
  58.      * @ignore
  59.      */
  60.     function GBFilePicker() 
  61.     {
  62.         parent::CMSModule();
  63.         $this->_loaded = false;
  64.         global $CMS_ADMIN_PAGE;
  65.         if(isset($CMS_ADMIN_PAGE) && $CMS_ADMIN_PAGE == 1) 
  66.         {
  67.             $config = cmsms()->GetConfig();
  68.             if(!file_exists(cms_join_path($config['previews_path'] , 'GBFilePickerThumbs')))
  69.             {
  70.                 @mkdir(cms_join_path($config['previews_path'] , 'GBFilePickerThumbs'), 0755);
  71.             }
  72.             $userops         =& cmsms()->GetUserOperations();
  73.             $this->_isAdmin  = $userops->UserInGroup(get_userid(false),1);
  74.             if($user =& $userops->LoadUserById(get_userid(false))) 
  75.             {
  76.                 $this->_username = $user->username;
  77.             }
  78.         }
  79.     }
  80.     
  81.     /**
  82.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetName
  83.      * @ignore
  84.      */
  85.     function GetName() 
  86.     {
  87.         return 'GBFilePicker';
  88.     }
  89.     
  90.     /**
  91.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetFriendlyName
  92.      * @ignore
  93.      */
  94.     function GetFriendlyName() 
  95.     {
  96.         return $this->Lang('GBFilePicker');
  97.     }
  98.     
  99.     /**
  100.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetVersion
  101.      * @ignore
  102.      */
  103.     function GetVersion() 
  104.     {
  105.         return '1.2';
  106.     }
  107.     
  108.     /**
  109.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetHelp
  110.      * @ignore
  111.      */
  112.     function GetHelp() 
  113.     {
  114.         return $this->lang('help');
  115.     }
  116.     
  117.     /**
  118.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetAuthor
  119.      * @ignore
  120.      */
  121.     function GetAuthor() 
  122.     {
  123.         return 'Georg Busch (NaN)';
  124.     }
  125.     
  126.     /**
  127.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetChangeLog
  128.      * @ignore
  129.      */
  130.     function GetChangeLog() 
  131.     {
  132.         return $this->lang('changelog');
  133.     }
  134.     
  135.     /**
  136.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#HasAdmin
  137.      * @ignore
  138.      */
  139.     function HasAdmin() 
  140.     {
  141.         return true;
  142.     }
  143.     
  144.     /**
  145.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetAdminSection
  146.      * @ignore
  147.      */
  148.     function GetAdminSection() 
  149.     {
  150.         return 'extensions';
  151.     }
  152.     
  153.     /**
  154.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetAdminDescription
  155.      * @ignore
  156.      */
  157.     function GetAdminDescription() 
  158.     {
  159.         return $this->lang('admindescription');
  160.     }
  161.     
  162.     /**
  163.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#VisibleToAdminUser
  164.      * @ignore
  165.      */
  166.     function VisibleToAdminUser() 
  167.     {
  168.         return $this->Checkpermission('Manage GBFilePicker');
  169.     }
  170.     
  171.     /**
  172.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#MinimumCMSVersion
  173.      * @ignore
  174.      */
  175.     function MinimumCMSVersion() 
  176.     {
  177.         return "1.8.2";
  178.     }
  179.     
  180.     /**
  181.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#MaximumCMSVersion
  182.      * @ignore
  183.      */
  184.     function MaximumCMSVersion() 
  185.     {
  186.         return "1.9.9";
  187.     }
  188.     
  189.     /**
  190.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#InstallPostMessage
  191.      * @ignore
  192.      */
  193.     function InstallPostMessage() 
  194.     {
  195.         return $this->Lang('post_install', $this->GetVersion());
  196.     }
  197.     
  198.     /**
  199.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#UninstallPostMessage
  200.      * @ignore
  201.      */
  202.     function UninstallPostMessage() 
  203.     {
  204.         return $this->Lang('post_uninstall', $this->GetVersion());
  205.     }
  206.     
  207.     /**
  208.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#UninstallPreMessage
  209.      * @ignore
  210.      */
  211.     function UninstallPreMessage() 
  212.     {
  213.         return $this->Lang('confirm_uninstall');
  214.     }
  215.     
  216.     /**
  217.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#HandlesEvents
  218.      * @ignore
  219.      */
  220.     function HandlesEvents() 
  221.     {
  222.         return false;
  223.     }
  224.     
  225.     /**
  226.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#IsPluginModule
  227.      * @ignore
  228.      */
  229.     function IsPluginModule() 
  230.     {
  231.         return true;
  232.     }
  233.     
  234.     /**
  235.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#DoAction
  236.      * @ignore
  237.      */
  238.     function DoAction($action, $id, $params, $returnid = '') 
  239.     {
  240.         switch($action) 
  241.         {
  242.             case 'defaultadmin':
  243.             case 'savePrefs':
  244.             case 'fileBrowser':
  245.                 parent::DoAction($action, $id, $params, $returnid);
  246.                 break;
  247.                 
  248.             default: break;
  249.         }
  250.     }
  251.     
  252.     /**
  253.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#SetParameters
  254.      * @todo create list of allowed parameters!
  255.      */
  256.     function SetParameters() 
  257.     {
  258.         #$this->RestrictUnknownParams();
  259.     }
  260.     
  261.     /**
  262.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#HasCapability
  263.      * @ignore
  264.      */
  265.     function HasCapability($capability,$params = array()) 
  266.     {
  267.         switch( $capability ) 
  268.         {
  269.             case 'contentblocks':
  270.             case 'content_attributes':
  271.                 return TRUE;
  272.             default:
  273.                 return FALSE;
  274.         }
  275.     }
  276.     
  277.     /**
  278.      * @link http://www.cmsmadesimple.org/apidoc/CMS/CMSModule.html#GetContentBlockInput
  279.      * @ignore
  280.      */
  281.     function GetContentBlockInput($blockname,$value,$params,$adding = false) 
  282.     {
  283.         if($this->CheckPermission('Use GBFilePicker'))
  284.         {
  285.             return $this->CreateFilePickerInput($this, '', str_replace(' ','_',$blockname), $value, $params);
  286.         }
  287.         return;
  288.     }
  289.     
  290. #-------------------------------------------------------------------------------
  291. # Not part of the CMSms module API
  292. #-------------------------------------------------------------------------------
  293.     
  294.     /**
  295.      * Creates the filepicker input.
  296.      *
  297.      * @since 1.0
  298.      * @access public
  299.      *
  300.      * @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)
  301.      * @param string $id - the id of the moduleinstance that creates the filepicker input
  302.      * @param string $name - the name of the input field
  303.      * @param string $value - the preselected value
  304.      * @param array $params - the input params (param_name => param_value):<br /><ul>
  305.      *         <li>(string)  'feu_access'               => a csv of group ids of the frontend users module,</li>
  306.      *         <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>
  307.      *         <li>(string)  'input_template'           => specify wich template should be used to create the input elements (default is GBFilePickers input.tpl),</li>
  308.      *         <li>(string)  'filebrowser_template'     => specify wich template should be used to create the filebrowser output elements (default is GBFilePickers fileBrowser.tpl),</li>
  309.      *         <li>(string)  'prompt'                   => the prompt of the input field,</li>
  310.      *         <li>(string)  'media_type'               => the media type (at the moment only image / file are supported),</li>
  311.      *         <li>(mixed)   'file_extensions'          => an array or a csv of allowed file extensions,</li>
  312.      *         <li>(mixed)   'exclude_prefix'           => an array or a csv of file prefixes that will be excluded,</li>
  313.      *         <li>(mixed)   'exclude_sufix'            => an array or a csv of file suffixes that will be excluded,</li>
  314.      *         <li>(mixed)   'include_prefix'           => an array or a csv of file prefixes that will be included,</li>
  315.      *         <li>(mixed)   'include_sufix'            => an array or a csv of file suffixes that will be included,</li>
  316.      *         <li>(boolean) 'show_subdirs'             => set to true if user may browse subdirs (notice: this has no effect if you are admin)</li>
  317.      *         <li>(string)  'mode'                     => dropdown/browser,</li>
  318.      *         <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>
  319.      *         <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>
  320.      *         <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>
  321.      *         <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>
  322.      *         <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>
  323.      *         <li>(string)  'add_txt'                  => any additional text that will be added to the html input when tag is rendered,</li>
  324.      *         <li>(integer) 'size'                     => the size of the textinput ('mode' => 'browser', 'media_type' => 'file' only),</li>
  325.      *         <li>(integer) 'maxlength'                => the max length of the textinput ('mode' => 'browser', 'media_type' => 'file' only),</li>
  326.      *         <li>(integer) 'scaling_width'            => the default width of images when allow_scaling is true,</li>
  327.      *         <li>(integer) 'scaling_height'           => the default height of images when allow_scaling is true,</li>
  328.      *         <li>(boolean) 'show_thumbfiles'          => set to true if thumbs should also be shown as regular files,</li>
  329.      *         <li>(boolean) 'allow_scaling'            => set to false if user may not scale the images on upload,</li>
  330.      *         <li>(boolean) 'create_thumbs'            => set to false if the module may not create thumbs for the input,</li>
  331.      *         <li>(boolean) 'allow_upscaling'          => set to true if user may enlarge the images</li>
  332.      *         <li>(boolean) 'force_scaling'            => set to true to force resizing of image to a given size if user may not resize images</li>
  333.      *         <li>(boolean) 'keep_aspectratio'         => set to false to change aspect ratio to that one of the scaling size on resizing images</li></ul>
  334.      * @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)
  335.      *
  336.      * @return string - the HTML output of the filepicker
  337.      */
  338.     public function CreateFilePickerInput(&$module, $id, $name, $value = '', $params = array(), $returnid = '') 
  339.     {
  340.         $name = str_replace(' ','_',$name);
  341.         if($module == '')
  342.         {
  343.             $module =& $this;
  344.         }
  345.         if(!$params =& $this->SetInputParams($module, $id, $name, $params))
  346.         {
  347.             return;
  348.         }
  349.         
  350.         $value  = $this->CleanUrl($value, false);
  351.         $config = cmsms()->GetConfig();
  352.         
  353.         $module->smarty->assign('thumb_width', get_site_preference('thumbnail_width',96));
  354.         $module->smarty->assign('thumb_height', get_site_preference('thumbnail_height',96));
  355.         
  356.         if($params['media_type'] == 'image') 
  357.         {
  358.             $thumbnail_size = $this->GetThumbnailSize($value);
  359.             $module->smarty->assign('gbfp_thumb_width', $thumbnail_size[0]);
  360.             $module->smarty->assign('gbfp_thumb_height', $thumbnail_size[1]);
  361.             $module->smarty->assign('gbfp_thumburl', $this->GetThumbnail($value, $params['create_thumbs'],true));
  362.         }
  363.         $module->smarty->assign('gbfp_value', $value);
  364.         $module->smarty->assign('gbfp_loaded', $this->_loaded);
  365.         $this->_loaded = true;
  366.         
  367.         $input      = '';
  368.         $upload_btn = '';
  369.         $browse_btn = '';
  370.         $clear_btn  = '';
  371.         $reload_btn = '';
  372.         $upload_url = '';
  373.         $browse_url = '';
  374.         $reload_url = '';
  375.         
  376.         if($params['mode'] == 'dropdown')
  377.         {
  378.             #if($params['add_txt'] == '')
  379.             #{
  380.             #    $params['add_txt'] = 'onchange="GBFP.ToggleThumbnail(\'#' . $id.$name . '\', jQuery(\'#' . $id.$name . ' option:selected:first\').attr(\'thumbnail\'),this.value,this.value)"';
  381.             #}
  382.             $input = $this->CreateFileDropdown(
  383.                 $id,
  384.                 $name, 
  385.                 $params['dir'],
  386.                 $value,
  387.                 $params['exclude_prefix'], 
  388.                 $params['include_prefix'], 
  389.                 $params['exclude_sufix'], 
  390.                 $params['include_sufix'], 
  391.                 $params['file_extensions'], 
  392.                 $params['media_type'], 
  393.                 $params['allow_none'],
  394.                 $params['add_txt']);
  395.             
  396.             if($params['upload'])
  397.             {
  398.                 $upload_url = str_replace('&amp;','&',$this->CreateLink(($id == '' ? 'm1_' : $id), 'fileBrowser', $returnid, $this->lang('upload'),array('name' =>$name,'disable_theme'=>true,'showtemplate' => 'false','dir'=>($this->_isAdmin?$params['dir']:'')),'', true));
  399.                 $upload_btn = '<input disabled="disabled" type="button" value="'.$this->lang('upload').'" 
  400.                     id="'.$id.$name.'_GBFP_browse" class="GBFP_browse GBFP_button GBFP_disabled" onclick="GBFP.LoadDir(\''.$upload_url.'\',\''.munge_string_to_url($id.$name.'_'.$params['dir']).'\'); return false;" />';
  401.             }
  402.             $reload_url = str_replace('&amp;','&',
  403.                 $this->CreateLink(($id == '' ? 'm1_' : $id), 
  404.                     'fileBrowser', 
  405.                     $returnid, 
  406.                     $this->lang('reload'),
  407.                     array('name' =>$name,
  408.                         'disable_theme'=>true,
  409.                         'showtemplate' => 'false',
  410.                         'reload'=>true),
  411.                     '', 
  412.                     true));
  413.             $reload_btn = '<input disabled="disabled" type="button" value="'.$this->lang('reload_dropdown').'" 
  414.                 id="'.$id.$name.'_GBFP_reload" class="GBFP_reload GBFP_button GBFP_disabled" onclick="GBFP.ReloadDropdown(\''.$reload_url.'\',\''.$id.$name.'\'); return false;" />';
  415.         }
  416.         else if($params['mode'] == 'browser') 
  417.         {
  418.             if($params['media_type'] == 'image') 
  419.             {
  420.                 $input = '<input id="'.$id.$name.'" type="hidden" name="'.$id.$name.'" value="' . $value . '" />';
  421.             }
  422.             else if($params['media_type'] == 'file') 
  423.             {
  424.                 $input = '<input id="'.$id.$name.'" class="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 . '" />';
  425.             }
  426.             
  427.             $browse_url = str_replace('&amp;','&',$this->CreateLink(($id == '' ? 'm1_' : $id), 'fileBrowser', $returnid, $this->lang('browse_'.$params['media_type']),array('name' =>$name,'disable_theme'=>true,'showtemplate' => 'false','dir'=>($this->_isAdmin?$params['dir']:'')),'', true));
  428.             $browse_btn = '<input disabled="disabled" type="button" value="'.$this->lang('browse_'.$params['media_type']).'" id="'.$id.$name.'_GBFP_browse" class="GBFP_browse GBFP_disabled GBFP_button" onclick="GBFP.LoadDir(\''.$browse_url.'\',\''.munge_string_to_url($id.$name.'_'.$params['dir']).'\'); return false;" />';
  429.             if($params['allow_none']) 
  430.             {
  431.                 $clear_btn = '<input disabled="disabled" class="GBFP_disabled GBFP_button" type="button" value="'.$this->lang('none').'" onclick="jQuery(\'#'.$id.$name.'\').val(\'\'); GBFP.ToggleThumbnail(\'#'.$id.$name.'\',\'\'); return false;" />';
  432.             }
  433.         }
  434.         
  435.         if($config['debug'])
  436.         {
  437.             debug_buffer($params,'GBFilePicker input params; input = "'.$id.$name.'"; function CreateFilePickerInput() FINAL');
  438.         }
  439.         $module->smarty->assign('gbfp_input', $input);
  440.         $module->smarty->assign('gbfp_browse_button', $browse_btn);
  441.         $module->smarty->assign('gbfp_reload_button', $reload_btn);
  442.         $module->smarty->assign('gbfp_reload_url', $reload_url);
  443.         $module->smarty->assign('gbfp_upload_button', $upload_btn);
  444.         $module->smarty->assign('gbfp_clear_button', $clear_btn);
  445.         $module->smarty->assign('gbfp_id', $id);
  446.         $module->smarty->assign('gbfp_name', $name);
  447.         $module->smarty->assign('gbfp_inputid', $id.$name);
  448.         $module->smarty->assign('gbfp_inputname', $name);
  449.         $module->smarty->assign('gbfp_upload_url', $upload_url);
  450.         $module->smarty->assign('gbfp_browse_url', $browse_url);
  451.         $module->smarty->assign('gbfp_title', $this->Lang('browser_title'));
  452.         $module->smarty->assign('gbfp_browse_url', $browse_url);
  453.         foreach($params as $k => $v)
  454.         {
  455.             $module->smarty->assign('gbfp_'.$k,$v);
  456.         }
  457.         $module->smarty->assign('gbfp_reload_dir_text', $this->lang('reload_dir'));
  458.         $module->smarty->assign('gbfp_clear_cache_text', $this->lang('clear_cache'));
  459.         $module->smarty->assign('gbfp_close_text', $this->lang('close'));
  460.         if(endswith($params['input_template'],'.tpl'))
  461.         {
  462.             return $module->ProcessTemplate($params['input_template']);
  463.         }
  464.         return $module->ProcessTemplateFromDatabase($params['input_template']);
  465.     }
  466.     
  467.     
  468.     /**
  469.      * Sets the params of a filepicker input and save them in a session var
  470.      * 
  471.      * @since 1.1
  472.      * @access private
  473.      *
  474.      * @param string $id - the id of the moduleinstance that creates the filepicker input
  475.      * @param string $name - the name of the input field
  476.      * @param array $params - the params
  477.      *
  478.      * @return array|false
  479.      *
  480.      * @ignore
  481.      */
  482.     private function &SetInputParams(&$module, $id, $name, $params = array()) 
  483.     {
  484.         global $CMS_ADMIN_PAGE;
  485.         $config = cmsms()->GetConfig();
  486.         @session_start();
  487.         $_SESSION['GPFP_' . ($id == '' ? 'm1_' : $id).$name] = array();
  488.         $result = false;
  489.         $name = str_replace(' ','_',$name);
  490.         if(!$session_params =& $this->GetInputParams($id, $name))
  491.         {
  492.             return $result;
  493.         }
  494.         
  495.         if(isset($params['prompt']))
  496.         {
  497.             $session_params['prompt'] = $params['prompt'];
  498.         }
  499.         
  500.         if(isset($params['input_template']))
  501.         {
  502.             $session_params['input_template'] = $params['input_template'];
  503.         }
  504.         if(isset($params['filepicker_template']))
  505.         {
  506.             $session_params['filebrowser_template'] = $params['filepicker_template'];
  507.         }
  508.         
  509.         $session_params['module'] = $module->GetName();
  510.         if(isset($params['feu_access']))
  511.         {
  512.             if(!is_array($params['feu_access']))
  513.             {
  514.                 $session_params['feu_access'] = $this->CleanArray(explode(',',$params['feu_access']));
  515.             }
  516.             else
  517.             {
  518.                 $session_params['feu_access'] = $this->CleanArray($params['feu_access']);
  519.             }
  520.         }
  521.         if(isset($params['restrict_users_diraccess']) && $this->IsFalse($params['restrict_users_diraccess'])) 
  522.         {
  523.             $session_params['restrict_users_diraccess'] = false;
  524.         }
  525.         
  526.         $dir = $session_params['start_dir'];
  527.         if(isset($params['dir']) && $params['dir'] != '')
  528.         {
  529.             $dir = $this->CleanUrl($params['dir'],false);
  530.             if(!$this->_isAdmin)
  531.             {
  532.                 $session_params['start_dir'] = $dir;
  533.             }
  534.         }
  535.         
  536.         if(isset($CMS_ADMIN_PAGE) && $CMS_ADMIN_PAGE == 1)
  537.         {
  538.             check_login();
  539.             if(!$this->CheckPermission('Use GBFilePicker'))
  540.             {
  541.                 return $result;
  542.             }
  543.             $username = $this->_username;
  544.         }
  545.         else 
  546.         {
  547.             if( !$feusers =& $this->GetModuleInstance('FrontEndUsers' ) )
  548.             {
  549.                 return $result;
  550.             }
  551.             if(!$userid = $feusers->LoggedInId())
  552.             {
  553.                 return $result;
  554.             }
  555.             if(!$groups = $feusers->GetMemberGroupsArray($userid))
  556.             {
  557.                 return $result;
  558.             }
  559.             $access = false;
  560.             foreach($groups as $_group) 
  561.             {
  562.                 if(in_array($_group['groupid'],$session_params['feu_access']))
  563.                 {
  564.                     $access = true;
  565.                     break;
  566.                 }
  567.             }
  568.             if(!$access)
  569.             {
  570.                 return $result;
  571.             }
  572.             
  573.             $username = $feusers->GetUserName($userid);
  574.             $params['media_type'] = 'image';
  575.             $params['restrict_users_diraccess'] = true;
  576.         }
  577.         
  578.         if(!$this->_isAdmin && $session_params['restrict_users_diraccess'])
  579.         {
  580.             if(!in_array($username, $this->CleanArray(explode('/',$dir))))
  581.             {
  582.                 $session_params['start_dir'] .= '/' . $dir;
  583.             }
  584.             else 
  585.             {
  586.                 $session_params['start_dir'] = $dir;
  587.             }
  588.             
  589.             $_dir = $this->CleanPath($session_params['start_dir']);
  590.             if(!@mkdir($_dir, 0755, true) && !file_exists($_dir) && !is_dir($_dir)) 
  591.             {
  592.                 return $result;
  593.             }
  594.         }
  595.         
  596.         if(isset($params['media_type']))
  597.         {
  598.             $session_params['media_type'] = strtolower($params['media_type']);
  599.         }
  600.         
  601.         if($session_params['media_type'] == 'file')
  602.         {
  603.             $session_params['file_extensions'] = array();
  604.         }
  605.         if(isset($params['file_extensions']) && $params['file_extensions'] != '')
  606.         {
  607.             $_file_ext = $this->CleanArray(explode(',',strtolower($params['file_extensions'])));
  608.             if($session_params['media_type'] == 'image')
  609.             {
  610.                 $_file_ext = $this->CleanArray(array_intersect($_file_ext, array('jpg','jpeg','gif','png')));
  611.             }
  612.             if(empty($_file_ext))
  613.             {
  614.                 $_file_ext = $session_params['file_extensions'];
  615.             }
  616.             $session_params['file_extensions'] = $_file_ext;
  617.         }
  618.         if(isset($params['exclude_prefix']))
  619.         {
  620.             $session_params['exclude_prefix'] = trim($params['exclude_prefix']);
  621.         }
  622.         if(isset($params['exclude_sufix']))
  623.         {
  624.             $session_params['exclude_sufix'] = trim($params['exclude_sufix']);
  625.         }
  626.         if(isset($params['include_prefix']))
  627.         {
  628.             $session_params['include_prefix'] = trim($params['include_prefix']);
  629.         }
  630.         if(isset($params['include_sufix']))
  631.         {
  632.             $session_params['include_sufix'] = trim($params['include_sufix']);
  633.         }
  634.         if(isset($params['show_subdirs']) && $this->IsTrue($params['show_subdirs']))
  635.         {
  636.             $session_params['show_subdirs'] = true;
  637.         }
  638.         if(isset($params['mode']))
  639.         {
  640.             $session_params['mode'] = strtolower($params['mode']);
  641.         }
  642.         if(isset($params['allow_none']) && $this->IsFalse($params['allow_none']))
  643.         {
  644.             $session_params['allow_none'] = intval(false);
  645.         }
  646.         if(isset($params['lock_input']) && $this->IsFalse($params['lock_input']))
  647.         {
  648.             $session_params['lock_input'] = intval(false);
  649.         }
  650.         if(isset($params['upload']) && $this->IsTrue($params['upload']) && $this->GetPreference('show_filemanagement')) 
  651.         {
  652.             $session_params['upload'] = true;
  653.         }
  654.         if(isset($params['delete']) && $this->IsTrue($params['delete']) && $this->GetPreference('show_filemanagement')) 
  655.         {
  656.             $session_params['delete'] = true;
  657.         }
  658.         if(isset($params['create_dirs']) && $this->IsTrue($params['create_dirs']) && $this->GetPreference('show_filemanagement')) 
  659.         {
  660.             $session_params['create_dirs'] = true;
  661.         }
  662.         if(isset($params['add_txt']))
  663.         {
  664.             $session_params['add_txt'] = trim($params['add_txt']);
  665.         }
  666.         if(isset($params['size']))
  667.         {
  668.             $session_params['size'] = intval($params['size']);
  669.         }
  670.         if(isset($params['maxlength']))
  671.         {
  672.             $session_params['maxlength'] = intval($params['maxlength']);
  673.         }
  674.         if(isset($params['scaling_width']))
  675.         {
  676.             $session_params['scaling_width'] = intval($params['scaling_width']);
  677.         }
  678.         if(isset($params['scaling_height']))
  679.         {
  680.             $session_params['scaling_height'] = intval($params['scaling_height']);
  681.         }
  682.         if(isset($params['show_thumbfiles']))
  683.         {
  684.             $session_params['show_thumbfiles'] = intval($params['show_thumbfiles']);
  685.         }
  686.         if(isset($params['allow_scaling']))
  687.         {
  688.             $session_params['allow_scaling'] = intval($params['allow_scaling']);
  689.         }
  690.         if(isset($params['create_thumbs']))
  691.         {
  692.             $session_params['create_thumbs'] = intval($params['create_thumbs']);
  693.         }
  694.         if(isset($params['allow_upscaling']))
  695.         {
  696.             $session_params['allow_upscaling'] = intval($params['allow_upscaling']);
  697.         }
  698.         if(isset($params['force_scaling']))
  699.         {
  700.             $session_params['force_scaling'] = intval($params['force_scaling']);
  701.         }
  702.         if(isset($params['keep_aspect_ratio']))
  703.         {
  704.             $session_params['keep_aspect_ratio'] = intval($params['keep_aspect_ratio']);
  705.         }
  706.         
  707.         if($session_params['mode'] == 'dropdown') 
  708.         {
  709.             $session_params['dir']       = $dir;
  710.             $session_params['start_dir'] = $dir;
  711.         }
  712.         
  713.         $_SESSION['GBFP_id_'.$name] = ($id == '' ? 'm1_' : $id);
  714.         
  715.         $_SESSION['GPFP_' . ($id == '' ? 'm1_' : $id).$name] = $session_params;
  716.         if($config['debug'])
  717.         {
  718.             debug_buffer($session_params,'GBFilePicker session vars; input = "'.$id.$name.'"; function SetInputParams()');
  719.         }
  720.         $session_params['dir'] = $dir;
  721.         return $session_params;
  722.     }
  723.     
  724.     
  725.     /**
  726.      * Gets the params of a filepicker input
  727.      * 
  728.      * @since 1.1
  729.      * @access protected
  730.      *
  731.      * @param string $id - the id of the moduleinstance that creates the filepicker input
  732.      * @param string $name - the name of the input field
  733.      *
  734.      * @return array 
  735.      * @ignore
  736.      */
  737.     protected function &GetInputParams($id, $name)
  738.     {
  739.         $name   = str_replace(' ','_',$name);
  740.         $params = array(
  741.             'id'                       => $id, 
  742.             'name'                     => $name,
  743.             'module'                   => $this->GetName(),
  744.             'start_dir'                => '', 
  745.             'feu_access'               => $this->CleanArray(explode(',',$this->GetPreference('feu_access'))),
  746.             'restrict_users_diraccess' => intval($this->GetPreference('restrict_users_diraccess', false)),
  747.             'input_template'           => 'input.tpl',
  748.             'filebrowser_template'     => 'fileBrowser.tpl',
  749.             'prompt'                   => '',
  750.             'media_type'               => 'image',
  751.             'file_extensions'          => array('jpg','jpeg','gif','png'),
  752.             'exclude_prefix'           => '',
  753.             'exclude_sufix'            => '',
  754.             'include_prefix'           => '',
  755.             'include_sufix'            => '',
  756.             'show_subdirs'             => intval($this->_isAdmin),
  757.             'mode'                     => 'dropdown',
  758.             'allow_none'               => true,
  759.             'lock_input'               => intval(!$this->_isAdmin),
  760.             'upload'                   => intval($this->_isAdmin || ($this->GetPreference('show_filemanagement', false) && $this->CheckPermission('Modify Files'))),
  761.             'delete'                   => intval($this->_isAdmin || ($this->GetPreference('show_filemanagement', false) && $this->CheckPermission('Modify Files'))),
  762.             'create_dirs'              => intval($this->_isAdmin || ($this->GetPreference('show_filemanagement', false) && $this->CheckPermission('Modify Files'))),
  763.             'add_txt'                  => 'onchange="GBFP.ToggleThumbnail(\'#' . $id.$name . '\', jQuery(\'#' . $id.$name . ' option:selected:first\').attr(\'thumbnail\'),this.value,this.value)"',
  764.             'size'                     => '',
  765.             'maxlength'                => '',
  766.             'scaling_width'            => intval($this->GetPreference('scaling_width', '')),
  767.             'scaling_height'           => intval($this->GetPreference('scaling_height', '')),
  768.             'show_thumbfiles'          => intval($this->GetPreference('show_thumbfiles', false)),
  769.             'allow_scaling'            => intval($this->GetPreference('allow_scaling', false) || $this->_isAdmin),
  770.             'create_thumbs'            => intval($this->GetPreference('create_thumbs', true)),
  771.             'allow_upscaling'          => intval($this->GetPreference('allow_upscaling', false) || $this->_isAdmin),
  772.             'force_scaling'            => intval($this->GetPreference('force_scaling',false)),
  773.             'keep_aspect_ratio'        => intval($this->GetPreference('keep_aspectratio',true)));
  774.         
  775.         global $CMS_ADMIN_PAGE;
  776.         $config = cmsms()->GetConfig();
  777.         $result = false;
  778.         if(isset($CMS_ADMIN_PAGE) && $CMS_ADMIN_PAGE == 1) 
  779.         {
  780.             check_login();
  781.             if(!$this->CheckPermission('Use GBFilePicker'))
  782.             {
  783.                 return $result;
  784.             }
  785.             if(!$this->_isAdmin && $params['restrict_users_diraccess'])
  786.             {
  787.                 $params['start_dir'] = $this->_username;
  788.             }
  789.         }
  790.         else
  791.         {
  792.             if( !$feusers =& $this->GetModuleInstance('FrontEndUsers' ) )
  793.             {
  794.                 return $result;
  795.             }
  796.             if(!$userid = $feusers->LoggedInId())
  797.             {
  798.                 return $result;
  799.             }
  800.             if(!$groups = $feusers->GetMemberGroupsArray($userid))
  801.             {
  802.                 return $result;
  803.             }
  804.             $access = false;
  805.             foreach($groups as $_group) 
  806.             {
  807.                 if(in_array($_group['groupid'],$params['feu_access'])) 
  808.                 {
  809.                     $access = true;
  810.                     break;
  811.                 }
  812.             }
  813.             if(!$access)
  814.             {
  815.                 return $result;
  816.             }
  817.             
  818.             $params['restrict_users_diraccess'] = true;
  819.             $params['start_dir'] = $feusers->GetPreference('image_destination_path', 'feusers') . '/' . $feusers->GetUserName($userid);
  820.         }
  821.         if($config['debug'])
  822.         {
  823.             debug_buffer($params,'GBFilePicker input params; input = "'.$id.$name.'"; function GetInputParams()');
  824.         }
  825.         if(isset($_SESSION['GPFP_' . ($id == '' ? 'm1_' : $id).$name]))
  826.         {
  827.             $params = array_merge($params, $_SESSION['GPFP_' . ($id == '' ? 'm1_' : $id).$name]);
  828.             return $params;
  829.         }
  830.         return $params;
  831.     }
  832.     
  833.     /**
  834.      * Gets the file type of a file.
  835.      * 
  836.      * @since 1.0
  837.      * @access public
  838.      *
  839.      * @param string $file - the path to a file
  840.      * @param string $use_mime - set to true to detect file type by mime type
  841.      *
  842.      * @return string - the mime-type or file extension
  843.      */
  844.     public function GetFileType($file, $use_mime = false) 
  845.     {
  846.         $filetype = '';
  847.         if($use_mime)
  848.         {
  849.             if (version_compare(PHP_VERSION, '5.3.0') >= 0 && function_exists('finfo_open')) 
  850.             {
  851.                 $finfo    = finfo_open(FILEINFO_MIME_TYPE); 
  852.                 $filetype = strtolower(finfo_file($finfo, $file));
  853.                 finfo_close($finfo);
  854.             }
  855.             else if(function_exists('mime_content_type')) 
  856.             {
  857.                 $filetype = strtolower(mime_content_type($file));
  858.             }
  859.         }
  860.         else
  861.         {
  862.             $fileinfo = pathinfo($file);
  863.             if(isset($fileinfo['extension']))
  864.             {
  865.                 $filetype = strtolower($fileinfo['extension']);
  866.             }
  867.         }
  868.         return $filetype;
  869.     }
  870.     
  871.     
  872.     /**
  873.      * Create a dropdown form element containing a list of files that match certain conditions
  874.      *
  875.      * @since 1.0
  876.      * @access public
  877.      *
  878.      * @param string $id - the id of the moduleinstance that creates the filepicker input
  879.      * @param string $name - the name of the input field
  880.      * @param string $dir - the directory to list the files of (may be relative to uploads dir or absolute path)
  881.      * @param string $selected - the preselected value
  882.      * @param array|string$excl_prefix - fileprefixes to exclude (array('foo','bar',...) or csv)
  883.      * @param array|string$incl_prefix - fileprefixes to include (array('foo','bar',...) or csv)
  884.      * @param array|string$excl_sufix - filesufixes to exclude (array('foo','bar',...) or csv)
  885.      * @param array|string$incl_sufix - filesufixes to include (array('foo','bar',...) or csv)
  886.      * @param array|string$file_ext - filesufixes to include (array('foo','bar',...) or csv)
  887.      * @param string $media_type - file or image
  888.      * @param boolean $allow_none - set to false to hide the option 'none'
  889.      * @param string $add_txt - any additional text that will be added to the html input when tag is rendered
  890.      *
  891.      * @return string - the HTML output of a select element with options
  892.      */
  893.     public function CreateFileDropdown($id, $name, $dir = '', $selected = '', $excl_prefix = '', $incl_prefix = '', 
  894.         $excl_sufix = '', $incl_sufix = '', $file_ext = '', $media_type = '', $allow_none = true, $add_txt = '')
  895.     {
  896.         $files =& $this->GetInputFiles($id, $name, $dir, true);
  897.         if(empty($files) && !$allow_none)
  898.         {
  899.             return $this->lang('dir_empty');
  900.         }
  901.         $dropdown = '<select class="GBFP_dropdown GBFP_'.$media_type.'" name="'.$id.$name.'" id="'.$id.$name.'"';
  902.         if($add_txt != '')
  903.         {
  904.             $dropdown .= ' '.$add_txt;
  905.         }
  906.         $dropdown .= '>';
  907.         if( $allow_none )
  908.         {
  909.             $dropdown .= '<option value=""';
  910.             if($selected == '')
  911.             {
  912.                 $dropdown .= ' selected="selected"';
  913.             }
  914.             $dropdown .= ' thumbnail="">--- '.lang('none').' ---</option>';
  915.         }
  916.         foreach( $files as $file )
  917.         {
  918.             $dropdown .= '<option value="'.$file->relurl.'"';
  919.             if($file->relurl == $selected)
  920.             {
  921.                 $dropdown .= ' selected="selected"';
  922.             }
  923.             if($file->is_image && $media_type == 'image')
  924.             {
  925.                 $dropdown .= ' thumbnail="'.(isset($file->thumburl) && $file->thumburl!=''?$file->thumburl:$file->fullurl).'"';
  926.             }
  927.             $dropdown .= '>'.$file->basename.'</option>';
  928.         }
  929.         $dropdown .= "</select>";
  930.         return $dropdown;
  931.     }
  932.     
  933.     
  934.     /**
  935.      * Return an array containing a list of files in a directory related to a certain input.<br />
  936.      * Performs a non recursive search.
  937.      *
  938.      * @since 1.1
  939.      * @access public
  940.      *
  941.      * @param string $id - the id of the moduleinstance that creates the filepicker input
  942.      * @param string $name - the name of the input field
  943.      * @param string $dir - the directory to list the files of (may be relative to uploads dir or absolute path)
  944.      * @param bool $excl_dirs 
  945.      *
  946.      * @return array 
  947.      */
  948.     public function &GetInputFiles($id, $name, $dir)
  949.     {
  950.         $params =& $this->GetInputParams($id, $name);
  951.         return $this->GetFiles($dir, $params['exclude_prefix'], 
  952.             $params['include_prefix'], $params['exclude_sufix'], 
  953.             $params['include_sufix'], $params['file_extensions'], 
  954.             $params['media_type'], ($params['mode'] == 'dropdown' ? true : !$params['show_subdirs']), $params['show_thumbfiles'],
  955.             $params['create_thumbs']);
  956.     }
  957.     
  958.     
  959.     /**
  960.      * Return an array containing a list of files in a directory.<br />
  961.      * Performs a non recursive search.
  962.      *
  963.      * @since 1.0
  964.      * @access public
  965.      *
  966.      * @param string $dir - the directory to list the files of (may be relative to uploads dir or absolute path)
  967.      * @param array|string$excl_prefix - fileprefixes to exclude (array('foo','bar',...) or csv)
  968.      * @param array|string$incl_prefix - fileprefixes to include (array('foo','bar',...) or csv)
  969.      * @param array|string$excl_sufix - filesufixes to exclude (array('foo','bar',...) or csv)
  970.      * @param array|string$incl_sufix - filesufixes to include (array('foo','bar',...) or csv)
  971.      * @param array|string$file_ext - filesufixes to include (array('foo','bar',...) or csv)
  972.      * @param string $media_type - file or image
  973.      * @param boolean $excl_dirs - set to true to exclude directories
  974.      * @param boolean $show_thumbfiles 
  975.      * @param boolean $create_thumbs = true
  976.      *
  977.      * @return array 
  978.      */
  979.     public function &GetFiles($dir = '', $excl_prefix = '', $incl_prefix = '', $excl_sufix = '', 
  980.         $incl_sufix = '', $file_ext = '', $media_type = 'image', $excl_dirs = false, $show_thumbfiles = false, $create_thumbs = true)
  981.     {
  982.         $config = cmsms()->GetConfig();
  983.         $files  = Array();
  984.         $dir    = $this->CleanPath($dir);
  985.         $url    = $this->CleanURL($dir);
  986.         
  987.         if(!file_exists($dir))
  988.         {
  989.             return $files;
  990.         }
  991.         
  992.         if(!is_array($excl_prefix))
  993.         {
  994.             $excl_prefix = $this->CleanArray(explode(',',$excl_prefix));
  995.         }
  996.         
  997.         if(!is_array($incl_prefix))
  998.         {
  999.             $incl_prefix = $this->CleanArray(explode(',',$incl_prefix));
  1000.         }
  1001.         
  1002.         if(!is_array($excl_sufix))
  1003.         {
  1004.             $excl_sufix = $this->CleanArray(explode(',',$excl_sufix));
  1005.         }
  1006.         
  1007.         if(!is_array($incl_sufix))
  1008.         {
  1009.             $incl_sufix = $this->CleanArray(explode(',',$incl_sufix));
  1010.         }
  1011.         
  1012.         if(!is_array($file_ext))
  1013.         {
  1014.             $file_ext = $this->CleanArray(explode(',',$file_ext));
  1015.         }
  1016.         
  1017.         $_file_ext = array('jpg','jpeg','gif','png');
  1018.         if($media_type == 'image') 
  1019.         {
  1020.             $file_ext = $this->CleanArray(array_intersect($_file_ext, $file_ext));
  1021.             if(empty($file_ext))
  1022.             {
  1023.                 $file_ext = $_file_ext;
  1024.             }
  1025.         }
  1026.         
  1027.         $excl_prefix = $this->CleanArray(array_diff($excl_prefix, $incl_prefix));
  1028.         $excl_sufix  = $this->CleanArray(array_diff($excl_sufix, $incl_sufix));
  1029.         
  1030.         $d = dir($dir);
  1031.         while ($entry = $d->read()) 
  1032.         {
  1033.             if ($entry[0] == '.' || (is_dir($dir.$entry) && $excl_dirs))
  1034.             {
  1035.                 continue;
  1036.             }
  1037.             
  1038.             $skip        = false;
  1039.             $incl_thumbs = false;
  1040.             
  1041.             $file = new stdClass();
  1042.             $file->is_dir = is_dir($dir.$entry);
  1043.             $fileinfo = pathinfo($dir.$entry);
  1044.             foreach($fileinfo as $k=>$v) 
  1045.             {
  1046.                 $file->$k = $v;
  1047.             }
  1048.             if(!$file->is_dir) 
  1049.             {
  1050.                 foreach($excl_prefix as $str) 
  1051.                 {
  1052.                     if(startswith($file->filename,$str)) 
  1053.                     {
  1054.                         $skip = true;
  1055.                         break;
  1056.                     }
  1057.                 }
  1058.                 if($skip) continue;
  1059.                 
  1060.                 foreach($incl_prefix as $str)
  1061.                 {
  1062.                     if(startswith($str,'thumb_')) 
  1063.                     {
  1064.                         $incl_thumbs = true;
  1065.                     }
  1066.                     if(!startswith($file->filename,$str)) 
  1067.                     {
  1068.                         $skip = true;
  1069.                         break;
  1070.                     }
  1071.                 }
  1072.                 if($skip) continue;
  1073.                 
  1074.                 foreach($excl_sufix as $str)
  1075.                 {
  1076.                     if(endswith($file->filename,$str)) 
  1077.                     {
  1078.                         $skip = true;
  1079.                         break;
  1080.                     }
  1081.                 }
  1082.                 if($skip) continue;
  1083.                 
  1084.                 foreach($incl_sufix as $str)
  1085.                 {
  1086.                     if(!endswith($file->filename,$str)) 
  1087.                     {
  1088.                         $skip = true;
  1089.                         break;
  1090.                     }
  1091.                 }
  1092.                 if($skip) 
  1093.                     continue;
  1094.             }
  1095.             
  1096.             if(startswith($entry,'thumb_') && !$show_thumbfiles && !$incl_thumbs)
  1097.             {
  1098.                 continue;
  1099.             }
  1100.             
  1101.             $filetype = $this->GetFileType($dir.$entry,$this->GetPreference('use_mimetype',false));
  1102.             if (!$file->is_dir && $media_type == 'image' && !in_array(str_replace('image/','',$filetype),$file_ext)) 
  1103.             {
  1104.                 continue;
  1105.             }
  1106.             else if(!$file->is_dir && $media_type != 'image' && !in_array($file->extension,$file_ext) && !empty($file_ext)) 
  1107.             {
  1108.                 continue;
  1109.             }
  1110.             
  1111.             $file->fullurl      = $url.$entry;
  1112.             $file->relurl       = trim(str_replace($config['uploads_url'],'',$file->fullurl),'/');
  1113.             $file->id           = munge_string_to_url($file->relurl);
  1114.             $file->last_modifed = filemtime($dir.$entry);
  1115.             
  1116.             if (!$file->is_dir)
  1117.             {
  1118.                 $file->is_image = false;
  1119.                 if (!$file->is_dir && in_array(str_replace('image/','',$filetype),array('jpg','jpeg','gif','png'))) 
  1120.                 {
  1121.                     $file->is_image = true;
  1122.                 }
  1123.                 $file->filetype = $filetype;
  1124.                 if($file->is_image) 
  1125.                 {
  1126.                     $file->thumbnail = '';
  1127.                     $file->thumburl  = '';
  1128.                     if ($show_thumbfiles || $incl_thumbs) 
  1129.                     {
  1130.                         $file->thumbnail = $this->GetThumbnail($dir.str_replace('thumb_', '', $entry), $create_thumbs);
  1131.                         $file->thumburl  = $this->GetThumbnail($dir.str_replace('thumb_', '', $entry), $create_thumbs,true);
  1132.                     } 
  1133.                     else 
  1134.                     {
  1135.                         $file->thumbnail = $this->GetThumbnail($dir.$entry, $create_thumbs);
  1136.                         $file->thumburl  = $this->GetThumbnail($dir.$entry, $create_thumbs,true);
  1137.                     }
  1138.                     
  1139.                     $file->imgsize = '';
  1140.                     $imgsize = @getimagesize($dir.$entry);
  1141.                     if ($imgsize) 
  1142.                     {
  1143.                         $file->imgsize = $imgsize[0] . ' x ' . $imgsize[1];
  1144.                     } 
  1145.                     else 
  1146.                     {
  1147.                         $file->imgsize = '&nbsp;';
  1148.                     }
  1149.                 }
  1150.                 $file->filesize = '';
  1151.                 $info = @stat($dir.$entry);
  1152.                 if ($info) 
  1153.                 {
  1154.                     $file->filesize = $info['size'];
  1155.                 }
  1156.                 $file->fileicon = $this->GetFileIcon($file->extension,false,true);
  1157.             }
  1158.             else 
  1159.             {
  1160.                 $file->fileicon = $this->GetFileIcon('',true);
  1161.             }
  1162.             $files[] = $file;
  1163.         }
  1164.         $d->close();
  1165.         usort($files, array($this, 'SortFiles'));
  1166.         return $files;
  1167.     }
  1168.     
  1169.     
  1170.     /**
  1171.      * Replaces all multiple DIRECTORY_SEPARATOR, dots and (multiple) slashes with one single DIRECTORY_SEPARATOR to make a clean secure path parameter
  1172.      *
  1173.      * @since 1.0
  1174.      * @access public
  1175.      * 
  1176.      * @param string $path - the path to clean
  1177.      * @param string $full_path - true to prepend uploads path on return, false to return only the cleaned $path
  1178.      *
  1179.      * @return string - the clean path
  1180.      */
  1181.     public function CleanPath($path, $full_path = true)
  1182.     {
  1183.         $config = cmsms()->GetConfig();
  1184.         $path   = trim(str_replace(array($config['uploads_path'],$config['uploads_url']), '', $path),'/'.DIRECTORY_SEPARATOR);
  1185.         $path   = str_replace(DIRECTORY_SEPARATOR,'/',$path);
  1186.         $path   = trim(preg_replace('/(\/\.)|(\.\/)|(\/?\.\.\/?)/','/',$path),'./');
  1187.         if($full_path)
  1188.         {
  1189.             $path = preg_replace('/[\\/]+/',DIRECTORY_SEPARATOR, '/' . $path . '/');
  1190.             $path = $config['uploads_path'] . $path;
  1191.             return $path;
  1192.         }
  1193.         return trim(preg_replace('/[\\/]+/',DIRECTORY_SEPARATOR, $path) , DIRECTORY_SEPARATOR);
  1194.     }
  1195.     
  1196.     
  1197.     /**
  1198.      * Replaces all multiple slashes, dots and (multiple) backslashes with one single slash to make a clean secure url parameter
  1199.      * 
  1200.      * @since 1.0
  1201.      * @access public
  1202.      *
  1203.      * @param string $url - the url to clean
  1204.      * @param string $full_url - true to prepend uploads url on return, false to return only the cleaned $url
  1205.      *
  1206.      * @return string - the clean url
  1207.      */
  1208.     public function CleanURL($url, $full_url = true)
  1209.     {
  1210.         $config = cmsms()->GetConfig();
  1211.         $url    = trim(str_replace(array($config['uploads_path'],$config['uploads_url']), '', $url),'/'.DIRECTORY_SEPARATOR);
  1212.         $url    = str_replace(DIRECTORY_SEPARATOR,'/',$url);
  1213.         $url    = trim(preg_replace('/(\/\.)|(\.\/)|(\/?\.\.\/?)/','/',$url),'./');
  1214.         if($full_url)
  1215.         {
  1216.             $url = preg_replace('/\/+/','/', '/' . str_replace('http://','',$url) . '/');
  1217.             $url = $config['uploads_url'] . $url;
  1218.             return $url;
  1219.         }
  1220.         return trim(preg_replace('/\/+/','/',$url),'/');
  1221.     }
  1222.     
  1223.     
  1224.     /**
  1225.      * Returns the thumbnail of a given image file.
  1226.      *
  1227.      * @since 1.0
  1228.      * @access public
  1229.      *
  1230.      * @param string $path - the path of the file to create a thumbnail of (can be relative to the uploads dir or absolute)
  1231.      * @param string $create_thumb - set to false if thumbnail may not be created if not exists
  1232.      * @param string $urlonly - set to true to get only the url to the thumbnail
  1233.      *
  1234.      * @return string - HTML img element or url
  1235.      */
  1236.     public function GetThumbnail($path, $create_thumb = true, $urlonly = false) 
  1237.     {
  1238.         if($path == '')
  1239.         {
  1240.             return false;
  1241.         }
  1242.         $config   = cmsms()->GetConfig();
  1243.         $filename = basename($path);
  1244.         $image    = '';
  1245.         $path     = $this->CleanPath(str_replace($filename,'',$path));
  1246.         $url      = $this->CleanUrl(str_replace($filename,'',$path));
  1247.         $thumbnail= cms_join_path($config['previews_path'] , 'GBFilePickerThumbs' , 'thumb_' . munge_string_to_url(str_replace($config['uploads_path'], '', $path)) . '_' . $filename);
  1248.         
  1249.         if((!file_exists($thumbnail) || filemtime($path . $filename) > filemtime($thumbnail)) && $create_thumb)
  1250.         {
  1251.             $this->HandleFileResizing($path . $filename, $thumbnail, get_site_preference('thumbnail_width', 96), get_site_preference('thumbnail_height',96),true,false,60,false);
  1252.         }
  1253.         if(file_exists($thumbnail)) 
  1254.         {
  1255.             $thumbUrl = $config['root_url'] . '/' . $this->CleanUrl(str_replace($config['root_path'], '', $thumbnail), false);
  1256.         }
  1257.         else
  1258.         {
  1259.             $thumbUrl = $url . $filename;
  1260.             $thumbnail_size = $this->GetThumbnailSize($path . $filename);
  1261.         }
  1262.         if($urlonly)
  1263.         {
  1264.             return $thumbUrl;
  1265.         }
  1266.         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 . '" />';
  1267.     }
  1268.     
  1269.     
  1270.     /**
  1271.      * Gets the icon for a file.<br />
  1272.      * If FileManager is installed it uses FileManager icons.<br />
  1273.      * Otherwise it uses own icons.
  1274.      *
  1275.      * @since 1.0
  1276.      * @access public
  1277.      *
  1278.      * @param string $ext - the file extension
  1279.      * @param bool $is_dir 
  1280.      * @param bool $is_image 
  1281.      * @return string - the HTML ouput of an image
  1282.      */
  1283.     public function GetFileIcon($ext = '', $is_dir = false, $is_image = false) 
  1284.     {
  1285.         $config = cmsms()->GetConfig();
  1286.         if($fm =& $this->GetModuleInstance('FileManager')) 
  1287.         {
  1288.             return $fm->GetFileIcon($ext, $is_dir);
  1289.         }
  1290.         if($is_dir)
  1291.         {
  1292.             return '<img class="GBFP_fileicon" src="'.$config['root_url'].'/modules/GBFilePicker/images/dir.gif" alt="" />';
  1293.         }
  1294.         if ($is_image) 
  1295.         {
  1296.             return '<img class="GBFP_fileicon" src="'.$config['root_url'].'/modules/GBFilePicker/images/images.gif" alt="" />';
  1297.         }
  1298.         return '<img class="GBFP_fileicon" src="'.$config['root_url'].'/modules/GBFilePicker/images/fileicon.gif" alt="" />';
  1299.     }
  1300.     
  1301.     
  1302.     /**
  1303.      * Gets the icon for the file operation. <br />
  1304.      * If FileManager is installed it uses FileManager icons. <br />
  1305.      * Otherwise it uses own icons<br />
  1306.      *
  1307.      * @since 1.0
  1308.      * @access public
  1309.      *
  1310.      * @param string $action - the file operation (e.g. 'delete')
  1311.      * @return string - the HTML ouput of an image
  1312.      */
  1313.     public function GetActionIcon($action) 
  1314.     {
  1315.         $config = cmsms()->GetConfig();
  1316.         if($fm =& $this->GetModuleInstance('FileManager')) 
  1317.         {
  1318.             return $fm->GetActionIcon($action);
  1319.         }
  1320.         else
  1321.         {
  1322.             return '<img class="GBFP_actionicon" src="'.$config['root_url'].'/modules/GBFilePicker/images/'.$action.'.gif" title="'.$action.'" alt="'.$action.'" />';
  1323.         }
  1324.     }
  1325.     
  1326.     
  1327.     /**
  1328.      * Checks if a directory is empty<br />
  1329.      * Taken from TinyMCE Module (extracted from filepicker).
  1330.      * @since 1.0
  1331.      * @access public
  1332.      * @param string $dir - the path to a directory
  1333.      * @return boolean 
  1334.      */
  1335.     public function IsDirEmpty($dir) 
  1336.     {
  1337.         $d = dir($this->CleanPath($dir));
  1338.         while ($entry = $d->read())
  1339.         {
  1340.             if ($entry == '.') 
  1341.             {
  1342.                 continue;
  1343.             }
  1344.             if ($entry == '..')
  1345.             {
  1346.                 continue;
  1347.             }
  1348.             return false;
  1349.         }
  1350.         return true;
  1351.     }
  1352.     
  1353.     
  1354.     /**
  1355.      * Sorts the files by filename; shows directories first<br />
  1356.      * this function is meant to be called from the php usort() function: usort($array,array($this,'SortFiles')<br />
  1357.      * Taken from TinyMCE filepicker.
  1358.      * @since 1.0
  1359.      * @access public
  1360.      * @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;
  1361.      * @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;
  1362.      * @return integer -1 or 1
  1363.      */
  1364.     public function SortFiles($file1, $file2) 
  1365.     {
  1366.         if ($file1->is_dir && !$file2->is_dir) return -1;
  1367.         if (!$file1->is_dir && $file2->is_dir) return 1;
  1368.         return strnatcasecmp($file1->basename, $file2->basename);
  1369.     }
  1370.     
  1371.     
  1372.     /**
  1373.      * resizes images<br />
  1374.      * Adapted from TinyMCE filepicker.
  1375.      * @since 1.0
  1376.      * @access public
  1377.      * 
  1378.      * @param string $source - the source path of the image
  1379.      * @param string $output - the destination path of the resized image
  1380.      * @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)
  1381.      * @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)
  1382.      * @param boolean $keep_aspectratio - set to false if image aspect ratio may be changed
  1383.      * @param boolean $allow_upscaling - set to true if user may enlarge the image
  1384.      * @param integer $quality - the quality of the new image (jpg only)
  1385.      * @param boolean $clean_path - set to false if source is the upload_tmp_dir
  1386.      *
  1387.      * @todo enable format change?
  1388.      */
  1389.     public function HandleFileResizing($source, $output, $new_width, $new_height, $keep_aspectratio = true, $allow_upscaling = false, $quality = 100, $clean_path = true) 
  1390.     {
  1391.         if(@ini_get("upload_tmp_dir") && !startswith($source,@ini_get("upload_tmp_dir")) && $clean_path) 
  1392.         {
  1393.             $source = $this->CleanPath(str_replace(basename($source),'',$source)).basename($source);
  1394.         }
  1395.         if($clean_path) 
  1396.         {
  1397.             $output = $this->CleanPath(str_replace(basename($output),'',$output)).basename($output);
  1398.         }
  1399.         $img_data = @getimagesize($source);
  1400.         
  1401.         if (!$img_data)
  1402.         {
  1403.             return false;
  1404.         }
  1405.         
  1406.         $orig_image = '';
  1407.         switch($img_data['mime']) 
  1408.         {
  1409.             case 'image/jpeg': 
  1410.                 $orig_image = @imagecreatefromjpeg($source); 
  1411.                 break;
  1412.             case 'image/gif' : 
  1413.                 $orig_image = @imagecreatefromgif($source); 
  1414.                 break;
  1415.             case 'image/png' : 
  1416.                 $orig_image = @imagecreatefrompng($source); 
  1417.                 break;
  1418.             default: 
  1419.                 return false;
  1420.         }
  1421.         $orig_width   = @imagesx($orig_image);
  1422.         $orig_height  = @imagesy($orig_image);
  1423.         $aspectratio = $orig_width / $orig_height;
  1424.         
  1425.         $new_width  = floor($new_width);
  1426.         $new_height = floor($new_height);
  1427.         
  1428.         if($new_width <= 0 && $new_height > 0) { // force height
  1429.             $new_width = $orig_width;
  1430.             if($new_height > $orig_height && !$allow_upscaling) 
  1431.             {
  1432.                 $new_height = $orig_height;
  1433.             }
  1434.             if($keep_aspectratio) 
  1435.             {
  1436.                 $new_width = floor($new_height * $aspectratio);
  1437.             }
  1438.         }
  1439.         else if($new_height <= 0 && $new_width > 0) { // force width
  1440.             $new_height = $orig_height;
  1441.             if($new_width > $orig_width && !$allow_upscaling) 
  1442.             {
  1443.                 $new_width = $orig_width;
  1444.             }
  1445.             if($keep_aspectratio) 
  1446.             {
  1447.                 $new_height = floor($new_width / $aspectratio);
  1448.             }
  1449.         }
  1450.         else if($new_height > 0 && $new_width > 0) { // both
  1451.             if($new_width > $orig_width && !$allow_upscaling) 
  1452.             {
  1453.                 $new_width = $orig_width;
  1454.             }
  1455.             if($new_height > $orig_height && !$allow_upscaling) 
  1456.             {
  1457.                 $new_height = $orig_height;
  1458.             }
  1459.             $new_aspectratio = $new_width / $new_height;
  1460.             if($keep_aspectratio) 
  1461.             {
  1462.                 if($aspectratio > 1 && $new_aspectratio < 1) 
  1463.                 { // landscape to portrait
  1464.                     $_tmp = floor($new_width / $aspectratio);
  1465.                     if($_tmp > 0 && $_tmp <= $new_height)
  1466.                     {
  1467.                         $new_height = $_tmp;
  1468.                     }
  1469.                 }
  1470.                 else if($aspectratio < 1 && $new_aspectratio > 1) 
  1471.                 { // portrait to landscape
  1472.                     $_tmp = floor($new_height * $aspectratio);
  1473.                     if($_tmp > 0 && $_tmp <= $new_width)
  1474.                     {
  1475.                         $new_width = $_tmp;
  1476.                     }
  1477.                 }
  1478.                 else 
  1479.                 {
  1480.                     if($new_aspectratio < $aspectratio) 
  1481.                     {
  1482.                         $_tmp = floor($new_width / $aspectratio);
  1483.                         if($_tmp > 0 && $_tmp <= $new_height)
  1484.                         {
  1485.                             $new_height = $_tmp;
  1486.                         }
  1487.                     }
  1488.                     else if($new_aspectratio > $aspectratio) 
  1489.                     {
  1490.                         $_tmp = floor($new_height * $aspectratio);
  1491.                         if($_tmp > 0 && $_tmp <= $new_width)
  1492.                         {
  1493.                             $new_width = $_tmp;
  1494.                         }
  1495.                     }
  1496.                 }
  1497.             }
  1498.         }
  1499.         else 
  1500.         {
  1501.             $new_height = $orig_height;
  1502.             $new_width  = $orig_width;
  1503.         }
  1504.         
  1505.         if($new_width < 1)
  1506.         {
  1507.             $new_width = 1;
  1508.         }
  1509.         if($new_height < 1)
  1510.         {
  1511.             $new_height = 1;
  1512.         }
  1513.         
  1514.         $new_image = @imagecreatetruecolor(floor($new_width), floor($new_height));
  1515.         @imagecopyresampled($new_image, $orig_image, 0, 0, 0, 0, $new_width, $new_height, $orig_width, $orig_height);
  1516.         switch($img_data['mime']) 
  1517.         {
  1518.             case 'image/jpeg': return @imagejpeg($new_image, $output, $quality);
  1519.             case 'image/gif' : return @imagegif($new_image, $output);
  1520.             case 'image/png' : return @imagepng($new_image, $output);
  1521.             default          : return false;
  1522.         }
  1523.         
  1524.         /*
  1525.         $format = 'unchanged';
  1526.         if ($format=='unchanged') 
  1527.         {
  1528.             switch($img_data['mime']) 
  1529.             {
  1530.                 case 'image/jpeg': return @imagejpeg($newImage, $output, $quality);
  1531.                 case 'image/gif' : return @imagegif($newImage, $output);
  1532.                 case 'image/png' : return @imagepng($newImage, $output);
  1533.                 default          : return false;
  1534.             }
  1535.         } else 
  1536.         {
  1537.             switch ($format) 
  1538.             {
  1539.                 case 'jpg': return @imagejpeg($newImage, $output, $quality);
  1540.                 case 'gif': return @imagegif($newImage, $output);
  1541.                 case 'png': return @imagepng($newImage, $output);
  1542.                 default   : return;
  1543.             }
  1544.         }
  1545.         */
  1546.     }
  1547.     
  1548.     
  1549.     /**
  1550.      * returns the calculated size of the thumbnail<br />
  1551.      *
  1552.      * @since 1.2
  1553.      * @access public
  1554.      * 
  1555.      * @param string $path - the source path of the image
  1556.      * @return array - array(width,height)
  1557.      */
  1558.     public function GetThumbnailSize($path)
  1559.     {
  1560.         $path = $this->CleanPath(str_replace(basename($path),'',$path)).basename($path);
  1561.         $img_data = @getimagesize($path);
  1562.         
  1563.         if (!$img_data)
  1564.         {
  1565.             return false;
  1566.         }
  1567.         
  1568.         $orig_width  = $img_data[0];
  1569.         $orig_height = $img_data[1];
  1570.         $aspectratio = $orig_width / $orig_height;
  1571.         
  1572.         $new_width  = floor(get_site_preference('thumbnail_width', 96));
  1573.         $new_height = floor(get_site_preference('thumbnail_height', 96));
  1574.         
  1575.         if($new_width <= 0)
  1576.         {
  1577.             $new_width = 96;
  1578.         }
  1579.         
  1580.         if($new_height <= 0)
  1581.         {
  1582.             $new_height = 96;
  1583.         }
  1584.         
  1585.         if($new_width > $orig_width) 
  1586.         {
  1587.             $new_width = $orig_width;
  1588.         }
  1589.         if($new_height > $orig_height) 
  1590.         {
  1591.             $new_height = $orig_height;
  1592.         }
  1593.         $new_aspectratio = $new_width / $new_height;
  1594.         
  1595.         if($aspectratio > 1 && $new_aspectratio < 1) 
  1596.         { // landscape to portrait
  1597.             $_tmp = floor($new_width / $aspectratio);
  1598.             if($_tmp > 0 && $_tmp <= $new_height)
  1599.             {
  1600.                 $new_height = $_tmp;
  1601.             }
  1602.         }
  1603.         else if($aspectratio < 1 && $new_aspectratio > 1) 
  1604.         { // portrait to landscape
  1605.             $_tmp = floor($new_height * $aspectratio);
  1606.             if($_tmp > 0 && $_tmp <= $new_width)
  1607.             {
  1608.                 $new_width = $_tmp;
  1609.             }
  1610.         }
  1611.         else 
  1612.         {
  1613.             if($new_aspectratio < $aspectratio) 
  1614.             {
  1615.                 $_tmp = floor($new_width / $aspectratio);
  1616.                 if($_tmp > 0 && $_tmp <= $new_height)
  1617.                 {
  1618.                     $new_height = $_tmp;
  1619.                 }
  1620.             }
  1621.             else if($new_aspectratio > $aspectratio) 
  1622.             {
  1623.                 $_tmp = floor($new_height * $aspectratio);
  1624.                 if($_tmp > 0 && $_tmp <= $new_width)
  1625.                 {
  1626.                     $new_width = $_tmp;
  1627.                 }
  1628.             }
  1629.         }
  1630.         
  1631.         if($new_width < 1)
  1632.         {
  1633.             $new_width = 1;
  1634.         }
  1635.         if($new_height < 1)
  1636.         {
  1637.             $new_height = 1;
  1638.         }
  1639.         return array($new_width, $new_height);
  1640.     }
  1641.     
  1642.     
  1643.     /**
  1644.      * Checks if a filename contains illegal chars<br />
  1645.      * Taken from TinyMCE Module.
  1646.      * @since 1.0
  1647.      * @access public
  1648.      * @param string $filename - the filename to check
  1649.      * @return boolean 
  1650.      */
  1651.     public function ContainsIllegalChars($filename) 
  1652.     {
  1653.         if (strpos($filename, '\'') !== false) return true;
  1654.         if (strpos($filename, '"' ) !== false) return true;
  1655.         if (strpos($filename, '/' ) !== false) return true;
  1656.         if (strpos($filename, '\\') !== false) return true;
  1657.         if (strpos($filename, '&' ) !== false) return true;
  1658.         if (strpos($filename, '\$') !== false) return true;
  1659.         if (strpos($filename, '+' ) !== false) return true;
  1660.         return false;
  1661.     }
  1662.     
  1663.     
  1664.     /**
  1665.      * Checks if a var is empty. <br />
  1666.      * If $var is an array it recursivley checks all elements.
  1667.      *
  1668.      * @since 1.0
  1669.      * @access public
  1670.      *
  1671.      * @param mixed &$var - the var to check for empty value(s)
  1672.      * @param boolean $trim - true to trim off spaces
  1673.      * @param boolean $unset_empty_indexes - true to delete empty elements from array
  1674.      * @return boolean - true if empty, false if not
  1675.      */
  1676.     public function IsVarEmpty(&$var, $trim = true, $unset_empty_indexes = false) 
  1677.     {
  1678.         if (is_array($var)) 
  1679.         {
  1680.             foreach ($var as $k=>$v) 
  1681.             {
  1682.                 if (!$this->IsVarEmpty($v)) 
  1683.                 {
  1684.                     return false;
  1685.                 }
  1686.                 
  1687.                 if($unset_empty_indexes)
  1688.                 {
  1689.                     unset($var[$k]);
  1690.                 }
  1691.                 return true;
  1692.             }
  1693.         }
  1694.         else if($trim && trim($var) == '') 
  1695.         {
  1696.             return true;
  1697.         }
  1698.         else if($var == '') 
  1699.         {
  1700.             return true;
  1701.         }
  1702.         return false;
  1703.     }
  1704.     
  1705.     
  1706.     /**
  1707.      * Removes empty elements from an array. <br />
  1708.      * (can be useful when using function explode to create the array from a csv)
  1709.      *
  1710.      * @since 1.0
  1711.      * @access public
  1712.      *
  1713.      * @param array $array - the array to clean up
  1714.      * @return array - an array without empty elements or an empty array
  1715.      */
  1716.     public function CleanArray($array)
  1717.     {
  1718.         if (is_array($array))
  1719.         {
  1720.             foreach ($array as $k=>$v)
  1721.             {
  1722.                 if ($this->IsVarEmpty($v,true,true))
  1723.                 {
  1724.                     unset($array[$k]);
  1725.                 }
  1726.                 else 
  1727.                 {
  1728.                     if(is_array($v))
  1729.                     {
  1730.                         $v = $this->CleanArray($v);
  1731.                         if($this->IsVarEmpty($v,true,true))
  1732.                         {
  1733.                             unset($array[$k]);
  1734.                         }
  1735.                         else
  1736.                         {
  1737.                             $array[$k] = $v;
  1738.                         }
  1739.                     }
  1740.                 }
  1741.             }
  1742.             return $array;
  1743.         }
  1744.         return array();
  1745.     }
  1746.     
  1747.     
  1748.     /**
  1749.      * Checks if a value is really meant to be "true". <br />
  1750.      * Can be usefull when checking smarty params for the value true
  1751.      *
  1752.      * @since 1.0
  1753.      * @access public
  1754.      *
  1755.      * @param mixed $value - the value to check
  1756.      * @return bool 
  1757.      */
  1758.     public function IsTrue($value)
  1759.     {
  1760.         return (strtolower($value) === 'true' || $value === 1 || $value === '1' || $value === true);
  1761.     }
  1762.     
  1763.     
  1764.     /**
  1765.      * Checks if a value is really meant to be "false". <br />
  1766.      * Can be usefull when checking smarty params for the value false
  1767.      *
  1768.      * @since 1.0
  1769.      * @access public
  1770.      *
  1771.      * @param mixed $value - the value to check
  1772.      * @return bool 
  1773.      */
  1774.     public function IsFalse($value)
  1775.     {
  1776.         return (strtolower($value) === 'false' || $value === '0' || $value === 0 || $value === false || $value === '');
  1777.     }
  1778.     
  1779.     
  1780.     /**
  1781.      * Indicates if GBFilePicker output is already done<br />
  1782.      * can be useful to avoid ouput of javascript and css twice
  1783.      *
  1784.      * @since 1.1
  1785.      * @access public
  1786.      *
  1787.      * @return bool - true if output done; false if not
  1788.      */
  1789.     public function Loaded()
  1790.     {
  1791.         return $this->_loaded;
  1792.     }
  1793.  
  1794. }
  1795. ?>

Documentation generated on Wed, 17 Nov 2010 11:59:41 +0100 by phpDocumentor 1.4.0a2