Ejemplo n.º 1
0
 /**
  * A convenience function to create a list of filenames in a specified directory.
  *
  * @deprecated
  * @param string $id The module action id
  * @param string $name the name for the dropdown.
  * @param string $selectedfile The initial value for the dropdown (an image filename)
  * @param string $dir The path (relative to the uploads path) to the directory to pull images from.  If not specified, the image uploads path will be used.
  * @param string $extensions A comma separated list of filename extensions to include in the list.  If not specified the module preference will be used.
  * @param bool   $allownone Allow no files to be selected.
  * @param bool   $allowmultiple To allow selecting multiple files.
  * @param int    $size The size of the dropdown.
  * @return string.
  */
 function CreateFileDropdown($id, $name, $selectedfile = '', $dir = '', $extensions = '', $allownone = '', $allowmultiple = false, $size = 3)
 {
     $config = cms_config::get_instance();
     if ($dir == '') {
         $dir = $config['uploads_path'];
     } else {
         while (startswith($dir, '/') && $dir != '') {
             $dir = substr($dir, 1);
         }
         $dir = $config['uploads_path'] . $dir;
     }
     if ($extensions == '') {
         $extensions = $this->GetPreference('fileextensions', '');
     }
     $tmp = cge_dir::get_file_list($dir, $extensions);
     $tmp2 = array();
     if (!empty($allownone)) {
         $cge = \cms_utils::get_module(MOD_CGEXTENSIONS);
         $tmp2[$cge->Lang('none')] = '';
     }
     $filelist = array_merge($tmp2, $tmp);
     if ($allowmultiple) {
         if (!endswith($name, '[]')) {
             $name .= '[]';
         }
         return $this->CreateInputSelectList($id, $name, $filelist, array(), $size);
     }
     return $this->CreateInputDropdown($id, $name, $filelist, -1, $selectedfile);
 }
 function CreateFileDropdown($id, $name, $selectedfile = '', $dir = '', $extensions = '', $allownone = '', $allowmultiple = false, $size = 3)
 {
     $config = cmsms()->GetConfig();
     if ($dir == '') {
         $dir = $config['uploads_path'];
     }
     if ($extensions == '') {
         $extensions = $this->GetPreference('fileextensions', '');
     }
     $tmp = cge_dir::get_file_list($dir, $extensions);
     $tmp2 = array();
     if (!empty($allownone)) {
         $tmp2[$this->Lang('none')] = '';
     }
     $filelist = array_merge($tmp2, $tmp);
     if ($allowmultiple) {
         if (!endswith($name, '[]')) {
             $name .= '[]';
         }
         return $this->CreateInputSelectList($id, $name, $filelist, array(), $size);
     }
     return $this->CreateInputDropdown($id, $name, $filelist, -1, $selectedfile);
 }