当前位置: 首页>>代码示例>>PHP>>正文


PHP ifset函数代码示例

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


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

示例1: testAddDocument

 public function testAddDocument()
 {
     $configuration = za()->getConfig('services');
     if (!$configuration) {
         echo "No services config found\n";
         return;
     }
     $searchConfig = ifset($configuration, 'SearchService');
     if (!$searchConfig) {
         echo "SearchService config not found\n";
         return;
     }
     $path = ifset($searchConfig, 'index');
     if (!$path) {
         echo "No search path set\n";
         return;
     }
     // Delete the search path
     rmdirr($path);
     $searchService = za()->getService('SearchService');
     $example = new Task();
     $example->id = 1;
     $example->title = 'Task for testing';
     $example->description = "Task description for testing";
     try {
         $searchService->index($example);
     } catch (Exception $e) {
         print_r($e);
     }
     $results = $searchService->search("testing");
     $this->assertEqual(count($results), 1);
 }
开发者ID:nyeholt,项目名称:relapse,代码行数:32,代码来源:TestSearchService.php

示例2: execute

 public function execute()
 {
     if (!$this->getUser()->getRights('shop', 'settings')) {
         throw new waRightsException(_w('Access denied'));
     }
     $cm = new waCountryModel();
     $rm = new waRegionModel();
     $country = waRequest::request('country');
     $this->saveFromPost($rm, $cm, $country);
     $countries = $cm->all();
     if (!$country || empty($countries[$country])) {
         $country = wa()->getSetting('country');
     }
     if (!$country || empty($countries[$country])) {
         // Show the first country with regions by default
         $region_countries = $rm->getCountries();
         $country = reset($region_countries);
         if (!$country || empty($countries[$country])) {
             $country = key($countries);
         }
     }
     $regions = $country ? $rm->getByCountry($country) : array();
     $this->view->assign('countries', $cm->allWithFav($countries));
     $this->view->assign('country', ifset($countries[$country], $cm->getEmptyRow()));
     $this->view->assign('regions', $regions);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:26,代码来源:shopSettingsRegions.action.php

示例3: execute

 public function execute()
 {
     $settings = waRequest::post('settings', array(), waRequest::TYPE_ARRAY);
     if (strlen($error = logsHelper::setPhpLogSetting(ifset($settings['php_log'], false)))) {
         $this->errors[] = $error;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:7,代码来源:logsBackendSettingsSave.controller.php

示例4: isAuth

 protected function isAuth($order, &$code)
 {
     $result = false;
     if (!$result) {
         $result = $order['id'] == wa()->getStorage()->get('shop/order_id');
     }
     if (!$result) {
         // Check that order exists and belongs to this user
         $result = $order['contact_id'] == wa()->getUser()->getId() && $order['state_id'] != 'deleted';
     }
     if (!$result && $code) {
         // Check auth code
         $opm = new shopOrderParamsModel();
         $params = $opm->get($order['id']);
         if (!empty($params['auth_pin']) && ifset($params['auth_code']) === $code) {
             $pin = wa()->getStorage()->get('shop/pin/' . $order['id']);
             if ($pin && $pin == $params['auth_pin']) {
                 $result = true;
             }
         } else {
             $code = false;
         }
     }
     return $result;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:25,代码来源:shopFrontendMyOrderPrintform.action.php

示例5: listplug_select

function listplug_select($template, $type)
{
    switch ($type) {
        case 'HEAD':
            echo '<select name="' . ifset($template['name']) . '" tabindex="' . ifset($template['tabindex']) . '" ' . ifset($template['javascript']) . '>';
            // add extra row if needed
            if (ifset($template['extra'])) {
                echo '<option value="', ifset($template['extraval']), '">', $template['extra'], '</option>';
            }
            break;
        case 'BODY':
            $current = $template['current'];
            echo '<option value="' . htmlspecialchars($current->value) . '"';
            if ($template['selected'] == $current->value) {
                echo ' selected="selected" ';
            }
            if (isset($template['shorten']) && $template['shorten'] > 0) {
                echo ' title="' . htmlspecialchars($current->text) . '"';
                $current->text = shorten($current->text, $template['shorten'], $template['shortenel']);
            }
            echo '>' . htmlspecialchars($current->text) . '</option>';
            break;
        case 'FOOT':
            echo '</select>';
            break;
    }
}
开发者ID:hatone,项目名称:Nucleus-v3.64,代码行数:27,代码来源:showlist.php

示例6: execute

 public function execute()
 {
     $id = waRequest::get('id');
     $model = new shopNotificationModel();
     $n = $model->getById($id);
     $params_model = new shopNotificationParamsModel();
     $params = $params_model->getParams($id);
     // Orders used as sample data for testing
     $om = new shopOrderModel();
     $test_orders = $om->where("paid_date IS NOT NULL AND state_id <> 'deleted'")->order('id DESC')->limit(10)->fetchAll('id');
     shopHelper::workupOrders($test_orders);
     $im = new shopOrderItemsModel();
     foreach ($im->getByField('order_id', array_keys($test_orders), true) as $i) {
         $test_orders[$i['order_id']]['items'][] = $i;
     }
     foreach ($test_orders as &$o) {
         $o['items'] = ifset($o['items'], array());
         $o['total_formatted'] = waCurrency::format('%{s}', $o['total'], $o['currency']);
     }
     $this->view->assign('n', $n);
     $this->view->assign('params', $params);
     $this->view->assign('transports', self::getTransports());
     $this->view->assign('events', $this->getEvents());
     $this->view->assign('test_orders', $test_orders);
     $this->view->assign('default_email_from', $this->getConfig()->getGeneralSettings('email'));
     $this->view->assign('sms_from', $this->getSmsFrom());
     $this->view->assign('routes', wa()->getRouting()->getByApp('shop'));
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:28,代码来源:shopSettingsNotificationsEdit.action.php

示例7: parseValue

 protected function parseValue($value, $type)
 {
     $code = null;
     $suggest = false;
     if (is_array($value)) {
         $code = ifset($value['code']);
         $value = trim(ifset($value['value']));
         //rgb(r,g,b) #ABC #AABBCC;
         if ($code === '') {
             $code = shopColorValue::getCode($value);
         } elseif (preg_match('@^#?([0-9A-F]{3}|[0-9A-F]{6})@ui', $code)) {
             if (strpos($code, '#') === 0) {
                 $code = substr($code, 1);
             }
             if ($parsed = sscanf(strtoupper($code), '%03X%03X')) {
                 if ($parsed[1] === null) {
                     $code = (0xf00 & $parsed[0]) << 12;
                     $code |= (0xff0 & $parsed[0]) << 8;
                     $code |= (0xff & $parsed[0]) << 4;
                     $code |= 0xf & $parsed[0];
                 } else {
                     $code = $parsed[0] << 12 | $parsed[1];
                 }
             } else {
                 $code = null;
             }
         } elseif (strpos('rgb', $code) === 0) {
             //TODO
         } else {
             $code = intval($code);
         }
         if ($value === '' && $code !== null) {
             $suggest = true;
             $value = shopColorValue::getName($code);
         }
     } else {
         $value = trim($value);
         if (preg_match('@^#?(([0-9A-F]{3})|([0-9A-F]{6}))$@ui', $value, $matches)) {
             if ($matches[2]) {
                 $value = sscanf(strtoupper($matches[2]), '%03X');
                 $code = reset($value);
             } elseif ($matches[3]) {
                 $value = sscanf(strtoupper($matches[3]), '%06X');
                 $code = reset($value);
             } else {
                 $code = 0;
             }
             $value = shopColorValue::getName($code);
         } else {
             $suggest = true;
             $code = shopColorValue::getCode($value);
         }
     }
     $data = array('value' => $value, 'search_value' => $value, 'suggest' => $suggest);
     if ($code !== null) {
         $data['code'] = $code;
     }
     return $data;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:59,代码来源:shopFeatureValuesColor.model.php

示例8: indexAction

 public function indexAction()
 {
     $this->view->pagerName = "contact-page";
     $this->view->letters = $this->clientService->getContactLetters();
     $currentLetter = ifset($this->_getAllParams(), $this->view->pagerName, ifset($this->view->letters, 0, 'A'));
     $this->view->contacts = $this->clientService->getContacts(null, array('firstname like ' => $currentLetter . '%'), 'firstname asc');
     $this->renderView('contact/index.php');
 }
开发者ID:nyeholt,项目名称:relapse,代码行数:8,代码来源:ContactController.php

示例9: getStaticImg

 private function getStaticImg($address, $options = array())
 {
     $zoom = ifset($options['zoom'], 10);
     $width = ifset($options['width'], '600');
     $height = ifset($options['height'], '400');
     $size = (int) $width . 'x' . (int) $height;
     return '<img src="//maps.googleapis.com/maps/api/staticmap?center=' . urlencode($address) . '.&zoom=' . $zoom . '&size=' . $size . '&markers=color:red%7Clabel:A%7C' . urlencode($address) . '&sensor=false" />';
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:8,代码来源:googleMap.class.php

示例10: execute

 public function execute()
 {
     $code = waRequest::param('code');
     $encoded_order_id = waRequest::param('id');
     $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);
     }
     if (!$order_id || $order_id != substr($code, 16, -16)) {
         throw new waException(_w('Order not found'), 404);
     }
     // When user is authorized, check if order belongs to him.
     // When it does, redirect to plain order page.
     if (wa()->getUser()->isAuth()) {
         $om = new shopOrderModel();
         $order = $om->getOrder($order_id);
         if (!$order) {
             throw new waException(_w('Order not found'), 404);
         }
         if ($order['contact_id'] == wa()->getUser()->getId()) {
             $this->redirect(wa()->getRouteUrl('/frontend/myOrder', array('id' => $order_id)));
         }
     }
     // Check auth code
     $opm = new shopOrderParamsModel();
     $params = $opm->get($order_id);
     if (ifset($params['auth_code']) !== $code || empty($params['auth_pin'])) {
         throw new waException(_w('Order not found'), 404);
     }
     // Check auth pin and show order page if pin is correct
     $pin = waRequest::request('pin', wa()->getStorage()->get('shop/pin/' . $order_id));
     if ($pin && $pin == $params['auth_pin']) {
         wa()->getStorage()->set('shop/pin/' . $order_id, $pin);
         parent::execute();
         if (!waRequest::isXMLHttpRequest()) {
             $this->layout->assign('breadcrumbs', self::getBreadcrumbs());
         }
         return;
     }
     //
     // No pin or pin is incorrect: show form to enter pin
     //
     $this->view->assign('wrong_pin', !!$pin);
     $this->view->assign('pin_required', true);
     $this->view->assign('encoded_order_id', $encoded_order_id);
     $this->view->assign('my_nav_selected', 'orders');
     // Set up layout and template from theme
     $this->setThemeTemplate('my.order.html');
     if (!waRequest::isXMLHttpRequest()) {
         $this->setLayout(new shopFrontendLayout());
         $this->getResponse()->setTitle(_w('Order') . ' ' . $encoded_order_id);
         $this->view->assign('breadcrumbs', self::getBreadcrumbs());
         $this->layout->assign('nofollow', true);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:57,代码来源:shopFrontendMyOrderByCode.action.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: configure

 public function configure($config)
 {
     $this->fileRoot = APP_DIR . ifset($config, 'root', '/data/files');
     if (!is_dir($this->fileRoot)) {
         // failure!
         if (!mkdirr($this->fileRoot, 0775)) {
             throw new Exception("Could not find file root at {$this->fileRoot}");
         }
     }
 }
开发者ID:nyeholt,项目名称:relapse,代码行数:10,代码来源:FileService.php

示例13: execute

 public function execute()
 {
     $data = waRequest::post('settings');
     unset($data['search_name']);
     if (isset($data['data_contact']) && is_array($data['data_contact'])) {
         if ($data['config_name'] != '') {
             if ($data['from'] != '') {
                 $info = $data;
                 $modelNotifierRule = new shopNotifierRuleModel();
                 $data_contact = json_encode($info['data_contact']);
                 unset($info['data_contact']);
                 $info['data_contact'] = $data_contact;
                 $state_name = json_encode($info['state_name']);
                 unset($info['state_name']);
                 $info['state_name'] = $state_name;
                 $info['group_senders'] = ifset($info['group_senders'], 0);
                 $info['save_to_order_log'] = ifset($info['save_to_order_log'], 0);
                 $result = $modelNotifierRule->getByField('config_name', $data['config_name']);
                 $val_update = '';
                 $column_insert = '';
                 $value_insert = '';
                 $len = count($info);
                 $i = 0;
                 foreach ($info as $key => $value) {
                     $i++;
                     if ($len == $i) {
                         $value_insert .= "'" . $value . "'";
                         $column_insert .= $key;
                         $val_update .= $key . "='" . $value . "'";
                     } else {
                         $value_insert .= "'" . $value . "', ";
                         $column_insert .= $key . ', ';
                         $val_update .= $key . "='" . $value . "',";
                     }
                 }
                 if ($result) {
                     $modelNotifierRule->updateById($result['id'], $info);
                     //                        query("UPDATE shop_notifier_rule SET ".$val_update." WHERE id = '".$result['id']."'");
                     $data['id'] = $result['id'];
                 } else {
                     $data['id'] = $modelNotifierRule->insert($info);
                     //query("INSERT INTO shop_notifier_rule (".$column_insert.") VALUES (".$value_insert.")");
                 }
                 $this->response['data'] = $data;
                 $this->response['message'] = 'ok';
             } else {
                 $this->response['message'] = 'fail_send_email';
             }
         } else {
             $this->response['message'] = 'fail_config_name_null';
         }
     } else {
         $this->response['message'] = 'fail_data_contact';
     }
 }
开发者ID:quadrodesign,项目名称:notifier,代码行数:55,代码来源:shopNotifierPluginSettingsSaverule.controller.php

示例14: Pager

 /**
  * @param int $total The total number of things being shown
  * @param int $perPage How many things per page
  * @param string $name the name of the page
  * @param array $params additional params to use
  * @param int $currentPage
  */
 public function Pager($total, $perPage, $name = 'page', $params = array(), $persistParams = false, $currentPage = 0, $prev = '&laquo;', $next = '&raquo;', $numberOfLinks = 10)
 {
     if ($total == 0 || $perPage == 0) {
         return;
     }
     if ($total <= $perPage) {
         return;
     }
     // If not set, check the request, otherwise just
     // assume first page
     if (!$currentPage) {
         $currentPage = ifset($_GET, $name, 1);
     }
     $totalPages = ceil($total / $perPage);
     // Figure out where to start printing from
     $eitherSide = floor($numberOfLinks / 2);
     $start = 1;
     $end = $numberOfLinks;
     if ($currentPage > $eitherSide) {
         $start = $currentPage - $eitherSide;
         $end = $currentPage + $eitherSide;
     }
     // Account for the extra item we get if we're
     // an even numberoflinks value
     $end--;
     if ($end > $totalPages) {
         $end = $totalPages;
     }
     $args = '';
     $ctrl = Zend_Controller_Front::getInstance();
     $oldRequest = $ctrl->getRequest()->getParams();
     if ($persistParams) {
         foreach ($oldRequest as $param => $value) {
             if ($param != 'action' && $param != 'controller' && $param != 'module' && $param != $name && !isset($params[$param])) {
                 $params[$param] = $value;
             }
         }
     }
     $args = '&amp;' . encode_params($params, '&amp;', '=');
     echo '<div class="pager-links">';
     if ($currentPage > 1) {
         echo '<a class="pager-prev-link pager-link" href="' . current_url() . '?' . $name . '=' . ($currentPage - 1) . $args . '">' . $prev . '</a>';
     }
     for ($i = $start; $i <= $end; $i++) {
         if ($i == $currentPage) {
             echo '<span class="pager-current-link pager-link">' . $i . '</span>';
         } else {
             echo '<a class="pager-link" href="' . current_url() . '?' . $name . '=' . $i . $args . '">' . $i . '</a>';
         }
     }
     if ($currentPage < $totalPages) {
         echo '<a class="pager-next-link pager-link" href="' . current_url() . '?' . $name . '=' . ($currentPage + 1) . $args . '">' . $next . '</a>';
     }
     echo '</div>';
 }
开发者ID:nyeholt,项目名称:relapse,代码行数:62,代码来源:Pager.php

示例15: getRole

 public static function getRole($role)
 {
     if (self::$roles == null) {
         self::$roles = array();
         self::$roles[self::ROLE_READ] = self::PERM_READ;
         self::$roles[self::ROLE_WRITE] = self::PERM_READ + self::PERM_WRITE;
         self::$roles[self::ROLE_POWER] = self::$roles[self::ROLE_WRITE] + self::PERM_POWER;
         self::$roles[self::ROLE_MANAGER] = self::$roles[self::ROLE_POWER] + self::PERM_MANAGER;
         self::$roles[self::ROLE_ADMIN] = self::$roles[self::ROLE_MANAGER] + self::PERM_ADMIN;
     }
     return ifset(self::$roles, $role, 0);
 }
开发者ID:nyeholt,项目名称:relapse,代码行数:12,代码来源:UserRole.php


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