本文整理汇总了PHP中value_or_default函数的典型用法代码示例。如果您正苦于以下问题:PHP value_or_default函数的具体用法?PHP value_or_default怎么用?PHP value_or_default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了value_or_default函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_webuser_groups
SET website = :website, name = :name, code = :code, description = :description
WHERE id = :id', array('id' => $this->id, 'website' => $this->website, 'name' => value_or_default($this->name, ""), 'code' => value_or_default($this->code, ""), 'description' => value_or_default($this->description, "")));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
示例2: update
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_profiles
SET name = :name, description = :description, menus = :menus
WHERE id = :id', array('name' => value_or_default($this->name, ""), 'description' => value_or_default($this->description, ""), 'menus' => json_encode($this->menus), 'id' => $this->id));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
示例3: update
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_functions
SET category = :category, codename = :codename, icon = :icon,
lid = :lid, enabled = :enabled
WHERE id = :id', array('id' => $this->id, 'category' => value_or_default($this->category, ""), 'codename' => value_or_default($this->codename, ""), 'icon' => value_or_default($this->icon, ""), 'lid' => value_or_default($this->lid, 0), 'enabled' => value_or_default($this->enabled, 0)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
示例4: update
public function update()
{
global $DB;
$ok = $DB->execute('
UPDATE nv_paths
SET type = :type, object_id = :object_id, lang = :lang,
path = :path, cache_file = :cache_file, cache_expires = :cache_expires, views = :views,
id = :id, website = :website', array("type" => $this->type, "object_id" => $this->object_id, "lang" => $this->lang, "path" => $this->path, "cache_file" => $this->cache_file, "cache_expires" => $this->cache_expires, "views" => value_or_default($this->views, 0), "id" => $this->id, "website" => $this->website));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
示例5: update
public function update()
{
global $DB;
global $website;
$this->date = core_time();
$ok = $DB->execute('
UPDATE nv_webuser_votes
SET webuser = :webuser, object = :object, object_id = :object_id, value = :value, date = :date
WHERE id = :id AND website = :website', array('id' => $this->id, 'website' => value_or_default($this->website, $website->id), 'webuser' => value_or_default($this->webuser, 0), 'object' => $this->object, 'object_id' => $this->object_id, 'value' => $this->value, 'date' => value_or_default($this->date, 0)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
示例6: save_properties_from_array
//.........这里部分代码省略.........
}
} else {
// compatibility with < Navigate 2.1 themes (to be removed)
$properties_names = array_keys($properties_assoc);
$block = block::block_group_block_by_property($properties_names[0]);
}
if (!isset($block->properties) || empty($block->properties)) {
return false;
}
$properties = $block->properties;
} else {
$properties = property::elements($template, $object_type);
}
if (!is_array($properties)) {
$properties = array();
}
foreach ($properties as $property) {
if (!isset($properties_assoc[$property->name]) && !isset($properties_assoc[$property->id])) {
continue;
}
$values_dict = array();
$value = '';
// we try to find the property value by "property name", if empty then we try to find it via "property id"
if (isset($properties_assoc[$property->name])) {
$value = $properties_assoc[$property->name];
}
if (empty($value)) {
$value = $properties_assoc[$property->id];
}
// multilanguage property?
if (in_array($property->type, array('text', 'textarea', 'link', 'rich_textarea')) || @$property->multilanguage == 'true' || @$property->multilanguage === true) {
if (isset($properties_assoc[$property->name])) {
$values_dict = $properties_assoc[$property->name];
}
if (empty($values_dict)) {
$values_dict = $properties_assoc[$property->id];
}
$value = '[dictionary]';
}
if ($property->type == 'coordinates') {
if (is_array($value)) {
$value = $value['latitude'] . '#' . $value['longitude'];
}
// if it isn't an array, then we suppose it already has the right format
}
// property->type "decimal"; we don't need to reconvert, it should already be in the right format
if ($property->type == 'webuser_groups' && !empty($value)) {
$value = 'g' . implode(',g', $value);
}
// boolean (checkbox): if not checked, form does not send the value
if ($property->type == 'boolean' && empty($value)) {
$value = 0;
}
if (is_null($value)) {
$value = "";
}
// should not be needed because of value_or_default, but doing this here fixes some warnings
// remove the old property value row
$DB->execute('
DELETE FROM nv_properties_items
WHERE property_id = ' . protect($property->id) . '
AND element = ' . protect($property_object_type) . '
AND node_id = ' . protect($object_id) . (empty($node_uid) ? '' : ' AND node_uid = ' . protect($node_uid)) . '
AND website = ' . $ws->id);
// now we insert a new row
$DB->execute('
INSERT INTO nv_properties_items
(id, website, property_id, element, node_id, node_uid, name, value)
VALUES
( 0,
:website,
:property_id,
:type,
:object_id,
:node_uid,
:name,
:value
)', array(':website' => $ws->id, ':property_id' => $property->id, ':type' => $property_object_type, ':object_id' => value_or_default($object_id, 0), ':node_uid' => value_or_default($node_uid, ""), ':name' => $property->name, ':value' => value_or_default($value, "")));
// $error = $DB->get_last_error();
// set the dictionary for the multilanguage properties
$default_language = '';
if (isset($property->multilanguage) && ($property->multilanguage === 'false' || $property->multilanguage === false)) {
$default_language = $ws->languages_list[0];
}
if (in_array($property->type, array('text', 'textarea', 'rich_textarea', 'link')) || @$property->multilanguage == 'true' || @$property->multilanguage === true) {
foreach ($ws->languages_list as $lang) {
if (!empty($default_language)) {
// property is NOT multilanguage, use the first value for all languages
$dictionary[$lang]['property-' . $property->id . '-' . $lang] = $values_dict[$default_language];
} else {
$dictionary[$lang]['property-' . $property->id . '-' . $lang] = $values_dict[$lang];
}
}
}
}
if (!empty($dictionary)) {
webdictionary::save_element_strings('property-' . $property_object_type, $object_id, $dictionary, $ws->id, $node_uid);
}
return true;
}
示例7: update
public function update()
{
global $DB;
$groups = '';
if (is_array($this->groups)) {
$this->groups = array_unique($this->groups);
// remove duplicates
$this->groups = array_filter($this->groups);
// remove empty
if (!empty($this->groups)) {
$groups = 'g' . implode(',g', $this->groups);
}
}
if ($groups == 'g') {
$groups = '';
}
$ok = $DB->execute('
UPDATE nv_files
SET
type = :type,
parent = :parent,
name = :fname,
size = :size,
mime = :mime,
width = :width,
height = :height,
focalpoint = :focalpoint,
title = :title,
description = :description,
date_added = :date_added,
uploaded_by = :uploaded_by,
permission = :permission,
access = :access,
groups = :groups,
system = :system,
enabled = :enabled
WHERE id = :id
AND website = :website_id
', array(":id" => $this->id, ":website_id" => $this->website, ":type" => $this->type, ":parent" => $this->parent, ":fname" => $this->name, ":size" => $this->size, ":mime" => $this->mime, ":width" => $this->width, ":height" => $this->height, ":focalpoint" => value_or_default($this->focalpoint, ''), ":title" => json_encode($this->title), ":description" => json_encode($this->description), ":date_added" => $this->date_added, ":uploaded_by" => $this->uploaded_by, ":permission" => $this->permission, ":access" => value_or_default($this->access, 0), ":groups" => $groups, ":system" => value_or_default($this->system, 0), ":enabled" => $this->enabled));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}
示例8: run
function run()
{
global $user;
switch (@$_REQUEST['act']) {
case 'json':
switch ($_REQUEST['oper']) {
case 'settings_panels':
// save dashboard panels state
$dashboard_panels = $_REQUEST['dashboard_panels'];
$user->setting('dashboard-panels', json_encode($dashboard_panels));
echo json_encode(true);
core_terminate();
break;
case 'feed':
$feed = new feed_parser();
$feed->set_cache(4 * 3600);
// once update each 4 hours
$feed->load($_REQUEST['url']);
list($channel, $articles, $count) = $feed->parse(0, $_REQUEST['limit'], 'newest');
$items = item::convert_from_rss($articles);
$display_language = $_REQUEST['language'];
if (!empty($items)) {
$feed_html = '';
for ($c = 0; $c < count($items); $c++) {
if (empty($items[$c])) {
break;
}
if (!isset($items[$c]->dictionary[$display_language])) {
// requested language not available, get the first available in the feed
$feed_languages = array_keys($items[$c]->dictionary);
$display_language = $feed_languages[0];
}
$tmp = array('<div class="navigate-panel-body-title ui-corner-all">' . '<a href="' . $items[$c]->paths[$display_language] . '" target="_blank">' . core_ts2date($items[$c]->date_to_display, true) . ' ' . '<strong>' . $items[$c]->dictionary[$display_language]['title'] . '</strong>' . '</a>' . '</div>', '<div id="navigatecms-feed-item-' . $items[$c]->id . '" class="navigate-panel-recent-feed-element">' . $items[$c]->dictionary[$display_language]['section-main'] . '</div>');
$feed_html .= implode("\n", $tmp);
}
}
echo $feed_html;
core_terminate();
break;
default:
// list or search
}
break;
case 'recent_items':
$ri = users_log::recent_items(value_or_default($_REQUEST['limit']), 10);
if (!is_array($ri)) {
$ri = array();
}
for ($i = 0; $i < count($ri); $i++) {
$action = $ri[$i];
$ri[$i]->_url = '?fid=' . $action->function . '&wid=' . $action->website . '&act=load&id=' . $action->item;
$ri[$i]->_link = '<a href="' . $ri[$i]->_url . '" title="' . htmlspecialchars($action->item_title) . ' | ' . htmlspecialchars(t($action->function_title, $action->function_title)) . '"><img src="' . $action->function_icon . '" align="absmiddle" /> ' . core_string_cut($action->item_title, 33) . '</a>';
}
echo json_encode($ri);
core_terminate();
break;
default:
$out = dashboard_create();
}
return $out;
}
示例9: v
/**
* An alias of {@link value_or_default()}
*
*
* @param mixed $value
* @param mixed $default
* @return mixed
*/
function v($value, $default)
{
return value_or_default($value, $default);
}
示例10: update
public function update()
{
global $DB;
global $website;
global $events;
global $user;
if (!is_null($user)) {
if ($user->permission("items.edit") == 'false' && $this->author != $user->id) {
throw new Exception(t(610, "Sorry, you are not allowed to execute this function."));
}
if (!structure::category_allowed($this->category)) {
throw new Exception(t(610, "Sorry, you are not allowed to execute this function."));
}
}
$this->date_modified = core_time();
$groups = '';
if (is_array($this->groups)) {
$this->groups = array_unique($this->groups);
// remove duplicates
$this->groups = array_filter($this->groups);
// remove empty
if (!empty($this->groups)) {
$groups = 'g' . implode(',g', $this->groups);
}
}
if ($groups == 'g') {
$groups = '';
}
$ok = $DB->execute('
UPDATE nv_items
SET
association = :association,
category = :category,
embedding = :embedding,
template = :template,
date_to_display = :date_to_display,
date_published = :date_published,
date_unpublish = :date_unpublish,
date_modified = :date_modified,
author = :author,
galleries = :galleries,
comments_enabled_to = :comments_enabled_to,
comments_moderator = :comments_moderator,
access = :access,
groups = :groups,
permission = :permission,
views = :views,
votes = :votes,
score = :score,
position = :position
WHERE id = :id
AND website = :website', array(":association" => $this->association, ":category" => $this->category, ":embedding" => $this->embedding, ":template" => $this->template, ":date_to_display" => value_or_default($this->date_to_display, 0), ":date_published" => value_or_default($this->date_published, 0), ":date_unpublish" => value_or_default($this->date_unpublish, 0), ":date_modified" => $this->date_modified, ":author" => $this->author, ":galleries" => serialize($this->galleries), ":comments_enabled_to" => value_or_default($this->comments_enabled_to, 0), ":comments_moderator" => value_or_default($this->comments_moderator, 0), ":access" => $this->access, ":groups" => $groups, ":permission" => $this->permission, ":views" => $this->views, ":votes" => $this->votes, ":score" => $this->score, ":position" => value_or_default($this->position, 0), ":id" => $this->id, ":website" => $this->website));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
webdictionary::save_element_strings('item', $this->id, $this->dictionary, $this->website);
webdictionary_history::save_element_strings('item', $this->id, $this->dictionary, false, $this->website);
path::saveElementPaths('item', $this->id, $this->paths, $this->website);
$events->trigger('item', 'save', array('item' => $this));
return true;
}
示例11: all_error_texts
function all_error_texts()
{
return implode('<br>', array_map('retry_error_text', array_keys(value_or_default($_GET, ERROR_GET_VARIABLE, array()))));
}
示例12: set_or_default
/**
* Sets a template variable with a value or a default value if value is empty
*
* @param string $name
* @param string $value
* @param string $default
* @return mixed setted value
*/
function set_or_default($name, $value, $default)
{
return set($name, value_or_default($value, $default));
}
示例13: update
public function update()
{
global $DB;
global $website;
$groups = '';
if (is_array($this->groups)) {
$this->groups = array_unique($this->groups);
// remove duplicates
$this->groups = array_filter($this->groups);
// remove empty
if (!empty($this->groups)) {
$groups = 'g' . implode(',g', $this->groups);
}
}
if ($groups == 'g') {
$groups = '';
}
$ok = $DB->execute('
UPDATE nv_structure
SET parent = :parent, position = :position, access = :access, groups = :groups,
permission = :permission, icon = :icon, metatags = :metatags,
date_published = :date_published, date_unpublish = :date_unpublish,
template = :template, visible = :visible, views = :views, votes = :votes, score = :score
WHERE id = :id
AND website = :website
', array(":id" => $this->id, ":website" => $this->website, ":parent" => value_or_default($this->parent, 0), ":position" => $this->position, ":access" => $this->access, ":groups" => $groups, ":permission" => $this->permission, ":icon" => value_or_default($this->icon, ''), ":metatags" => value_or_default($this->metatags, ''), ":template" => $this->template, ":date_published" => value_or_default($this->date_published, 0), ":date_unpublish" => value_or_default($this->date_unpublish, 0), ":visible" => $this->visible, ":views" => $this->views, ":votes" => $this->votes, ":score" => $this->score));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
webdictionary::save_element_strings('structure', $this->id, $this->dictionary, $this->website);
path::saveElementPaths('structure', $this->id, $this->paths, $this->website);
return true;
}
示例14: update
public function update()
{
global $DB;
if (!is_array($this->categories)) {
$this->categories = array();
}
$ok = $DB->execute('
UPDATE nv_feeds
SET categories = :categories, format = :format, image = :image, entries = :entries,
content = :content, views = :views, permission = :permission, enabled = :enabled
WHERE id = :id AND website = :website', array('id' => $this->id, 'website' => $this->website, 'categories' => implode(',', $this->categories), 'format' => $this->format, 'image' => value_or_default($this->image, 0), 'entries' => value_or_default($this->entries, 10), 'content' => $this->content, 'views' => value_or_default($this->views, 0), 'permission' => value_or_default($this->permission, 0), 'enabled' => value_or_default($this->enabled, 0)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
webdictionary::save_element_strings('feed', $this->id, $this->dictionary);
path::saveElementPaths('feed', $this->id, $this->paths);
return true;
}
示例15: update
public function update()
{
global $DB;
global $website;
$ok = $DB->execute('UPDATE nv_block_groups
SET
`code` = :code,
title = :title,
notes = :notes,
blocks = :blocks
WHERE id = :id
AND website = :website
', array(':id' => $this->id, ':website' => $this->website, ':code' => value_or_default($this->code, ''), ':title' => value_or_default($this->title, ''), ':notes' => value_or_default($this->notes, ''), ':blocks' => json_encode($this->blocks)));
if (!$ok) {
throw new Exception($DB->get_last_error());
}
return true;
}