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


PHP Gdn_Format::ActivityHeadline方法代码示例

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


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

示例1: WriteActivity

function WriteActivity($Activity, &$Sender, &$Session, $Comment)
{
    $Activity = (object) $Activity;
    // If this was a status update or a wall comment, don't bother with activity strings
    $ActivityType = explode(' ', $Activity->ActivityType);
    // Make sure you strip out any extra css classes munged in here
    $ActivityType = $ActivityType[0];
    $Author = UserBuilder($Activity, 'Activity');
    $PhotoAnchor = UserPhoto($Author, 'Photo');
    $CssClass = 'Item Activity ' . $ActivityType;
    if ($PhotoAnchor != '') {
        $CssClass .= ' HasPhoto';
    }
    if (in_array($ActivityType, array('WallComment', 'WallPost', 'AboutUpdate'))) {
        $CssClass .= ' Condensed';
    }
    $Title = '';
    $Excerpt = $Activity->Story;
    if (!in_array($ActivityType, array('WallComment', 'WallPost', 'AboutUpdate'))) {
        $Title = '<div class="Title">' . Gdn_Format::ActivityHeadline($Activity, $Sender->ProfileUserID) . '</div>';
    } else {
        if ($ActivityType == 'WallPost') {
            $RegardingUser = UserBuilder($Activity, 'Regarding');
            $PhotoAnchor = UserPhoto($RegardingUser);
            $Title = '<div class="Title">' . UserAnchor($RegardingUser, 'Name') . ' <span>&rarr;</span> ' . UserAnchor($Author, 'Title Name') . '</div>';
            $Excerpt = Gdn_Format::Display($Excerpt);
        } else {
            $Title = UserAnchor($Author, 'Title Name');
            $Excerpt = Gdn_Format::Display($Excerpt);
        }
    }
    $Sender->EventArguments['Activity'] =& $Activity;
    $Sender->EventArguments['CssClass'] =& $CssClass;
    $Sender->FireEvent('BeforeActivity');
    ?>
<li id="Activity_<?php 
    echo $Activity->ActivityID;
    ?>
" class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    if ($Session->IsValid() && ($Session->UserID == $Activity->InsertUserID || $Session->CheckPermission('Garden.Activity.Delete'))) {
        echo '<div class="OptionButton">' . Anchor(T('Activity.Delete', 'Delete'), 'dashboard/activity/delete/' . $Activity->ActivityID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'Delete') . '</div>';
    }
    if ($PhotoAnchor != '') {
        ?>
   <div class="Author Photo"><?php 
        echo $PhotoAnchor;
        ?>
</div>
   <?php 
    }
    ?>
   <div class="ItemContent Activity">
      <?php 
    echo $Title;
    ?>
      <div class="Excerpt"><?php 
    echo $Excerpt;
    ?>
</div>
      <div class="Meta">
         <span class="DateCreated"><?php 
    echo Gdn_Format::Date($Activity->DateInserted);
    ?>
