当前位置: 首页>>代码示例>>PHP>>正文


PHP FormatString函数代码示例

本文整理汇总了PHP中FormatString函数的典型用法代码示例。如果您正苦于以下问题:PHP FormatString函数的具体用法?PHP FormatString怎么用?PHP FormatString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FormatString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Breadcrumbs

 public static function Breadcrumbs($Data, $HomeLink = TRUE, $Options = array())
 {
     $Format = '<a href="{Url,html}" itemprop="url"><span itemprop="title">{Name,html}</span></a>';
     $Result = '';
     if (!is_array($Data)) {
         $Data = array();
     }
     if ($HomeLink) {
         $HomeUrl = GetValue('HomeUrl', $Options);
         if (!$HomeUrl) {
             $HomeUrl = Url('/', TRUE);
         }
         $Row = array('Name' => $HomeLink, 'Url' => $HomeUrl, 'CssClass' => 'CrumbLabel HomeCrumb');
         if (!is_string($HomeLink)) {
             $Row['Name'] = T('Home');
         }
         array_unshift($Data, $Row);
     }
     if (GetValue('HideLast', $Options)) {
         // Remove the last item off the list.
         array_pop($Data);
     }
     $DefaultRoute = ltrim(GetValue('Destination', Gdn::Router()->GetRoute('DefaultController'), ''), '/');
     $Count = 0;
     $DataCount = 0;
     $HomeLinkFound = false;
     foreach ($Data as $Row) {
         $DataCount++;
         if ($HomeLinkFound && Gdn::Request()->UrlCompare($Row['Url'], $DefaultRoute) === 0) {
             continue;
             // don't show default route twice.
         } else {
             $HomeLinkFound = true;
         }
         // Add the breadcrumb wrapper.
         if ($Count > 0) {
             $Result .= '<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
         }
         $Row['Url'] = Url($Row['Url']);
         $CssClass = 'CrumbLabel ' . GetValue('CssClass', $Row);
         if ($DataCount == count($Data)) {
             $CssClass .= ' Last';
         }
         $Label = '<span class="' . $CssClass . '">' . FormatString($Format, $Row) . '</span> ';
         $Result = ConcatSep('<span class="Crumb">' . T('Breadcrumbs Crumb', '›') . '</span> ', $Result, $Label);
         $Count++;
     }
     // Close the stack.
     for ($Count--; $Count > 0; $Count--) {
         $Result .= '</span>';
     }
     $Result = '<span class="Breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $Result . '</span>';
     return $Result;
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:54,代码来源:class.theme.php

示例2: GetPrice

function GetPrice($symbol)
{
    //google finance can only handle up to 100 quotes at a time so split up query then merge results
    if (count($symbol) > 100) {
        $retArr = array();
        for ($j = 0; $j < count($symbol); $j += 100) {
            $arr = LookUpWithFormattedString(FormatString(array_slice($symbol, $j, 100)));
            $retArr = array_merge($retArr, $arr);
        }
        return $retArr;
    } else {
        return LookUpWithFormattedString(FormatString($symbol));
    }
}
开发者ID:xop32,项目名称:google-stock-prices-php,代码行数:14,代码来源:stockprices.php

示例3: connectButton

 public static function connectButton($Provider, $Options = array())
 {
     if (!is_array($Provider)) {
         $Provider = self::getProvider($Provider);
     }
     $Url = htmlspecialchars(self::connectUrl($Provider));
     $Data = $Provider;
     $Target = Gdn::Request()->Get('Target');
     if (!$Target) {
         $Target = '/' . ltrim(Gdn::Request()->Path());
     }
     if (StringBeginsWith($Target, '/entry/signin')) {
         $Target = '/';
     }
     $ConnectQuery = array('client_id' => $Provider['AuthenticationKey'], 'Target' => $Target);
     $Data['Target'] = urlencode(Url('entry/jsconnect', TRUE) . '?' . http_build_query($ConnectQuery));
     $Data['Redirect'] = $Data['target'] = $Data['redirect'] = $Data['Target'];
     $SignInUrl = FormatString(GetValue('SignInUrl', $Provider, ''), $Data);
     $RegisterUrl = FormatString(GetValue('RegisterUrl', $Provider, ''), $Data);
     if ($RegisterUrl && !GetValue('NoRegister', $Options)) {
         $RegisterLink = ' ' . Anchor(sprintf(T('Register with %s', 'Register'), $Provider['Name']), $RegisterUrl, 'Button RegisterLink');
     } else {
         $RegisterLink = '';
     }
     if (IsMobile()) {
         $PopupWindow = '';
     } else {
         $PopupWindow = 'PopupWindow';
     }
     if (GetValue('NoConnectLabel', $Options)) {
         $ConnectLabel = '';
     } else {
         $ConnectLabel = '<span class="Username"></span><div class="ConnectLabel TextColor">' . sprintf(T('Sign In with %s'), $Provider['Name']) . '</div>';
     }
     if (!C('Plugins.JsConnect.NoGuestCheck')) {
         $Result = '<div style="display: none" class="JsConnect-Container ConnectButton Small UserInfo" rel="' . $Url . '">';
         if (!GetValue('IsDefault', $Provider)) {
             $Result .= '<div class="JsConnect-Guest">' . Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
         }
         $Result .= '<div class="JsConnect-Connect"><a class="ConnectLink">' . Img('https://cd8ba0b44a15c10065fd-24461f391e20b7336331d5789078af53.ssl.cf1.rackcdn.com/images/usericon_50.png', array('class' => 'ProfilePhotoSmall UserPhoto')) . $ConnectLabel . '</a></div>';
         $Result .= '</div>';
     } else {
         if (!GetValue('IsDefault', $Provider)) {
             $Result = '<div class="JsConnect-Guest">' . Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
         }
     }
     return $Result;
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:48,代码来源:class.jsconnect.plugin.php

示例4: Breadcrumbs

   public static function Breadcrumbs($Data, $Format, $HomeLink = TRUE) {
      $Result = '';

      if ($HomeLink) {
         if (!is_string($HomeLink))
            $HomeLink = T('Home');
            $Result .= '<span class="Label"><a href="'.Url('/').'">'.$HomeLink.'</a></span>';
      }

      foreach ($Data as $Row) {
         $Label = '<span class="Label">'.FormatString($Format, $Row).'</span>';
         $Result = ConcatSep('<span class="Crumb">'.T('Breadcrumbs Crumb', '&raquo;').'</span>', $Result, $Label);
      }

      $Result ='<span class="BreadCrumbs">'.$Result.'</span>';
      return $Result;
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:17,代码来源:class.theme.php

示例5: DrawEdited

 protected function DrawEdited($Sender)
 {
     $Record = $Sender->Data('Discussion');
     if (!$Record) {
         $Record = $Sender->Data('Record');
     }
     if (!$Record) {
         return;
     }
     $PermissionCategoryID = GetValue('PermissionCategoryID', $Record);
     $Data = $Record;
     $RecordType = 'discussion';
     $RecordID = GetValue('DiscussionID', $Data);
     // But override if comment
     if (isset($Sender->EventArguments['Comment']) || GetValue('RecordType', $Record) == 'comment') {
         $Data = $Sender->EventArguments['Comment'];
         $RecordType = 'comment';
         $RecordID = GetValue('CommentID', $Data);
     }
     $UserCanEdit = Gdn::Session()->CheckPermission('Vanilla.' . ucfirst($RecordType) . 's.Edit', TRUE, 'Category', $PermissionCategoryID);
     if (is_null($Data->DateUpdated)) {
         return;
     }
     if (Gdn_Format::ToTimestamp($Data->DateUpdated) <= Gdn_Format::ToTimestamp($Data->DateInserted)) {
         return;
     }
     $SourceUserID = $Data->InsertUserID;
     $UpdatedUserID = $Data->UpdateUserID;
     $UserData = Gdn::UserModel()->GetID($UpdatedUserID);
     $Edited = array('EditUser' => GetValue('Name', $UserData, T('Unknown User')), 'EditDate' => Gdn_Format::Date($Data->DateUpdated, 'html'), 'EditLogUrl' => Url("/log/record/{$RecordType}/{$RecordID}"), 'EditWord' => 'at');
     $DateUpdateTime = Gdn_Format::ToTimestamp($Data->DateUpdated);
     if (date('ymd', $DateUpdateTime) != date('ymd')) {
         $Edited['EditWord'] = 'on';
     }
     $Format = T('PostEdited.Plain', 'Post edited by {EditUser} {EditWord} {EditDate}');
     if ($UserCanEdit) {
         $Format = T('PostEdited.Log', 'Post edited by {EditUser} {EditWord} {EditDate} (<a href="{EditLogUrl}">log</a>)');
     }
     $Display = '<div class="PostEdited">' . FormatString($Format, $Edited) . '</div>';
     echo $Display;
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:41,代码来源:class.lastedited.plugin.php

示例6: Breadcrumbs

 public static function Breadcrumbs($Data, $HomeLink = TRUE)
 {
     $Format = '<a href="{Url,html}" itemprop="url"><span itemprop="title">{Name,html}</span></a>';
     $Result = '';
     if (!is_array($Data)) {
         $Data = array();
     }
     if ($HomeLink) {
         $Row = array('Name' => $HomeLink, 'Url' => Url('/', TRUE), 'CssClass' => 'CrumbLabel HomeCrumb');
         if (!is_string($HomeLink)) {
             $Row['Name'] = T('Home');
         }
         array_unshift($Data, $Row);
     }
     $DefaultRoute = ltrim(GetValue('Destination', Gdn::Router()->GetRoute('DefaultController'), ''), '/');
     $Count = 0;
     foreach ($Data as $Row) {
         if (ltrim($Row['Url'], '/') == $DefaultRoute && $HomeLink) {
             continue;
         }
         // don't show default route twice.
         // Add the breadcrumb wrapper.
         if ($Count > 0) {
             $Result .= '<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
         }
         $Row['Url'] = Url($Row['Url']);
         $CssClass = GetValue('CssClass', $Row, 'CrumbLabel');
         $Label = '<span class="' . $CssClass . '">' . FormatString($Format, $Row) . '</span> ';
         $Result = ConcatSep('<span class="Crumb">' . T('Breadcrumbs Crumb', '›') . '</span> ', $Result, $Label);
         $Count++;
     }
     // Close the stack.
     for ($Count--; $Count > 0; $Count--) {
         $Result .= '</span>';
     }
     $Result = '<span class="Breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $Result . '</span>';
     return $Result;
 }
开发者ID:remobjects,项目名称:Garden,代码行数:38,代码来源:class.theme.php

示例7: ClearCache

 /**
  * Delete cached data for user
  * 
  * @param type $UserID
  * @return type 
  */
 public function ClearCache($UserID, $CacheTypesToClear = NULL)
 {
     if (is_null($UserID) || !$UserID) {
         return FALSE;
     }
     if (is_null($CacheTypesToClear)) {
         $CacheTypesToClear = array('user', 'roles', 'permissions');
     }
     if (in_array('user', $CacheTypesToClear)) {
         $UserKey = FormatString(self::USERID_KEY, array('UserID' => $UserID));
         Gdn::Cache()->Remove($UserKey);
     }
     if (in_array('roles', $CacheTypesToClear)) {
         $UserRolesKey = FormatString(self::USERROLES_KEY, array('UserID' => $UserID));
         Gdn::Cache()->Remove($UserRolesKey);
     }
     if (in_array('permissions', $CacheTypesToClear)) {
         Gdn::SQL()->Put('User', array('Permissions' => ''), array('UserID' => $UserID));
         $PermissionsIncrement = $this->GetPermissionsIncrement();
         $UserPermissionsKey = FormatString(self::USERPERMISSIONS_KEY, array('UserID' => $UserID, 'PermissionsIncrement' => $PermissionsIncrement));
         Gdn::Cache()->Remove($UserPermissionsKey);
     }
     return TRUE;
 }
开发者ID:statico,项目名称:openshift-origin-vanillaforums,代码行数:30,代码来源:class.usermodel.php

示例8: GetRecord

 function GetRecord($RecordType, $ID, $ThrowError = FALSE)
 {
     $Row = FALSE;
     switch (strtolower($RecordType)) {
         case 'discussion':
             $Model = new DiscussionModel();
             $Row = $Model->GetID($ID);
             $Row->Url = DiscussionUrl($Row);
             $Row->ShareUrl = $Row->Url;
             if ($Row) {
                 return (array) $Row;
             }
             break;
         case 'comment':
             $Model = new CommentModel();
             $Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Url'] = Url("/discussion/comment/{$ID}#Comment_{$ID}", TRUE);
                 $Model = new DiscussionModel();
                 $Discussion = $Model->GetID($Row['DiscussionID']);
                 if ($Discussion) {
                     $Discussion->Url = DiscussionUrl($Discussion);
                     $Row['ShareUrl'] = $Discussion->Url;
                     $Row['Name'] = $Discussion->Name;
                     $Row['Discussion'] = (array) $Discussion;
                 }
                 return $Row;
             }
             break;
         case 'activity':
             $Model = new ActivityModel();
             $Row = $Model->GetID($ID, DATASET_TYPE_ARRAY);
             if ($Row) {
                 $Row['Name'] = FormatString($Row['HeadlineFormat'], $Row);
                 $Row['Body'] = $Row['Story'];
                 return $Row;
             }
         default:
             throw new Gdn_UserException(sprintf("I don't know what a %s is.", strtolower($RecordType)));
     }
     if ($ThrowError) {
         throw NotFoundException($RecordType);
     } else {
         return FALSE;
     }
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:46,代码来源:functions.general.php

示例9: ModerationController_MergeDiscussions_Create

 /**
  * Add a method to the ModerationController to handle merging discussions.
  * @param Gdn_Controller $Sender
  */
 public function ModerationController_MergeDiscussions_Create($Sender)
 {
     $Session = Gdn::Session();
     $Sender->Form = new Gdn_Form();
     $Sender->Title(T('Merge Discussions'));
     $DiscussionModel = new DiscussionModel();
     $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
     if (!is_array($CheckedDiscussions)) {
         $CheckedDiscussions = array();
     }
     $DiscussionIDs = $CheckedDiscussions;
     $Sender->SetData('DiscussionIDs', $DiscussionIDs);
     $CountCheckedDiscussions = count($DiscussionIDs);
     $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
     $Sender->SetData('Discussions', $Discussions);
     // Perform the merge
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
             if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                 $MergeDiscussion = $Discussion;
                 break;
             }
         }
         $RedirectLink = $Sender->Form->GetFormValue('RedirectLink');
         if ($MergeDiscussion) {
             $ErrorCount = 0;
             // Verify that the user has permission to perform the merge.
             $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
             if ($Category && !$Category['PermsDiscussionsEdit']) {
                 throw PermissionException('Vanilla.Discussions.Edit');
             }
             $DiscussionModel->DefineSchema();
             $MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
             // Assign the comments to the new discussion record
             $DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $MergeDiscussionID)->WhereIn('DiscussionID', $DiscussionIDs)->Put();
             $CommentModel = new CommentModel();
             foreach ($Discussions as $Discussion) {
                 if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                     continue;
                 }
                 // Create a comment out of the discussion.
                 $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
                 $Comment['DiscussionID'] = $MergeDiscussionID;
                 $CommentModel->Validation->Results(TRUE);
                 $CommentID = $CommentModel->Save($Comment);
                 if ($CommentID) {
                     // Move any attachments (FileUpload plugin awareness)
                     if (class_exists('MediaModel')) {
                         $MediaModel = new MediaModel();
                         $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                     }
                     if ($RedirectLink) {
                         // The discussion needs to be changed to a moved link.
                         $RedirectDiscussion = array('Name' => SliceString(sprintf(T('Merged: %s'), $Discussion['Name']), $MaxNameLength), 'Type' => 'redirect', 'Body' => FormatString(T('This discussion has been <a href="{url,html}">merged</a>.'), array('url' => DiscussionUrl($MergeDiscussion))), 'Format' => 'Html');
                         $DiscussionModel->SetField($Discussion['DiscussionID'], $RedirectDiscussion);
                         $CommentModel->UpdateCommentCount($Discussion['DiscussionID']);
                         $CommentModel->RemovePageCache($Discussion['DiscussionID']);
                     } else {
                         // Delete discussion that was merged.
                         $DiscussionModel->Delete($Discussion['DiscussionID']);
                     }
                 } else {
                     $Sender->InformMessage($CommentModel->Validation->ResultsText());
                     $ErrorCount++;
                 }
             }
             // Update counts on all affected discussions.
             $CommentModel->UpdateCommentCount($MergeDiscussionID);
             $CommentModel->RemovePageCache($MergeDiscussionID);
             // Clear selections
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($Sender);
             if ($ErrorCount == 0) {
                 $Sender->JsonTarget('', '', 'Refresh');
             }
         }
     }
     $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:87,代码来源:class.splitmerge.plugin.php

