本文整理汇总了PHP中ifset函数的典型用法代码示例。如果您正苦于以下问题:PHP ifset函数的具体用法?PHP ifset怎么用?PHP ifset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ifset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 = '«', $next = '»', $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 = '&' . encode_params($params, '&', '=');
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
示例16: calculate
/**
* Returns aggregate discount amount applicable to order.
*
* @param array $order Order data array
* @param bool $apply Whether discount-related information must be added to order parameters (where appropriate)
* @return float Total discount value expressed in order currency
*/
public static function calculate(&$order, $apply = false)
{
$currency = isset($order['currency']) ? $order['currency'] : wa('shop')->getConfig()->getCurrency(false);
$applicable_discounts = array();
$contact = self::getContact($order);
// Discount by contact category applicable?
if (self::isEnabled('category')) {
$applicable_discounts[] = self::byCategory($order, $contact, $apply);
}
// Discount by coupon applicable?
if (self::isEnabled('coupons')) {
$applicable_discounts[] = self::byCoupons($order, $contact, $apply);
}
// Discount by order total applicable?
if (self::isEnabled('order_total')) {
$crm = new shopCurrencyModel();
$dbsm = new shopDiscountBySumModel();
// Order total in default currency
$order_total = (double) $crm->convert($order['total'], $currency, wa('shop')->getConfig()->getCurrency());
$applicable_discounts[] = max(0.0, min(100.0, (double) $dbsm->getDiscount('order_total', $order_total))) * $order['total'] / 100.0;
}
// Discount by customer total spent applicable?
if (self::isEnabled('customer_total')) {
$applicable_discounts[] = self::byCustomerTotal($order, $contact, $apply);
}
/**
* @event order_calculate_discount
* @param array $params
* @param array[string] $params['order'] order info array('total' => '', 'items' => array(...))
* @param array[string] $params['contact'] contact info
* @param array[string] $params['apply'] calculate or apply discount
* @return float discount
*/
$event_params = array('order' => &$order, 'contact' => $contact, 'apply' => $apply);
$plugins_discounts = wa('shop')->event('order_calculate_discount', $event_params);
foreach ($plugins_discounts as $plugin_discount) {
$applicable_discounts[] = $plugin_discount;
}
// Select max discount or sum depending on global setting.
$discount = 0.0;
if ($applicable_discounts = array_filter($applicable_discounts, 'is_numeric')) {
if (wa('shop')->getSetting('discounts_combine') == 'sum') {
$discount = (double) array_sum($applicable_discounts);
} else {
$discount = (double) max($applicable_discounts);
}
}
// Discount based on affiliate bonus?
if (shopAffiliate::isEnabled()) {
$discount = $discount + (double) shopAffiliate::discount($order, $contact, $apply, $discount);
}
return min(max(0, $discount), ifset($order['total'], 0));
}
开发者ID:Lazary,项目名称:webasyst,代码行数:60,代码来源:shopDiscounts.class.php
示例17: execute
public function execute()
{
$term = waRequest::request('term');
$limit = waRequest::request('limit', 30, 'int');
if (mb_strlen($term) < 2) {
return;
}
$type = waRequest::request('type', null, waRequest::TYPE_STRING_TRIM);
$model = new waModel();
if (strpos($term, '@') !== FALSE) {
$contacts = new contactsCollection('/search/email*=' . $term);
} else {
$contacts = new contactsCollection();
$t_a = preg_split("/\\s+/", $term);
$cond = array();
foreach ($t_a as $t) {
$t = trim($t);
if ($t) {
$t = $model->escape($t, 'like');
if ($type === 'person') {
$cond[] = "(c.firstname LIKE '{$t}%' OR c.middlename LIKE '{$t}%' OR c.lastname LIKE '{$t}%')";
} else {
if ($type === 'company') {
$cond[] = "c.name LIKE '{$t}%'";
} else {
$cond[] = "(c.firstname LIKE '{$t}%' OR c.middlename LIKE '{$t}%' OR c.lastname LIKE '{$t}%' OR c.name LIKE '{$t}%')";
}
}
}
}
if ($cond) {
$contacts->addWhere(implode(" AND ", $cond));
}
}
if ($type) {
if ($type === 'person') {
$contacts->addWhere("is_company = 0");
} else {
if ($type === 'company') {
$contacts->addWhere("is_company = 1");
}
}
}
$this->response = array();
$term_safe = htmlspecialchars($term);
foreach ($contacts->getContacts('id,name,company,email', 0, $limit) as $c) {
$name = $this->prepare($c['name'], $term_safe);
$email = $this->prepare(ifset($c['email'][0], ''), $term_safe);
$company = $this->prepare($c['company'], $term_safe);
$this->response[] = array('label' => implode(', ', array_filter(array($name, $company, $email))), 'value' => $c['id'], 'name' => $c['name'], 'email' => ifset($c['email'][0], ''), 'company' => $c['company']);
}
}
开发者ID:Lazary,项目名称:webasyst,代码行数:52,代码来源:contactsBackendAutocomplete.controller.php
示例18: execute
public function execute()
{
$asm = new waAppSettingsModel();
if (waRequest::post()) {
$conf = waRequest::post('conf');
if ($conf && is_array($conf)) {
$conf['affiliate_credit_rate'] = str_replace(',', '.', (double) str_replace(',', '.', ifset($conf['affiliate_credit_rate'], '0')));
$conf['affiliate_usage_rate'] = str_replace(',', '.', (double) str_replace(',', '.', ifset($conf['affiliate_usage_rate'], '0')));
foreach ($conf as $k => $v) {
$asm->set('shop', $k, $v);
}
}
}
$enabled = shopAffiliate::isEnabled();
$def_cur = waCurrency::getInfo(wa()->getConfig()->getCurrency());
$tm = new shopTypeModel();
$product_types = $tm->getAll();
$conf = $asm->get('shop');
if (!empty($conf['affiliate_product_types'])) {
$conf['affiliate_product_types'] = array_fill_keys(explode(',', $conf['affiliate_product_types']), true);
} else {
$conf['affiliate_product_types'] = array();
}
$this->view->assign('conf', $conf);
$this->view->assign('enabled', $enabled);
$this->view->assign('product_types', $product_types);
$this->view->assign('def_cur_sym', ifset($def_cur['sign'], wa()->getConfig()->getCurrency()));
/**
* Backend affiliate settings
*
* Plugins are expected to return one item or a list of items to to add to affiliate menu.
* Each item is represented by an array:
* array(
* 'id' => string, // Required.
* 'name' => string, // Required.
* 'url' => string, // Required (unless you hack into JS using 'html' parameter). Content for settings page is fetched from this URL.
* )
*
* @event backend_settings_discounts
*/
$plugins = wa()->event('backend_settings_affiliate');
$config = wa('shop')->getConfig();
foreach ($plugins as $k => &$p) {
if (substr($k, -7) == '-plugin') {
$plugin_id = substr($k, 0, -7);
$plugin_info = $config->getPluginInfo($plugin_id);
$p['img'] = $plugin_info['img'];
}
}
$this->view->assign('plugins', $plugins);
$this->view->assign('installer', $this->getUser()->getRights('installer', 'backend'));
}
开发者ID:Lazary,项目名称:webasyst,代码行数:52,代码来源:shopSettingsAffiliate.action.php
示例19: parse_modal_layout
function parse_modal_layout($layout)
{
function parse_modal_layout_styles($width)
{
if (preg_match("/(\\d+(\\.\\d+)?)(px)/", $width)) {
return "class=\"span\" style=\"width: {$width}; margin-left: 0;\"";
} else {
return "class=\"span{$width}\"";
}
}
switch ($layout["type"]) {
case "horizontal":
$width = explode(":", $layout["width"]);
$child_counter = 0;
?>
<div class="row-fluid">
<?php
foreach ($layout["sublayouts"] as $sublayout_id => $sublayout) {
?>
<div <?php
echo parse_modal_layout_styles($width[$child_counter++]);
?>
>
<?php
parse_modal_layout($sublayout);
?>
</div>
<?php
}
?>
<?php
foreach ($layout["properties"] as $property_id => $property) {
?>
<div <?php
echo parse_modal_layout_styles($width[$child_counter++]);
?>
>
<?php
echo aw_modal::parse_properties(array($property_id => $property), ifset($layout, "captionside") === "left");
?>
</div>
<?php
}
?>
</div>
<?php
break;
case "vertical":
echo aw_modal::parse_properties($layout["properties"], false);
break;
}
}
开发者ID:automatweb,项目名称:automatweb_sales,代码行数:52,代码来源:default-layouts.php
示例20: execute
public function execute()
{
$f = waRequest::param('f');
$fid = waRequest::param('fid');
$parent = waRequest::param('parent');
$css_class = waRequest::param('css_class');
$new_field = false;
if (!$f instanceof waContactField) {
$new_field = true;
$f = new waContactStringField($fid, '', array('app_id' => 'shop'));
}
$prefix = 'options';
if ($parent) {
$prefix .= '[' . $parent . '][fields]';
}
static $ftypes = null;
if ($ftypes === null) {
$ftypes = array('NameSubfield' => _w('Text (input)'), 'Email' => _w('Text (input)'), 'Address' => _w('Address'), 'Text' => _w('Text (textarea)'), 'String' => _w('Text (input)'), 'Select' => _w('Select'), 'Phone' => _w('Text (input)'), 'IM' => _w('Text (input)'), 'Url' => _w('Text (input)'), 'Date' => _w('Date'), 'Composite' => _w('Composite field group'), 'Checkbox' => _w('Checkbox'));
}
$form = waContactForm::loadConfig(array('_default_value' => $f), array('namespace' => "{$prefix}[{$fid}]"));
// Get default value
$default_value = null;
if (!$new_field && $f->getParameter('_disabled')) {
$settings = wa('shop')->getConfig()->getCheckoutSettings();
if (!isset($settings['contactinfo'])) {
$settings = wa('shop')->getConfig()->getCheckoutSettings(true);
}
$fields_config = ifset($settings['contactinfo']['fields'], array());
if ($parent) {
if (!empty($fields_config[$parent]['fields'][$fid]['hidden'])) {
$default_value = ifset($fields_config[$parent]['fields'][$fid]['value']);
}
} else {
if (!empty($fields_config[$fid]['hidden'])) {
$default_value = ifset($fields_config[$fid]['value']);
}
}
if ($default_value !== null) {
$form->setValue('_default_value', $default_value);
}
}
$this->view->assign('f', $f);
$this->view->assign('fid', $fid);
$this->view->assign('form', $form);
$this->view->assign('parent', $parent);
$this->view->assign('prefix', $prefix);
$this->view->assign('uniqid', 'f' . uniqid());
$this->view->assign('new_field', $new_field);
$this->view->assign('tr_classes', $css_class);
$this->view->assign('default_value', $default_value);
$this->view->assign('ftypes', $ftypes);
}
开发者ID:Lazary,项目名称:webasyst,代码行数:52,代码来源:shopSettingsCheckoutContactFormRow.action.php
注:本文中的ifset函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论