Пример #1
0
echo t('Howdy, Stranger!');
?>
</h4>

    <p><?php 
echo t($this->MessageCode, $this->MessageDefault);
?>
</p>

    <p><?php 
$this->fireEvent('BeforeSignInButton');
?>
</p>

    <?php 
$signInUrl = SignInUrl($this->_Sender->SelfUrl);
if ($signInUrl) {
    echo '<div class="P">';
    echo anchor(t('Sign In'), SignInUrl($this->_Sender->SelfUrl), 'Button Primary' . (SignInPopup() ? ' SignInPopup' : ''), array('rel' => 'nofollow'));
    $Url = RegisterUrl($this->_Sender->SelfUrl);
    if (!empty($Url)) {
        echo ' ' . anchor(t('Register', t('Apply for Membership', 'Register')), $Url, 'Button ApplyButton', array('rel' => 'nofollow'));
    }
    echo '</div>';
}
?>
    <?php 
$this->fireEvent('AfterSignInButton');
?>
</div>
    function writeCommentForm()
    {
        $Session = Gdn::session();
        $Controller = Gdn::controller();
        $Discussion = $Controller->data('Discussion');
        $PermissionCategoryID = val('PermissionCategoryID', $Discussion);
        $UserCanClose = $Session->checkPermission('Vanilla.Discussions.Close', TRUE, 'Category', $PermissionCategoryID);
        $UserCanComment = $Session->checkPermission('Vanilla.Comments.Add', TRUE, 'Category', $PermissionCategoryID);
        // Closed notification
        if ($Discussion->Closed == '1') {
            ?>
            <div class="Foot Closed">
                <div class="Note Closed"><?php 
            echo t('This discussion has been closed.');
            ?>
</div>
                <?php 
            //echo anchor(t('All Discussions'), 'discussions', 'TabLink');
            ?>
            </div>
        <?php 
        } else {
            if (!$UserCanComment) {
                if (!Gdn::session()->isValid()) {
                    ?>
                <div class="Foot Closed">
                    <div class="Note Closed SignInOrRegister"><?php 
                    $Popup = c('Garden.SignIn.Popup') ? ' class="Popup"' : '';
                    $ReturnUrl = Gdn::request()->PathAndQuery();
                    echo formatString(t('Sign In or Register to Comment.', '<a href="{SignInUrl,html}"{Popup}>Sign In</a> or <a href="{RegisterUrl,html}">Register</a> to comment.'), array('SignInUrl' => url(SignInUrl($ReturnUrl)), 'RegisterUrl' => url(RegisterUrl($ReturnUrl)), 'Popup' => $Popup));
                    ?>
                    </div>
                    <?php 
                    //echo anchor(t('All Discussions'), 'discussions', 'TabLink');
                    ?>
                </div>
            <?php 
                }
            }
        }
        if ($Discussion->Closed == '1' && $UserCanClose || $Discussion->Closed == '0' && $UserCanComment) {
            echo $Controller->fetchView('comment', 'post', 'vanilla');
        }
    }
Пример #3
0
    function WriteCommentForm()
    {
        $Session = Gdn::Session();
        $Controller = Gdn::Controller();
        $Discussion = $Controller->Data('Discussion');
        $PermissionCategoryID = GetValue('PermissionCategoryID', $Discussion);
        $UserCanClose = $Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $PermissionCategoryID);
        $UserCanComment = $Session->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $PermissionCategoryID);
        // Closed notification
        if ($Discussion->Closed == '1') {
            ?>
		<div class="Foot Closed">
			<div class="Note Closed"><?php 
            echo T('This discussion has been closed.');
            ?>
</div>
			<?php 
            //echo Anchor(T('All Discussions'), 'discussions', 'TabLink');
            ?>
		</div>
		<?php 
        } else {
            if (!$UserCanComment) {
                if (!Gdn::Session()->IsValid()) {
                    ?>
		<div class="Foot Closed">
			<div class="Note Closed"><?php 
                    $Popup = C('Garden.SignIn.Popup') ? ' class="Popup"' : '';
                    echo FormatString(T('Sign In or Register to Comment.', '<a href="{SignInUrl,html}"{Popup}>Sign In</a> or <a href="{RegisterUrl,html}">Register</a> to comment.'), array('SignInUrl' => Url(SignInUrl(Url(''))), 'RegisterUrl' => Url(RegisterUrl(Url(''))), 'Popup' => $Popup));
                    ?>
         </div>
			<?php 
                    //echo Anchor(T('All Discussions'), 'discussions', 'TabLink');
                    ?>
		</div>
		<?php 
                }
            }
        }
        if ($Discussion->Closed == '1' && $UserCanClose || $Discussion->Closed == '0' && $UserCanComment) {
            echo $Controller->FetchView('comment', 'post');
        }
    }
