1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

file/form handlers minor update

This commit is contained in:
secretr
2010-01-16 14:17:10 +00:00
parent 3bcad4475e
commit e9c6e7a5c4
2 changed files with 61 additions and 60 deletions

View File

@@ -9,9 +9,9 @@
*
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/file_class.php,v $
* $Revision: 1.8 $
* $Date: 2009-12-13 21:52:31 $
* $Author: e107steved $
* $Revision: 1.9 $
* $Date: 2010-01-16 14:17:10 $
* $Author: secretr $
*/
if (!defined('e107_INIT')) { exit; }
@@ -30,7 +30,7 @@ get_files() is the usual entry point.
'standard' or empty string - uses the standard exclude list
Otherwise a single directory name, or an array of names.
$recurse_level - number of directory levels to search.
If the standard file or directory filter is unacceptable in a special application, the relevant variable can be set to an empty array (emphasis - ARRAY).
setDefaults() restores the defaults - preferable to setting using a 'fixed' string. Can be called prior to using the class without knowledge of what went before.
@@ -40,7 +40,7 @@ get_dirs() returns a list of the directories in a specified directory (no recurs
rmtree() attempts to remove a complete directory tree, including the files it contains
Note:
Note:
Directory filters look for an exact match (i.e. regex not supported)
Behaviour is slightly different to previous version:
$omit used to be applied to just files (so would recurse down a tree even if no files match) - now used for directories
@@ -57,7 +57,7 @@ class e_file
var $finfo = 'default';
// Constructor
function e_file()
function __construct()
{
$this->setDefaults();
}
@@ -68,18 +68,19 @@ class e_file
$this->dirFilter = array('/', 'CVS', '.svn'); // Default directory filter (exact matches only)
$this->fileFilter = array('^thumbs\.db$','^Thumbs\.db$','.*\._$','^\.htaccess$','^index\.html$','^null\.txt$','\.bak$','^.tmp'); // Default file filter (regex format)
}
public function setFileInfo($val='default')
{
$this->finfo = $val;
$this->finfo = $val;
}
/**
*
* @param object $path
* @param object $fmask [optional]
* @param object $omit [optional]
* @param object $recurse_level [optional]
* Read files from given path
*
* @param string $path
* @param string $fmask [optional]
* @param string $omit [optional]
* @param integer $recurse_level [optional]
* @return array of file names/paths
*/
function get_files($path, $fmask = '', $omit='standard', $recurse_level = 0)
@@ -144,39 +145,39 @@ class e_file
}
}
if($rejected == FALSE)
{
switch($this->mode) //TODO remove this check from the loop.
{
switch($this->mode) //TODO remove this check from the loop.
{
case 'fname':
$ret[] = $file;
break;
case 'path':
$ret[] = $path."/";
break;
break;
case 'full':
$ret[] = $path."/".$file;
break;
break;
default:
if($this->finfo == 'all')
{
$finfo = $this->get_file_info($path."/".$file);
$finfo = $this->get_file_info($path."/".$file);
}
$finfo['path'] = $path."/"; // important: leave this slash here and update other file instead.
$finfo['fname'] = $file;
$finfo['fname'] = $file;
$ret[] = $finfo;
break;
}
}
}
}
}
}
}
return $ret;
}
@@ -184,18 +185,18 @@ class e_file
function get_file_info($path_to_file)
{
$finfo = array();
$tmp = getimagesize($path_to_file);
$finfo['img-width'] = $tmp[0];
$finfo['img-height'] = $tmp[1];
$finfo['mime'] = $tmp['mime'];
$tmp2 = stat($path_to_file);
$finfo['fsize'] = $tmp2['size'];
$finfo['modified'] = $tmp2['mtime'];
return $finfo;
return $finfo;
}
@@ -279,4 +280,3 @@ class e_file
}
}
?>

View File

