Provides access to an attribute of the current order

@param  array $params
@param  \Smarty $smarty
@return string the value of the requested attribute
162052
public function orderDataAccess($params, &$smarty)
    {
        /** @var Order $order */
        $order = $this->getSession()->getOrder();
        $attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr'));
        switch ($attribute) {
            case 'untaxed_postage':
                return $order->getUntaxedPostage();
            case 'postage':
                return $order->getPostage();
            case 'postage_tax':
                return $order->getPostageTax();
            case 'discount':
                return $order->getDiscount();
            case 'delivery_address':
                return $order->getChoosenDeliveryAddress();
            case 'invoice_address':
                return $order->getChoosenInvoiceAddress();
            case 'delivery_module':
                return $order->getDeliveryModuleId();
            case 'payment_module':
                return $order->getPaymentModuleId();
            case 'has_virtual_product':
                return $order->hasVirtualProduct();
        }

        throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", 'Order', $attribute));
    }
461239
public static function ask($param1, $param2 = null, $param3 = null) {
        self::init();
        if(is_array($param1)) {
            return self::smartSelect($param1, $param2, $param3);
        } else {
            switch(substr($param1, 0, 1)) {
                case '>':
                case '/':
                    return self::smartQuery($param1, $param2);
                    break;
                case '?':
                    return self::smartSelect(substr($param1, 1), $param2, $param3);
                    break;
                default:
                    if(is_array($param3)) {
                        return self::smartUpdate($param1, $param2, $param3);
                    } else {
                        return self::smartInsert($param1, $param2);
                    }
            }
        }
    }
550842
public function form($params, $content, $smarty, &$repeat) {
        //$content is null when repeat is true and has block content when repeat is false
        if ($repeat) {
            $attributes = isset($params['attrs']) ? $params['attrs'] : array();
            $hidden = isset($params['hidden']) ? $params['hidden'] : array();
            return Form::open($attributes, $hidden);
        } else {
            return $content . Form::close();
        }
    }
1194167
public static function widget(?array $params = null): ?string
    {
        self::$class = get_called_class();
        self::$view = App::$View;
        self::$request = App::$Request;
        self::$response = App::$Response;

        // check if class exist
        if (!class_exists(self::$class)) {
            return 'Error: Widget is not founded: ' . self::$class;
        }

        /** @var iWidget $object */
        $object = new self::$class;
        if (Any::isArray($params) && count($params) > 0) {
            foreach ($params as $property => $value) {
                if (property_exists($object, $property)) {
                    $object->{$property} = $value;
                }
            }
        }

        // initialize widget
        $object->init();
        return $object->display();
    }
