Пример #1
0
 /**
  * Return render value
  * (non-PHPdoc)
  * @see \Engine\Crud\Grid\Column::render()
  * @param mixed $row
  * @return string
  */
 public function render($row)
 {
     if ($this->_template) {
         $image = \Engine\Tools\String::generateStringTemplate($this->_template, $row, '{', '}');
     } else {
         $image = $this->_empty;
     }
     return $this->createImage($image);
 }
Пример #2
0
 /**
  * Return render value
  * (non-PHPdoc)
  * @see \Engine\Crud\Grid\Column::render()
  * @param mixed $row
  * @return string
  */
 public function render($row)
 {
     $attribs = $this->getAttribs();
     $href = \Engine\Tools\String::generateStringTemplate($this->_template, $row, '{', '}');
     $code = '<a href="' . $href . '"';
     foreach ($attribs as $name => $value) {
         $code .= ' ' . $name . '="' . $value . '"';
     }
     $title = \Engine\Tools\String::generateStringTemplate($this->_templateTitle, $row, '{', '}');
     $code .= '><span>' . $title . '</span></a>';
     return $code;
 }
Пример #3
0
 /**
  * (non-PHPdoc)
  * @see Crud\Form\Field.Field::getRenderValue()
  */
 public function getRenderValue()
 {
     $value = $this->getValue();
     $values = $this->_form->getData();
     $source = \Engine\Tools\String::generateStringTemplate($this->_renderTemplate, $values, '{', '}');
     if ($source === false) {
         return $value;
     }
     $values = $this->_form->getRenderData();
     $label = \Engine\Tools\String::generateStringTemplate($this->_labelTemplate, $values, '{' . '}');
     $class = $this->getAttrib('class');
     $xhtml = $this->createImage($source, $label, $class);
     return $xhtml;
 }
Пример #4
0
 /**
  * Return decrypt password
  *
  * @return string
  */
 public function getDecryptValue()
 {
     //Create an instance
     $crypt = new \Phalcon\Crypt();
     $crypt->setCipher($this->_cryptType);
     $key = \Engine\Tools\String::generateStringTemplate($this->_keyTemplate, $this->_form->getData(), '{', '}');
     $value = $this->_value;
     return $crypt->decryptBase64($value, $key);
 }
Пример #5
0
 /**
  * Generate form item link from link template
  *
  * @return string
  */
 public function getLink()
 {
     if (!$this->_linkTemplate) {
         return false;
     }
     return \Engine\Tools\String::generateStringTemplate($this->_linkTemplate, $this->getData(), "{", "}");
 }
Пример #6
0
 /**
  * After save field trigger
  *
  * @param array $data
  */
 public function postSaveAction(array $data)
 {
     $key = $this->getKey();
     if (empty($_FILES) || !isset($_FILES[$key]) || !empty($_FILES[$key]['error'])) {
         return false;
     }
     $fullName = $this->_template;
     if (!$fullName) {
         $file = explode(".", $_FILES[$key]['name']);
         $fullName = $file[0];
     }
     if (strpos($fullName, '{sha}') !== false) {
         $file_hash_name = $this->sha1 ? $this->sha1($this->getId()) : $this->getId();
         $fullName = str_replace('{sha}', $file_hash_name, $fullName);
     }
     $uploadDirectory = rtrim(\Engine\Tools\String::generateStringTemplate($this->_uploadDirectory, $data, '{', '}'), "/)");
     $fullName = \Engine\Tools\String::generateStringTemplate($fullName, $data, '{', '}');
     $fileType = strtolower(end(explode(".", $_FILES[$key]['name'])));
     $fullName = $fullName . '.' . $fileType;
     $zend_upload_dir = $uploadDirectory;
     $fullName = $uploadDirectory . '/' . $fullName;
     $pathinfo = pathinfo($fullName);
     $uploadDirectory = $pathinfo['dirname'];
     $fileName = $pathinfo['basename'];
     /* Debuger: */
     /*
      echo '$fileType = '.$fileType."\n";
      echo '$this->fileName = '.$this->fileName."\n";
      echo '$this->uploadDirectory = '.$this->uploadDirectory."\n";
      echo '$fullName = '.$fullName."\n";
      exit;
     */
     if (!is_dir($uploadDirectory)) {
         mkdir($uploadDirectory, 0755, true);
     }
     if (file_exists($fullName)) {
         unlink($fullName);
     }
     if (is_uploaded_file($_FILES[$key]['tmp_name'])) {
         $result = move_uploaded_file($_FILES[$key]['tmp_name'], $fullName);
     } elseif (is_file($zend_upload_dir . '/' . $_FILES[$key]['name'])) {
         $result = rename($zend_upload_dir . '/' . $_FILES[$key]['name'], $fullName);
     }
     $def_data = [$this->_name => $fileName];
     $container = $this->_form->getContainer();
     $result = $container->update($this->_id, $def_data);
     $_FILES[$key]['name'] = $fileName;
 }