27 $required = array_key_exists(
'required', $this->cfg->valid) && $this->cfg->getInArray(
'valid',
'required');
30 $this->keep = $htVars->getVar($this->name.
'NyroKeep');
34 $prm = array_merge($this->cfg->fileUploadedPrm, array(
35 'name'=>$this->cfg->name,
36 'current'=>$this->cfg->value,
37 'helper'=>$this->cfg->helper,
38 'helperPrm'=>$this->cfg->helperPrm,
43 $prm[
'dir'] = $this->cfg->dir;
44 if ($this->cfg->subdir)
45 $prm[
'subdir'] = $this->cfg->subdir;
47 $this->cfg->value =
factory::get(
'form_fileUploaded', $prm);
49 if ($this->cfg->autoDeleteOnGet && !$this->cfg->value->isSaved(
true) && $htVars->getVar($this->name.
'NyroDel')) {
50 $this->cfg->value->delete();
51 $this->deleted =
true;
54 $this->cfg->valid = array_merge($this->cfg->valid, array(
55 'callback'=>array($this->cfg->value,
'isValid')
62 $this->cfg->classLine.=
' fileError';
66 return $this->cfg->value->getCurrent();
69 public function setValue($value, $refill =
false) {
70 if (!$this->deleted && !$refill) {
71 if ($value || !$this->keep)
72 $this->cfg->value->setCurrent($value, $refill);
83 public function uploadify(array $opt = array(), $hideSubmit =
true) {
85 $resp->addJs(
'jquery');
86 $resp->addJs(
'swfobject');
87 $resp->addJs(
'uploadify');
88 $resp->addCss(
'uploadify');
90 $uploadifyOpt = array_merge(array(
91 'fileDataName'=>$this->name
92 ), $this->cfg->uploadify, $opt);
95 $uploadifyOpt[
'scriptAccess'] =
'always';
97 $resp->blockjQuery(
'$("#'.$this->
id.
'").uploadify('.
utils::jsEncode($uploadifyOpt).
');');
99 $resp->blockjQuery(
'$("#'.$this->
id.
'").closest("form").find("fieldset.submit").hide();');
109 public function plupload(array $opts = array(), $hideSubmit =
true) {
111 $resp->addJs(
'jquery');
112 $resp->addJs(
'plupload');
113 $resp->addJs(
'nyroPlupload');
114 $resp->addCss(
'plupload');
116 $pluploadOpts = $this->cfg->plupload;
119 $pluploadOpts[
'file_data_name'] = $this->name;
121 $resp->blockjQuery(
'$("#'.$this->
id.
'").nyroPlupload('.
utils::jsEncode($pluploadOpts).
');');
123 $resp->blockjQuery(
'$("#'.$this->
id.
'").closest("form").find("fieldset.submit").hide();');
127 if ($this->cfg->mode ==
'view')
128 return $this->cfg->value->getView();
130 $start = $end = null;
131 if ($this->cfg->showPreview || $this->cfg->showDelete) {
132 $start =
'<'.$this->cfg->htmlWrap.
'>';
133 if ($this->cfg->value->getCurrent()) {
134 $end.=
'<input type="hidden" name="'.$this->name.
'NyroKeep" value="'.$this->cfg->value->getCurrent().
'" />';
136 if ($this->cfg->showDelete) {
137 $end.=
'<a href="#" class="deleteFile" id="'.$this->id.
'NyroDel">'.$this->cfg->deleteLabel.
'</a>';
139 $("#'.$this->
id.
'NyroDel").click(function(e) { 141 $(this).parent("span").replaceWith("<input type=\"hidden\" name=\"'.$this->name.
'NyroDel\" value=\"1\" />"); 145 if ($this->cfg->showPreview)
146 $end.= $this->cfg->value->getView();
149 $end.=
'</'.$this->cfg->htmlWrap.
'>';
151 return $start.utils::htmlTag($this->htmlTagName,
152 array_merge($this->html, array(
160 array_merge($this->xul, array(
static htmlTag($tag, array $attributes, $content=null)
static mergeCfg(array &$prm, array $cfg)
static get($className, array $cfg=array())