@@ -9,9 +9,9 @@
* Form Handler
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
* $Revision: 1.113 $
* $Date: 2010-01-12 17:25:20 $
* $Author: e107coders $
* $Revision: 1.114 $
* $Date: 2010-01-16 14:17:10 $
* $Author: secretr $
*
*/
@@ -445,10 +445,10 @@ class e_form
/**
*
* @param object $name
* @param string $name
* @param array $option_array
* @param object $selected [optional]
* @param object $options [optional]
* @param boolean $selected [optional]
* @param string|array $options [optional]
* @param boolean $defaultBlank [optional] set to TRUE if the first entry should be blank
* @return string HTML text for display
*/
@@ -463,13 +463,13 @@ class e_form
$text = $this->select_open($name, $options)."\n";
if(vartrue($options['default']))
{
{
$text .= $this->option($options['default'],'');
}
if(vartrue($defaultBlank))
{
$text .= $this->option(' ','');
$text .= $this->option(' ','');
}
$text .= $this->option_multi($option_array, $selected)."\n".$this->select_close();
@@ -1084,22 +1084,22 @@ class e_form
$query = http_build_query($query);
$value = "<a href='".e_SELF."?{$query}' title='".LAN_EDIT."'><img class='icon action edit' src='".ADMIN_EDIT_ICON_PATH."' alt='".LAN_EDIT."' /></a>&nbsp;";
if(varset($parms['deleteClass']))
{
$cls = (deftrue($parms['deleteClass'])) ? constant($parms['deleteClass']) : $parms['deleteClass'];
if(check_class($cls))
{
$value .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]');
}
}
}
else
{
$value .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]');
$value .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]');
}
}
//$attributes['type'] = 'text';
return $value;
@@ -1195,7 +1195,7 @@ class e_form
$toexpand = $value != $oldval;
}
if($toexpand)
{
{
// force hide! TODO - core style .expand-c (expand container)
$value .= '<div class="expand-c" style="display: none" id="'.$elid.'-expand"><div>'.str_replace($truncated,' ',$oldval).'</div></div>';
}
@@ -1338,7 +1338,7 @@ class e_form
if(vartrue($attributes['readonly']) && vartrue($value)) // quick fix (maybe 'noedit'=>'readonly'?)
{
return $this->renderValue($key, $value, $attributes).$this->hidden($key, $value); //
return $this->renderValue($key, $value, $attributes).$this->hidden($key, $value); //
}
switch($attributes['type'])
@@ -1365,13 +1365,13 @@ class e_form
case 'textarea':
$text = "";
if($parms['append']) // similar to comments - TODO TBD. a 'comment' field type may be better.
if($parms['append']) // similar to comments - TODO TBD. a 'comment' field type may be better.
{
$attributes['readParms'] = 'bb=1';
$text = $this->renderValue($key, $value, $attributes).$this->hidden($key, $value).'<br />';
$value = "";
}
$text .= $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options']), varset($parms['counter'], false));
return $text;
break;
@@ -1394,19 +1394,19 @@ class e_form
break;
case 'datestamp':
// If hidden, value is updated regardless. eg. a 'last updated' field.
// If hidden, value is updated regardless. eg. a 'last updated' field.
// If not hidden, and there is a value, it is retained. eg. during the update of an existing record.
// otherwise it is added. eg. during the creation of a new record.
// otherwise it is added. eg. during the creation of a new record.
if(vartrue($parms['auto']) && (($value == null) || vartrue($parms['hidden'])))
{
$value = time();
$value = time();
}
if(vartrue($parms['hidden']))
{
return $this->hidden($key, $value);
}
return $this->datepicker($key, $value, $parms);
break;
@@ -1524,6 +1524,7 @@ class e_form
break;
case 'upload': //TODO - from method
// TODO uploadfile SC is now processing uploads as well (add it to admin UI), write/readParms have to be added (see uploadfile.php parms)
return $tp->parseTemplate("{UPLOADFILE=".e_UPLOAD."}");
break;
@@ -1637,8 +1638,8 @@ class e_form
$nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
if ($nextprev)
{
$text .= "<div class='nextprev-bar'>".$nextprev."</div>";
}
$text .= "<div class='nextprev-bar'>".$nextprev."</div>";
}
}
$text .= "