コード例 #1
0
ファイル: profile.php プロジェクト: jhampha/Garden
 public function BuildProfile($UserReference = '')
 {
     $Session = Gdn::Session();
     $this->CssClass = 'Profile';
     if (!$this->GetUserInfo($UserReference)) {
         return FALSE;
     }
     if ($this->Head) {
         $this->Head->Title(Format::Text($this->User->Name));
     }
     if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
         $UserInfoModule = new UserInfoModule($this);
         $UserInfoModule->User = $this->User;
         $UserInfoModule->Roles = $this->Roles;
         $this->AddModule($UserInfoModule);
         if ($this->Head) {
             $this->Head->AddScript('/js/library/jquery.jcrop.pack.js');
             $this->Head->AddScript('/applications/garden/js/profile.js');
             $this->Head->AddScript('/applications/garden/js/activity.js');
         }
         $this->AddProfileTab('Activity');
         if ($this->User->UserID == $Session->UserID) {
             $Notifications = Gdn::Translate('Notifications');
             $CountNotifications = $Session->User->CountNotifications;
             if (is_numeric($CountNotifications) && $CountNotifications > 0) {
                 $Notifications .= '<span>' . $CountNotifications . '</span>';
             }
             $this->AddProfileTab(array($Notifications => 'profile/notifications'));
         }
         $this->FireEvent('AddProfileTabs');
     }
     return TRUE;
 }
コード例 #2
0
ファイル: profile.php プロジェクト: Valooo/Garden
 public function BuildProfile($UserReference = '')
 {
     $Session = Gdn::Session();
     $this->CssClass = 'Profile';
     if (!$this->GetUserInfo($UserReference)) {
         return FALSE;
     }
     if ($this->Head) {
         $this->Head->Title(Format::Text($this->User->Name));
     }
     if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
         $UserInfoModule = new UserInfoModule($this);
         $UserInfoModule->User = $this->User;
         $UserInfoModule->Roles = $this->Roles;
         $this->AddModule($UserInfoModule);
         if ($this->Head) {
             $this->Head->AddScript('/js/library/jquery.jcrop.pack.js');
             $this->Head->AddScript('/applications/garden/js/profile.js');
             $this->Head->AddScript('/applications/garden/js/activity.js');
         }
         $this->AddProfileTab(array('Activity' => ''));
         $this->FireEvent('AddProfileTabs');
     }
     return TRUE;
 }
コード例 #3
0
ファイル: search.php プロジェクト: Aetasiric/Garden
 public function Index($Offset = 0, $Limit = NULL)
 {
     $this->AddJsFile('/js/library/jquery.gardenmorepager.js');
     $this->AddJsFile('search.js');
     $this->Title(Translate('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', Format::Text($Search), TRUE);
     $NumResults = $ResultSet->NumRows();
     if ($NumResults == $Offset + $Limit) {
         $NumResults++;
     }
     // Build a pager
     $PagerFactory = new PagerFactory();
     $Pager = $PagerFactory->GetPager('MorePager', $this);
     $Pager->MoreCode = 'More Results';
     $Pager->LessCode = 'Previous Results';
     $Pager->ClientID = 'Pager';
     $Pager->Configure($Offset, $Limit, $NumResults, 'garden/search/%1$s/%2$s/?Search=' . Format::Url($Search));
     $this->SetData('Pager', $Pager, TRUE);
     $this->View = 'results';
     $this->Render();
 }
コード例 #4
0
 public function RecordActivity($UserID, $DiscussionID, $DiscussionName)
 {
     // Report that the discussion was created
     AddActivity($UserID, 'NewDiscussion', Anchor(Format::Text($DiscussionName), 'vanilla/discussion/' . $DiscussionID . '/' . Format::Url($DiscussionName)));
     // Get the user's discussion count
     $Data = $this->SQL->Select('DiscussionID', 'count', 'CountDiscussions')->From('Discussion')->Where('InsertUserID', $UserID)->Get();
     // Save the count to the user table
     $this->SQL->Update('User')->Set('CountDiscussions', $Data->NumRows() > 0 ? $Data->FirstRow()->CountDiscussions : 0)->Where('UserID', $UserID)->Put();
 }
コード例 #5
0
ファイル: categories.php プロジェクト: nbudin/Garden
    }
    ?>
