Example #1
0
 /**
  * @param string                $name
  * @param Ajde_Shop_Transaction $transaction
  *
  * @throws Ajde_Exception
  *
  * @return Ajde_Shop_Transaction_Provider
  */
 public static function getProvider($name, $transaction = null)
 {
     $providerClass = Ajde_Core_ExternalLibs::getClassname('Ajde_Shop_Transaction_Provider_' . self::classnameToUppercase($name));
     if (!class_exists($providerClass)) {
         // TODO:
         throw new Ajde_Exception('Payment provider ' . $name . ' not found');
     }
     $obj = new $providerClass();
     if ($transaction) {
         $obj->setTransaction($transaction);
     }
     return $obj;
 }
Example #2
0
 public static function purify($var)
 {
     $external = Ajde_Core_ExternalLibs::getInstance();
     if ($external->has('HTMLPurifier')) {
         $purifier = $external->get('HTMLPurifier');
         /* @var $purifier HTMLPurifier */
         $config = HTMLPurifier_Config::createDefault();
         $config->set('AutoFormat.AutoParagraph', true);
         $config->set('AutoFormat.DisplayLinkURI', false);
         $config->set('AutoFormat.Linkify', false);
         $config->set('AutoFormat.RemoveEmpty', true);
         $config->set('AutoFormat.RemoveSpansWithoutAttributes', true);
         $config->set('CSS.AllowedProperties', '');
         $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
         $config->set('URI.DisableExternalResources', true);
         $purifier->config = HTMLPurifier_Config::create($config);
         return $purifier->purify($var);
     } else {
         return self::clean($var);
     }
 }
Example #3
0
File: Crud.php Project: nabble/ajde
 public function createField($fieldOptions)
 {
     if (!isset($fieldOptions['type'])) {
         $fieldOptions['type'] = 'text';
     }
     $fieldClass = Ajde_Core_ExternalLibs::getClassname('Ajde_Crud_Field_' . ucfirst($fieldOptions['type']));
     $field = new $fieldClass($this, $fieldOptions);
     if ($this->getOperation() === 'edit') {
         if (!$field->hasValue() || $field->hasEmpty('value')) {
             if ($this->isNew() && $field->hasNotEmpty('default')) {
                 $field->setValue($field->getDefault());
             } elseif (!$this->isNew() && $this->getItem()->has($field->getName())) {
                 $field->setValue($this->getItem()->get($field->getName()));
             } else {
                 $field->setValue(false);
             }
         }
     }
     return $field;
 }
Example #4
0
 public function getFields()
 {
     if (!isset($this->_fields)) {
         $model = $this->getModel();
         $item = $this->getItem();
         $fields = array();
         $fieldsArray = $model->getTable()->getFieldProperties();
         $parents = $item->getTable()->getParents();
         foreach ($fieldsArray as $fieldProperties) {
             $fieldOptions = $this->getFieldOptions($fieldProperties['name'], $fieldProperties);
             if (in_array($fieldOptions['name'], $parents)) {
                 $fieldOptions['type'] = 'fk';
             }
             $fieldClass = Ajde_Core_ExternalLibs::getClassname("Ajde_Crud_Field_" . ucfirst($fieldOptions['type']));
             $field = new $fieldClass($this, $fieldOptions);
             if ($this->getOperation() === 'edit') {
                 if (!$field->hasValue() || $field->hasEmpty('value')) {
                     if ($this->isNew() && $field->hasNotEmpty('default')) {
                         $field->setValue($field->getDefault());
                     } elseif (!$this->isNew()) {
                         $field->setValue($item->get($field->getName()));
                     } else {
                         $field->setValue(false);
                     }
                 }
             }
             $fields[$field->getName()] = $field;
         }
         $this->_fields = $fields;
     }
     return $this->_fields;
 }