</span>
         <?php 
    if ($Activity->AllowComments == '1' && $Session->IsValid()) {
        echo '<span class="AddComment">' . Anchor(T('Activity.Comment', 'Comment'), '#CommentForm_' . $Activity->ActivityID, 'CommentOption') . '</span>';
    }
    $Sender->FireEvent('AfterMeta');
    ?>
      </div>
   </div>
   <?php 
    if ($Activity->AllowComments == '1') {
        // If there are comments, show them
        $FoundComments = FALSE;
        if (property_exists($Sender, 'CommentData') && is_object($Sender->CommentData)) {
            foreach ($Sender->CommentData->Result() as $Comment) {
                if (is_object($Comment) && $Comment->CommentActivityID == $Activity->ActivityID) {
                    if ($FoundComments == FALSE) {
                        echo '<ul class="DataList ActivityComments">';
                    }
                    $FoundComments = TRUE;
                    WriteActivityComment($Comment, $Sender, $Session);
                }
            }
        }
        if ($FoundComments == FALSE) {
            echo '<ul class="DataList ActivityComments Hidden">';
        }
        if ($Session->IsValid()) {
            ?>
         <li class="CommentForm">
         <?php 
            echo Anchor(T('Write a comment'), '/dashboard/activity/comment/' . $Activity->ActivityID, 'CommentLink');
            $CommentForm = Gdn::Factory('Form');
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:helper_functions.php

示例2: QueueNotification

 /**
  * Queue a notification for sending.
  *
  * @since 2.0.17
  * @access public
  * @param int $ActivityID
  * @param string $Story
  * @param string $Position
  * @param bool $Force
  */
 public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE)
 {
     $Activity = $this->GetID($ActivityID);
     if (!is_object($Activity)) {
         return;
     }
     $Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
     // If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
     if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
         $CommentActivity = $this->GetID($Activity->CommentActivityID);
         $Activity->RegardingUserID = $CommentActivity->RegardingUserID;
         $Activity->Route = '/activity/item/' . $Activity->CommentActivityID;
     }
     $User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT);
     //$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
     if ($User) {
         if ($Force) {
             $Preference = $Force;
         } else {
             //            $Preferences = Gdn_Format::Unserialize($User->Preferences);
             $ConfigPreference = C('Preferences.Email.' . $Activity->ActivityType, '0');
             if ($ConfigPreference !== FALSE) {
                 $Preference = GetValue('Email.' . $Activity->ActivityType, $User->Preferences, $ConfigPreference);
             } else {
                 $Preference = FALSE;
             }
         }
         if ($Preference) {
             $ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
             $Email = new Gdn_Email();
             $Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
             $Email->To($User);
             $Message = sprintf($Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"), $ActivityHeadline, ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route), $Story);
             $Email->Message($Message);
             if (!array_key_exists($User->UserID, $this->_NotificationQueue)) {
                 $this->_NotificationQueue[$User->UserID] = array();
             }
             $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
             if ($Position == 'first') {
                 $this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]);
             } else {
                 $this->_NotificationQueue[$User->UserID][] = $Notification;
             }
         }
     }
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:56,代码来源:class.activitymodel.php

示例3: QueueNotification

 /**
  * Queue a notification for sending.
  */
 public function QueueNotification($ActivityID, $Story = '')
 {
     $Activity = $this->GetID($ActivityID);
     if (!is_object($Activity)) {
         return;
     }
     $Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
     // If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
     if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
         $CommentActivity = $this->GetID($Activity->CommentActivityID);
         $Activity->RegardingUserID = $CommentActivity->RegardingUserID;
         $Activity->Route = '/profile/' . $CommentActivity->RegardingUserID . '/' . Gdn_Format::Url($CommentActivity->RegardingName) . '/#Activity_' . $Activity->CommentActivityID;
     }
     $User = $this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
     if ($User) {
         $Preferences = Gdn_Format::Unserialize($User->Preferences);
         $Preference = ArrayValue('Email.' . $Activity->ActivityType, $Preferences, Gdn::Config('Preferences.Email.' . $Activity->ActivityType));
         if ($Preference) {
             $ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
             $Email = new Gdn_Email();
             $Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
             $Email->To($User->Email, $User->Name);
             //$Email->From(Gdn::Config('Garden.SupportEmail'), Gdn::Config('Garden.SupportName'));
             $Email->Message(sprintf(T($Story == '' ? 'EmailNotification' : 'EmailStoryNotification'), $ActivityHeadline, Url($Activity->Route == '' ? '/' : $Activity->Route, TRUE), $Story));
             if (!array_key_exists($User->UserID, $this->_NotificationQueue)) {
                 $this->_NotificationQueue[$User->UserID] = array();
             }
             $this->_NotificationQueue[$User->UserID][] = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email);
         }
     }
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:34,代码来源:class.activitymodel.php

示例4: explode

    echo '<li class="Activity ' . $Activity->ActivityType . '">';
    // If this was a status update or a wall comment, don't bother with activity strings
    $ActivityType = explode(' ', $Activity->ActivityType);
    // Make sure you strip out any extra css classes munged in here
    $ActivityType = $ActivityType[0];
    $Author = UserBuilder($Activity, 'Activity');
    if (in_array($ActivityType, array('WallComment', 'AboutUpdate'))) {
        echo UserAnchor($Author, 'Name');
        if ($Activity->ActivityType == 'WallComment' && $Activity->RegardingUserID > 0) {
            $Author = UserBuilder($Activity, 'Regarding');
            echo '<span>&rarr;</span>' . UserAnchor($Author, 'Name');
        }
        echo ' ' . Gdn_Format::Display($Activity->Story) . ' ';
        echo '<em>' . Gdn_Format::Date($Activity->DateInserted) . '</em>';
    } else {
        echo Gdn_Format::ActivityHeadline($Activity);
        echo '<em>' . Gdn_Format::Date($Activity->DateInserted) . '</em>';
        if ($Activity->Story != '') {
            echo '<div class="Story">';
            echo $Activity->Story;
            echo '</div>';
        }
    }
    echo '</li>';
}
?>
      <li class="ShowAll"><?php 