><strong><?php 
    echo Anchor(Format::Text(T('All Discussions')), '/discussions');
    ?>
</strong> <?php 
    echo $CountDiscussions;
    ?>
</li>
      <?php 
    foreach ($this->_CategoryData->Result() as $Category) {
        ?>
      <li<?php 
        if ($CategoryID == $Category->CategoryID) {
            echo ' class="Active"';
        }
        ?>
><strong><?php 
        echo Anchor(Format::Text(str_replace('&rarr;', '→', $Category->Name)), '/categories/' . $Category->UrlCode);
        ?>
</strong> <?php 
        echo $Category->CountDiscussions;
        ?>
</li>
      <?php 
    }
    ?>
   </ul>
</div>
   <?php 
}
コード例 #6
0
ファイル: class.headmodule.php プロジェクト: Beyzie/Garden
 public function SubTitle($SubTitle = FALSE, $Title = FALSE, $TitleDivider = ' - ')
 {
     $this->_TitleDivider = '';
     if ($Title === FALSE) {
         $Title = Gdn::Config('Garden.Title', FALSE);
     }
     if ($Title !== FALSE) {
         $this->_Title = Format::Text($Title);
     }
     if ($SubTitle !== FALSE) {
         $this->_SubTitle = $SubTitle;
     }
     if ($this->_SubTitle != '' && $this->_Title != '') {
         $this->_TitleDivider = $TitleDivider;
     }
     return $this->_Title . $this->_TitleDivider . $this->_SubTitle;
 }
