예제 #1
0
 function _subProductsFields($types, $prefix = 'ShopSubproduct.')
 {
     App::import('Lib', 'Shop.SetMulti');
     $config = ShopConfig::load();
     $typeFields = array();
     if (!empty($types)) {
         foreach ($types as $key => $type) {
             $fields = set::normalize(array('id', 'code', 'label_fre', 'label_eng', 'operator', 'price'));
             if (isset($type['price']) && $type['price'] === false) {
                 unset($fields['price']);
                 unset($fields['operator']);
             }
             if (array_key_exists('price', $fields) && !empty($config['currencies'])) {
                 //$fields['price']['label'] = __('Default Price',true);
                 unset($fields['price']);
                 foreach ($config['currencies'] as $currency) {
                     $fOpt = array('label' => str_replace('%currency%', $currency, __('Price %currency%', true)), 'type' => 'text');
                     $fields['currency_prices.' . $currency] = $fOpt;
                 }
             }
             if (array_key_exists('operator', $fields)) {
                 if (count($type['operators']) == 1) {
                     $fields = SetMulti::insertBeforeKey($fields, 'operator', array('operator_display' => array('type' => 'definition', 'value' => $type['operators'][0], 'label' => __('Operator', true))));
                     $fields['operator']['type'] = 'hidden';
                     $fields['operator']['value'] = $type['operators'][0];
                 } else {
                     $fields['operator']['options'] = $type['operators'];
                 }
                 if (isset($type['adminFields'])) {
                     $fields = set::merge($fields, $type['adminFields']);
                 }
             }
             $typeField = array('type' => 'multiple', 'fields' => $fields, 'div' => array('class' => 'type'));
             if (!empty($type['children'])) {
                 $typeField['subline'] = $this->_subProductsFields($type['children'], 'children.');
             }
             $typeFields[$prefix . $key] = $typeField;
         }
     }
     return $typeFields;
 }
예제 #2
0
파일: tile.php 프로젝트: kevthunder/arch
 function _updateTile($data, $x, $y, $zone_id, $tiles, $maxRange, $actions = null)
 {
     App::import('Lib', 'SetMulti');
     $modifs = array();
     $acts = $this->updateActions;
     if (!empty($actions)) {
         $acts = array_intersect_key($acts, set::normalize($actions));
     }
     foreach ($acts as $name => $act) {
         if ($act['range'] <= $maxRange) {
             if (SetMulti::testCond($act['target'], $data)) {
                 if (empty($act['callback'])) {
                     $callBack = array($this, 'update_' . $name);
                 } else {
                     $callBack = $act['callback'];
                 }
                 $modif = call_user_func($callBack, $data, $x, $y, $zone_id, $tiles);
                 $modifs = SetMulti::merge2($modifs, $modif);
             }
         }
     }
     return $modifs;
 }