本文整理匯總了PHP中StringIsNullOrEmpty函數的典型用法代碼示例。如果您正苦於以下問題:PHP StringIsNullOrEmpty函數的具體用法?PHP StringIsNullOrEmpty怎麽用?PHP StringIsNullOrEmpty使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了StringIsNullOrEmpty函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Activity
public function Activity($UserReference = '', $Username = '', $UserID = '')
{
$this->Permission('Garden.Profiles.View');
$this->GetUserInfo($UserReference, $Username, $UserID);
$this->SetTabView('Activity');
$this->ActivityModel = new ActivityModel();
$Session = Gdn::Session();
$Comment = $this->Form->GetFormValue('Comment');
if ($Session->UserID > 0 && $this->Form->AuthenticatedPostBack() && !StringIsNullOrEmpty($Comment)) {
$Comment = substr($Comment, 0, 1000);
// Limit to 1000 characters...
// Update About if necessary
$ActivityType = 'WallComment';
$SendNotification = TRUE;
if ($Session->UserID == $this->User->UserID) {
$SendNotification = FALSE;
$this->UserModel->SaveAbout($Session->UserID, $Comment);
$this->User->About = $Comment;
$this->SetJson('UserData', $this->FetchView('user'));
$ActivityType = 'AboutUpdate';
}
$NewActivityID = $this->ActivityModel->Add($Session->UserID, $ActivityType, $Comment, $this->User->UserID, '', '/profile/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), $SendNotification);
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
Redirect('dashboard/profile/' . $UserReference);
} else {
// Load just the single new comment
$this->HideActivity = TRUE;
$this->ActivityData = $this->ActivityModel->GetWhere('ActivityID', $NewActivityID);
$this->View = 'activities';
$this->ControllerName = 'activity';
}
} else {
$this->ProfileUserID = $this->User->UserID;
$this->ActivityData = $this->ActivityModel->Get($this->User->UserID);
if ($this->ActivityData->NumRows() > 0) {
$ActivityData = $this->ActivityData->Result();
$ActivityIDs = ConsolidateArrayValuesByKey($ActivityData, 'ActivityID');
$LastActivity = $this->ActivityData->FirstRow();
$LastModifiedDate = Gdn_Format::ToTimestamp($this->User->DateUpdated);
$LastActivityDate = Gdn_Format::ToTimestamp($LastActivity->DateInserted);
if ($LastModifiedDate < $LastActivityDate) {
$LastModifiedDate = $LastActivityDate;
}
// Make sure to only query this page if the user has no new activity since the requesting browser last saw it.
$this->SetLastModified($LastModifiedDate);
$this->CommentData = $this->ActivityModel->GetComments($ActivityIDs);
} else {
$this->CommentData = FALSE;
}
}
// Set the canonical Url.
if (is_numeric($this->User->Name) || Gdn_Format::Url($this->User->Name) != strtolower($this->User->Name)) {
$this->CanonicalUrl(Url('profile/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), TRUE));
} else {
$this->CanonicalUrl(Url('profile/' . strtolower($this->User->Name), TRUE));
}
$this->Render();
}
示例2: ToString
public function ToString()
{
if (!Gdn::Session()->CheckPermission('Garden.Activity.View')) {
return '';
}
if (StringIsNullOrEmpty($this->ActivityModuleTitle)) {
$this->ActivityModuleTitle = T('Recent Activity');
}
$Data = $this->ActivityData;
if (is_object($Data) && $Data->NumRows() > 0) {
return parent::ToString();
}
return '';
}
示例3: discussionModel_beforeSaveDiscussion_handler
/**
* Set DateLastComment to null & sink & close if this is an insert and 'Show as Page' was selected.
*/
public function discussionModel_beforeSaveDiscussion_handler($sender, &$args)
{
if (CheckPermission('Garden.Community.Manage') || CheckPermission('Garden.Settings.Manage')) {
if ($args['Insert'] && $args['FormPostValues']['Page'] == 1) {
$args['FormPostValues']['DateLastComment'] = NULL;
$args['FormPostValues']['Sink'] = 1;
$args['FormPostValues']['Closed'] = 1;
$args['FormPostValues']['Type'] = 'SimplePage';
if (StringIsNullOrEmpty($args['FormPostValues']['ForeignID'])) {
$sender->Validation->AddValidationResult('ForeignID', 'URL Slug required for pages.');
}
}
}
}
示例4: DefineLocation
public function DefineLocation($Message)
{
if (is_object($Message)) {
if ($Message->Controller == 'Base') {
$Message->Location = 'Base';
} else {
$Message->Location = $Message->Application;
if (!StringIsNullOrEmpty($Message->Controller)) {
$Message->Location .= '/' . $Message->Controller;
}
if (!StringIsNullOrEmpty($Message->Method)) {
$Message->Location .= '/' . $Message->Method;
}
}
}
return $Message;
}
示例5: DefineLocation
public function DefineLocation($Message)
{
if (is_object($Message)) {
if (in_array($Message->Controller, $this->_SpecialLocations)) {
$Message->Location = $Message->Controller;
} else {
$Message->Location = $Message->Application;
if (!StringIsNullOrEmpty($Message->Controller)) {
$Message->Location .= '/' . $Message->Controller;
}
if (!StringIsNullOrEmpty($Message->Method)) {
$Message->Location .= '/' . $Message->Method;
}
}
}
return $Message;
}
示例6: DefineLocation
/**
* Build the Message's Location property and add it.
*
* @param mixed $Message Array or object.
* @return mixed Array or object given with Location property/key added.
*/
public function DefineLocation($Message)
{
$Controller = GetValue('Controller', $Message);
$Application = GetValue('Application', $Message);
$Method = GetValue('Method', $Message);
if (in_array($Controller, $this->_SpecialLocations)) {
SetValue('Location', $Message, $Controller);
} else {
SetValue('Location', $Message, $Application);
if (!StringIsNullOrEmpty($Controller)) {
SetValue('Location', $Message, GetValue('Location', $Message) . '/' . $Controller);
}
if (!StringIsNullOrEmpty($Method)) {
SetValue('Location', $Message, GetValue('Location', $Message) . '/' . $Method);
}
}
return $Message;
}
示例7: Index
public function Index($RoleID = '')
{
$this->Permission('Garden.Activity.View');
// Limit to specific RoleIDs?
if ($RoleID != '') {
$RoleID = explode(',', $RoleID);
}
$this->AddJsFile('activity.js');
$this->Title(T('Recent Activity'));
$Session = Gdn::Session();
$Comment = $this->Form->GetFormValue('Comment');
$this->CommentData = FALSE;
if ($Session->UserID > 0 && $this->Form->AuthenticatedPostBack() && !StringIsNullOrEmpty($Comment)) {
$Comment = substr($Comment, 0, 1000);
// Limit to 1000 characters...
// Update About if necessary
$ActivityType = 'WallComment';
$NewActivityID = $this->ActivityModel->Add($Session->UserID, $ActivityType, $Comment);
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
Redirect('activity');
} else {
// Load just the single new comment
$this->HideActivity = TRUE;
$this->ActivityData = $this->ActivityModel->GetWhere('ActivityID', $NewActivityID);
$this->View = 'activities';
}
} else {
$this->ActivityData = is_array($RoleID) ? $this->ActivityModel->GetForRole($RoleID) : $this->ActivityModel->Get();
if ($this->ActivityData->NumRows() > 0) {
$ActivityData = $this->ActivityData->ResultArray();
$ActivityIDs = ConsolidateArrayValuesByKey($ActivityData, 'ActivityID');
$this->CommentData = $this->ActivityModel->GetComments($ActivityIDs);
}
$this->View = 'all';
}
$this->Render();
}
示例8: ReplaceEmpty
function ReplaceEmpty(&$Collection, $R)
{
if (is_object($Collection)) {
foreach (get_object_vars($Collection) as $Property => $Value) {
if (StringIsNullOrEmpty($Value)) {
$Collection->{$Property} = $R;
}
}
} else {
if (is_array($Collection)) {
foreach ($Collection as &$Value) {
if (StringIsNullOrEmpty($Value)) {
$Value = $R;
}
}
}
}
return $Collection;
}
示例9: CheckRequirements
function CheckRequirements($ItemName, $RequiredItems, $EnabledItems, $RequiredItemTypeCode)
{
// 1. Make sure that $RequiredItems are present
if (is_array($RequiredItems)) {
foreach ($RequiredItems as $RequiredItemName => $RequiredVersion) {
if (array_key_exists($RequiredItemName, $EnabledItems) === FALSE) {
throw new Exception(sprintf(Gdn::Translate('%1$s requires the %2$s %3$s version %4$s.'), $ItemName, $RequiredItemName, $RequiredItemTypeCode, $RequiredVersion));
} else {
if (StringIsNullOrEmpty($RequiredVersion) === FALSE) {
// If the item exists and is enabled, check the version
$EnabledVersion = ArrayValue('Version', ArrayValue($RequiredItemName, $EnabledItems, array()), '');
if ($EnabledVersion !== $RequiredVersion) {
// Check for version ranges (<, <=, >, >=)
$Matches = FALSE;
preg_match_all('/(>|>=|<|<=){1}([\\d\\.]+)/', $RequiredVersion, $Matches);
if (is_array($Matches) && count($Matches) == 3 && count($Matches[1]) > 0) {
// The matches array should contain a three parts:
/*
eg. The following $RequiredVersion string:
>1.33<=4.1
would result in:
Array (
[0] => Array
(
[0] => >1.33
[1] => <=4.1
)
[1] => Array
(
[0] => >
[1] => <=
)
[2] => Array
(
[0] => 1.33
[1] => 4.1
)
)
*/
$Operators = $Matches[1];
$Versions = $Matches[2];
$Count = count($Operators);
for ($i = 0; $i < $Count; ++$i) {
$Operator = $Operators[$i];
$MatchVersion = $Versions[$i];
if (!version_compare($EnabledVersion, $MatchVersion, $Operator)) {
throw new Exception(sprintf(Gdn::Translate('%1$s requires the %2$s %3$s version %4$s %5$s'), $ItemName, $RequiredItemName, $RequiredItemTypeCode, $Operator, $MatchVersion));
}
}
} else {
if ($RequiredVersion != '*' && $RequiredVersion != '') {
throw new Exception(sprintf(Gdn::Translate('%1$s requires the %2$s %3$s version %4$s'), $ItemName, $RequiredItemName, $RequiredItemTypeCode, $RequiredVersion));
}
}
}
}
}
}
}
}
示例10: Activity
public function Activity($UserReference = '')
{
$this->SetTabView($UserReference, 'Activity');
$this->ActivityModel = new ActivityModel();
$Session = Gdn::Session();
$Comment = $this->Form->GetFormValue('Comment');
if ($Session->UserID > 0 && $this->Form->AuthenticatedPostBack() && !StringIsNullOrEmpty($Comment)) {
$Comment = substr($Comment, 0, 1000);
// Limit to 1000 characters...
// Update About if necessary
$ActivityType = 'WallComment';
if ($Session->UserID == $this->User->UserID) {
$this->UserModel->SaveAbout($Session->UserID, $Comment);
$this->User->About = $Comment;
$this->SetJson('UserData', $this->FetchView('user'));
$ActivityType = 'AboutUpdate';
}
$NewActivityID = $this->ActivityModel->Add($Session->UserID, $ActivityType, $Comment, $this->User->UserID);
/* if (strlen(trim($About)) > 0)
AddActivity($UserID, 'AboutUpdate', $About);
*/
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
Redirect('garden/profile/' . $UserReference);
} else {
// Load just the single new comment
$this->HideActivity = TRUE;
$this->ActivityData = $this->ActivityModel->GetWhere('ActivityID', $NewActivityID);
$this->View = 'activities';
$this->ControllerName = 'activity';
}
} else {
$this->ProfileUserID = $this->User->UserID;
$this->ActivityData = $this->ActivityModel->Get($this->User->UserID);
if ($this->ActivityData->NumRows() > 0) {
$LastActivity = $this->ActivityData->FirstRow();
$LastModifiedDate = Format::ToTimestamp($this->User->DateUpdated);
$LastActivityDate = Format::ToTimestamp($LastActivity->DateInserted);
if ($LastModifiedDate < $LastActivityDate) {
$LastModifiedDate = $LastActivityDate;
}
// Make sure to only query this page if the user has no new activity since the requesting browser last saw it.
$this->SetLastModified($LastModifiedDate);
$FirstActivityID = $this->ActivityData->LastRow()->ActivityID;
$this->CommentData = $this->ActivityModel->GetComments($FirstActivityID, $LastActivity->ActivityID, $this->User->UserID);
} else {
$this->CommentData = FALSE;
}
}
$this->Render();
}
示例11: StringIsNullOrEmpty
if (!defined('APPLICATION')) {
exit;
}
// Get the information for displaying the connection information.
if (!($ConnectName = $this->Form->GetFormValue('FullName'))) {
$ConnectName = $this->Form->GetFormValue('Name');
}
$ConnectPhoto = $this->Form->GetFormValue('Photo');
if (!$ConnectPhoto) {
$ConnectPhoto = '/applications/dashboard/design/images/usericon.gif';
}
$ConnectSource = $this->Form->GetFormValue('ProviderName');
?>
<div class="Connect">
<h1><?php
echo StringIsNullOrEmpty($ConnectSource) ? T("Sign in") : sprintf(T('%s Connect'), $ConnectSource);
?>
</h1>
<div>
<?php
echo $this->Form->Open();
echo $this->Form->Errors();
if ($ConnectName || $ConnectPhoto) {
?>
<div class="MeBox">
<?php
if ($ConnectPhoto) {
echo '<span class="PhotoWrap">', Img($ConnectPhoto, array('alt' => T('Profile Picture'), 'class' => 'ProfilePhoto')), '</span>';
}
echo '<div class="WhoIs">';
if ($ConnectName && $ConnectSource) {
示例12: GetUpdate
/**
* Returns an update statement for the specified table with the provided
* $Data.
*
* @param array $Tables The name of the table to updated data in.
* @param array $Data An associative array of FieldName => Value pairs that should be inserted
* $Table.
* @param mixed $Where A where clause (or array containing multiple where clauses) to be applied
* to the where portion of the update statement.
*/
public function GetUpdate($Tables, $Data, $Where) {
if (!is_array($Data))
trigger_error(ErrorMessage('The data provided is not in a proper format (Array).', 'MySQLDriver', '_GetUpdate'), E_USER_ERROR);
$Sets = array();
foreach($Data as $Field => $Value) {
$Sets[] = $Field." = ".$Value;
}
$sql = 'update '.$this->_FromTables($Tables);
if (count($this->_Joins) > 0) {
$sql .= "\n";
$Join = $this->_Joins[count($this->_Joins) - 1];
$sql .= implode("\n", $this->_Joins);
}
$sql .= " set \n ".implode(",\n ", $Sets);
if (is_array($Where) && count($Where) > 0) {
$sql .= "\nwhere ".implode("\n ", $Where);
// Close any where groups that were left open.
for ($i = 0; $i < $this->_OpenWhereGroupCount; ++$i) {
$sql .= ')';
}
$this->_OpenWhereGroupCount = 0;
} else if (is_string($Where) && !StringIsNullOrEmpty($Where)) {
$sql .= ' where '.$Where;
}
return $sql;
}
示例13: DiscussionModel_BeforeSaveDiscussion_Handler
/**
* Validate tags when saving a discussion.
*/
public function DiscussionModel_BeforeSaveDiscussion_Handler($Sender, $Args)
{
$FormPostValues = GetValue('FormPostValues', $Args, array());
$TagsString = trim(strtolower(GetValue('Tags', $FormPostValues, '')));
$NumTagsMax = C('Plugin.Tagging.Max', 5);
// Tags can only contain unicode and the following ASCII: a-z 0-9 + # _ .
if (StringIsNullOrEmpty($TagsString) && C('Plugins.Tagging.Required')) {
$Sender->Validation->AddValidationResult('Tags', 'You must specify at least one tag.');
} else {
$Tags = TagModel::SplitTags($TagsString);
if (!TagModel::ValidateTags($Tags)) {
$Sender->Validation->AddValidationResult('Tags', '@' . T('ValidateTag', 'Tags cannot contain commas.'));
} elseif (count($Tags) > $NumTagsMax) {
$Sender->Validation->AddValidationResult('Tags', '@' . sprintf(T('You can only specify up to %s tags.'), $NumTagsMax));
} else {
}
}
}
示例14: htmlspecialchars
?>
<li id="Conversation_<?php
echo $Row['ConversationID'];
?>
" class="Item">
<?php
$JumpToItem = $Row['CountMessages'] - $Row['CountNewMessages'];
$Url = "/messages/{$Row['ConversationID']}/#Item_{$JumpToItem}";
if ($SubjectsVisible && $Row['Subject']) {
$Message = htmlspecialchars($Row['Title']);
} elseif ($Row['Format'] == 'Text') {
$Message = SliceString(Gdn_Format::To($Row['LastMessage'], $Conversation['Format']), 100);
} else {
$Message = SliceString(Gdn_Format::Text(Gdn_Format::To($Row['LastMessage'], $Row['Format']), FALSE), 100);
}
if (StringIsNullOrEmpty(trim($Message))) {
$Message = T('Blank Message');
}
echo Anchor($Message, $Url, 'ConversationLink');
?>
<div class="Meta">
<span class="MItem Participants">
<?php
$First = TRUE;
foreach ($Row['Participants'] as $User) {
if ($First) {
$First = FALSE;
} else {
echo ', ';
}
if ($User['UserID'] == Gdn::Session()->UserID) {
示例15: Activity
/**
* Show activity feed for this user.
*
* @since 2.0.0
* @access public
* @param mixed $UserReference Unique identifier, possible ID or username.
* @param string $Username Username.
* @param int $UserID Unique ID.
* @param int $Offset How many to skip (for paging).
*/
public function Activity($UserReference = '', $Username = '', $UserID = '', $Offset = '0')
{
$this->Permission('Garden.Profiles.View');
// Object setup
$Session = Gdn::Session();
$this->ActivityModel = new ActivityModel();
// Calculate offset
$Offset = is_numeric($Offset) ? $Offset : 0;
if ($Offset < 0) {
$Offset = 0;
}
// Get user, tab, and comment
$this->GetUserInfo($UserReference, $Username, $UserID);
$this->SetTabView('Activity');
$Comment = $this->Form->GetFormValue('Comment');
if ($Session->UserID > 0 && $this->Form->AuthenticatedPostBack() && !StringIsNullOrEmpty($Comment) && CheckPermission('Garden.Profiles.Edit')) {
// Active user has submitted a comment
$Comment = substr($Comment, 0, 1000);
// Limit to 1000 characters...
// Update About if necessary.
$SendNotification = TRUE;
if ($Session->UserID == $this->User->UserID) {
$SendNotification = FALSE;
$this->UserModel->SaveAbout($Session->UserID, $Comment);
$this->User->About = $Comment;
$this->SetJson('UserData', $this->FetchView('user'));
$ActivityUserID = $Session->UserID;
$RegardingUserID = $ActivityUserID;
$ActivityType = 'AboutUpdate';
} else {
$ActivityUserID = $this->User->UserID;
$RegardingUserID = $Session->UserID;
$ActivityType = 'WallPost';
}
// Create activity entry
$NewActivityID = $this->ActivityModel->Add($ActivityUserID, $ActivityType, $Comment, $RegardingUserID, '', '/profile/' . $this->ProfileUrl(), FALSE);
// @todo Add a notification too.
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
Redirect('dashboard/profile/' . $this->ProfileUrl());
} else {
// Load just the single new comment
$this->HideActivity = TRUE;
$this->ActivityData = $this->ActivityModel->GetWhere('ActivityID', $NewActivityID);
$this->View = 'activities';
$this->ControllerName = 'activity';
}
} else {
// Load data to display
$this->ProfileUserID = $this->User->UserID;
$Limit = 50;
$this->SetData('ActivityData', $this->ActivityModel->Get($this->User->UserID, $Offset, $Limit), TRUE);
$TotalRecords = $this->ActivityModel->GetCount($this->User->UserID);
if ($this->ActivityData->NumRows() > 0) {
$ActivityData = $this->ActivityData->Result();
$ActivityIDs = ConsolidateArrayValuesByKey($ActivityData, 'ActivityID');
$LastActivity = $this->ActivityData->FirstRow();
$LastModifiedDate = Gdn_Format::ToTimestamp($this->User->DateUpdated);
$LastActivityDate = Gdn_Format::ToTimestamp($LastActivity->DateInserted);
if ($LastModifiedDate < $LastActivityDate) {
$LastModifiedDate = $LastActivityDate;
}
// Make sure to only query this page if the user has no new activity since the requesting browser last saw it.
$this->SetLastModified($LastModifiedDate);
$this->CommentData = $this->ActivityModel->GetComments($ActivityIDs);
} else {
$this->CommentData = FALSE;
}
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$this->Pager = $PagerFactory->GetPager('MorePager', $this);
$this->Pager->MoreCode = 'More';
$this->Pager->LessCode = 'Newer Activity';
$this->Pager->ClientID = 'Pager';
$this->Pager->Configure($Offset, $Limit, $TotalRecords, 'profile/activity/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name) . '/' . $this->User->UserID . '/%1$s/');
// Deliver json data if necessary
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
if ($Offset > 0) {
$this->View = 'activities';
$this->ControllerName = 'Activity';
}
}
}
// Set the canonical Url.
if (is_numeric($this->User->Name) || Gdn_Format::Url($this->User->Name) != strtolower($this->User->Name)) {
$this->CanonicalUrl(Url('profile/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), TRUE));
} else {
$this->CanonicalUrl(Url('profile/' . strtolower($this->User->Name), TRUE));
}
//.........這裏部分代碼省略.........