示例10: setSignatureRules

 public function setSignatureRules(&$Sender)
 {
     $rules = array();
     $rulesParams = array();
     $imagesAllowed = true;
     if (C('Plugins.Signatures.MaxNumberImages', 'Unlimited') !== 'Unlimited') {
         if (C('Plugins.Signatures.MaxNumberImages') === 'None') {
             $rules[] = T('Images not allowed.');
             $imagesAllowed = false;
         } else {
             $rulesParams['maxImages'] = C('Plugins.Signatures.MaxNumberImages');
             $rules[] = FormatString(T('Use up to {maxImages,plural,%s image, %s images}.'), $rulesParams);
         }
     }
     if ($imagesAllowed && C('Plugins.Signatures.MaxImageHeight') && C('Plugins.Signatures.MaxImageHeight') > 0) {
         $rulesParams['maxImageHeight'] = C('Plugins.Signatures.MaxImageHeight');
         $rules[] = FormatString(T('Images will be scaled to a maximum height of {maxImageHeight}px.'), $rulesParams);
     }
     if (C('Plugins.Signatures.MaxLength') && C('Plugins.Signatures.MaxLength') > 0) {
         $rulesParams['maxLength'] = C('Plugins.Signatures.MaxLength');
         $rules[] = FormatString(T('Signatures can be up to {maxLength} characters long.'), $rulesParams);
     }
     $Sender->SetData('SignatureRules', implode(' ', $rules));
 }
