• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ifempty函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ifempty函数的典型用法代码示例。如果您正苦于以下问题:PHP ifempty函数的具体用法?PHP ifempty怎么用?PHP ifempty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ifempty函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($options = array())
 {
     parent::__construct($options);
     // @todo: check required options
     $this->app_id = ifempty($this->options['app_id']);
     $this->app_secret = ifempty($this->options['app_secret']);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:7,代码来源:waOAuth2Adapter.class.php


示例2: callbackHandler

 protected function callbackHandler($request)
 {
     if (!$this->order_id || !$this->app_id || !$this->merchant_id) {
         throw new waPaymentException('invalid order number', 404);
     }
     if (!$this->verifySign($request)) {
         throw new waPaymentException('invalid signature', 404);
     }
     $result = array();
     $transaction_data = $this->formalizeData($request);
     if (!empty($request['customer'])) {
         switch (ifempty($transaction_data['state'])) {
             case self::STATE_CAPTURED:
                 $result['redirect'] = $this->getAdapter()->getBackUrl(waAppPayment::URL_SUCCESS, $transaction_data);
                 break;
             case self::STATE_DECLINED:
                 $result['redirect'] = $this->getAdapter()->getBackUrl(waAppPayment::URL_FAIL, $transaction_data);
         }
     }
     if (ifempty($transaction_data['state']) == self::STATE_CAPTURED) {
         $transaction_data = $this->saveTransaction($transaction_data, $request);
         $this->execAppCallback(self::CALLBACK_PAYMENT, $transaction_data);
     }
     return $result;
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:25,代码来源:private24Payment.class.php


示例3: get_edit_announcement_input_form

function get_edit_announcement_input_form($announcement_r, $HTTP_VARS = NULL)
{
    global $PHP_SELF;
    $buffer .= "<form action=\"{$PHP_SELF}\" method=\"POST\">";
    $buffer .= "\n<input type=\"hidden\" name=\"type\" value=\"announcements\">";
    if (is_array($announcement_r)) {
        $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"update\">" . "\n<input type=\"hidden\" name=\"announcement_id\" value=\"" . $announcement_r['announcement_id'] . "\">";
    } else {
        $buffer .= "\n<input type=\"hidden\" name=\"op\" value=\"insert\">";
    }
    $buffer .= "<table>";
    $buffer .= get_input_field("title", NULL, 'Title', "text(50,500)", "Y", ifempty($announcement_r['title'], $HTTP_VARS['title']), TRUE);
    $buffer .= get_input_field("content", NULL, 'Announcement', "htmlarea(60,15)", "Y", ifempty($announcement_r['content'], $HTTP_VARS['content']), TRUE);
    $buffer .= get_input_field("display_days", NULL, 'Display Days', "number(10,10)", "Y", ifempty($announcement_r['display_days'], $HTTP_VARS['display_days']), TRUE);
    if (is_array($announcement_r)) {
        $buffer .= get_input_field("closed_ind", NULL, 'Closed', "checkbox(Y,N)", "N", ifempty($announcement_r['closed_ind'], $HTTP_VARS['closed_ind']), TRUE);
    }
    $buffer .= "</table>";
    $help_r[] = array('img' => 'compulsory.gif', 'text' => get_opendb_lang_var('compulsory_field'), id => 'compulsory');
    $help_r[] = array('text' => 'A zero in Display Days indicates the announcment will never expire.');
    $help_r[] = array('text' => 'No validation is performed on HTML entered in the Announcement text field.');
    $buffer .= format_help_block($help_r);
    if (get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE) {
        $onclick_event = "if(!checkForm(this.form)){return false;}else{this.form.submit();}";
    } else {
        $onclick_event = "this.form.submit();";
    }
    $buffer .= "<input type=\"button\" class=\"button\" onclick=\"{$onclick_event}\" value=\"Save\">";
    $buffer .= "\n</form>";
    return $buffer;
}
开发者ID:horrabin,项目名称:opendb,代码行数:31,代码来源:index.php


示例4: widgetAddAction

 public function widgetAddAction()
 {
     $data = waRequest::post();
     if (isset($data['new_block'])) {
         $new_block = $data['new_block'];
         unset($data['new_block']);
     } else {
         $new_block = false;
     }
     $dashboard_id = waRequest::request('dashboard_id', null, 'int');
     if ($dashboard_id && !wa()->getUser()->isAdmin('webasyst')) {
         throw new waException('Access denied', 403);
     }
     $widgets = wa($data['app_id'])->getConfig()->getWidgets();
     $data['name'] = $widgets[$data['widget']]['name'];
     $id = $this->getWidgetModel()->add($data, $new_block, ifempty($dashboard_id, null));
     $w = wa()->getWidget($id)->getInfo();
     $w['size'] = explode('x', $w['size']);
     $w['sizes'] = $widgets[$data['widget']]['sizes'];
     foreach ($w['sizes'] as $s) {
         if ($s == array(1, 1)) {
             $w['has_sizes']['small'] = true;
         } elseif ($s == array(2, 1)) {
             $w['has_sizes']['medium'] = true;
         } elseif ($s == array(2, 2)) {
             $w['has_sizes']['big'] = true;
         }
     }
     $w['has_settings'] = $widgets[$data['widget']]['has_settings'];
     $this->displayJson(array('id' => $id, 'html' => $this->display(array('w' => $w), $this->getPluginRoot() . 'templates/actions/dashboard/DashboardWidget.html', true)));
 }
开发者ID:Rupreht,项目名称:webasyst-framework,代码行数:31,代码来源:webasystDashboard.actions.php


示例5: getAllSettings

 public function getAllSettings()
 {
     $this->enable = $this->getSettings('enable') ? 1 : 0;
     $this->where = $this->getSettings('where');
     $this->phone_mask = $this->getSettings('phone_mask');
     $this->phone_placeholder = $this->getSettings('phone_placeholder');
     $this->error_msg = $this->getSettings('error_msg');
     $this->error_msg = ifempty($this->error_msg, 'Неверный формат');
     $this->validate = $this->getSettings('validate') ? 1 : 0;
     $this->phone_input_names = $this->getSettings('phone_input_names');
     if (empty($this->phone_input_names)) {
         $this->phone_input_names = 'phone';
     }
     $this->view = wa()->getView();
     if (!empty($this->phone_input_names)) {
         $this->phone_input_names = explode(',', $this->getSettings('phone_input_names'));
         foreach ($this->phone_input_names as $i => $phone) {
             $this->phone_input_names[$i] = '[name*="[' . trim($phone) . ']"]';
         }
         $this->view->assign('phone_input_names', join(', ', $this->phone_input_names));
     } else {
         $this->phone_input_names = false;
     }
     $this->view->assign('where', $this->where);
     $this->view->assign('error_msg', $this->error_msg);
     $this->view->assign('phone_mask', $this->phone_mask);
     $this->view->assign('phone_placeholder', $this->phone_placeholder);
     $this->view->assign('validate', $this->validate);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:29,代码来源:shopKmphonemaskvalidatePlugin.class.php


示例6: create

 protected function create($params = array())
 {
     $config = array('name' => empty($params['name']) ? ucfirst($this->plugin_id) : $params['name'], 'icon' => 'img/' . $this->plugin_id . '.gif', 'version' => ifempty($params['version'], $this->getDefaults('version')), 'vendor' => ifempty($params['vendor'], $this->getDefaults('vendor')), 'handlers' => array());
     $paths = array('css/' . $this->plugin_id . '.css', 'js/' . $this->plugin_id . '.js', 'img/', 'lib/', 'lib/actions/backend/', 'lib/classes/', 'lib/config/', 'lib/' . $this->app_id . ucfirst($this->plugin_id) . 'Plugin.class.php' => $this->getPluginClassCode(), 'lib/vendors/');
     if (isset($params['db'])) {
         array_push($paths, array('lib/models/'));
     }
     if (isset($params['locale'])) {
         array_push($paths, array('locale/'));
     }
     if (isset($params['frontend'])) {
         $config['frontend'] = true;
         array_push($paths, array('lib/actions/frontend/', 'templates/actions/frontend/'));
         $paths['lib/config/routing.php'] = array('*' => 'frontend');
     }
     if (isset($params['settings'])) {
         $paths['lib/config/settings.php'] = array();
     }
     $paths['lib/config/plugin.php'] = $config;
     $protected_paths = array('lib/', 'templates/');
     if (isset($params['locale'])) {
         array_push($protected_paths, array('locale/'));
     }
     $this->createStructure($paths);
     $this->protect($protected_paths);
     if (!isset($params['disable'])) {
         $this->installPlugin();
         $errors = $this->flushCache();
         if ($errors) {
             print "Error during delete cache files:\n\t" . implode("\n\t", $errors) . "\n";
         }
     }
     return $config;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:34,代码来源:webasystCreatePlugin.cli.php


示例7: get_opendb_title

/**
 * Enter description here...
 *
 * @param unknown_type $override_title
 * @return unknown
 */
function get_opendb_title($override_default_title = TRUE)
{
    if ($override_default_title) {
        return ifempty(get_opendb_config_var('site', 'title'), __OPENDB_TITLE__);
    } else {
        return __OPENDB_TITLE__;
    }
}
开发者ID:horrabin,项目名称:opendb,代码行数:14,代码来源:config.php


示例8: defaultAction

 public function defaultAction()
 {
     $settings = $this->getSettings();
     $rss_url = ifempty($settings['rss_feed']);
     if ($rss_url == 'custom') {
         $rss_url = ifempty($settings['custom_rss_feed']);
     }
     $this->display(array('rss_url' => $rss_url, 'uniqid' => 'n' . uniqid(true)), $this->getTemplatePath('Default.html'));
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:9,代码来源:news.widget.php


示例9: getHTML

 public function getHTML($params = array(), $attrs = '')
 {
     $value = isset($params['value']) ? $params['value'] : '';
     $disabled = '';
     if (wa()->getEnv() === 'frontend' && isset($params['my_profile']) && $params['my_profile'] == '1') {
         $disabled = 'disabled="disabled"';
     }
     return '<input type="hidden" ' . $disabled . ' name="' . $this->getHTMLName($params) . '" value=""><input type="checkbox"' . ($value ? ' checked="checked"' : '') . ' name="' . $this->getHTMLName($params) . '" value="' . ifempty($value, '1') . '" ' . $attrs . '>';
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:9,代码来源:waContactCheckboxField.class.php


示例10: doTree

function doTree($group = false)
{
    global $misc;
    $servers = $misc->getServers(true, $group);
    $reqvars = $misc->getRequestVars('server');
    $attrs = array('text' => field('desc'), 'icon' => ifempty(field('username'), 'DisconnectedServer', 'Server'), 'toolTip' => field('id'), 'action' => url('redirect.php', $reqvars, array('server' => field('id'))), 'branch' => ifempty(field('username'), false, url('all_db.php', $reqvars, array('action' => 'tree', 'server' => field('id')))));
    $misc->printTreeXML($servers, $attrs);
    exit;
}
开发者ID:hardikk,项目名称:HNH,代码行数:9,代码来源:servers.php


示例11: execute

 public function execute()
 {
     list($start_date, $end_date, $group_by) = shopReportsSalesAction::getTimeframeParams();
     // Init by-day arrays with zeroes.
     $by_day = array();
     // Data for main graph: 'yyyy-mm-dd' => array(...)
     $sales_by_day = array();
     // Total sales data
     $om = new shopOrderModel();
     foreach ($om->getSales($start_date, $end_date, $group_by) as $date => $row) {
         $sales_by_day[$date] = $row['total'];
         $by_day[$date] = array('date' => $date, 'total_percent' => 0, 'total' => 0);
     }
     // Max profit in a single day
     $max_day_profit = 0;
     // Totals for period, in default currency
     $total = array('profit' => 0, 'purchase' => 0, 'shipping' => 0, 'sales' => 0, 'tax' => 0);
     // Loop over all days of a period that had at least one order paid,
     // and gather data into vars listed above.
     foreach ($om->getProfit($start_date, $end_date, $group_by) as $row) {
         $sales = ifset($sales_by_day[$row['date']], 0);
         $profit = $sales - $row['purchase'] - $row['shipping'] - $row['tax'];
         $max_day_profit = max($max_day_profit, $profit);
         $by_day[$row['date']]['total'] = $profit;
         $total['sales'] += $sales;
         $total['profit'] += $profit;
         $total['purchase'] += $row['purchase'];
         $total['shipping'] += $row['shipping'];
         $total['tax'] += $row['tax'];
     }
     // Data for main chart
     $profit_data = array();
     foreach ($by_day as &$d) {
         $d['total_percent'] = $max_day_profit ? $d['total'] * 100 / ifempty($max_day_profit, 1) : 0;
         $profit_data[] = array($d['date'], $d['total']);
     }
     unset($d);
     // Data for pie chart
     $pie_data = array();
     $pie_total = $total['shipping'] + $total['profit'] + $total['purchase'] + $total['tax'];
     if ($pie_total) {
         $pie_data[] = array(_w('Shipping') . ' (' . round($total['shipping'] * 100 / ifempty($pie_total, 1), 1) . '%)', (double) $total['shipping']);
         $pie_data[] = array(_w('Profit') . ' (' . round($total['profit'] * 100 / ifempty($pie_total, 1), 1) . '%)', (double) $total['profit']);
         $pie_data[] = array(_w('Product purchases') . ' (' . round($total['purchase'] * 100 / ifempty($pie_total, 1), 1) . '%)', (double) $total['purchase']);
         $pie_data[] = array(_w('Tax') . ' (' . round($total['tax'] * 100 / ifempty($pie_total, 1), 1) . '%)', (double) $total['tax']);
         $pie_data = array($pie_data);
     }
     $def_cur = wa()->getConfig()->getCurrency();
     $this->view->assign('total', $total);
     $this->view->assign('by_day', $by_day);
     $this->view->assign('def_cur', $def_cur);
     $this->view->assign('group_by', $group_by);
     $this->view->assign('pie_data', $pie_data);
     $this->view->assign('profit_data', $profit_data);
     $this->view->assign('avg_profit', $by_day ? round($total['profit'] / count($by_day), 2) : 0);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:56,代码来源:shopReportsProfit.action.php


示例12: generate_language_sql

function generate_language_sql($language, $options = NULL)
{
    $CRLF = get_user_browser_crlf();
    $sqlscript = '';
    //language, description, default_ind
    $language_r = fetch_language_r($language);
    if (is_not_empty_array($language_r)) {
        $sqlscript = '#########################################################' . $CRLF . '# OpenDb ' . get_opendb_version() . ' \'' . $language . '\' Language Pack' . $CRLF . '#########################################################' . $CRLF . $CRLF;
        $sqlscript .= "INSERT INTO s_language (language, description, default_ind) " . "VALUES ('" . $language_r['language'] . "', '" . addslashes($language_r['description']) . "', '" . $language_r['default_ind'] . "'); " . $CRLF;
        $results = fetch_language_langvar_rs($language, $options);
        if ($results) {
            $sqlscript .= $CRLF . '#' . $CRLF . '# System Language Variables' . $CRLF . '#' . $CRLF;
            while ($lang_var_r = db_fetch_assoc($results)) {
                if ($language_r['default_ind'] != 'Y') {
                    $value = ifempty($lang_var_r['value'], $lang_var_r['default_value']);
                } else {
                    $value = $lang_var_r['value'];
                }
                $sqlscript .= "INSERT INTO s_language_var (language, varname, value) " . "VALUES ('" . $language_r['language'] . "', '" . $lang_var_r['varname'] . "', '" . addslashes($value) . "'); " . $CRLF;
            }
            db_free_result($results);
        }
        if ($language_r['default_ind'] != 'Y') {
            $table_r = get_system_table_r();
            if (is_array($table_r)) {
                $sqlscript .= $CRLF . '#' . $CRLF . '# System Table Language Variables' . $CRLF . '#' . $CRLF;
                reset($table_r);
                while (list(, $table) = each($table_r)) {
                    $tableconf_r = get_system_table_config($table);
                    // key, column
                    if (is_array($tableconf_r) && is_array($tableconf_r['columns'])) {
                        reset($tableconf_r['columns']);
                        while (list(, $column) = each($tableconf_r['columns'])) {
                            $results = fetch_system_table_column_langvar_rs($language, $table, $column, $options);
                            if ($results) {
                                while ($lang_var_r = db_fetch_assoc($results)) {
                                    if ($language_r['default_ind'] != 'Y') {
                                        $value = ifempty($lang_var_r['value'], $lang_var_r[$column]);
                                    } else {
                                        $value = $lang_var_r['value'];
                                    }
                                    if (strlen($value)) {
                                        $sqlscript .= "INSERT INTO s_table_language_var (language, tablename, columnname, key1, key2, key3, value) " . "VALUES ('" . $language_r['language'] . "', '" . $table . "', '" . $column . "', '" . $lang_var_r['key1'] . "', " . (strlen($lang_var_r['key2']) > 0 ? "'" . $lang_var_r['key2'] . "'" : "''") . ", " . (strlen($lang_var_r['key3']) > 0 ? "'" . $lang_var_r['key3'] . "'" : "''") . ", '" . addslashes($value) . "'); " . $CRLF;
                                    }
                                }
                                db_free_result($results);
                            }
                        }
                    }
                }
            }
        }
    }
    return $sqlscript;
}
开发者ID:horrabin,项目名称:opendb,代码行数:55,代码来源:index.php


示例13: unserialize

 public function unserialize($serialized)
 {
     $data = unserialize($serialized);
     $this->file = ifset($data['file']);
     $this->delimiter = ifempty($data['delimiter'], ';');
     $this->encoding = ifempty($data['encoding'], 'utf-8');
     $this->method = ifempty($data['method'], 'iconv');
     $this->data_mapping = ifset($data['data_mapping']);
     $this->offset = ifset($data['offset'], 0);
     $this->restore();
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:11,代码来源:shopCsvWriter.class.php


示例14: __construct

 public function __construct($coupon = array())
 {
     waLocale::loadByDomain(array('shop', 'coupon'));
     waSystem::pushActivePlugin('coupon', 'shop');
     $this->data['code'] = ifempty($coupon['code'], '');
     $this->data['expire'] = ifempty($coupon['expire_datetime']);
     $curm = new shopCurrencyModel();
     $currencies = $curm->getAll('code');
     $this->data['discount'] = shopCouponPlugin::formatValue($coupon, $currencies);
     waSystem::popActivePlugin();
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:11,代码来源:shopCouponPluginCoupon.class.php


示例15: frontendCheckout

 public function frontendCheckout($info)
 {
     $step = ifempty($info['step'], '');
     if ($step == 'success') {
         return '';
     }
     $cart = new shopCart();
     $m = new shopCartsreportPluginCartModel();
     $m->insert(array('code' => $cart->getCode(), 'checkout.' . $step => 1, 'edit_datetime' => date('Y-m-d H:i:s')), 1);
     return '';
 }
开发者ID:ZloyTip,项目名称:cartsreport,代码行数:11,代码来源:shopCartsreportPlugin.class.php


示例16: execute

 public function execute()
 {
     $om = new shopOrderModel();
     $encoded_order_id = waRequest::param('id');
     $code = waRequest::param('code');
     $order_id = shopHelper::decodeOrderId($encoded_order_id);
     if (!$order_id) {
         // fall back to non-encoded id
         $order_id = $encoded_order_id;
         $encoded_order_id = shopHelper::encodeOrderId($order_id);
     }
     $order = $om->getOrder($order_id);
     if (!$order) {
         throw new waException(_w('Order not found'), 404);
     } elseif (!$this->isAuth($order, $code)) {
         if ($code && $order_id != substr($code, 16, -16)) {
             throw new waException(_w('Order not found'), 404);
         } else {
             $redirect = array('id' => $order_id);
             if (!empty($code)) {
                 $redirect['code'] = $code;
             }
             $url = $code ? '/frontend/myOrderByCode' : '/frontend/myOrder';
             $this->redirect(wa()->getRouteUrl($url, $redirect));
         }
     } elseif ($code && $order['contact_id'] == wa()->getUser()->getId()) {
         $redirect = array('id' => $order_id, 'form_type' => waRequest::param('form_type'), 'form_id' => waRequest::param('form_id'));
         $this->redirect(wa()->getRouteUrl('/frontend/myOrderPrintform', $redirect));
     }
     $order_params_model = new shopOrderParamsModel();
     $order['params'] = $order_params_model->get($order['id']);
     $order['id_str'] = $encoded_order_id;
     switch (waRequest::param('form_type')) {
         case 'payment':
             if (empty($order['params']['payment_id']) || !($payment = shopPayment::getPlugin(null, $order['params']['payment_id']))) {
                 throw new waException(_w('Printform not found'), 404);
             }
             $form_id = waRequest::param('form_id');
             $params = null;
             if (strpos($form_id, '.')) {
                 $form = explode('.', $form_id, 2);
                 $form_id = array_shift($form);
                 $params = array_shift($form);
             }
             print $payment->displayPrintForm(ifempty($form_id, $payment->getId()), shopPayment::getOrderData($order, $payment), intval($params));
             exit;
             break;
         default:
             throw new waException(_w('Printform not found'), 404);
             break;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:52,代码来源:shopFrontendMyOrderPrintform.action.php


示例17: getAvailableLanguages

 public static function getAvailableLanguages()
 {
     static $options;
     if ($options !== null) {
         return $options;
     }
     $langs = waLocale::getAll('info');
     $options = array();
     foreach ($langs as $code => $lang) {
         $code = substr($code, 0, 2);
         $options[$code] = ifempty($lang['name'], '') . ' (' . $code . ')';
     }
     return $options;
 }
开发者ID:ZloyTip,项目名称:lang,代码行数:14,代码来源:shopLang.plugin.php


示例18: isAuth

 /**
  * @return array|bool|null
  * @throws waException
  */
 public function isAuth()
 {
     $info = waSystem::getInstance()->getStorage()->read('auth_user');
     if (!$info) {
         $info = $this->_authByCookie();
         if ($info) {
             waSystem::getInstance()->getStorage()->write('auth_user', $info);
         }
     }
     // check options
     if ($info && $info['id'] && (!$this->getOption('is_user') || ifempty($info['is_user']) > 0)) {
         return $info;
     }
     return false;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:19,代码来源:waAuth.class.php


示例19: __get

    public function __get($field)
    {
        switch ($field) {
            case self::HSV:
            case self::RGB:
            case self::CMYK:
                if (!isset($this->_data[$field])) {
                    $this->_data[$field] = $this->convert($field, $this->code);
                }
                return $this->_data[$field];
            case 'style':
                $style = "";
                if ($this->code !== null) {
                    $d = !!(0xff & $this->code < 0x7f) + !!(0xff & $this->code >> 8 < 0x7f) + 2 * !!(0xff & $this->code >> 16 < 0x7f);
                    if ($d > 2) {
                        $color = 0xffffff;
                    } else {
                        $color = 0x0;
                    }
                    $style .= "color:{$this->convert(self::HEX, $color)};";
                    $style .= "background-color:{$this->hex};";
                }
                return $style;
                break;
            case 'html':
                $name = htmlentities(ifempty($this->value, $this->hex), ENT_QUOTES, 'utf-8');
                return <<<HTML
<span style="white-space: nowrap;">{$this->icon}{$name}</span>
HTML;
                break;
            case 'icon':
                if ($this->code === null) {
                    return null;
                } else {
                    return <<<HTML
 <i class="icon16 color" style="background:{$this->hex};"></i>
HTML;
                }
                break;
            case 'compare':
                return trim($this->value);
                break;
            default:
                return isset($this->{$field}) ? $this->{$field} : $this->convert($field);
                break;
        }
    }
开发者ID:Lazary,项目名称:webasyst,代码行数:47,代码来源:shopColorValue.class.php


示例20: getByTaxAddress

 /**
  * @param int $tax_id
  * @param array $address
  * @return float
  */
 public function getByTaxAddress($tax_id, $address)
 {
     $result = false;
     $country = ifempty($address['country'], wa('shop')->getConfig()->getGeneralSettings('country'));
     if ($country) {
         $data = array('id' => $tax_id, 'country' => $country);
         if (empty($address['region'])) {
             $region_sql = " AND region_code IS NULL ";
         } else {
             $data['region'] = $address['region'];
             $region_sql = " AND (region_code IS NULL OR region_code=:region) ";
         }
         $sql = "SELECT tax_value\n                    FROM {$this->table}\n                    WHERE tax_id=:id\n                        AND country_iso3=:country\n                        {$region_sql}\n                    ORDER BY region_code IS NOT NULL\n                    LIMIT 1";
         $result = $this->query($sql, $data)->fetchField();
     }
     if ($result === false) {
         static $all_rates = null, $eu_rates = null, $rest_rates = null;
         if ($rest_rates === null) {
             $all_rates = $eu_rates = $rest_rates = array();
             $sql = "SELECT * FROM {$this->table} WHERE country_iso3 IN ('%AL', '%EU', '%RW') AND region_code iS NULL";
             foreach ($this->query($sql) as $row) {
                 switch ($row['country_iso3']) {
                     case '%AL':
                         $all_rates[$row['tax_id']] = $row['tax_value'];
                         break;
                     case '%EU':
                         $eu_rates[$row['tax_id']] = $row['tax_value'];
                         break;
                     case '%RW':
                         $rest_rates[$row['tax_id']] = $row['tax_value'];
                         break;
                 }
             }
         }
         if (isset($all_rates[$tax_id])) {
             $result = $all_rates[$tax_id];
         }
         if (isset($rest_rates[$tax_id])) {
             $result = $rest_rates[$tax_id];
         }
         if ($country && self::isEuropean($country)) {
             $result = ifset($eu_rates[$tax_id]);
         }
     }
     return (double) $result;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:51,代码来源:shopTaxRegions.model.php



注:本文中的ifempty函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ifgroup函数代码示例发布时间:2022-05-15
下一篇:
PHP ife函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap