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


PHP Gdn::controller方法代码示例

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


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

示例1: mediaCache

 /**
  * Get our cache.
  *
  * @return array|null
  */
 public function mediaCache()
 {
     if ($this->_MediaCache === null) {
         $this->cacheAttachedMedia(Gdn::controller());
     }
     return $this->_MediaCache;
 }
开发者ID:vanilla,项目名称:addons,代码行数:12,代码来源:class.fileupload.plugin.php

示例2: smarty_function_asset

/**
 * Renders an asset from the controller.
 *
 * @param array $Params The parameters passed into the function.
 * The parameters that can be passed to this function are as follows.
 * - <b>name</b>: The name of the asset.
 * - <b>tag</b>: The type of tag to wrap the asset in.
 * - <b>id</b>: The id of the tag if different than the name.
 * @param object $Smarty Smarty The smarty object rendering the template.
 * @return string The rendered asset.
 */
function smarty_function_asset($Params, &$Smarty)
{
    $Name = val('name', $Params);
    $Tag = val('tag', $Params, '');
    $Id = val('id', $Params, $Name);
    $Class = val('class', $Params, '');
    if ($Class != '') {
        $Class = ' class="' . $Class . '"';
    }
    $Controller = Gdn::controller();
    $Controller->EventArguments['AssetName'] = $Name;
    $Result = '';
    ob_start();
    $Controller->fireEvent('BeforeRenderAsset');
    $Result .= ob_get_clean();
    $Asset = $Controller->getAsset($Name);
    if (is_object($Asset)) {
        $Asset->AssetName = $Name;
        if (val('Visible', $Asset, true)) {
            $Asset = $Asset->toString();
        } else {
            $Asset = '';
        }
    }
    if (!empty($Tag)) {
        $Result .= '<' . $Tag . ' id="' . $Id . '"' . $Class . '>' . $Asset . '</' . $Tag . '>';
    } else {
        $Result .= $Asset;
    }
    ob_start();
    $Controller->fireEvent('AfterRenderAsset');
    $Result .= ob_get_clean();
    return $Result;
}
开发者ID:vanilla,项目名称:vanilla,代码行数:45,代码来源:function.asset.php

示例3: base_beforeDiscussionMeta_handler

 /**
  * Hook for discussion prefixes in /discussions.
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function base_beforeDiscussionMeta_handler($Sender, $Args)
 {
     if (Gdn::controller()->ControllerName == 'addoncontroller') {
         return;
     }
     $this->addonDiscussionPrefix($Args['Discussion']);
 }
开发者ID:vanilla,项目名称:community,代码行数:13,代码来源:class.hooks.php

示例4: smarty_function_custom_menu

/**
 * A placeholder for future menu items.
 *
 * @param array $Params The parameters passed into the function.
 * @param Smarty $Smarty The smarty object rendering the template.
 * @return string
 */
function smarty_function_custom_menu($Params, &$Smarty)
{
    $Controller = Gdn::controller();
    if (is_object($Menu = val('Menu', $Controller))) {
        $Format = val('format', $Params, wrap('<a href="%url" class="%class">%text</a>', val('wrap', $Params, 'li')));
        $Result = '';
        foreach ($Menu->Items as $Group) {
            foreach ($Group as $Item) {
                // Make sure the item is a custom item.
                if (valr('Attributes.Standard', $Item)) {
                    continue;
                }
                // Make sure the user has permission for the item.
                if ($Permission = val('Permission', $Item)) {
                    if (!Gdn::session()->checkPermission($Permission)) {
                        continue;
                    }
                }
                if (($Url = val('Url', $Item)) && ($Text = val('Text', $Item))) {
                    $Attributes = val('Attributes', $Item);
                    $Result .= Gdn_Theme::link($Url, $Text, $Format, $Attributes) . "\r\n";
                }
            }
        }
        return $Result;
    }
    return '';
}
开发者ID:vanilla,项目名称:vanilla,代码行数:35,代码来源:function.custom_menu.php