开发者ID:jamesinc,项目名称:addons,代码行数:24,代码来源:class.signatures.plugin.php

示例11: FormatString

<?php

if (!defined('APPLICATION')) {
    return;
}
?>
<h1><?php 
echo $this->Data('Title');
?>
</h1>
<div class="Wrap">
<?php 
echo $this->Form->Open();
echo $this->Form->Errors();
?>

<div class="DismissMessage WarningMessage">
   <?php 
echo FormatString(T('You are about to unban {User.UserID,user}.'), $this->Data);
?>
</div>
   
<?php 
if ($LogID = $this->Data('User.Attributes.BanLogID')) {
    echo '<div class="P">', $this->Form->CheckBox('RestoreContent', "Restore deleted content."), '</div>';
}
echo '<div class="Buttons P">', $this->Form->Button('Unban'), '</div>';
echo $this->Form->Close();
?>
</div>
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:30,代码来源:unban.php

示例12: Comment

 /**
  * Create or update a comment.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DiscussionID Unique ID to add the comment to. If blank, this method will throw an error.
  */
 public function Comment($DiscussionID = '')
 {
     // Get $DiscussionID from RequestArgs if valid
     if ($DiscussionID == '' && count($this->RequestArgs)) {
         if (is_numeric($this->RequestArgs[0])) {
             $DiscussionID = $this->RequestArgs[0];
         }
     }
     // If invalid $DiscussionID, get from form.
     $this->Form->SetModel($this->CommentModel);
     $DiscussionID = is_numeric($DiscussionID) ? $DiscussionID : $this->Form->GetFormValue('DiscussionID', 0);
     // Set discussion data
     $this->DiscussionID = $DiscussionID;
     $this->Discussion = $Discussion = $this->DiscussionModel->GetID($DiscussionID);
     // Is this an embedded comment being posted to a discussion that doesn't exist yet?
     $vanilla_type = $this->Form->GetFormValue('vanilla_type', '');
     $vanilla_url = $this->Form->GetFormValue('vanilla_url', '');
     $vanilla_category_id = $this->Form->GetFormValue('vanilla_category_id', '');
     $Attributes = array('ForeignUrl' => $vanilla_url);
     $vanilla_identifier = $this->Form->GetFormValue('vanilla_identifier', '');
     // Only allow vanilla identifiers of 32 chars or less - md5 if larger
     if (strlen($vanilla_identifier) > 32) {
         $Attributes['vanilla_identifier'] = $vanilla_identifier;
         $vanilla_identifier = md5($vanilla_identifier);
     }
     if (!$Discussion && $vanilla_url != '' && $vanilla_identifier != '') {
         $Discussion = $Discussion = $this->DiscussionModel->GetForeignID($vanilla_identifier, $vanilla_type);
         if ($Discussion) {
             $this->DiscussionID = $DiscussionID = $Discussion->DiscussionID;
             $this->Form->SetValue('DiscussionID', $DiscussionID);
         }
     }
     // If so, create it!
     if (!$Discussion && $vanilla_url != '' && $vanilla_identifier != '') {
         // Add these values back to the form if they exist!
         $this->Form->AddHidden('vanilla_identifier', $vanilla_identifier);
         $this->Form->AddHidden('vanilla_type', $vanilla_type);
         $this->Form->AddHidden('vanilla_url', $vanilla_url);
         $this->Form->AddHidden('vanilla_category_id', $vanilla_category_id);
         $PageInfo = FetchPageInfo($vanilla_url);
         if (!($Title = $this->Form->GetFormValue('Name'))) {
             $Title = GetValue('Title', $PageInfo, '');
             if ($Title == '') {
                 $Title = T('Undefined discussion subject.');
             }
         }
         $Description = GetValue('Description', $PageInfo, '');
         $Images = GetValue('Images', $PageInfo, array());
         $LinkText = T('EmbededDiscussionLinkText', 'Read the full story here');
         if (!$Description && count($Images) == 0) {
             $Body = FormatString('<p><a href="{Url}">{LinkText}</a></p>', array('Url' => $vanilla_url, 'LinkText' => $LinkText));
         } else {
             $Body = FormatString('
         <div class="EmbeddedContent">{Image}<strong>{Title}</strong>
            <p>{Excerpt}</p>
            <p><a href="{Url}">{LinkText}</a></p>
            <div class="ClearFix"></div>
         </div>', array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? Img(GetValue(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $vanilla_url, 'LinkText' => $LinkText));
         }
         if ($Body == '') {
             $Body = $vanilla_url;
         }
         if ($Body == '') {
             $Body = T('Undefined discussion body.');
         }
         // Validate the CategoryID for inserting.
         $Category = CategoryModel::Categories($vanilla_category_id);
         if (!$Category) {
             $vanilla_category_id = C('Vanilla.Embed.DefaultCategoryID', 0);
             if ($vanilla_category_id <= 0) {
                 // No default category defined, so grab the first non-root category and use that.
                 $vanilla_category_id = $this->DiscussionModel->SQL->Select('CategoryID')->From('Category')->Where('CategoryID >', 0)->Get()->FirstRow()->CategoryID;
                 // No categories in the db? default to 0
                 if (!$vanilla_category_id) {
                     $vanilla_category_id = 0;
                 }
             }
         } else {
             $vanilla_category_id = $Category['CategoryID'];
         }
         $EmbedUserID = C('Garden.Embed.UserID');
         if ($EmbedUserID) {
             $EmbedUser = Gdn::UserModel()->GetID($EmbedUserID);
         }
         if (!$EmbedUserID || !$EmbedUser) {
             $EmbedUserID = Gdn::UserModel()->GetSystemUserID();
         }
         $EmbeddedDiscussionData = array('InsertUserID' => $EmbedUserID, 'DateInserted' => Gdn_Format::ToDateTime(), 'DateUpdated' => Gdn_Format::ToDateTime(), 'CategoryID' => $vanilla_category_id, 'ForeignID' => $vanilla_identifier, 'Type' => $vanilla_type, 'Name' => $Title, 'Body' => $Body, 'Format' => 'Html', 'Attributes' => serialize($Attributes));
         $this->EventArguments['Discussion'] = $EmbeddedDiscussionData;
         $this->FireEvent('BeforeEmbedDiscussion');
         $DiscussionID = $this->DiscussionModel->SQL->Insert('Discussion', $EmbeddedDiscussionData);
         $ValidationResults = $this->DiscussionModel->ValidationResults();
//.........这里部分代码省略.........
开发者ID:embo-hd,项目名称:vanilla,代码行数:101,代码来源:class.postcontroller.php

示例13: Wrap

<?php

if (!defined('APPLICATION')) {
    exit;
}
?>

<h1><?php 
echo $this->Data('Title');
?>
</h1>
   <?php 
echo $this->Form->Open();
echo $this->Form->Errors();
echo Wrap(FormatString(T("ConfirmDeleteProfileField", "You are about to delete the profile field &ldquo;{Field.Label}&rdquo; from all users."), $this->Data), 'p');
echo '<div class="Buttons Buttons-Confirm">';
echo $this->Form->Button('Delete Field');
echo $this->Form->Button('Cancel', array('type' => 'button', 'class' => 'Button Close Cancel'));
echo '</div>';
echo $this->Form->Close();
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:20,代码来源:delete.php

示例14: Base_Render_Before

 /**
  *
  * @param Gdn_Controller $Sender
  */
 public function Base_Render_Before($Sender)
 {
     $Session = Gdn::Session();
     // Enable theme previewing
     if ($Session->IsValid()) {
         $PreviewThemeName = $Session->GetPreference('PreviewThemeName', '');
         $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
         if ($PreviewThemeName != '') {
             $Sender->Theme = $PreviewThemeName;
             $Sender->InformMessage(sprintf(T('You are previewing the %s theme.'), Wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . Anchor(T('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->TransientKey(), 'PreviewThemeButton') . ' ' . Anchor(T('Cancel'), 'settings/cancelpreview/', 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
     }
     if ($Session->IsValid()) {
         $ConfirmEmail = C('Garden.Registration.ConfirmEmail', false);
         $Confirmed = GetValue('Confirmed', Gdn::Session()->User, true);
         if ($ConfirmEmail && !$Confirmed) {
             $Message = FormatString(T('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
             $Sender->InformMessage($Message, '');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::Config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     // 2011-09-09 - mosullivan - No longer allowing messages in dashboard
     //		if ($Sender->MasterView == 'admin')
     //			$Exceptions[] = '[Admin]';
     //		else if (in_array($Sender->MasterView, array('', 'default')))
     if (in_array($Sender->MasterView, array('', 'default'))) {
         $Exceptions[] = '[NonAdmin]';
     }
     // SignIn popup is a special case
     $SignInOnly = $Sender->DeliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
     if ($SignInOnly) {
         $Exceptions = array();
     }
     if ($Sender->MasterView != 'admin' && !$Sender->Data('_NoMessages') && (GetValue('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions, $Sender->Data('Category.CategoryID'));
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             if ($SignInOnly) {
                 // Insert special messages even in SignIn popup
                 echo $MessageModule;
             } elseif ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                 $Sender->AddModule($MessageModule);
             }
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::Factory('Statistics');
         $Gdn_Statistics->Check($Sender);
     }
     // Allow forum embedding
     if ($Embed = C('Garden.Embed.Allow')) {
         // Record the remote url where the forum is being embedded.
         $RemoteUrl = C('Garden.Embed.RemoteUrl');
         if (!$RemoteUrl) {
             $RemoteUrl = GetIncomingValue('remote');
             if ($RemoteUrl) {
                 SaveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
             }
         }
         if ($RemoteUrl) {
             $Sender->AddDefinition('RemoteUrl', $RemoteUrl);
         }
         // Force embedding?
         if (!IsSearchEngine() && !IsMobile() && strtolower($Sender->ControllerName) != 'entry') {
             $Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0');
             $Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->AddDefinition('Path', Gdn::Request()->Path());
         // $Sender->AddDefinition('MasterView', $Sender->MasterView);
         $Sender->AddDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
         if ($Embed === 2) {
             $Sender->AddJsFile('vanilla.embed.local.js');
         } else {
             $Sender->AddJsFile('embed_local.js');
         }
     } else {
         $Sender->SetHeader('X-Frame-Options', 'SAMEORIGIN');
     }
     // Allow return to mobile site
     $ForceNoMobile = Gdn_CookieIdentity::GetCookiePayload('VanillaNoMobile');
     if ($ForceNoMobile !== FALSE && is_array($ForceNoMobile) && in_array('force', $ForceNoMobile)) {
         $Sender->AddAsset('Foot', Wrap(Anchor(T('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink');
     }
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:94,代码来源:class.hooks.php

示例15: AddKrit

function AddKrit($Array, $kriterium, $wert, $Tags)
{
    $kriterium = addslashes(FormatString($kriterium, "StripSpaces"));
    $kriterium = addslashes(FormatString($kriterium, "StripSpaces"));
    $Table = constant("DBTab" . $Array);
    if (!isset($_SESSION[$Array]) or !is_array($_SESSION[$Array])) {
        $_SESSION[$Array] = array();
    }
    $Vorhanden = DBQ("SELECT * FROM " . $Table . " WHERE Kriterium='" . $kriterium . "' AND Wert='" . $wert . "' AND Tags='" . $Tags . "'");
    if (count($Vorhanden) == 1) {
        // Wenn kein Fehler in der Query und kein Ergebniswert zurückgegeben wurde ...
        $ID = generateContentID($Table);
        if (strlen($Tags)) {
            $Tags = explode(",", $Tags);
            $InsertTagsID = array();
            $InsertTags = array();
            foreach ($Tags as $Tag) {
                $InsertTagsID[count($InsertTagsID)] = GenerateContentID(DBTabTags);
                $InsertTags[count($InsertTags)] = $Tag;
            }
        }
        DBIN($Table, "ID,Kriterium,Wert,Tags", "'" . $ID . "','" . $kriterium . "','" . $wert . "','" . $Tags . "'");
        // TODO Dies wird später erst erledigt, wenn die Hardware tatsächlich hinzugefügt wird.
    }
    $x = count($_SESSION[$Array]);
    $_SESSION[$Array][$x]['kriterium'] = $kriterium;
    $_SESSION[$Array][$x]['wert'] = $wert;
    $o = PrintKrits($_SESSION[$Array]);
    return $o;
}
开发者ID:BackupTheBerlios,项目名称:banbury-svn,代码行数:30,代码来源:RemoteFunctions.php


注:本文中的FormatString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。