497472
public function statsAccess($params, $smarty)
    {
        if (false === array_key_exists("key", $params)) {
            throw new \InvalidArgumentException(sprintf("missing key attribute in stats access function"));
        }
        if (false === array_key_exists("startDate", $params) || $params['startDate'] === '') {
            throw new \InvalidArgumentException(sprintf("missing startDate attribute in stats access function"));
        }
        if (false === array_key_exists("endDate", $params) || $params['endDate'] === '') {
            throw new \InvalidArgumentException(sprintf("missing endDate attribute in stats access function"));
        }

        if (false !== array_key_exists("includeShipping", $params) && $params['includeShipping'] == 'false') {
            $includeShipping = false;
        } else {
            $includeShipping = true;
        }

        if (false !== array_key_exists("withTaxes", $params) && $params['withTaxes'] == 'false') {
            $withTaxes = false;
        } else {
            $withTaxes = true;
        }

        if ($params['startDate'] == 'today') {
            $startDate = new \DateTime();
            $startDate->setTime(0, 0, 0);
        } elseif ($params['startDate'] == 'yesterday') {
            $startDate = new \DateTime();
            $startDate->setTime(0, 0, 0);
            $startDate->modify('-1 day');
        } elseif ($params['startDate'] == 'this_month') {
            $startDate = new \DateTime();
            $startDate->modify('first day of this month');
            $startDate->setTime(0, 0, 0);
        } elseif ($params['startDate'] == 'last_month') {
            $startDate = new \DateTime();
            $startDate->modify('first day of last month');
            $startDate->setTime(0, 0, 0);
        } elseif ($params['startDate'] == 'this_year') {
            $startDate = new \DateTime();
            $startDate->modify('first day of January this year');
            $startDate->setTime(0, 0, 0);
        } elseif ($params['startDate'] == 'last_year') {
            $startDate = new \DateTime();
            $startDate->modify('first day of January last year');
            $startDate->setTime(0, 0, 0);
        } else {
            try {
                $startDate = new \DateTime($params['startDate']);
            } catch (\Exception $e) {
                throw new \InvalidArgumentException(
                    sprintf("invalid startDate attribute '%s' in stats access function", $params['startDate'])
                );
            }
        }

        if ($params['endDate'] == 'today') {
            $endDate = new \DateTime();
            $endDate->setTime(0, 0, 0);
        } elseif ($params['endDate'] == 'yesterday') {
            $endDate = new \DateTime();
            $endDate->setTime(0, 0, 0);
            $endDate->modify('-1 day');
        } elseif ($params['endDate'] == 'this_month') {
            $endDate = new \DateTime();
            $endDate->modify('last day of this month');
            $endDate->setTime(0, 0, 0);
        } elseif ($params['endDate'] == 'last_month') {
            $endDate = new \DateTime();
            $endDate->modify('last day of last month');
            $endDate->setTime(0, 0, 0);
        } elseif ($params['endDate'] == 'this_year') {
            $endDate = new \DateTime();
            $endDate->modify('last day of December this year');
            $endDate->setTime(0, 0, 0);
        } elseif ($params['endDate'] == 'last_year') {
            $endDate = new \DateTime();
            $endDate->modify('last day of December last year');
            $endDate->setTime(0, 0, 0);
        } else {
            try {
                $endDate = new \DateTime($params['endDate']);
            } catch (\Exception $e) {
                throw new \InvalidArgumentException(
                    sprintf("invalid endDate attribute '%s' in stats access function", $params['endDate'])
                );
            }
        }

        switch ($params['key']) {
            case 'sales':
                return OrderQuery::getSaleStats($startDate, $endDate, $includeShipping, $withTaxes);
                break;
            case 'orders':
                return OrderQuery::getOrderStats($startDate, $endDate, OrderStatusQuery::getPaidStatusIdList());
                break;
        }

        throw new \InvalidArgumentException(
            sprintf("invalid key attribute '%s' in stats access function", $params['key'])
        );
    }
1272616
public function get($smartCollectionId, array $params = array())
    {
        $endpoint = '/admin/smart_collections/'.$smartCollectionId.'.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createObject(SmartCollection::class, $response['smart_collection']);
    }
86369
public function fetch($template, $parameters = [])
    {
        try {
            if (count($parameters) > 0) {
                $this->smarty->assign($parameters);
            }

            return $this->smarty->fetch($template);
        } catch (\Exception $e) {
            throw new SmartyException($e->getMessage());
        }
    }
91928
public function get($params) {
        $orm = !is_null($params['ormObject']) ? $params['ormObject'] : ORM::for_table($params['table']);

        return ($params['args'] && $params['args'][0] == 'object') ? $orm->find_many() : $orm->find_array();
    }
928441
public function to_smarty_php()
    {
        $code = '';
        foreach ($this->subtrees as $subtree) {
            if ($code !== "") {
                $code .= ".";
            }
            if ($subtree instanceof _smarty_tag) {
                $more_php = $subtree->assign_to_var();
            } else {
                $more_php = $subtree->to_smarty_php();
            }

            $code .= $more_php;

            if (!$subtree instanceof _smarty_dq_content) {
                $this->parser->compiler->has_variable_string = true;
            }
        }

        return $code;
    }