コード例 #7
0
ファイル: results.php プロジェクト: nbudin/Garden
<ul class="DataList SearchResults">
<?php 
if (method_exists($this->SearchResults, 'NumRows') && $this->SearchResults->NumRows() > 0) {
    foreach ($this->SearchResults->ResultObject() as $Row) {
        ?>
	<li class="Item">
		<div class="ItemContent">
			<?php 
        echo Anchor(Format::Text($Row->Title), $Row->Url, 'Title');
        ?>
			<div class="Excerpt"><?php 
        echo Anchor(Format::Text(SliceString($Row->Summary, 250)), $Row->Url);
        ?>
</div>
			<div class="Meta">
				<span><?php 
        printf(T('Comment by %s'), UserAnchor($Row));
        ?>
</span>
				<span><?php 
        echo Format::Date($Row->DateInserted);
        ?>
</span>
				<span><?php 
        echo Anchor(T('permalink'), $Row->Url);
        ?>
</span>
			</div>
		</div>
	</li>
<?php 
コード例 #8
0
ファイル: results.php プロジェクト: Aetasiric/Garden
echo $this->Pager->ToString('less');
?>
<ul class="DataList SearchResults">
<?php 
if ($this->SearchResults->NumRows() > 0) {
    foreach ($this->SearchResults->ResultObject() as $Row) {
        ?>
	<li class="Row">
		<ul>
			<li class="Title">
				<strong><?php 
        echo Anchor(Format::Text($Row->Title), $Row->Url);
        ?>
</strong>
				<?php 
        echo Anchor(Format::Text($Row->Summary), $Row->Url);
        ?>
			</li>
			<li class="Meta">
				<span><?php 
        printf(Gdn::Translate('Comment by %s'), UserAnchor($Row));
        ?>
</span>
				<span><?php 
        echo Format::Date($Row->DateInserted);
        ?>
</span>
				<span><?php 
        echo Anchor(Gdn::Translate('permalink'), $Row->Url);
        ?>
</span>
コード例 #9
0
ファイル: drafts.php プロジェクト: jhampha/Garden
if (!defined('APPLICATION')) {
    exit;
}
$Session = Gdn::Session();
$ShowOptions = TRUE;
$Alt = '';
foreach ($this->DraftData->Result() as $Draft) {
    $EditUrl = !is_numeric($Draft->DiscussionID) || $Draft->DiscussionID <= 0 ? '/post/editdiscussion/0/' . $Draft->DraftID : '/post/editcomment/0/' . $Draft->DraftID;
    $Alt = $Alt == ' Alt' ? '' : ' Alt';
    ?>
   <li class="<?php 
    echo 'DiscussionRow Draft' . $Alt;
    ?>
">
      <ul>
         <li class="Title">
            <?php 
    echo Anchor('Delete', 'vanilla/drafts/delete/' . $Draft->DraftID . '/' . $Session->TransientKey() . '?Target=' . urlencode($this->SelfUrl), 'DeleteDraft');
    ?>
            <strong><?php 
    echo Anchor($Draft->Name, $EditUrl, 'DraftLink');
    ?>
</strong>
            <?php 
    echo Anchor(SliceString(Format::Text($Draft->Body), 200), $EditUrl);
    ?>
         </li>
      </ul>
   </li>
   <?php 
}
コード例 #10
0
ファイル: conversations.php プロジェクト: robi-bobi/Garden
    $Class = trim($Class);
    $Name = $Session->UserID == $Conversation->LastMessageUserID ? 'You' : $Conversation->LastMessageName;
    $JumpToItem = $Conversation->CountMessages - $Conversation->CountNewMessages;
    ?>
<li<?php 
    echo $Class == '' ? '' : ' class="' . $Class . '"';
    ?>
>
   <?php 
    $LastAuthor = UserBuilder($Conversation, 'LastMessage');
    echo UserPhoto($LastAuthor, 'Photo');
    ?>
   <div>
      <?php 
    echo UserAnchor($LastAuthor, 'Name');
    echo Anchor(SliceString(Format::Text($Conversation->LastMessage), 100), '/messages/' . $Conversation->ConversationID . '/#Item_' . $JumpToItem, 'Message');
    echo '<div class="Meta">';
    echo Format::Date($Conversation->DateLastMessage);
    echo '<span>&bull;</span>';
    printf(Gdn::Translate(Plural($Conversation->CountMessages, '%s message', '%s messages')), $Conversation->CountMessages);
    if ($Conversation->CountNewMessages > 0) {
        echo '<span>&bull;</span>';
        echo '<em>';
        printf(Gdn::Translate('%s new'), $Conversation->CountNewMessages);
        echo '</em>';
    }
    echo '</div>';
    ?>
   </div>
</li>
<?php 
コード例 #11
0
ファイル: class.commentmodel.php プロジェクト: jhampha/Garden
 public function RecordActivity($Discussion, $ActivityUserID, $CommentID)
 {
     // Get the author of the discussion
     if ($Discussion->InsertUserID != $ActivityUserID) {
         AddActivity($ActivityUserID, 'DiscussionComment', Anchor(Format::Text($Discussion->Name), 'discussion/comment/' . $CommentID . '/#Comment_' . $CommentID), $Discussion->InsertUserID, 'discussion/comment/' . $CommentID . '/#Comment_' . $CommentID);
     }
 }
コード例 #12
0
ファイル: index.php プロジェクト: Valooo/Garden
<div>
         <strong><?php 
    echo $Message->Enabled == '1' ? 'Enabled' : 'Disabled';
    ?>
</strong>
         <span>|</span>
         <?php 
    echo Anchor('Edit', '/garden/messages/edit/' . $Message->MessageID, 'EditMessage');
    ?>
         <span>|</span>
         <?php 
    echo Anchor('Delete', '/garden/messages/delete/' . $Message->MessageID . '/' . $Session->TransientKey(), 'DeleteMessage');
    ?>
         </div>
      </td>
      <td class="Alt"><?php 
    if ($Message->CssClass != '') {
        echo '<div class="' . $Message->CssClass . '">';
    }
    echo Format::Text($Message->Content);
    if ($Message->CssClass != '') {
        echo '</div>';
    }
    ?>
</td>
   </tr>
<?php 
}
?>
   </tbody>
</table>
コード例 #13
0
ファイル: drafts.php プロジェクト: kidmax/Garden
if (!defined('APPLICATION')) {
    exit;
}
if ($this->_DraftData !== FALSE && $this->_DraftData->NumRows() > 0) {
    ?>
<div class="Box">
   <h4><?php 
    echo Gdn::Translate('My Drafts');
    ?>
</h4>
   <ul class="PanelDiscussions">
      <?php 
    foreach ($this->_DraftData->Result() as $Draft) {
        $EditUrl = !is_numeric($Draft->DiscussionID) || $Draft->DiscussionID <= 0 ? '/post/editdiscussion/0/' . $Draft->DraftID : '/post/editcomment/0/' . $Draft->DraftID;
        ?>
      <li>
         <strong><?php 
        echo Anchor($Draft->Name, $EditUrl, 'DraftLink');
        ?>
</strong>
         <?php 
        echo Anchor(SliceString(Format::Text($Draft->Body), 200), $EditUrl, 'DraftCommentLink');
        ?>
      </li>
      <?php 
    }
    ?>
   </ul>
</div>
<?php 
}
コード例 #14
0
ファイル: helper_functions.php プロジェクト: nbudin/Garden
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt)
{
    $CssClass = 'Item';
    $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
    $CssClass .= $Alt . ' ';
    $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
    $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
    $CountUnreadComments = $Discussion->CountComments - $Discussion->CountCommentWatch;
    $CssClass .= $CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
    $Sender->EventArguments['Discussion'] =& $Discussion;
    $Last = UserBuilder($Discussion, 'Last');
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
">
   <?php 
    WriteOptions($Discussion, $Sender, $Session);
    ?>
   <div class="ItemContent Discussion">
      <?php 
    echo Anchor(Format::Text($Discussion->Name), '/discussion/' . $Discussion->DiscussionID . '/' . Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'Title');
    ?>
      <?php 
    $Sender->FireEvent('AfterDiscussionTitle');
    ?>
      <div class="Meta">
         <?php 
    if ($Discussion->Announce == '1') {
        ?>
         <span class="Announcement"><?php 
        echo T('Announcement');
        ?>
</span>
         <?php 
    }
    ?>
         <span><?php 
    printf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments);
    ?>
</span>
         <?php 
    if ($CountUnreadComments > 0 && $Session->IsValid()) {
        echo '<strong>', sprintf(T('%s new'), $CountUnreadComments), '</strong>';
    }
    ?>
         <span><?php 
    printf(T('Most recent by %1$s %2$s'), UserAnchor($Last), Format::Date($Discussion->LastDate));
    ?>
</span>
         <span><?php 
    echo Anchor($Discussion->Category, '/categories/' . $Discussion->CategoryUrlCode, 'Category');
    ?>
</span>
         <?php 
    $Sender->FireEvent('DiscussionMeta');
    ?>
      </div>
   </div>
</li>
<?php 
}
コード例 #15
0
ファイル: discussion.php プロジェクト: Beyzie/Garden
 public function Index($DiscussionID = '', $Offset = '', $Limit = '')
 {
     $this->AddCssFile('vanilla.css');
     $Session = Gdn::Session();
     if ($this->Head) {
         $this->Head->AddScript('/js/library/jquery.resizable.js');
         $this->Head->AddScript('/js/library/jquery.ui.packed.js');
         $this->Head->AddScript('/js/library/jquery.autogrow.js');
         $this->Head->AddScript('/js/library/jquery.gardenmorepager.js');
         $this->Head->AddScript('/applications/vanilla/js/options.js');
         $this->Head->AddScript('/applications/vanilla/js/bookmark.js');
         $this->Head->AddScript('/applications/vanilla/js/discussion.js');
         $this->Head->AddScript('/applications/vanilla/js/autosave.js');
     }
     // Load the discussion record
     $DiscussionID = is_numeric($DiscussionID) && $DiscussionID > 0 ? $DiscussionID : 0;
     $this->SetData('Discussion', $this->DiscussionModel->GetID($DiscussionID), TRUE);
     if (!is_object($this->Discussion)) {
         Redirect('FileNotFound');
     }
     // Check Permissions
     $this->Permission('Vanilla.Discussions.View', $this->Discussion->CategoryID);
     $this->SetData('CategoryID', $this->CategoryID = $this->Discussion->CategoryID, TRUE);
     if ($this->Discussion === FALSE) {
         return $this->ReDispatch('garden/home/filenotfound');
     } else {
         // Setup
         if ($this->Head) {
             $this->Head->Title(Format::Text($this->Discussion->Name));
         }
         // Define the query offset & limit
         if (!is_numeric($Limit) || $Limit < 0) {
             $Limit = Gdn::Config('Vanilla.Comments.PerPage', 50);
         }
         $this->Offset = $Offset;
         if (!is_numeric($this->Offset) || $this->Offset < 0) {
             // Round down to the appropriate offset based on the user's read comments & comments per page
             $CountCommentWatch = $this->Discussion->CountCommentWatch > 0 ? $this->Discussion->CountCommentWatch : 0;
             if ($CountCommentWatch > $this->Discussion->CountComments) {
                 $CountCommentWatch = $this->Discussion->CountComments;
             }
             // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
             $this->Offset = floor($CountCommentWatch / $Limit) * $Limit;
         }
         if ($this->Offset < 0) {
             $this->Offset = 0;
         }
         // Make sure to set the user's discussion watch records
         $this->CommentModel->SetWatch($this->Discussion, $Limit, $this->Offset, $this->Discussion->CountComments);
         // Load the comments
         $this->SetData('CommentData', $this->CommentData = $this->CommentModel->Get($DiscussionID, $Limit, $this->Offset), TRUE);
         // Build a pager
         $PagerFactory = new PagerFactory();
         $this->Pager = $PagerFactory->GetPager('MorePager', $this);
         $this->Pager->MoreCode = '%1$s more comments';
         $this->Pager->LessCode = '%1$s older comments';
         $this->Pager->ClientID = 'Pager';
         $this->Pager->Configure($this->Offset, $Limit, $this->Discussion->CountComments, 'vanilla/discussion/' . $DiscussionID . '/%1$s/%2$s/' . Format::Url($this->Discussion->Name));
     }
     // Define the form for the comment input
     $this->Form = Gdn::Factory('Form', 'Comment');
     $this->DiscussionID = $this->Discussion->DiscussionID;
     $this->Form->AddHidden('DiscussionID', $this->DiscussionID);
     $this->Form->AddHidden('CommentID', '');
     $this->Form->AddHidden('DraftID', '');
     $this->Form->Action = Url('/vanilla/post/comment/');
     // 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->View = 'comments';
     }
     // Add Modules
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $DraftsModule = new DraftsModule($this);
     $DraftsModule->GetData(20, $DiscussionID);
     $this->AddModule($DraftsModule);
     $BookmarkedModule = new BookmarkedModule($this);
     $BookmarkedModule->GetData();
     $this->AddModule($BookmarkedModule);
     $this->FireEvent('DiscussionRenderBefore');
     $this->Render();
 }