echo Anchor(T('↳ Show All'), 'activity/' . implode(',', $this->_RoleID));
?>
</li>
   </ul>
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:31,代码来源:recentactivity.php

示例5: 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 object $Sender The object calling this method.
  */
 public static function InformNotifications($Sender)
 {
     $Session = Gdn::Session();
     if (!$Session->IsValid()) {
         return;
     }
     // Set the user's DateLastInform attribute to now. This value can be used
     // by addons to determine if their inform messages have already been sent.
     $InformLastActivityID = $Session->GetAttribute('Notifications.InformLastActivityID', 0);
     // Allow pluggability
     $Sender->EventArguments['InformLastActivityID'] =& $InformLastActivityID;
     $Sender->FireEvent('BeforeInformNotifications');
     // Retrieve default preferences
     $Preferences = array();
     $DefaultPreferences = C('Preferences.Popup', array());
     foreach ($DefaultPreferences as $Preference => $Val) {
         if ($Val) {
             $Preferences[] = $Preference;
         }
     }
     //		$User = Gdn::Database()->SQL()->Select('Preferences')->From('User')->Where('UserID', $Session->UserID)->Get()->FirstRow();
     //      if ($User) {
     //         $PrefData = Gdn_Format::Unserialize($User->Preferences);
     //			foreach ($PrefData as $Pref => $Val) {
     //				if (substr($Pref, 0, 6) == 'Popup.') {
     //					$Pref = substr($Pref, 6);
     //					if ($Val) {
     //						$Preferences[] = $Pref;
     //					} else {
     //						if (in_array($Pref, $Preferences))
     //							unset($Preferences[array_search($Pref, $Preferences)]);
     //					}
     //				}
     //			}
     //		}
     //		if (count($Preferences) > 0) {
     // Grab the activity type ids for the desired notification prefs.
     $ActivityTypeIDs = array();
     //         $ActivityTypes = array();
     $Data = Gdn::Database()->SQL()->GetWhere('ActivityType', array('Notify' => TRUE))->ResultArray();
     //  ->WhereIn('Name', $Preferences)->Get();
     foreach ($Data as $ActivityType) {
         if (Gdn::Session()->GetPreference("Popup.{$ActivityType['Name']}", C("Preferences.Popup.{$ActivityType['Name']}", TRUE))) {
             $ActivityTypeIDs[] = $ActivityType['ActivityTypeID'];
             //               $ActivityTypes[] = $ActivityType['Name'];
         }
     }
     if (count($ActivityTypeIDs) > 0) {
         // Retrieve new notifications
         $ActivityModel = new ActivityModel();
         $NotificationData = $ActivityModel->GetNotificationsSince($Session->UserID, $InformLastActivityID, $ActivityTypeIDs);
         $InformLastActivityID = -1;
         // Add (no more than 5) notifications to the inform stack
         foreach ($NotificationData->Result() as $Notification) {
             // Make sure the user wants to be notified of this
             //					if (!in_array($Notification->ActivityType, $Preferences)) {
             //                  continue;
             //               }
             $UserPhoto = UserPhoto(UserBuilder($Notification, 'Activity'), 'Icon');
             $ActivityType = explode(' ', $Notification->ActivityType);
             $ActivityType = $ActivityType[0];
             $Excerpt = $Notification->Story;
             if (in_array($ActivityType, array('WallComment', 'AboutUpdate'))) {
                 $Excerpt = Gdn_Format::Display($Excerpt);
             }
             // Inform the user of new messages
             $Sender->InformMessage($UserPhoto . Wrap(Gdn_Format::ActivityHeadline($Notification, $Session->UserID), 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . ($UserPhoto == '' ? '' : ' HasIcon'));
             // Assign the most recent activity id
             if ($InformLastActivityID == -1) {
                 $InformLastActivityID = $Notification->ActivityID;
             }
         }
     }
     //		}
     if ($InformLastActivityID > 0) {
         Gdn::UserModel()->SaveAttribute($Session->UserID, 'Notifications.InformLastActivityID', $InformLastActivityID);
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:89,代码来源:class.notificationscontroller.php


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