本文整理汇总了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;
}
示例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;
}
示例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']);
}
示例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 '';
}
示例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;
}
示例6: toString
public function toString()
{
if (!$this->data('Discussions')) {
$this->GetData();
}
require_once Gdn::controller()->fetchViewLocation('helper_functions', 'Discussions', 'Vanilla');
return parent::ToString();
}
示例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);
}
示例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');
}
}
示例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'));
}
}
}
示例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;
}
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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';
}
}