function _promoMethodList()
 {
     $conds = array();
     $methods = array();
     if (ShopConfig::load('promo.complexBehavior') || ShopConfig::load('promo.complexConditions')) {
         App::import('Lib', 'Shop.ClassCollection');
         $all = ClassCollection::getList('promo', 'flat');
         foreach ($all as $name => $label) {
             $class = ClassCollection::getClass('promo', $name);
             if (!method_exists($class, 'isAvailable') || call_user_func(array($class, 'isAvailable'))) {
                 $obj = new $class();
                 if (method_exists($class, 'beforeForm')) {
                     $obj->beforeForm($this);
                 }
                 if (!empty($obj->type) && ($obj->type = 'condition')) {
                     $conds[$name] = $obj;
                 } else {
                     $methods[$name] = $obj;
                 }
             }
         }
     }
     if (!ShopConfig::load('promo.complexConditions')) {
         $conds = array();
     }
     if (!ShopConfig::load('promo.complexBehavior')) {
         App::import('Lib', 'Shop.ClassCollection');
         $class = ClassCollection::getClass('promo', 'Shop.operation');
         $obj = new $class();
         $methods = array('Shop.operation' => $obj);
     }
     return array('methods' => $methods, 'conds' => $conds);
 }
 function getType($cond = null, $Model = null)
 {
     if (is_null($cond)) {
         $cond = $this->data;
     }
     App::import('Lib', 'CustomFilter.ClassCollection');
     if (empty($Model)) {
         $Model = $this->CustomFilter->getFilteredModel($cond);
     }
     $FilterType = null;
     $type = !empty($cond[$this->alias]['type']) ? $cond[$this->alias]['type'] : null;
     if (!$type) {
         $toCheck = ClassCollection::getList('FilterType', array('hasMethod' => 'detect'));
         foreach ($toCheck as $ttype) {
             if ($TestFilterType = ClassCollection::getObject('FilterType', $ttype, array($cond, $Model))) {
                 if ($TestFilterType->detect()) {
                     $FilterType = $TestFilterType;
                     $type = $ttype;
                 }
             }
         }
         if (!$type) {
             $schema = $Model->schema($cond[$this->alias]['field']);
             $type = $schema['type'];
         }
     }
     if (empty($FilterType)) {
         $FilterType = ClassCollection::getObject('FilterType', $type, array($cond, $Model));
     }
     return $FilterType;
 }
Пример #3
0
 function handlersList($includeSpecial = true)
 {
     App::import('Lib', 'ClassCollection');
     $handlers = ClassCollection::getList("handler", true);
     if ($includeSpecial) {
         $specials = $this->specialHandlersList();
         $handlers = array_merge($specials, $handlers);
     }
     return $handlers;
 }
Пример #4
0
 function getOperations()
 {
     $operations = array();
     if (is_null($this->defOps)) {
         $schema = $this->Model->schema($this->fieldname);
         if (in_array($schema['type'], array('string', 'text'))) {
             $this->defOps = array('Equals', 'Contains', 'Starts', 'Ends');
         } else {
             $this->defOps = array('Equals', 'Bigger', 'Smaller', 'Between');
         }
     }
     if (!empty($this->defOps)) {
         foreach ($this->defOps as $type) {
             $FilterOperation = ClassCollection::getObject('FilterOperation', $type, array($this));
             $operations[$type] = $FilterOperation;
         }
     }
     $toCheck = ClassCollection::getList('FilterOperation', array('hasMethod' => 'detect'));
     foreach ($toCheck as $type) {
         if (empty($operations[$type])) {
             $FilterOperation = ClassCollection::getObject('FilterOperation', $type, array($this));
             $operations[$type] = $FilterOperation;
         }
     }
     return $operations;
 }