本文整理汇总了PHP中getDefault函数的典型用法代码示例。如果您正苦于以下问题:PHP getDefault函数的具体用法?PHP getDefault怎么用?PHP getDefault使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDefault函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _post_save_vote
function _post_save_vote(&$data, &$msg)
{
$msg->voteHash = md5(strtolower(substr($data['text'], 1)));
// but if this person already voted, we need to unregister these previous votes
DB_Update('UPDATE ' . getTableName('messages') . ' SET m_votehash = "", m_deleted = "Y" WHERE m_parent = ? AND m_author = ?', array($msg->parentKey, $msg->authorEntity->key()));
DB_Update('DELETE FROM ' . getTableName('votes') . ' WHERE v_msg = ?', array($msg->parentKey));
// update the vote summary
foreach (DB_GetList('SELECT COUNT(*) as votecount,m_data,m_id,m_votehash as count FROM ' . getTableName('messages') . '
WHERE m_parent = ? AND m_deleted = "N" AND m_type="post" AND m_votehash != ""
GROUP BY m_votehash') as $vds) {
$msgData = HubbubMessage::unpackData($vds);
// get the some exemplary votes for this
$voterList = array();
foreach (DB_GetList('SELECT m_author FROM ' . getTableName('messages') . ' WHERE m_parent = ? AND m_votehash = ? ORDER BY m_created DESC LIMIT 3', array($msg->parentKey, $vds['m_votehash'])) as $vex) {
$voterList[] = $vex;
}
// if this is also what this message votes for, add it to the list
if ($this->{$msg}->voteHash == $vds['m_votehash']) {
$voterList[] = getDefault($msg->authorKey, $msg->ownerKey);
}
// make the vote summary dataset
$voteDS = array('v_msg' => $msg->parentKey, 'v_choice' => $vds['m_votehash'], 'v_text' => $msgData['text'], 'v_voters' => implode(',', $voterList), 'v_count' => $vds['votecount']);
DB_UpdateDataset('votes', $voteDS);
}
}
示例2: smarty_lifestream
/**
* Output a lifestream feed
*
* @param array $params
* @return string
*/
function smarty_lifestream($params)
{
global $lifestream_config, $PIVOTX;
$style = getDefault($PIVOTX['config']->get('lifestream_style'), $lifestream_config['lifestream_style']);
$output = $PIVOTX['extensions']->getLoadCode('defer_file', 'lifestream/lifestream.php', $style);
return $output;
}
示例3: ajax_pingserver
function ajax_pingserver()
{
$server = new HubbubServer($_REQUEST['server'], true);
$reload = '<script>
setTimeout("reload_'.md5($_REQUEST['server']).'()", 2000);
</script>';
if($server->isTrusted())
{
?><span class="green">
<?= htmlspecialchars($_REQUEST['url']) ?>
</span><?
}
else if($server->isWaitingForKey())
{
?><?= htmlspecialchars($_REQUEST['url']) ?><div class="gray">
waiting for response...
</div><?= $reload ?><?
}
else
{
$res = $server->msg_trust_sendkey1();
if($res['result'] == 'OK')
{
?><?= htmlspecialchars($_REQUEST['url']) ?><div class="gray">
exchanging credentials...
</div><?= $reload ?><?
}
else
{
?><div class="red">
✘ <a class="red" title="<?= htmlspecialchars(getDefault($res['reason'], 'no connection')) ?>"><?= htmlspecialchars($_REQUEST['url']) ?></a>
</div><?
}
}
}
示例4: ajax_commiturl
function ajax_commiturl()
{
access_policy('write');
$this->skipView = false;
if ($_REQUEST['newurl']) {
$this->changeResult = $this->model->changeMyUrl($_REQUEST['newurl']);
}
$this->myNewUrl = getDefault($_REQUEST['newurl'], $this->user->getUrl());
}
示例5: ajax_post
function ajax_post()
{
access_policy('write');
if (trim($_REQUEST['text']) != '') {
$ds = $this->model->post(array('text' => $_REQUEST['text'], 'author' => array('_key' => $this->user->entity), 'owner' => array('_key' => getDefault($_REQUEST['to'], $this->user->entity))));
ob_start();
tmpl_postlist(array('list' => array($ds)), false);
print json_encode(array('post' => ob_get_clean(), 'result' => 'OK'));
}
}
示例6: trust_sendkey2_receive
/**
* On-receive event handler
*
* This handler gets called when server (B) receives a trust_sendkey2 message from server (A),
* and it generally happens to determine whether server (A) did send a corresponding trust_sendkey1
* before. It is also used to send server (B)'s key.
*
* @param array $data
* @param object $msg
* @return boolean
*/
function trust_sendkey2_receive(&$data, &$msg)
{
$serverUrl = getDefault($data['author']['server']);
if ($serverUrl == '') {
$msg->fail('invalid server field in "from" array');
} else {
// does it really originate from server (A)?
if (!$msg->validateSignature()) {
return true;
}
// accept this server (A)'s key for future data
$msg->fromServer->ds['s_key_out'] = $msg->data['mykey'];
DB_UpdateField('servers', $msg->fromServer->ds['s_key'], 's_key_out', $msg->data['mykey']);
$msg->ok();
}
return true;
}
示例7: returnAllMenuInfo
public function returnAllMenuInfo($slug)
{
$results = \MenuItem::where('menu_item_slug', '=', $slug)->get(array('menu_item_description', 'menu_item_picture_uri', 'menu_item_name', 'menu_item_slug', 'menu_item_id', 'menu_item_category_fk', 'menu_item_short', 'menu_item_price'));
foreach ($results as $result) {
$menu_item_description = $result->menu_item_description;
$menu_item_name = $result->menu_item_name;
$menu_item_picture_uri = $result->menu_item_picture_uri;
$menu_item_id = $result->menu_item_id;
$slug = $result->menu_item_slug;
$menu_item_category_fk = $result->menu_item_category_fk;
$menu_item_short = $result->menu_item_short;
$menu_item_price = $result->menu_item_price;
}
function getCategories()
{
$category = array();
$categories = \MenuCategory::get();
foreach ($categories as $cat) {
$cat_name = $cat->menu_category_name;
$cat_id = $cat->menu_category_id;
$category[$cat_id] = $cat_name;
}
return $category;
}
function getDefault($menu_item_category_fk)
{
$results = \MenuCategory::where('menu_category_id', '=', $menu_item_category_fk)->get(array('menu_category_id'));
foreach ($results as $result) {
$category = $result->menu_category_id;
}
return $category;
}
$categories = getCategories();
$default = "";
if (isset($menu_item_category_fk)) {
$default = getDefault($menu_item_category_fk);
}
if (\Auth::check()) {
if (!isset($menu_item_description)) {
return \Redirect::to('admin');
}
return \View::make('menu-items.edit')->withMenuItemDescription($menu_item_description)->withMenuItemPictureUri($menu_item_picture_uri)->withMenuItemName($menu_item_name)->withMenuItemShort($menu_item_short)->withSlug($slug)->withCategories($categories)->withDefault($default)->withMenuItemPrice($menu_item_price);
}
return \Redirect::to('admin');
}
示例8: setUsername
function setUsername($username)
{
$userObj = object('user');
$userObj->isNewUser = $this->ds['u_entity'] == 0;
$userObj->server = new HubbubServer(cfg('service/server'), true);
$userObj->loadEntity();
$userObj->entityDS['user'] = safename($username);
$userObj->entityDS['url'] = getDefault($userObj->entityDS['url'], cfg('service/server').'/'.(cfg('service/url_rewrite') ? '' : '?').$username);
$userObj->entityDS['_local'] = 'Y';
$userObj->entityDS['_serverkey'] = $userObj->server->ds['s_key'];
$userObj->entityDS['server'] = cfg('service/server');
if(trim($userObj->entityDS['user']) != '') $ekey = DB_UpdateDataset('entities', $userObj->entityDS);
$userObj->ds['u_entity'] = $ekey;
if(trim($userObj->ds['u_name']) != '') DB_UpdateDataset('users', $userObj->ds);
if($userObj->isNewUser) h2_execute_event('user_new', $userObj->entityDS, $userObj->ds);
}
示例9: tmpl_friendlist
function tmpl_friendlist($list, $rowCallback2 = '')
{
?>
<table width="100%"><?php
foreach ($list as $ds) {
?>
<tr class="drow_<?php
echo $ds['_key'];
?>
">
<td colspan="10"><div style="width: 100%; border-top: 1px solid #aaa;"></div></td>
</tr class="drow_<?php
echo $ds['_key'];
?>
"><tr>
<td valign="top" width="60"><img src="<?php
echo getDefault($ds['pic'], 'img/anonymous.png');
?>
" width="48" style="max-height: 48px"/></td>
<td valign="top" width="50%">
<div><?php
echo HubbubEntity::link($ds);
?>
</div>
<div class="smalltext"><?php
echo htmlspecialchars($ds['url']);
?>
</div>
</td>
<td valign="top">
<?
if($rowCallback2 != '') $rowCallback2($ds);
?>
</td>
</tr><?php
}
?>
</table><?php
}
示例10: trust_sendkey1_receive
/**
* On-receive event handler
*
* Gets called when this server (A) receives a trust_sendkey1 message from another server (B).
* Usually this means, server (B) wants to establish contact for the first time or it wants
* to revoke its existing key. In both cases, the key can only be accepted when this server (A)
* contacts server (B) to confirm the origin of the trust_sendkey1 message.
*
* @param array $data
* @param object $msg
* @return boolean
*/
function trust_sendkey1_receive(&$data, &$msg)
{
$data['mykey'] = trim($data['mykey']);
$serverUrl = getDefault($data['author']['server']);
if ($serverUrl == '') {
$msg->fail('invalid server field in "author" array');
}
if ($data['mykey'] == '') {
$msg->fail('"mykey" field missing');
} else {
// accept the new key (it's not confirmed yet)
$server = new HubbubServer($serverUrl, true);
$server->ds['s_newkey_out'] = $data['mykey'];
$server->ds['s_key_in'] = getDefault($server->ds['s_key_in'], randomHashId());
DB_UpdateField('servers', $server->ds['s_key'], 's_key_in', $server->ds['s_key_in']);
logError('notrace', 'received temp outbound key: ' . $data['mykey'] . ' /// ' . dumpArray($server->ds));
// now, get origin confirmation
$confirmMsg = new HubbubMessage('trust_sendkey2');
$confirmMsg->author($server->localEntity());
$confirmMsg->owner($server->entity());
$confirmMsg->data['mykey'] = $server->ds['s_key_in'];
$responseData = $confirmMsg->sendtourl($server->ds['s_url'], $server->ds['s_newkey_out']);
if ($responseData['result'] == 'OK') {
/* we need to reload, because the server record might have changed in the meantime */
$server = new HubbubServer($serverUrl, true);
// okay, the remote server really sent the original message
$server->ds['s_key_out'] = $server->ds['s_newkey_out'];
$server->ds['s_status'] = 'OK';
DB_UpdateField('servers', $server->ds['s_key'], 's_key_out', $data['mykey']);
$msg->ok();
} else {
// this didn't work
$server->ds['s_newkey_out'] = '';
$msg->fail('unsuccessful trust_sendkey2: ' . $responseData['reason']);
}
}
return true;
}
示例11: getDefault
/**
* Getting some variables from config. If they are not set, revert to the defaults
* from widget_lifestream.php
*
*/
$twittername = getDefault($PIVOTX['config']->get('lifestream_twitterusername'), $lifestream_config['lifestream_twitterusername']);
$twitterpass = getDefault($PIVOTX['config']->get('lifestream_twitterpassword'), $lifestream_config['lifestream_twitterpassword']);
$summize = getDefault($PIVOTX['config']->get('lifestream_summize'), $lifestream_config['lifestream_summize']);
$tumblrname = getDefault($PIVOTX['config']->get('lifestream_tumblrusername'), $lifestream_config['lifestream_tumblrusername']);
$flickrfeed = getDefault($PIVOTX['config']->get('lifestream_flickrfeed'), $lifestream_config['lifestream_flickrfeed']);
$lastfmname = getDefault($PIVOTX['config']->get('lifestream_lastfmusername'), $lifestream_config['lifestream_lastfmusername']);
$max = getDefault($PIVOTX['config']->get('lifestream_max_items'), $lifestream_config['lifestream_max_items']);
$maxperfeed = getDefault($PIVOTX['config']->get('lifestream_max_perfeed'), $lifestream_config['lifestream_max_perfeed']);
$header = getDefault($PIVOTX['config']->get('lifestream_header'), $lifestream_config['lifestream_header']);
$format = getDefault($PIVOTX['config']->get('lifestream_format'), $lifestream_config['lifestream_format']);
$footer = getDefault($PIVOTX['config']->get('lifestream_footer'), $lifestream_config['lifestream_footer']);
if (empty($twittername) && empty($summize) && empty($tumblrname) && empty($flickrfeed) && empty($lastfmname)) {
$text = "At least one username must be entered in the Lifestream configuration.";
echo $text;
debug($text);
die;
}
define("MAGPIE_CACHE_AGE", 600);
include_once $PIVOTX['paths']['pivotx_path'] . 'includes/magpie/rss_fetch.inc';
$iconpath = sprintf("%slifestream/%s", $PIVOTX['paths']['extensions_url'], '%icon%');
$items = array();
$count = 0;
/**
* First get updates from Summize.. (because these will weigh least heavy, when
* ordering later on)
*/
示例12: switch
$msg .= '<div class="red">✘ please install JSON support</div>';
$c = $_SESSION['installer'];
switch($_REQUEST['part'])
{
case(0): {
$msg .= '<div class="green">✔ Installing...</div>';
break;
}
case(1): {
$cv = array();
include_once('lib/special-io.php');
$_SESSION['installer']['cfg']['service']['salt'] = randomHashId();
$myUserName = trim(shell_exec('whoami'));
$myUserName = getDefault($myUserName, 'root');
$tmplFile = '<? $GLOBALS[$cfgCategory] = json_decode(\''.json_format(json_encode($_SESSION['installer']['cfg'])).'\', true); ?>';
$cfgFileName = 'conf/default.php';
if(!file_exists($cfgFileName))
{
@chmod('conf', 0777);
WriteToFile($cfgFileName, $tmplFile);
$cfgWritable = trim(file_get_contents($cfgFileName)) == trim($tmplFile);
if(!$_SESSION['installer']['cfg']['ping']['remote']) $cronInfo = l10n('cron.setup').'
<pre>* * * * * '.$myUserName.' php -f '.$GLOBALS['APP.BASEDIR'].'/cron.php > /dev/null 2>&1</pre>
<a href="ext/installer/cronhelp.php" target="_blank">> More information / help</a><br/>';
if($cfgWritable)
$msg .= '<div class="green">✔ Config file written</div>
<br/>
'.$cronInfo.'
示例13: __init
function __init()
{
$this->invokeModel();
$srv = getDefault($_SERVER['HTTP_HOST'], l10n('this.server'));
$this->srvName = strtoupper(substr($srv, 0, 1)) . substr($srv, 1);
}
示例14: pagem_editcomment
function pagem_editcomment()
{
global $PIVOTX;
require_once dirname(__FILE__) . '/modules/module_comments.php';
$PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
// uid should be numeric. (If it's not, someone is hacking ...)
if (!is_numeric($_GET['uid'])) {
echo "uid must be numeric";
die;
}
$entry = $PIVOTX['db']->read_entry(intval($_GET['uid']));
// Check if the user is allowed to edit this entry. It should either be his/her own
// Entry, or the userlevel should be advanced.
if ($PIVOTX['session']->currentUsername() != $entry['user']) {
$PIVOTX['session']->minLevel(PIVOTX_UL_ADVANCED);
}
if (isset($entry['comments'][$_GET['key']])) {
$comment = $entry['comments'][$_GET['key']];
} else {
// This should only happen for non-SQL db when editing a comment from
// the latest comments screen (or similar functions) which uses fake UIDs.
foreach ($entry['comments'] as $key => $value) {
if ($_GET['key'] == makeCommentUID($value)) {
$comment = $value;
// Setting the key to the array key
$_GET['key'] = $key;
break;
}
}
}
if (count($_POST) < 4) {
$PIVOTX['template']->assign('uid', $_GET['uid']);
$PIVOTX['template']->assign('comment', $comment);
$PIVOTX['template']->assign('pivotxsession', $PIVOTX['session']->getCSRF());
$PIVOTX['template']->assign("title", __('Edit Comment'));
$PIVOTX['template']->assign("active", "comments");
renderTemplate('mobile/editcomment.tpl');
} else {
// Make sure the current user is properly logged in, and that the request is legitimate
$PIVOTX['session']->checkCSRF($_POST['pivotxsession']);
// Make sure 'moderate' is set..
$_POST['moderate'] = getDefault($_POST['moderate'], 0);
// Merge the $_POST into the comment..
foreach ($comment as $key => $value) {
if (isset($_POST[$key])) {
$comment[$key] = $_POST[$key];
}
}
editComment($entry, $_GET['key'], $comment);
$PIVOTX['messages']->addMessage(__('The Comment was saved!'));
pagem_comments();
}
}
示例15: display
function display($opt = array())
{
if ($this->getDataOnDisplay) {
$this->getData();
}
if ($this->hidden) {
return;
}
if ($this->formClosed != true) {
$this->params['formsubmit'] = $this->name;
$this->add('end', $name, $name, array('params' => $this->params));
$this->formClosed = true;
}
include_once $this->presentationDir . $this->presentationName . '.php';
$templateInitFunction = $this->presentationName . '_init';
if (is_callable($templateInitFunction)) {
$templateInitFunction($this);
}
foreach ($this->elements as $e) {
$sessionFieldName = $this->name . '-' . $e['name'];
$e['pure-caption'] = $e['caption'];
$e['caption'] .= $this->packCaption;
if ($e['validate'] == 'notempty' && isset($this->mandatoryMarker)) {
$e['caption'] = $e['caption'] . $this->mandatoryMarker;
}
if (trim($e['info']) != '') {
$e['infomarker'] = str_replace('$', $e['info'], $this->infoMarker);
}
print $this->packStart;
print getDefault($opt['field-start']);
$dFunction = $this->presentationName . '_' . $e['type'];
if ($e['sessiondefault'] == true) {
$e['default'] = getDefault($_SESSION[$sessionFieldName], $e['default']);
}
$e['value'] = getDefault(getValueFromArray($this->ds, $e['name']), $e['default']);
if ($e['sessiondefault'] == true) {
$_SESSION[$sessionFieldName] = $e['value'];
}
$e['error'] = $this->errors[$e['name']];
if (is_callable($dFunction)) {
$dFunction($e, $this);
} else {
logError('form', 'CQForm: unknown form element type "' . $e['type'] . '"');
}
print getDefault($opt['field-end']);
print $this->packEnd;
}
return $this;
}