コード例 #16
0
ファイル: class.activitymodel.php プロジェクト: nbudin/Garden
 public function SendNotification($ActivityID, $Story = '')
 {
     $Activity = $this->GetID($ActivityID);
     if (!is_object($Activity)) {
         return;
     }
     $Story = Format::Text($Story == '' ? $Activity->Story : $Story);
     // 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 . '/' . Format::Url($CommentActivity->RegardingName) . '/#Activity_' . $Activity->CommentActivityID;
     }
     $User = $this->SQL->Select('Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
     if ($User) {
         $Preferences = Format::Unserialize($User->Preferences);
         $Preference = ArrayValue('Email.' . $Activity->ActivityType, $Preferences, Gdn::Config('Preferences.Email.' . $Activity->ActivityType));
         if ($Preference) {
             $ActivityHeadline = Format::Text(Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID));
             $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));
             try {
                 $Email->Send();
             } catch (Exception $ex) {
                 // Don't do anything with the exception.
             }
         }
     }
 }
コード例 #17
0
ファイル: helper_functions.php プロジェクト: jhampha/Garden
function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt)
{
    $CssClass = 'DiscussionRow';
    $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : '';
    $CssClass .= $Alt . ' ';
    $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : '';
    $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : '';
    $CountUnreadComments = $Discussion->CountComments - $Discussion->CountCommentWatch;
    $CssClass .= $CountUnreadComments > 0 && $Session->IsValid() ? ' New' : '';
    ?>
<li class="<?php 
    echo $CssClass;
    ?>
">
   <ul class="Discussion">
      <?php 
    if ($Sender->ShowOptions) {
        ?>
      <li class="Options">
         <?php 
        // Build up the options that the user has for each discussion
        if ($Session->IsValid()) {
            // Bookmark link
            echo Anchor('<span>*</span>', '/vanilla/discussion/bookmark/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'Bookmark' . ($Discussion->Bookmarked == '1' ? ' Bookmarked' : ''), array('title' => Gdn::Translate($Discussion->Bookmarked == '1' ? 'Unbookmark' : 'Bookmark')));
            $Sender->Options = '';
            // Dismiss an announcement
            if ($Discussion->Announce == '1' && $Discussion->Dismissed != '1') {
                $Sender->Options .= '<li>' . Anchor('Dismiss', 'vanilla/discussion/dismissannouncement/' . $Discussion->DiscussionID . '/' . $Session->TransientKey(), 'DismissAnnouncement') . '</li>';
            }
            // Edit discussion
            if ($Discussion->FirstUserID == $Session->UserID || $Session->CheckPermission('Vanilla.Discussions.Edit', $Discussion->CategoryID)) {
                $Sender->Options .= '<li>' . Anchor('Edit', 'vanilla/post/editdiscussion/' . $Discussion->DiscussionID, 'EditDiscussion') . '</li>';
            }
            // Announce discussion
            if ($Session->CheckPermission('Vanilla.Discussions.Announce', $Discussion->CategoryID)) {
                $Sender->Options .= '<li>' . Anchor($Discussion->Announce == '1' ? 'Unannounce' : 'Announce', 'vanilla/discussion/announce/' . $Discussion->DiscussionID . '/' . $Session->TransientKey(), 'AnnounceDiscussion') . '</li>';
            }
            // Sink discussion
            if ($Session->CheckPermission('Vanilla.Discussions.Sink', $Discussion->CategoryID)) {
                $Sender->Options .= '<li>' . Anchor($Discussion->Sink == '1' ? 'Unsink' : 'Sink', 'vanilla/discussion/sink/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'SinkDiscussion') . '</li>';
            }
            // Close discussion
            if ($Session->CheckPermission('Vanilla.Discussions.Close', $Discussion->CategoryID)) {
                $Sender->Options .= '<li>' . Anchor($Discussion->Closed == '1' ? 'Reopen' : 'Close', 'vanilla/discussion/close/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'CloseDiscussion') . '</li>';
            }
            // Delete discussion
            if ($Session->CheckPermission('Vanilla.Discussions.Delete', $Discussion->CategoryID)) {
                $Sender->Options .= '<li>' . Anchor('Delete', 'vanilla/discussion/delete/' . $Discussion->DiscussionID . '/' . $Session->TransientKey() . '?Target=' . urlencode($Sender->SelfUrl), 'DeleteDiscussion') . '</li>';
            }
            // Allow plugins to add options
            $Sender->FireEvent('DiscussionOptions');
            if ($Sender->Options != '') {
                ?>
               <ul class="Options">
                  <li><strong><?php 
                echo Gdn::Translate('Options');
                ?>
</strong>
                     <ul>
                        <?php 
                echo $Sender->Options;
                ?>
                     </ul>
                  </li>
               </ul>
               <?php 
            }
        }
        ?>
      </li>
      <?php 
    }
    ?>
      <li class="Title">
         <strong><?php 
    echo Anchor(Format::Text($Discussion->Name), '/discussion/' . $Discussion->DiscussionID . '/' . Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink');
    ?>
</strong>
      </li>
      <li class="Meta">
         <?php 
    echo '<span>';
    echo sprintf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments);
    echo '</span>';
    if ($CountUnreadComments > 0 && $Session->IsValid()) {
        echo '<strong>', sprintf(Gdn::Translate('%s new'), $CountUnreadComments), '</strong>';
    }
    echo '<span>';
    printf(Gdn::Translate('Most recent by %1$s %2$s'), UserAnchor($Discussion->LastName), Format::Date($Discussion->LastDate));
    echo '</span>';
    echo Anchor($Discussion->Category, '/categories/' . urlencode($Discussion->Category), 'Category');
    $Sender->FireEvent('DiscussionMeta');
    ?>
      </li>
   </ul>
</li>
<?php 
}
コード例 #18
0
ファイル: class.format.php プロジェクト: kidmax/Garden
 /**
  * Takes a mixed variable, formats it in the specified format type, and
  * returns it.
  *
  * @param mixed $Mixed An object, array, or string to be formatted.
  * @param string $FormatMethod The method with which the variable should be formatted.
  * @return mixed
  */
 public static function To($Mixed, $FormatMethod)
 {
     if ($FormatMethod == '') {
         return $Mixed;
     }
     if (is_string($Mixed)) {
         if (method_exists('Format', $FormatMethod)) {
             $Mixed = self::$FormatMethod($Mixed);
         } else {
             if (function_exists($FormatMethod)) {
                 $Mixed = $FormatMethod($Mixed);
             } else {
                 $Mixed = Format::Text($Mixed);
             }
         }
     } else {
         if (is_array($Mixed)) {
             foreach ($Mixed as $Key => $Val) {
                 $Mixed[$Key] = self::To($Val, $FormatMethod);
             }
         } else {
             if (is_object($Mixed)) {
                 foreach (get_object_vars($Mixed) as $Prop => $Val) {
                     $Mixed->{$Prop} = self::To($Val, $FormatMethod);
                 }
             }
         }
     }
     return $Mixed;
 }
コード例 #19
0
ファイル: preview.php プロジェクト: kidmax/Garden
<?php

if (!defined('APPLICATION')) {
    exit;
}
if (property_exists($this, 'Discussion')) {
    ?>
<h2><?php 
    echo Format::Text($this->Discussion->Name);
    ?>
</h2>
<?php 
}
?>
<ul class="Discussion Preview">
   <li class="Comment">
      <ul class="Info">
         <li class="Author"><?php 
echo UserPhoto($this->Comment->InsertName, $this->Comment->InsertPhoto);
echo UserAnchor($this->Comment->InsertName);
?>
</li>
         <li class="Created"><?php 
echo Format::Date($this->Comment->DateInserted);
?>
</li>
      </ul>
      <div class="Body"><?php 
echo Format::To($this->Comment->Body, Gdn::Config('Garden.InputFormatter'));
?>
</div>
コード例 #20
0
ファイル: categories.php プロジェクト: jhampha/Garden
    }
    ?>
><strong><?php 
    echo Anchor(Format::Text(Gdn::Translate('All Discussions')), '/discussions');
    ?>
</strong> <?php 
    echo $CountDiscussions;
    ?>
</li>
      <?php 
    foreach ($this->_CategoryData->Result() as $Category) {
        ?>
      <li<?php 
        if ($CategoryID == $Category->CategoryID) {
            echo ' class="Active"';
        }
        ?>
><strong><?php 
        echo Anchor(Format::Text($Category->Name), '/categories/' . urlencode($Category->Name));
        ?>
</strong> <?php 
        echo $Category->CountDiscussions;
        ?>
</li>
      <?php 
    }
    ?>
   </ul>
</div>
   <?php 
}