Пример #1
0
 /**
  * @param string $position
  * @param array  $args
  * @return string|void
  */
 public function renderPosition($position, $args = array())
 {
     // init vars
     $elements = array();
     $output = array();
     $style = isset($args['style']) ? $args['style'] : 'order.validator';
     $layout = $this->_layout;
     // render elements
     foreach ($this->_getConfigPosition($position) as $index => $data) {
         if ($element = $this->_order->getValidatorElement($data['identifier'])) {
             if (!$element->canAccess() || !$element->hasValue()) {
                 continue;
             }
             $data['_layout'] = $this->_layout;
             $data['_position'] = $position;
             $data['_index'] = $index;
             // set params
             $params = array_merge((array) $data, $args);
             // check value
             $elements[] = compact('element', 'params');
         }
     }
     foreach ($elements as $i => $data) {
         $output[$i] = parent::render('element.' . $style, array('element' => $data['element'], 'params' => array_merge(array('first' => $i == 0, 'last' => $i == count($elements) - 1), $data['params'])));
     }
     $this->_layout = $layout;
     if (isset($args['rowAttrs']) && is_array($args['rowAttrs'])) {
         $rowOutput = '';
         $_rowAttrs = array('class' => 'grid-row');
         $rowAttrs = array_replace_recursive($_rowAttrs, $args['rowAttrs']);
         $column = isset($args['column']) ? (int) $args['column'] : 3;
         $rowElements = array_chunk($output, $column);
         foreach ($rowElements as $elements) {
             $rowOutput .= '<div ' . $this->app->jbhtml->buildAttrs($rowAttrs) . '>';
             foreach ($elements as $element) {
                 $rowOutput .= $element;
             }
             $rowOutput .= '</div>';
         }
         return $rowOutput;
     }
     return implode(PHP_EOL, $output);
 }
Пример #2
0
 /**
  * @param string $eventType
  * @param JBCartOrder $order
  * @return array
  */
 public function getByEvent($eventType = null, $order)
 {
     $result = array();
     $eventType = 'list';
     // TODO add new evenet types
     $params = JBModelConfig::model()->get($eventType, array(), 'cart.validator');
     if (!empty($params)) {
         $result = array();
         foreach ($params as $elementParams) {
             $result[$elementParams['identifier']] = $order->getValidatorElement($elementParams['identifier']);
         }
     }
     return $result;
 }