Exemple #1
0
 /**
  *
  * @param string $name
  * @param Ajde_Shop_Transaction $transaction
  * @return Ajde_Shop_Transaction_Provider
  * @throws Ajde_Exception 
  */
 public static function getProvider($name, $transaction = null)
 {
     $providerClass = ExternalLibs::getClassname('Ajde_Shop_Transaction_Provider_' . self::classnameToUppercase($name));
     if (!Autoloader::exists($providerClass)) {
         // TODO:
         throw new Exception('Payment provider ' . $name . ' not found');
     }
     $obj = new $providerClass();
     if ($transaction) {
         $obj->setTransaction($transaction);
     }
     return $obj;
 }
Exemple #2
0
 public static function purify($var)
 {
     $external = 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);
     }
 }
Exemple #3
0
 public function createField($fieldOptions)
 {
     if (!isset($fieldOptions['type'])) {
         $fieldOptions['type'] = 'text';
     }
     $fieldClass = 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;
 }