48                 $this->dir = $this->cfg->dir;
    49                 if ($this->cfg->subdir) {
    50                         $this->subdir = $this->cfg->subdir.DS;
    56                 if (strpos($this->cfg->name, 
'[')) {
    57                         $tmp = explode(
'[', str_replace(
']', 
'', $this->cfg->name));
    59                         if (!empty($tmpfile) && is_array($tmpfile)) {
    60                                 $this->
file = $tmpfile;
    61                                 $this->
file[
'saved'] = 
false;
    62                                 $uploaded = $this->
file[
'error'] == UPLOAD_ERR_OK;
    64                 } 
else if (array_key_exists($this->cfg->name, $_FILES)) {
    65                         $this->
file = $_FILES[$this->cfg->name];
    66                         $this->
file[
'saved'] = 
false;
    67                         $uploaded = $this->
file[
'error'] == UPLOAD_ERR_OK;
    69                 if ($this->cfg->current && !$uploaded) {
    70                         $name = basename($this->cfg->current);
    71                         $savePath = $this->dir.$name;
    72                         $webPath = str_replace(
DS, 
'/', $this->subdir.$name);
    77                                 'error'=>UPLOAD_ERR_OK,
    81                                         'savePath'=>$savePath,
    84                                 'savedFromValue'=>
true    86                         $this->saved = $webPath;
    93                 if ($this->cfg->autoSave && !empty($this->
file) && $this->
isValid() === 
true)
   114                 $tmp = $this->cfg->getInArray(
'helperPrm', $name);
   115                 return is_array($tmp)? $tmp : array();
   126         protected function callHelper($fct, $filename = null, $defRet = 
true) {
   127                 $callback = array($this->helper, $fct);
   128                 if ($this->helper && is_callable($callback))
   129                         return call_user_func($callback, $filename, $this->
getHelperPrm($fct));
   138                 if (!$this->
file[
'saved'] && $this->
isValid() === 
true) {
   140                         $savePath = $this->dir.$name;
   141                         if (move_uploaded_file($this->
file[
'tmp_name'], $savePath)) {
   142                                 $tmpName = $this->
callHelper(
'upload', $savePath);
   143                                 if ($tmpName && !is_bool($tmpName)) {
   145                                         $savePath = $this->dir.$tmpName;
   147                                 $webPath = str_replace(
DS, 
'/', $this->subdir.$name);
   148                                 $this->
file[
'saved'] = array(
   150                                         'savePath'=>$savePath,
   153                                 if ($this->cfg->deleteCurrent && ($current = $this->getCurrent())
   154                                                 && str_replace(
'/', 
DS, $savePath) != str_replace(
'/', 
DS, $this->cfg->dir.$current)
   155                                                 && (!array_key_exists(
'webPath', $this->
file) || $current != $this->
file[
'webPath'])) {
   160                                 $this->saved = $webPath;
   180                 return $this->saved? $this->saved : $this->cfg->current;
   190                 if (
$file || !$refill)
   191                         $this->cfg->current = 
$file;
   202                         if (!$ret = $this->
callHelper(
'view', $current, null))
   203                                 $ret = 
utils::htmlTag(
'a', array_merge($this->cfg->previewPrm, array(
'href'=>
request::uploadedUri($current))), $this->cfg->previewText ? $this->cfg->previewText : basename($current));
   213         public function isSaved($fromRequest = 
false) {
   214                 $ret = array_key_exists(
'saved', $this->
file) && $this->
file[
'saved'];
   215                 if ($ret && $fromRequest)
   216                         $ret = !(isset($this->
file[
'savedFromValue']) && $this->
file[
'savedFromValue']);
   225         public function delete() {
   228                 if ($current && strpos($current, $this->cfg->dir) === 
false)
   229                         $current = $this->cfg->dir.$current;
   235                 $this->saved = 
false;
   247                         (array_key_exists(
'error', 
$file) && 
$file[
'error'] === 0
   248                         && array_key_exists(
'size', 
$file) && 
$file[
'size'] > 0);
   250                 return $tmp? (is_bool($helperValid) ? $helperValid : $helperValid) : ($this->cfg->required ? 
'required' : 
true);
   264                 $initName = substr($name, 0, -strlen($ext));
   267                         $name = $initName.
'-'.$i.$ext;
 
static urlify($text, $ignore=null)
 
static htmlTag($tag, array $attributes, $content=null)
 
if(!defined('NYROROOT')) define('NYROROOT' ROOT DS
 
static getHelper($className, array $cfg=array())
 
static uploadedUri($file, array $prm=array())
 
static createDir($path, $chmod=0777)
 
static isCreable($className)
 
static getValInArray(array $source, array $keys)