1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +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 $ * $Source: /cvs_backup/e107_0.8/e107_handlers/file_class.php,v $
* $Revision: 1.8 $ * $Revision: 1.9 $
* $Date: 2009-12-13 21:52:31 $ * $Date: 2010-01-16 14:17:10 $
* $Author: e107steved $ * $Author: secretr $
*/ */
if (!defined('e107_INIT')) { exit; } 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 'standard' or empty string - uses the standard exclude list
Otherwise a single directory name, or an array of names. Otherwise a single directory name, or an array of names.
$recurse_level - number of directory levels to search. $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). 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. 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 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) Directory filters look for an exact match (i.e. regex not supported)
Behaviour is slightly different to previous version: 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 $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'; var $finfo = 'default';
// Constructor // Constructor
function e_file() function __construct()
{ {
$this->setDefaults(); $this->setDefaults();
} }
@@ -68,18 +68,19 @@ class e_file
$this->dirFilter = array('/', 'CVS', '.svn'); // Default directory filter (exact matches only) $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) $this->fileFilter = array('^thumbs\.db$','^Thumbs\.db$','.*\._$','^\.htaccess$','^index\.html$','^null\.txt$','\.bak$','^.tmp'); // Default file filter (regex format)
} }
public function setFileInfo($val='default') public function setFileInfo($val='default')
{ {
$this->finfo = $val; $this->finfo = $val;
} }
/** /**
* * Read files from given path
* @param object $path *
* @param object $fmask [optional] * @param string $path
* @param object $omit [optional] * @param string $fmask [optional]
* @param object $recurse_level [optional] * @param string $omit [optional]
* @param integer $recurse_level [optional]
* @return array of file names/paths * @return array of file names/paths
*/ */
function get_files($path, $fmask = '', $omit='standard', $recurse_level = 0) function get_files($path, $fmask = '', $omit='standard', $recurse_level = 0)
@@ -144,39 +145,39 @@ class e_file
} }
} }
if($rejected == FALSE) 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': case 'fname':
$ret[] = $file; $ret[] = $file;
break; break;
case 'path': case 'path':
$ret[] = $path."/"; $ret[] = $path."/";
break; break;
case 'full': case 'full':
$ret[] = $path."/".$file; $ret[] = $path."/".$file;
break; break;
default: default:
if($this->finfo == 'all') 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['path'] = $path."/"; // important: leave this slash here and update other file instead.
$finfo['fname'] = $file; $finfo['fname'] = $file;
$ret[] = $finfo; $ret[] = $finfo;
break; break;
} }
} }
} }
}
}
} }
return $ret; return $ret;
} }
@@ -184,18 +185,18 @@ class e_file
function get_file_info($path_to_file) function get_file_info($path_to_file)
{ {
$finfo = array(); $finfo = array();
$tmp = getimagesize($path_to_file); $tmp = getimagesize($path_to_file);
$finfo['img-width'] = $tmp[0]; $finfo['img-width'] = $tmp[0];
$finfo['img-height'] = $tmp[1]; $finfo['img-height'] = $tmp[1];
$finfo['mime'] = $tmp['mime']; $finfo['mime'] = $tmp['mime'];
$tmp2 = stat($path_to_file); $tmp2 = stat($path_to_file);
$finfo['fsize'] = $tmp2['size']; $finfo['fsize'] = $tmp2['size'];
$finfo['modified'] = $tmp2['mtime']; $finfo['modified'] = $tmp2['mtime'];
return $finfo; return $finfo;
} }
@@ -279,4 +280,3 @@ class e_file
} }
} }
?>

View File

@@ -9,9 +9,9 @@
* Form Handler * Form Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
* $Revision: 1.113 $ * $Revision: 1.114 $
* $Date: 2010-01-12 17:25:20 $ * $Date: 2010-01-16 14:17:10 $
* $Author: e107coders $ * $Author: secretr $
* *
*/ */
@@ -445,10 +445,10 @@ class e_form
/** /**
* *
* @param object $name * @param string $name
* @param array $option_array * @param array $option_array
* @param object $selected [optional] * @param boolean $selected [optional]
* @param object $options [optional] * @param string|array $options [optional]
* @param boolean $defaultBlank [optional] set to TRUE if the first entry should be blank * @param boolean $defaultBlank [optional] set to TRUE if the first entry should be blank
* @return string HTML text for display * @return string HTML text for display
*/ */
@@ -463,13 +463,13 @@ class e_form
$text = $this->select_open($name, $options)."\n"; $text = $this->select_open($name, $options)."\n";
if(vartrue($options['default'])) if(vartrue($options['default']))
{ {
$text .= $this->option($options['default'],''); $text .= $this->option($options['default'],'');
} }
if(vartrue($defaultBlank)) if(vartrue($defaultBlank))
{ {
$text .= $this->option(' ',''); $text .= $this->option(' ','');
} }
$text .= $this->option_multi($option_array, $selected)."\n".$this->select_close(); $text .= $this->option_multi($option_array, $selected)."\n".$this->select_close();
@@ -1084,22 +1084,22 @@ class e_form
$query = http_build_query($query); $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;"; $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'])) if(varset($parms['deleteClass']))
{ {
$cls = (deftrue($parms['deleteClass'])) ? constant($parms['deleteClass']) : $parms['deleteClass']; $cls = (deftrue($parms['deleteClass'])) ? constant($parms['deleteClass']) : $parms['deleteClass'];
if(check_class($cls)) if(check_class($cls))
{ {
$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.' ]');
} }
} }
else 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'; //$attributes['type'] = 'text';
return $value; return $value;
@@ -1195,7 +1195,7 @@ class e_form
$toexpand = $value != $oldval; $toexpand = $value != $oldval;
} }
if($toexpand) if($toexpand)
{ {
// force hide! TODO - core style .expand-c (expand container) // 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>'; $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'?) 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']) switch($attributes['type'])
@@ -1365,13 +1365,13 @@ class e_form
case 'textarea': case 'textarea':
$text = ""; $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'; $attributes['readParms'] = 'bb=1';
$text = $this->renderValue($key, $value, $attributes).$this->hidden($key, $value).'<br />'; $text = $this->renderValue($key, $value, $attributes).$this->hidden($key, $value).'<br />';
$value = ""; $value = "";
} }
$text .= $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options']), varset($parms['counter'], false)); $text .= $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options']), varset($parms['counter'], false));
return $text; return $text;
break; break;
@@ -1394,19 +1394,19 @@ class e_form
break; break;
case 'datestamp': 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. // 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']))) if(vartrue($parms['auto']) && (($value == null) || vartrue($parms['hidden'])))
{ {
$value = time(); $value = time();
} }
if(vartrue($parms['hidden'])) if(vartrue($parms['hidden']))
{ {
return $this->hidden($key, $value); return $this->hidden($key, $value);
} }
return $this->datepicker($key, $value, $parms); return $this->datepicker($key, $value, $parms);
break; break;
@@ -1524,6 +1524,7 @@ class e_form
break; break;
case 'upload': //TODO - from method 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."}"); return $tp->parseTemplate("{UPLOADFILE=".e_UPLOAD."}");
break; break;
@@ -1637,8 +1638,8 @@ class e_form
$nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}"); $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
if ($nextprev) if ($nextprev)
{ {
$text .= "<div class='nextprev-bar'>".$nextprev."</div>"; $text .= "<div class='nextprev-bar'>".$nextprev."</div>";
} }
} }
$text .= " $text .= "