示例5: addControl

 /**
  * Add an element to the controls collection. Used to render settings forms.
  *
  * @param string $key
  * @param array $item
  * @throws Exception
  */
 public function addControl($key, $item)
 {
     // Make sure this isn't called before it's ready.
     if (!isset(Gdn::controller()->Data['_Controls'])) {
         throw new Exception("You can't add a control before the controls collection has been initialized.", 500);
     }
     Gdn::controller()->Data['_Controls'][$key] = $item;
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:15,代码来源:class.jsconnect.plugin.php

示例6: toString

 public function toString()
 {
     if (!$this->data('Discussions')) {
         $this->GetData();
     }
     require_once Gdn::controller()->fetchViewLocation('helper_functions', 'Discussions', 'Vanilla');
     return parent::ToString();
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:8,代码来源:class.discussionsmodule.php

示例7: smarty_function_breadcrumbs

/**
 * Render a breadcrumb trail for the user based on the page they are on.
 *
 * @param array $Params
 * @param object $Smarty
 * @return string
 */
function smarty_function_breadcrumbs($Params, &$Smarty)
{
    $Breadcrumbs = Gdn::controller()->data('Breadcrumbs');
    if (!is_array($Breadcrumbs)) {
        $Breadcrumbs = array();
    }
    $Options = arrayTranslate($Params, array('homeurl' => 'HomeUrl', 'hidelast' => 'HideLast'));
    return Gdn_Theme::breadcrumbs($Breadcrumbs, val('homelink', $Params, true), $Options);
}
开发者ID:vanilla,项目名称:vanilla,代码行数:16,代码来源:function.breadcrumbs.php

示例8: loadData

 public function loadData()
 {
     $UserID = Gdn::controller()->data('Profile.UserID', Gdn::session()->UserID);
     $this->User = Gdn::userModel()->getID($UserID);
     $this->Roles = Gdn::userModel()->GetRoles($UserID)->resultArray();
     // Hide personal info roles
     if (!checkPermission('Garden.PersonalInfo.View')) {
         $this->Roles = array_filter($this->Roles, 'RoleModel::FilterPersonalInfo');
     }
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:10,代码来源:class.userinfomodule.php

示例9: meModule_flyoutMenu_handler

 /**
  * Adds "Mark All Viewed" and (conditionally) "Mark Category Viewed" to MeModule menu.
  *
  * @since 2.0
  * @access public
  */
 public function meModule_flyoutMenu_handler($Sender)
 {
     // Add "Mark All Viewed" to menu
     if (Gdn::session()->isValid()) {
         echo wrap(Anchor(sprite('SpMarkAllViewed') . ' ' . t('Mark All Viewed'), '/discussions/markallviewed'), 'li', array('class' => 'MarkAllViewed'));
         $CategoryID = (int) (empty(Gdn::controller()->CategoryID) ? 0 : Gdn::controller()->CategoryID);
         if ($CategoryID > 0) {
             echo wrap(Anchor(sprite('SpMarkCategoryViewed') . ' ' . t('Mark Category Viewed'), "/discussions/markcategoryviewed/{$CategoryID}"), 'li', array('class' => 'MarkCategoryViewed'));
         }
     }
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:17,代码来源:class.allviewed.plugin.php

示例10: attachButtonBar

 /**
  * Attach button bar in place
  *
  * This method is abstracted because it is called from multiple places, due
  * to the way that the comment.php view is invoked both by the DiscussionController
  * and the PostController.
  *
  * @param Gdn_Controller $Sender
  */
 protected function attachButtonBar($Sender, $Wrap = false)
 {
     $Formatter = c('Garden.InputFormatter', 'Html');
     if (!in_array($Formatter, $this->Formats)) {
         return;
     }
     $View = Gdn::controller()->fetchView('buttonbar', '', 'plugins/ButtonBar');
     if ($Wrap) {
         echo wrap($View, 'div', array('class' => 'P'));
     } else {
         echo $View;
     }
 }
开发者ID:adlerj,项目名称:vanilla,代码行数:22,代码来源:class.buttonbar.plugin.php

示例11: toString

 /**
  * Render the module.
  *
  * @return string
  */
 public function toString()
 {
     // Set CategoryID if we have one.
     if ($this->CategoryID === null) {
         $this->CategoryID = Gdn::controller()->data('Category.CategoryID', false);
     }
     // Allow plugins and themes to modify parameters.
     Gdn::controller()->EventArguments['NewDiscussionModule'] =& $this;
     Gdn::controller()->fireEvent('BeforeNewDiscussionButton');
     // Make sure the user has the most basic of permissions first.
     $PermissionCategory = CategoryModel::permissionCategory($this->CategoryID);
     if ($this->CategoryID) {
         $Category = CategoryModel::categories($this->CategoryID);
         $HasPermission = Gdn::session()->checkPermission('Vanilla.Discussions.Add', true, 'Category', val('CategoryID', $PermissionCategory));
     } else {
         $HasPermission = Gdn::session()->checkPermission('Vanilla.Discussions.Add', true, 'Category', 'any');
     }
     // Determine if this is a guest & we're using "New Discussion" button as call to action.
     $PrivilegedGuest = $this->ShowGuests && !Gdn::session()->isValid();
     // No module for you!
     if (!$HasPermission && !$PrivilegedGuest) {
         return '';
     }
     // Grab the allowed discussion types.
     $DiscussionTypes = CategoryModel::allowedDiscussionTypes($PermissionCategory);
     foreach ($DiscussionTypes as $Key => $Type) {
         if (isset($Type['AddPermission']) && !Gdn::session()->checkPermission($Type['AddPermission'])) {
             unset($DiscussionTypes[$Key]);
             continue;
         }
         $Url = val('AddUrl', $Type);
         if (!$Url) {
             continue;
         }
         if (isset($Category)) {
             $Url .= '/' . rawurlencode(val('UrlCode', $Category));
         }
         // Present a signin redirect for a $PrivilegedGuest.
         if (!$HasPermission) {
             $Url = $this->GuestUrl . '?Target=' . $Url;
         }
         $this->addButton(t(val('AddText', $Type)), $Url);
     }
     // Add QueryString to URL if one is defined.
     if ($this->QueryString && $HasPermission) {
         foreach ($this->Buttons as &$Row) {
             $Row['Url'] .= (strpos($Row['Url'], '?') !== false ? '&' : '?') . $this->QueryString;
         }
     }
     return parent::toString();
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:56,代码来源:class.newdiscussionmodule.php

示例12: settingsController_PostUrl_create

 public function settingsController_PostUrl_create($Sender, $args)
 {
     $Sender->permission('Garden.Settings.Manage');
     $Cf = new ConfigurationModule($Sender);
     if (c('Plugins.PostUrl.Display1') == "") {
         Gdn::config()->set('Plugins.PostUrl.Display1', "from: %post_url%", false, false);
     }
     $Description = '<p>可接受下列占位符号,该符号和wordpress兼容: <br />%site_url% - the URI of your site<br />%site_name% - the name of your site<br />%post_url% - the URI of the post where the text is displayed<br />%post_title% - the title of the post where the text is displayed</p>';
     $Cf->initialize(array('Plugins.PostUrl.ItemName1' => array('LabelCode' => '版权名称一', 'Control' => 'TextBox', 'Description' => "该字段用于发布话题时选择方便记忆"), 'Plugins.PostUrl.Display1' => array('LabelCode' => '版权信息一', 'Control' => 'TextBox', 'Description' => $Description, 'Items' => array(), 'Options' => array("MultiLine" => true, "rows" => "20", "cols" => 30)), 'Plugins.PostUrl.ItemName2' => array('LabelCode' => '<hr /><br />版权名称二', 'Control' => 'TextBox', 'Description' => "该字段用于发布话题时选择方便记忆"), 'Plugins.PostUrl.Display2' => array('LabelCode' => '版权信息二', 'Control' => 'TextBox', 'Options' => array("MultiLine" => true, "rows" => "20", "cols" => 30)), 'Plugins.PostUrl.ItemName3' => array('LabelCode' => '<hr /><br />版权名称三', 'Control' => 'TextBox', 'Description' => "该字段用于发布话题时选择方便记忆"), 'Plugins.PostUrl.Display3' => array('LabelCode' => '版权信息三', 'Control' => 'TextBox', 'Options' => array("MultiLine" => true, "rows" => "20", "cols" => 30)), 'Plugins.PostUrl.Default' => array('LabelCode' => '默认版权信息', 'Control' => 'DropDown', 'Description' => "没有选择或者历史文章将会使用该设定", 'Items' => array(0 => '', 1 => '版权一', 2 => '版权二', 3 => '版权三'), 'Options' => array('Value' => c('Plugins.PostUrl.Default')))));
     $c = Gdn::controller();
     $c->addJsFile('settings.js', 'plugins/CDNManager');
     $Sender->addSideMenu();
     $Sender->setData('Title', t('Add Post Url'));
     $Cf->renderAll();
 }
开发者ID:xjtdy888,项目名称:vanilla-posturl,代码行数:15,代码来源:class.posturl.plugin.php

示例13: connectButton

function connectButton($Row)
{
    $c = Gdn::controller();
    $Connected = val('Connected', $Row);
    $CssClass = $Connected ? 'Active' : 'InActive';
    $ConnectUrl = val('ConnectUrl', $Row);
    $DisconnectUrl = userUrl($c->User, '', 'Disconnect', array('provider' => $Row['ProviderKey']));
    $Result = '<span class="ActivateSlider ActivateSlider-' . $CssClass . '">';
    if ($Connected) {
        $Result .= anchor(t('Connected'), $DisconnectUrl, 'Button Primary Hijack ActivateSlider-Button');
    } else {
        $Result .= anchor(t('Connect'), $ConnectUrl, 'Button ActivateSlider-Button', array('target' => '_top'));
    }
    $Result .= '</span>';
    return $Result;
}
开发者ID:vanilla,项目名称:vanilla,代码行数:16,代码来源:connection_functions.php

示例14: settingsController_cdnmanager_create

    public function settingsController_cdnmanager_create($Sender, $args)
    {
        $Sender->permission('Garden.Settings.Manage');
        $Cf = new ConfigurationModule($Sender);
        if (c('Plugins.CDNManager.CDNSources') == "") {
            $defaultCDNValue = "jquery.js = \"http://libs.baidu.com/jquery/1.10.2/jquery.min.js\"\r\njquery-ui.js = \"http://apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js\"";
            Gdn::config()->set('Plugins.CDNManager.CDNSources', $defaultCDNValue, false, false);
        }
        $Cf->initialize(array('Plugins.CDNManager.CDNSources' => array('LabelCode' => 'CDN使用源列表', 'Control' => 'TextBox', 'Options' => array('MultiLine' => true, 'rows' => 20, 'cols' => 50), 'Description' => '<p>输入需要用CDN加速的文件和对应的地址,如jquery等国内国外都有开放的CDN源,也可申请<font color="red"><a href="https://portal.qiniu.com/signup?code=3lcqpvqtedfma" target="_blank">七牛</a></font>免费的空间来加速您的网站,<a href="https://portal.qiniu.com/signup?code=3lcqpvqtedfma" target="_blank">点击这里免费申请七牛加速空间</a></p> <p><small><strong>
</strong> </small></p>', 'Items' => array())));
        $c = Gdn::controller();
        $c->addJsFile('settings.js', 'plugins/CDNManager');
        $Sender->addSideMenu();
        $Sender->setData('Title', t('CDN源设置'));
        $Cf->renderAll();
    }
开发者ID:xjtdy888,项目名称:Vanilla-Plugin-CDNManager,代码行数:16,代码来源:class.cdnmanager.plugin.php

示例15: autoContext

 /**
  *
  *
  * @param null $Hint
  */
 protected function autoContext($Hint = null)
 {
     // If we're already configured, don't auto configure
     if (!is_null($this->ParentID) && is_null($Hint)) {
         return;
     }
     // If no hint was given, determine by environment
     if (is_null($Hint)) {
         if (Gdn::controller() instanceof Gdn_Controller) {
             $DiscussionID = Gdn::controller()->data('Discussion.DiscussionID', null);
             $CategoryID = Gdn::controller()->data('Category.CategoryID', null);
             if ($DiscussionID) {
                 $Hint = 'Discussion';
             } elseif ($CategoryID) {
                 $Hint = 'Category';
             } else {
                 $Hint = 'Global';
             }
         }
     }
     switch ($Hint) {
         case 'Discussion':
             $this->ParentType = 'Discussion';
             $DiscussionID = Gdn::controller()->data('Discussion.DiscussionID');
             $this->ParentID = $DiscussionID;
             break;
         case 'Category':
             if ($this->CategorySearch) {
                 $this->ParentType = 'Category';
                 $CategoryID = Gdn::controller()->data('Category.CategoryID');
                 $this->ParentID = $CategoryID;
             }
             break;
     }
     if (!$this->ParentID) {
         $this->ParentID = 0;
         $this->ParentType = 'Global';
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:44,代码来源:class.tagmodule.php


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