本文整理汇总了PHP中ifempty函数的典型用法代码示例。如果您正苦于以下问题:PHP ifempty函数的具体用法?PHP ifempty怎么用?PHP ifempty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ifempty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']);
}
示例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;
}
示例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;
}
示例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)));
}
示例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);
}
示例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;
}
示例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__;
}
}
示例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'));
}
示例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 . '>';
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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 '';
}