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


PHP Gdn_Format类代码示例

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


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

示例1: _CacheOnlineUserss

 protected function _CacheOnlineUserss(&$Sender)
 {
     //logic taken from Who's Online plugin
     $SQL = Gdn::SQL();
     // $this->_OnlineUsers = $SQL
     // insert or update entry into table
     $Session = Gdn::Session();
     $Invisible = $Invisible ? 1 : 0;
     if ($Session->UserID) {
         $SQL->Replace('Whosonline', array('UserID' => $Session->UserID, 'Timestamp' => Gdn_Format::ToDateTime(), 'Invisible' => $Invisible), array('UserID' => $Session->UserID));
     }
     $Frequency = C('WhosOnline.Frequency', 4);
     $History = time() - $Frequency;
     $SQL->Select('u.UserID, u.Name, w.Timestamp, w.Invisible')->From('Whosonline w')->Join('User u', 'w.UserID = u.UserID')->Where('w.Timestamp >=', date('Y-m-d H:i:s', $History))->OrderBy('u.Name');
     if (!$Session->CheckPermission('Plugins.WhosOnline.ViewHidden')) {
         $SQL->Where('w.Invisible', 0);
     }
     $OnlineUsers = $SQL->Get();
     $arrOnline = array();
     if ($OnlineUsers->NumRows() > 0) {
         foreach ($OnlineUsers->Result() as $User) {
             $arrOnline[] = $User->UserID;
         }
     }
     $Sender->SetData('Plugin-OnlineUsers-Marker', $arrOnline);
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:26,代码来源:class.onlineusers.plugin.php

示例2: informNotifications

 /**
  * Grabs all new notifications and adds them to the sender's inform queue.
  *
  * This method gets called by dashboard's hooks file to display new
  * notifications on every pageload.
  *
  * @since 2.0.18
  * @access public
  *
  * @param Gdn_Controller $Sender The object calling this method.
  */
 public static function informNotifications($Sender)
 {
     $Session = Gdn::session();
     if (!$Session->isValid()) {
         return;
     }
     $ActivityModel = new ActivityModel();
     // Get five pending notifications.
     $Where = array('NotifyUserID' => Gdn::session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
     // If we're in the middle of a visit only get very recent notifications.
     $Where['DateUpdated >'] = Gdn_Format::toDateTime(strtotime('-5 minutes'));
     $Activities = $ActivityModel->getWhere($Where, 0, 5)->resultArray();
     $ActivityIDs = array_column($Activities, 'ActivityID');
     $ActivityModel->setNotified($ActivityIDs);
     $Sender->EventArguments['Activities'] =& $Activities;
     $Sender->fireEvent('InformNotifications');
     foreach ($Activities as $Activity) {
         if ($Activity['Photo']) {
             $UserPhoto = anchor(img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
         } else {
             $UserPhoto = '';
         }
         $Excerpt = Gdn_Format::plainText($Activity['Story']);
         $ActivityClass = ' Activity-' . $Activity['ActivityType'];
         $Sender->informMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
     }
 }
开发者ID:austins,项目名称:vanilla,代码行数:38,代码来源:class.notificationscontroller.php

示例3: Index

 public function Index($Offset = 0, $Limit = NULL)
 {
     $this->AddJsFile('/js/library/jquery.gardenmorepager.js');
     $this->AddJsFile('search.js');
     $this->Title(T('Search'));
     if (!is_numeric($Limit)) {
         $Limit = Gdn::Config('Garden.Search.PerPage', 20);
     }
     $Search = $this->Form->GetFormValue('Search');
     $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
     $this->SetData('SearchResults', $ResultSet, TRUE);
     $this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
     if ($ResultSet) {
         $NumResults = $ResultSet->NumRows();
     } else {
         $NumResults = 0;
     }
     if ($NumResults == $Offset + $Limit) {
         $NumResults++;
     }
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $Pager = $PagerFactory->GetPager('MorePager', $this);
     $Pager->MoreCode = 'More Results';
     $Pager->LessCode = 'Previous Results';
     $Pager->ClientID = 'Pager';
     $Pager->Configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::Url($Search));
     $this->SetData('Pager', $Pager, TRUE);
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->SetJson('LessRow', $this->Pager->ToString('less'));
         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
         $this->View = 'results';
     }
     $this->Render();
 }
开发者ID:sipp11,项目名称:Garden,代码行数:35,代码来源:class.searchcontroller.php

示例4: ToString

 public function ToString()
 {
     if ($this->_UserData->NumRows() == 0) {
         return '';
     }
     $String = '';
     ob_start();
     ?>
   <div class="Box">
      <?php 
     echo panelHeading(T('In this Discussion'));
     ?>
      <ul class="PanelInfo">
         <?php 
     foreach ($this->_UserData->Result() as $User) {
         ?>
            <li>
               <?php 
         echo Anchor(Wrap(Wrap(Gdn_Format::Date($User->DateLastActive, 'html')), 'span', array('class' => 'Aside')) . ' ' . Wrap(Wrap(GetValue('Name', $User), 'span', array('class' => 'Username')), 'span'), UserUrl($User));
         ?>
            </li>
         <?php 
     }
     ?>
      </ul>
   </div>
   <?php 
     $String = ob_get_contents();
     @ob_end_clean();
     return $String;
 }
开发者ID:embo-hd,项目名称:vanilla,代码行数:31,代码来源:class.inthisdiscussionmodule.php

示例5: addLabel

 /**
  *
  *
  * @param $Name
  * @param string $Code
  * @param string $Url
  */
 public function addLabel($Name, $Code = '', $Url = '')
 {
     if ($Code == '') {
         $Code = Gdn_Format::url(ucwords(trim(Gdn_Format::plainText($Name))));
     }
     $this->_Labels[] = array('Name' => $Name, 'Code' => $Code, 'Url' => $Url);
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:14,代码来源:class.togglemenumodule.php

示例6: WriteDiscussion

function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt)
{
    $CssClass = 'Item';
    $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
    $CssClass .= $Alt . ' ';
    $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
    $CssClass .= $Discussion->Closed == '1' ? ' Closed' : '';
    $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
    $CssClass .= $Discussion->CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
    $Sender->EventArguments['Discussion'] =& $Discussion;
    $Sender->FireEvent('BeforeDiscussionName');
    $DiscussionName = Gdn_Format::Text($Discussion->Name);
    if ($DiscussionName == '') {
        $DiscussionName = T('Blank Discussion Topic');
    }
    static $FirstDiscussion = TRUE;
    if (!$FirstDiscussion) {
        $Sender->FireEvent('BetweenDiscussion');
    } else {
        $FirstDiscussion = FALSE;
    }
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    if ($Discussion->FirstPhoto != '') {
        if (strtolower(substr($Discussion->FirstPhoto, 0, 7)) == 'http://' || strtolower(substr($Discussion->FirstPhoto, 0, 8)) == 'https://') {
            $PhotoUrl = $Discussion->FirstPhoto;
        } else {
            $PhotoUrl = 'uploads/' . ChangeBasename($Discussion->FirstPhoto, 'n%s');
        }
        echo Img($PhotoUrl, array('alt' => $Discussion->FirstName));
    }
    ?>
   <div class="ItemContent Discussion">
      <?php 
    echo Anchor($DiscussionName, '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title');
    ?>
      <?php 
    $Sender->FireEvent('AfterDiscussionTitle');
    ?>
      <div class="Meta">
         <span class="Author"><?php 
    echo $Discussion->FirstName;
    ?>
</span>
         <?php 
    echo '<span class="Counts' . ($Discussion->CountUnreadComments > 0 ? ' NewCounts' : '') . '">' . ($Discussion->CountUnreadComments > 0 ? $Discussion->CountUnreadComments . '/' : '') . $Discussion->CountComments . '</span>';
    if ($Discussion->LastCommentID != '') {
        echo '<span class="LastCommentBy">' . sprintf(T('Latest %1$s'), $Discussion->LastName) . '</span> ';
    }
    echo '<span class="LastCommentDate">' . Gdn_Format::Date($Discussion->FirstDate) . '</span> ';
    ?>
      </div>
   </div>
</li>
<?php 
}
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:60,代码来源:helper_functions.php

示例7: _checkTable

/**
 *
 *
 * @param $Data
 */
function _checkTable($Data)
{
    echo "<table class='Data' width='100%' style='table-layout: fixed;'>\n";
    echo "<thead><tr><td width='20%'>Field</td><td width='45%'>Current</td><td width='35%'>File</td></tr></thead>";
    $First = true;
    foreach ($Data as $Key => $Value) {
        if (stringBeginsWith($Key, 'File_') || is_array($Value) || $Key == 'Name') {
            continue;
        }
        $Value = Gdn_Format::html($Value);
        $FileValue = Gdn_Format::html(val('File_' . $Key, $Data));
        if ($Key == 'MD5') {
            $Value = substr($Value, 0, 10);
            $FileValue = substr($FileValue, 0, 10);
        }
        if ($Key == 'FileSize') {
            $Value = Gdn_Upload::FormatFileSize($Value);
        }
        echo "<tr><td>{$Key}</td><td>{$Value}</td>";
        if ($Error = val('File_Error', $Data)) {
            if ($First) {
                echo '<td rowspan="4">', htmlspecialchars($Error), '</td>';
            }
        } else {
            echo "<td>{$FileValue}</td></tr>";
        }
        echo "\n";
        $First = false;
    }
    echo '</table>';
}
开发者ID:vanilla,项目名称:community,代码行数:36,代码来源:check.php

示例8: toString

 /**
  * Build HTML.
  *
  * @return string HTML.
  */
 public function toString()
 {
     if ($this->_UserData->numRows() == 0) {
         return '';
     }
     $String = '';
     ob_start();
     ?>
     <div class="Box BoxInThisDiscussion">
         <?php 
     echo panelHeading(t('In this Discussion'));
     ?>
         <ul class="PanelInfo PanelInThisDiscussion">
             <?php 
     foreach ($this->_UserData->Result() as $User) {
         ?>
                 <li>
                     <?php 
         echo anchor(wrap(wrap(Gdn_Format::date($User->DateLastActive, 'html')), 'span', array('class' => 'Aside')) . ' ' . wrap(wrap(val('Name', $User), 'span', array('class' => 'Username')), 'span'), userUrl($User));
         ?>
                 </li>
             <?php 
     }
     ?>
         </ul>
     </div>
     <?php 
     $String = ob_get_clean();
     return $String;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:35,代码来源:class.inthisdiscussionmodule.php

示例9: Award

 /**
  * Award a badge to a user and record some activity
  *
  * @param int $BadgeID
  * @param int $UserID This is the user that should get the award
  * @param int $InsertUserID This is the user that gave the award
  * @param string $Reason This is the reason the giver gave with the award
  */
 public function Award($BadgeID, $UserID, $InsertUserID = NULL, $Reason = '')
 {
     $Badge = Yaga::BadgeModel()->GetByID($BadgeID);
     if (!empty($Badge)) {
         if (!$this->Exists($UserID, $BadgeID)) {
             $this->SQL->Insert('BadgeAward', array('BadgeID' => $BadgeID, 'UserID' => $UserID, 'InsertUserID' => $InsertUserID, 'Reason' => $Reason, 'DateInserted' => date(DATE_ISO8601)));
             // Record the points for this badge
             UserModel::GivePoints($UserID, $Badge->AwardValue, 'Badge');
             // Increment the user's badge count
             $this->SQL->Update('User')->Set('CountBadges', 'CountBadges + 1', FALSE)->Where('UserID', $UserID)->Put();
             if (is_null($InsertUserID)) {
                 $InsertUserID = Gdn::Session()->UserID;
             }
             // Record some activity
             $ActivityModel = new ActivityModel();
             $Activity = array('ActivityType' => 'BadgeAward', 'ActivityUserID' => $UserID, 'RegardingUserID' => $InsertUserID, 'Photo' => $Badge->Photo, 'RecordType' => 'Badge', 'RecordID' => $BadgeID, 'Route' => '/badges/detail/' . $Badge->BadgeID . '/' . Gdn_Format::Url($Badge->Name), 'HeadlineFormat' => T('Yaga.Badge.EarnedHeadlineFormat'), 'Data' => array('Name' => $Badge->Name), 'Story' => $Badge->Description);
             // Create a public record
             $ActivityModel->Queue($Activity, FALSE);
             // TODO: enable the grouped notifications after issue #1776 is resolved , array('GroupBy' => 'Route'));
             // Notify the user of the award
             $Activity['NotifyUserID'] = $UserID;
             $ActivityModel->Queue($Activity, 'BadgeAward', array('Force' => TRUE));
             // Actually save the activity
             $ActivityModel->SaveQueue();
             $this->EventArguments['UserID'] = $UserID;
             $this->FireEvent('AfterBadgeAward');
         }
     }
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:37,代码来源:class.badgeawardmodel.php

示例10: resolve

 /**
  * Resolves a discussion
  *
  * @param object $discussion
  * @param int $resolve
  * @return void
  */
 public function resolve(&$discussion, $resolve)
 {
     $resolution = array('Resolved' => $resolve, 'DateResolved' => $resolve ? Gdn_Format::toDateTime() : null, 'ResolvedUserID' => $resolve ? Gdn::session()->UserID : null);
     $discussionID = val('DiscussionID', $discussion);
     self::discussionModel()->setField($discussionID, $resolution);
     svalr('Resolved', $discussion, $resolve);
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:14,代码来源:class.resolved.plugin.php

示例11: ToString

    public function ToString()
    {
        $String = '';
        ob_start();
        ?>
      <div class="Box">
         <h4><?php 
        echo T('In this Discussion');
        ?>
</h4>
         <ul class="PanelInfo">
         <?php 
        foreach ($this->_UserData->Result() as $User) {
            ?>
            <li>
               <strong><?php 
            echo UserAnchor($User, 'UserLink');
            ?>
</strong>
               <?php 
            echo Gdn_Format::Date($User->DateLastActive);
            ?>
            </li>
            <?php 
        }
        ?>
         </ul>
      </div>
      <?php 
        $String = ob_get_contents();
        @ob_end_clean();
        return $String;
    }
开发者ID:sheldon,项目名称:Garden,代码行数:33,代码来源:class.inthisdiscussionmodule.php

示例12: index

 /**
  * List download stats.
  *
  * @param bool|false $Offset
  */
 public function index($Offset = false)
 {
     $this->permission('Garden.Settings.Manage');
     $this->addSideMenu('vstats');
     $this->addJsFile('jquery.gardenmorepager.js');
     $this->title('Vanilla Stats');
     $this->Form->Method = 'get';
     $Offset = is_numeric($Offset) ? $Offset : 0;
     $Limit = 19;
     $this->StatsData = array();
     $Offset--;
     $Year = date('Y');
     $Month = date('m');
     $BaseDate = Gdn_Format::toTimestamp($Year . '-' . str_pad($Month, 2, '0', STR_PAD_LEFT) . '-01 00:00:00');
     for ($i = $Offset; $i <= $Limit; ++$i) {
         $String = "-{$i} month";
         $this->StatsData[] = $this->_getStats(date("Y-m-d 00:00:00", strtotime($String, $BaseDate)));
     }
     $TotalRecords = count($this->StatsData);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->getPager('MorePager', $this);
     $this->Pager->MoreCode = 'More';
     $this->Pager->LessCode = 'Previous';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Wrapper = '<tr %1$s><td colspan="6">%2$s</td></tr>';
     $this->Pager->configure($Offset, $Limit, $TotalRecords, 'vstats/index/%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'));
     }
     $this->render();
 }
开发者ID:vanilla,项目名称:community,代码行数:39,代码来源:class.vstatscontroller.php

示例13: GetByID

 /**
  * Checks the local Steam Profile cache for existing user profile
  * information.  If found, serve it up.  If not found, attempt to fetch
  * it from the Steam Community website.
  *
  * @param string $SteamID A sixty-four bit integer representing the target Steam ID
  * @return mixed SimpleXMLElement on success, FALSE on failure
  */
 public function GetByID($SteamID)
 {
     // Verify that the ID is only digits and that we have SimpleXML capabilities
     if (preg_match('/\\d+/', $SteamID) && function_exists('simplexml_load_file')) {
         /**
          * Check to see if there are any cached profile records matching the ID and are
          * more than five minutes old
          */
         $CachedProfile = $this->SQL->Select()->From('SteamProfileCache')->Where('SteamID64', $SteamID)->Where('DateRetrieved >', Gdn_Format::ToDateTime(strtotime('-5 minutes')))->Get()->Firstrow();
         // Any cached entries?
         if ($CachedProfile) {
             // ...if so, load up the profile XML into a SimpleXMLElement...
             $CommunityProfile = simplexml_load_string($CachedProfile->ProfileXML, 'SimpleXMLElement', LIBXML_NOCDATA);
             // set the DateRetrieved of the cached record and go
             $CommunityProfile->DateRetrieved = $CachedProfile->DateRetrieved;
             return $CommunityProfile;
         } else {
             // ...if not, attempt to grab the profile's XML
             $CommunityProfile = simplexml_load_file('http://steamcommunity.com/profiles/' . $SteamID . '?xml=1', 'SimpleXMLElement', LIBXML_NOCDATA);
             // Were we able to successfully fetch the profile?
             if ($CommunityProfile && !isset($CommunityProfile->error)) {
                 // ...if so, insert or update the profile XML into the cache table
                 $this->SQL->Replace('SteamProfileCache', array('SteamID64' => $SteamID, 'ProfileXML' => $CommunityProfile->asXML(), 'DateRetrieved' => Gdn_Format::ToDateTime()), array('SteamID64' => $SteamID), TRUE);
                 // Set the DateRetrieved record to now and go
                 $CommunityProfile->DateRetrieved = Gdn_Format::ToDateTime();
                 return $CommunityProfile;
             }
         }
     }
     // If we hit this point, something bad has happened.
     return FALSE;
 }
开发者ID:29th,项目名称:VanillaAddons,代码行数:40,代码来源:class.steamprofilemodel.php

示例14: Format

 public function Format($Html)
 {
     $Attributes = C('Garden.Html.BlockedAttributes', 'on*');
     $Config = array('anti_link_spam' => array('`.`', ''), 'comment' => 1, 'cdata' => 3, 'css_expression' => 1, 'deny_attribute' => $Attributes, 'unique_ids' => 1, 'elements' => '*-applet-form-input-textarea-iframe-script-style-embed-object-select-option-button-fieldset-optgroup-legend', 'keep_bad' => 0, 'schemes' => 'classid:clsid; href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; style: nil; *:file, http, https', 'valid_xhtml' => 0, 'direct_list_nest' => 1, 'balance' => 1);
     // Turn embedded videos into simple links (legacy workaround)
     $Html = Gdn_Format::UnembedVideos($Html);
     // We check the flag within Gdn_Format to see
     // if htmLawed should place rel="nofollow" links
     // within output or not.
     // A plugin can set this flag (for example).
     // The default is to show rel="nofollow" on all links.
     if (Gdn_Format::$DisplayNoFollow) {
         // display rel="nofollow" on all links.
         $Config['anti_link_spam'] = array('`.`', '');
     } else {
         // never display rel="nofollow"
         $Config['anti_link_spam'] = array('', '');
     }
     if ($this->SafeStyles) {
         // Deny all class and style attributes.
         // A lot of damage can be done by hackers with these attributes.
         $Config['deny_attribute'] .= ',style';
         //      } else {
         //         $Config['hook_tag'] = 'HTMLawedHookTag';
     }
     // Block some IDs so you can't break Javascript
     $GLOBALS['hl_Ids'] = array('Bookmarks' => 1, 'CommentForm' => 1, 'Content' => 1, 'Definitions' => 1, 'DiscussionForm' => 1, 'Foot' => 1, 'Form_Comment' => 1, 'Form_User_Password' => 1, 'Form_User_SignIn' => 1, 'Head' => 1, 'HighlightColor' => 1, 'InformMessageStack' => 1, 'Menu' => 1, 'PagerMore' => 1, 'Panel' => 1, 'Status' => 1);
     $Spec = 'object=-classid-type, -codebase; embed=type(oneof=application/x-shockwave-flash); a=class(noneof=Hijack|Dismiss|MorePager/nomatch=%pop[in|up|down]|flyout|ajax%i)';
     $Result = htmLawed($Html, $Config, $Spec);
     return $Result;
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:31,代码来源:class.htmlawed.plugin.php

示例15: DiscussionController_Render_Before

	public function DiscussionController_Render_Before(&$Sender) {
		$Sender->Head->AddTag('meta', array('content' => Gdn_Format::Text($Sender->Discussion->Name), 'property' => 'og:title'));
		$Sender->Head->AddTag('meta', array('content' => Gdn_Url::Request(true, true, true), 'property' => 'og:url'));
		$Sender->Head->AddTag('meta', array('content' => C('Garden.Title'), 'property' => 'og:site_name'));
		$Sender->Head->AddTag('meta', array('content' => 'article', 'property' => 'og:type'));
		$Sender->addJsFile('http://connect.facebook.net/en_US/all.js#xfbml=1');
	}
开发者ID:real-chocopanda,项目名称:Liked,代码行数:7,代码来源:class.liked.plugin.php


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