Exemple #1
0
 /**
  * @param $xml
  * @return mixed
  */
 public function execBlock($xml)
 {
     $errors = array();
     $submit = false;
     $values = $this->request->getGPAsArray();
     if ($this->request->post('mailform')) {
         $submit = true;
         $required = $values['required'];
         $fields = $values['field'];
         $this->validation->setData($fields);
         $this->validation->addRule('email', 'email');
         $errorMessages = array();
         foreach ($required as $field => $val) {
             $this->validation->addRule($field, 'notEmpty');
             $errorMessages = array_merge($errorMessages, array($field => array($field => $this->translation->getTranslation('Please fill out the field'))));
         }
         $this->validation->setErrorMessages($errorMessages);
         $check = $this->validation->check();
         if ($check === true) {
             $msg = $this->mail->getMessageInstance();
             $msg->setFrom(array($fields['email']));
             $msg->setSubject($this->config->get('MAILFORM_SUBJECT')->value);
             $msg->setTo(explode(',', $this->config->get('MAILFORM_TO')->value));
             $this->template->assign('fields', $fields);
             $msg->setBody($this->template->fetch('Extension/Mailform/Mail'), 'text/html');
             $this->mail->send();
         } else {
             $errors = $check;
         }
     }
     $this->mailformController->renderHtml($submit, $values, $errors);
 }
Exemple #2
0
 /**
  * @param $filename
  * @param string $ext
  * @return string
  */
 protected function getImageSavePath($filename, $ext = 'jpg')
 {
     $convertedImageFileName = trim($this->config->get('IMAGE_PATH')->value, '/');
     if (!is_dir('Public' . DIRECTORY_SEPARATOR . $convertedImageFileName)) {
         mkdir('Public' . DIRECTORY_SEPARATOR . $convertedImageFileName, 0755, true);
     }
     $convertedImageFileName .= DIRECTORY_SEPARATOR . $filename . '.' . $ext;
     return 'Public' . DIRECTORY_SEPARATOR . trim($this->fileManager->convertDirSeparator($convertedImageFileName), '/');
 }
Exemple #3
0
 /**
  * @return array
  */
 public function getStorages()
 {
     $config = $this->config->get('FILEMANAGER_STORAGES')->value;
     $storages = explode(',', $config);
     $storagesGroup = [];
     foreach ($storages as $path) {
         $key = basename($path);
         if (is_dir($path)) {
             if (!isset($storagesGroup[$key])) {
                 $storagesGroup[$key] = [];
             }
             $storagesGroup[$key]['path'] = $path;
             $storagesGroup[$key]['storage'] = md5($path);
             $storagesGroup[$key]['isRelative'] = substr($path, 0, 1) === '/' ? false : true;
         }
     }
     return $storagesGroup;
 }
Exemple #4
0
 /**
  * @return \Fraym\Registry\Entity\text|string
  */
 protected function getTemplatePath()
 {
     $config = $this->config->get('DYNAMIC_TEMPLATE_PATH');
     if (!empty($config->value)) {
         $path = $config->value;
     } else {
         $path = $this->template->getTemplateDir() . DIRECTORY_SEPARATOR . 'Dynamic';
     }
     return $path;
 }
Exemple #5
0
 /**
  * @param $key
  * @param $value
  * @param $locale
  * @param string $defaultLocale
  * @return Entity\Translation
  */
 public function createTranslation($key, $value, $locale, $defaultLocale = 'en_US')
 {
     $em = $this->db;
     $translation = $this->db->getRepository('\\Fraym\\Translation\\Entity\\Translation')->findOneByKey($key);
     if ($translation === null) {
         $translation = new \Fraym\Translation\Entity\Translation();
         $translation->key = $key;
         $translation->value = $value;
         $translation->locale = $defaultLocale;
     }
     if ($locale != $defaultLocale && $this->config->get('TRANSLATION_AUTO')->value == '1') {
         $value = $this->autoTranslation($value, $defaultLocale, $locale);
         $repository = $em->getRepository('Gedmo\\Translatable\\Entity\\Translation');
         $repository->translate($translation, 'value', $locale, $value);
     }
     $em->persist($translation);
     $em->flush();
     return $translation;
 }