Пример #4
0
 public static function Link($Path, $Text = FALSE, $Format = NULL, $Options = array())
 {
     $Session = Gdn::Session();
     $Class = GetValue('class', $Options, '');
     $WithDomain = GetValue('WithDomain', $Options);
     $Target = GetValue('Target', $Options, '');
     if ($Target == 'current') {
         $Target = trim(Url('', TRUE), '/ ');
     }
     if (is_null($Format)) {
         $Format = '<a href="%url" class="%class">%text</a>';
     }
     switch ($Path) {
         case 'activity':
             TouchValue('Permissions', $Options, 'Garden.Activity.View');
             break;
         case 'category':
             $Breadcrumbs = Gdn::Controller()->Data('Breadcrumbs');
             if (is_array($Breadcrumbs) && count($Breadcrumbs) > 0) {
                 $Last = array_pop($Breadcrumbs);
                 $Path = GetValue('Url', $Last);
                 $DefaultText = GetValue('Name', $Last, T('Back'));
             } else {
                 $Path = '/';
                 $DefaultText = C('Garden.Title', T('Back'));
             }
             if (!$Text) {
                 $Text = $DefaultText;
             }
             break;
         case 'dashboard':
             $Path = 'dashboard/settings';
             TouchValue('Permissions', $Options, array('Garden.Settings.Manage', 'Garden.Settings.View'));
             if (!$Text) {
                 $Text = T('Dashboard');
             }
             break;
         case 'home':
             $Path = '/';
             if (!$Text) {
                 $Text = T('Home');
             }
             break;
         case 'inbox':
             $Path = 'messages/inbox';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('Inbox');
             }
             if ($Session->IsValid() && $Session->User->CountUnreadConversations) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountUnreadConversations . '</span>';
             }
             if (!$Session->IsValid()) {
                 $Text = FALSE;
             }
             break;
         case 'forumroot':
             $Route = Gdn::Router()->GetDestination('DefaultForumRoot');
             if (is_null($Route)) {
                 $Path = '/';
             } else {
                 $Path = CombinePaths(array('/', $Route));
             }
             break;
         case 'profile':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $Text = $Session->User->Name;
             }
             if ($Session->IsValid() && $Session->User->CountNotifications) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountNotifications . '</span>';
             }
             break;
         case 'user':
             $Path = 'profile';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $Text = $Session->User->Name;
             }
             break;
         case 'photo':
             $Path = 'profile';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->IsValid()) {
                 $IsFullPath = strtolower(substr($Session->User->Photo, 0, 7)) == 'http://' || strtolower(substr($Session->User->Photo, 0, 8)) == 'https://';
                 $PhotoUrl = $IsFullPath ? $Session->User->Photo : Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'n%s'));
                 $Text = Img($PhotoUrl, array('alt' => htmlspecialchars($Session->User->Name)));
             }
             break;
         case 'drafts':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Drafts');
             }
             if ($Session->IsValid() && $Session->User->CountDrafts) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountDrafts . '</span>';
             }
             break;
         case 'discussions/bookmarked':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Bookmarks');
             }
             if ($Session->IsValid() && $Session->User->CountBookmarks) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Count">' . $Session->User->CountBookmarks . '</span>';
             }
             break;
         case 'discussions/mine':
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = T('My Discussions');
             }
             if ($Session->IsValid() && $Session->User->CountDiscussions) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Count">' . $Session->User->CountDiscussions . '</span>';
             }
             break;
         case 'register':
             if (!$Text) {
                 $Text = T('Register');
             }
             $Path = RegisterUrl($Target);
             break;
         case 'signin':
         case 'signinout':
             // The destination is the signin/signout toggle link.
             if ($Session->IsValid()) {
                 if (!$Text) {
                     $Text = T('Sign Out');
                 }
                 $Path = SignOutUrl($Target);
                 $Class = ConcatSep(' ', $Class, 'SignOut');
             } else {
                 if (!$Text) {
                     $Text = T('Sign In');
                 }
                 $Path = SignInUrl($Target);
                 if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE) {
                     $Class = ConcatSep(' ', $Class, 'SignInPopup');
                 }
             }
             break;
     }
     if ($Text == FALSE && strpos($Format, '%text') !== FALSE) {
         return '';
     }
     if (GetValue('Permissions', $Options) && !$Session->CheckPermission($Options['Permissions'], FALSE)) {
         return '';
     }
     $Url = Gdn::Request()->Url($Path, $WithDomain);
     if ($TK = GetValue('TK', $Options)) {
         if (in_array($TK, array(1, 'true'))) {
             $TK = 'TransientKey';
         }
         $Url .= (strpos($Url, '?') === FALSE ? '?' : '&') . $TK . '=' . urlencode(Gdn::Session()->TransientKey());
     }
     if (strcasecmp(trim($Path, '/'), Gdn::Request()->Path()) == 0) {
         $Class = ConcatSep(' ', $Class, 'Selected');
     }
     // Build the final result.
     $Result = $Format;
     $Result = str_replace('%url', $Url, $Result);
     $Result = str_replace('%text', $Text, $Result);
     $Result = str_replace('%class', $Class, $Result);
     return $Result;
 }