782540
public function folderDataAccess($params, &$smarty)
    {
        $folderId = $this->getRequest()->get('folder_id');

        if ($folderId === null) {
            $contentId = $this->getRequest()->get('content_id');

            if ($contentId !== null) {
                if (null !== $content = ContentQuery::create()->findPk($contentId)) {
                    $folderId = $content->getDefaultFolderId();
                }
            }
        }

        if ($folderId !== null) {
            return $this->dataAccessWithI18n(
                "Folder",
                $params,
                FolderQuery::create()->filterByPrimaryKey($folderId)
            );
        }

        return '';
    }
819615
public static function getOption(...$params)
    {
        $trace = debug_backtrace(2, 1);

        $id = (isset($trace[0]['file'])) ? self::setHash($trace[0]['file']) : 0;

        $key = array_shift($params);

        $col[] = isset(self::$data[$id][$key]) ? self::$data[$id][$key] : 0;

        if (! count($params)) {
            return ($col[0]) ? $col[0] : self::$data[$id];
        }

        foreach ($params as $param) {
            $col = array_column($col, $param);
        }

        return (isset($col[0])) ? $col[0] : '';
    }
1032688
function sectionIDbyName( $params )
    {
        $sectionID = false;
        $sectionName = $params['section_name'];

        $sectionList = eZSection::fetchFilteredList( array( 'name' => $sectionName ), false, false, true );

        if( is_array( $sectionList ) && count( $sectionList ) > 0 )
        {
            $section = $sectionList[0];
            if( is_object( $section ) )
            {
                $sectionID = $section->attribute( 'id' );
            }
        }

        return $sectionID;
    }
1356878
public function form_fieldset($params, $content, $smarty, &$repeat) {
        //$content is null when repeat is true and has block content when repeat is false
        if ($repeat) {
            $attributes = isset($params['attrs']) ? $params['attrs'] : array();
            $legend = isset($params['legend']) ? $params['legend'] : null;
            return Form::fieldset_open($attributes, $legend);
        } else {
            return $content . Form::fieldset_close();
        }
    }
242299
public function setPreviousUrlFunction($params, &$smarty)
    {
        $ignore_current = $this->getParam($params, 'ignore_current', false);

        if ($ignore_current !== false) {
            $this->getRequest()->attributes->set('_previous_url', 'dont-save');
        } else {
            $this->getRequest()->attributes->set('_previous_url', $this->generateUrlFunction($params, $smarty));
        }
    }
459631
public function form_select($params) {
        if (!isset($params['field'])) {
            throw new \UnexpectedValueException("The field parameter is required.");
        }
        $values = isset($params['values']) ? $params['values'] : null;
        $attributes = isset($params['attrs']) ? $params['attrs'] : array();
        $options = isset($params['options']) ? $params['options'] : array();
        return Form::select($params['field'], $values, $options, $attributes);
    }
401395
public function createOrder(Array $params)
    {
        $createOrderRequest = $this->getRequestParam('CreateOrderRequestParam', $params, $this->config, $this->sign);

        $result = $this->executeCurlRequest($createOrderRequest);

        $result = json_decode($result, true);

        $sign = isset($result['sign']) ? $result['sign'] : '';
        $response = isset($result['alipay_trade_precreate_response']) ? $result['alipay_trade_precreate_response'] : [];
        if ($response['code'] != '10000') {
            return $this->error($this->getErrorMessage('qrpay', $response['sub_code']), $result);
        }

        $data['sign'] = $sign;
        $data['prestr'] = json_encode($response,  JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE);

        if (!$this->sign->verifySign($data, $this->config['ali_rsa_public_key_path'])) {
            return $this->error('无效签名', $result);
        }

        return $this->success('发起支付成功', $response);
    }
970915
public static function key(string $key, array $params = []): string
    {
        $key = md5(serialize($key));
        if (count($params) > 0) {
            $key .= '-' . md5(serialize($params));
        }
        return $key;
    }