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


PHP Gdn::factory方法代码示例

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


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

示例1: smarty_function_searchbox

/**
 * Writes the search box to the page.
 *
 * @param array The parameters passed into the function. This currently takes no parameters.
 * @param $smarty The smarty object rendering the template.
 * @return The url.
 */
function smarty_function_searchbox($params, &$smarty)
{
    $placeholder = array_key_exists('placeholder', $params) ? val('placeholder', $params, '', true) : t('SearchBoxPlaceHolder', 'Search');
    $form = Gdn::factory('Form');
    $result = $form->open(array('action' => url('/search'), 'method' => 'get')) . $form->textBox('Search', array('placeholder' => $placeholder, 'accesskey' => '/')) . $form->button('Go', array('Name' => '')) . $form->close();
    return $result;
}
开发者ID:korelstar,项目名称:vanilla,代码行数:14,代码来源:function.searchbox.php

示例2: base_render_before

 public function base_render_before($sender)
 {
     if ($sender->MasterView == 'admin') {
         return;
     }
     //tell the browser this is a mobile style
     $sender->Head->addTag('meta', array('name' => 'viewport', 'content' => "width=device-width,minimum-scale=1.0,maximum-scale=1.0"));
     /*
             $sender->InformMessage(
                 'This message will stay here until you dismiss it!',
                 array(
                     'CssClass' => 'Dismissable',
                     'DismissCallbackUrl' => '/plugin/dismissmessage/'
                 )
             );
     */
     $sender->Head->addTag('meta', array('name' => 'theme-color', 'content' => "#C08F00"));
     // YOU CAN REMOVE FONT-AWESOME IN ONLINE-VERSION
     $sender->Head->addTag('link', array('rel' => 'stylesheet', 'href' => "https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"));
     //position of the panel
     $sender->CssClass .= c('MinusBaseline.Panel.Left', false) ? ' PanelLeft' : ' PanelRight';
     //add the hamburger menu
     $sender->addAsset('Content', anchor('n', url('#'), 'Hamburger'), 'Hamburger');
     //add the searchbox to the panel
     //copied from library/vendors/SmartyPlugins/function.searchbox.php
     $form = Gdn::factory('Form');
     $form->InputPrefix = '';
     $search = $form->open(array('action' => Url('/search'), 'method' => 'get')) . $form->textBox('Search', array('placeholder' => t('SearchBoxPlaceHolder', 'Search'))) . $form->button('Go', array('Name' => '')) . $form->close();
     $sender->addAsset('Panel', wrap($search, 'div', array('class' => 'SiteSearch')), 'SearchBox');
     //nomobile link to switch to the full site
     $sender->addAsset('Foot', Gdn_Theme::link('/', t(' '), '<div class="LogoFoot"><a href="%url" class="%class">%text</a></div>'), 'LogoFoot');
     //Add logo to button of site
     $sender->addAsset('Foot', Gdn_Theme::link('profile/nomobile', t('Full Site'), '<div class="NoMobile"><a href="%url" class="%class">%text</a></div>'), 'NoMobile');
 }
开发者ID:Nordic-T,项目名称:vanilla-themes,代码行数:34,代码来源:class.minusbaselinethemehooks.php

示例3: delete

 /**
  * Delete a single draft.
  *
  * Redirects user back to Index unless DeliveryType is set.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DraftID Unique ID of draft to be deleted.
  * @param string $TransientKey Single-use hash to prove intent.
  */
 public function delete($DraftID = '', $TransientKey = '')
 {
     $Form = Gdn::factory('Form');
     $Session = Gdn::session();
     if (is_numeric($DraftID) && $DraftID > 0) {
         $Draft = $this->DraftModel->getID($DraftID);
     }
     if ($Draft) {
         if ($Session->validateTransientKey($TransientKey) && (val('InsertUserID', $Draft) == $Session->UserID || checkPermission('Garden.Community.Manage'))) {
             // Delete the draft
             if (!$this->DraftModel->deleteID($DraftID)) {
                 $Form->addError('Failed to delete draft');
             }
         } else {
             throw permissionException('Garden.Community.Manage');
         }
     } else {
         throw notFoundException('Draft');
     }
     // Redirect
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         $Target = GetIncomingValue('Target', '/drafts');
         redirect($Target);
     }
     // Return any errors
     if ($Form->errorCount() > 0) {
         $this->setJson('ErrorMessage', $Form->errors());
     }
     // Render default view
     $this->render();
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:42,代码来源:class.draftscontroller.php

示例4: __construct

 /**
  *
  * @param Gdn_Controller $Sender
  * @throws Exception
  */
 public function __construct($Sender = null)
 {
     if (property_exists($Sender, 'Conversation')) {
         $this->Conversation = $Sender->Conversation;
     }
     // Allowed to use this module?
     $this->AddUserAllowed = $Sender->ConversationModel->addUserAllowed($this->Conversation->ConversationID);
     $this->Form = Gdn::factory('Form', 'AddPeople');
     // If the form was posted back, check for people to add to the conversation
     if ($this->Form->authenticatedPostBack()) {
         // Defer exceptions until they try to use the form so we don't fill our logs
         if (!$this->AddUserAllowed || !checkPermission('Conversations.Conversations.Add')) {
             throw permissionException();
         }
         $NewRecipientUserIDs = array();
         $NewRecipients = explode(',', $this->Form->getFormValue('AddPeople', ''));
         $UserModel = Gdn::factory("UserModel");
         foreach ($NewRecipients as $Name) {
             if (trim($Name) != '') {
                 $User = $UserModel->getByUsername(trim($Name));
                 if (is_object($User)) {
                     $NewRecipientUserIDs[] = $User->UserID;
                 }
             }
         }
         $Sender->ConversationModel->addUserToConversation($this->Conversation->ConversationID, $NewRecipientUserIDs);
         $Sender->informMessage(t('Your changes were saved.'));
         $Sender->RedirectUrl = url('/messages/' . $this->Conversation->ConversationID);
     }
     $this->_ApplicationFolder = $Sender->Application;
     $this->_ThemeFolder = $Sender->Theme;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:37,代码来源:class.addpeoplemodule.php

示例5: setField

 /**
  * Allows the user to declare which values are being manipulated in the
  * $this->Name configuration array.
  *
  * @param mixed $FieldName The name of the field (or array of field names) to ensure.
  */
 public function setField($FieldName)
 {
     $Config = Gdn::factory(Gdn::AliasConfig);
     if (is_array($FieldName) === false) {
         $FieldName = array($FieldName);
     }
     foreach ($FieldName as $Index => $Value) {
         if (is_numeric($Index)) {
             $NameKey = $Value;
             $Default = '';
         } else {
             $NameKey = $Index;
             $Default = $Value;
         }
         /*
         if ($this->Name != 'Configuration')
            $Name = $NameKey;
         else
            $Name = $this->Name.'.'.$NameKey;
         */
         $this->Data[$NameKey] = $Config->get($NameKey, $Default);
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:29,代码来源:class.configurationmodel.php

示例6: chain

 /**
  * Add a formatter and create a chain in the Gdn factory.
  *
  * This is a conveinience method for chaining formatters without having to deal with the object creation logic.
  *
  * @param string $Type The type of formatter.
  * @param object $Formatter The formatter to install.
  * @param int $Priority The priority of the formatter in the chain. High priorities come first.
  * @return Gdn_FormatterChain The chain object that was created.
  */
 public static function chain($Type, $Formatter, $Priority = Gdn_FormatterChain::PRIORITY_DEFAULT)
 {
     // Grab the existing formatter from the factory.
     $Formatter = Gdn::factory($Type . 'Formatter');
     if ($Formatter === null) {
         $Chain = new Gdn_FormatterChain();
         Gdn::factoryInstall($Type . 'Formatter', 'Gdn_FormatterChain', __FILE__, Gdn::FactorySingleton, $Chain);
     } elseif (is_a($Formatter, 'Gdn_FormatterChain')) {
         $Chain = $Formatter;
     } else {
         Gdn::factoryUninstall($Type . 'Formatter');
         // Look for a priority on the existing object.
         if (property_exists($Formatter, 'Priority')) {
             $Priority = $Formatter->Priority;
         } else {
             $Priority = self::PRIORITY_DEFAULT;
         }
         $Chain = new Gdn_FormatterChain();
         $Chain->add($Formatter, $Priority);
         Gdn::factoryInstall($Type . 'Formatter', 'Gdn_FormatterChain', __FILE__, Gdn::FactorySingleton, $Chain);
     }
     $Chain->add($Formatter, $Priority);
     return $Chain;
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:34,代码来源:class.formatterchain.php

示例7: renderMaster

 /**
  *
  */
 public function renderMaster()
 {
     // Build the master view if necessary
     if (in_array($this->_DeliveryType, array(DELIVERY_TYPE_ALL))) {
         $this->MasterView = $this->masterView();
         // Only get css & ui components if this is NOT a syndication request
         if ($this->SyndicationMethod == SYNDICATION_NONE && is_object($this->Head)) {
             $CssAnchors = AssetModel::getAnchors();
             $this->EventArguments['CssFiles'] =& $this->_CssFiles;
             $this->fireEvent('BeforeAddCss');
             $ETag = AssetModel::eTag();
             $CombineAssets = c('Garden.CombineAssets');
             $ThemeType = isMobile() ? 'mobile' : 'desktop';
             // And now search for/add all css files.
             foreach ($this->_CssFiles as $CssInfo) {
                 $CssFile = $CssInfo['FileName'];
                 if (!array_key_exists('Options', $CssInfo) || !is_array($CssInfo['Options'])) {
                     $CssInfo['Options'] = array();
                 }
                 $Options =& $CssInfo['Options'];
                 // style.css and admin.css deserve some custom processing.
                 if (in_array($CssFile, $CssAnchors)) {
                     if (!$CombineAssets) {
                         // Grab all of the css files from the asset model.
                         $AssetModel = new AssetModel();
                         $CssFiles = $AssetModel->getCssFiles($ThemeType, ucfirst(substr($CssFile, 0, -4)), $ETag);
                         foreach ($CssFiles as $Info) {
                             $this->Head->addCss($Info[1], 'all', true, $CssInfo);
                         }
                     } else {
                         $Basename = substr($CssFile, 0, -4);
                         $this->Head->addCss(url("/asset/css/{$ThemeType}/{$Basename}-{$ETag}.css", '//'), 'all', false, $CssInfo['Options']);
                     }
                     continue;
                 }
                 $AppFolder = $CssInfo['AppFolder'];
                 $LookupFolder = !empty($AppFolder) ? $AppFolder : $this->ApplicationFolder;
                 $Search = AssetModel::CssPath($CssFile, $LookupFolder, $ThemeType);
                 if (!$Search) {
                     continue;
                 }
                 list($Path, $UrlPath) = $Search;
                 if (isUrl($Path)) {
                     $this->Head->AddCss($Path, 'all', val('AddVersion', $Options, true), $Options);
                     continue;
                 } else {
                     // Check to see if there is a CSS cacher.
                     $CssCacher = Gdn::factory('CssCacher');
                     if (!is_null($CssCacher)) {
                         $Path = $CssCacher->get($Path, $AppFolder);
                     }
                     if ($Path !== false) {
                         $Path = substr($Path, strlen(PATH_ROOT));
                         $Path = str_replace(DS, '/', $Path);
                         $this->Head->addCss($Path, 'all', true, $Options);
                     }
                 }
             }
             // Add a custom js file.
             if (arrayHasValue($this->_CssFiles, 'style.css')) {
                 $this->addJsFile('custom.js');
                 // only to non-admin pages.
             }
             $Cdns = array();
             if (!c('Garden.Cdns.Disable', false)) {
                 $Cdns = array('jquery.js' => "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js");
             }
             // And now search for/add all JS files.
             $this->EventArguments['Cdns'] =& $Cdns;
             $this->fireEvent('AfterJsCdns');
             $this->Head->addScript('', 'text/javascript', false, array('content' => $this->definitionList(false)));
             foreach ($this->_JsFiles as $Index => $JsInfo) {
                 $JsFile = $JsInfo['FileName'];
                 if (!is_array($JsInfo['Options'])) {
                     $JsInfo['Options'] = array();
                 }
                 $Options =& $JsInfo['Options'];
                 if (isset($Cdns[$JsFile])) {
                     $JsFile = $Cdns[$JsFile];
                 }
                 $AppFolder = $JsInfo['AppFolder'];
                 $LookupFolder = !empty($AppFolder) ? $AppFolder : $this->ApplicationFolder;
                 $Search = AssetModel::JsPath($JsFile, $LookupFolder, $ThemeType);
                 if (!$Search) {
                     continue;
                 }
                 list($Path, $UrlPath) = $Search;
                 if ($Path !== false) {
                     $AddVersion = true;
                     if (!isUrl($Path)) {
                         $Path = substr($Path, strlen(PATH_ROOT));
                         $Path = str_replace(DS, '/', $Path);
                         $AddVersion = val('AddVersion', $Options, true);
                     }
                     $this->Head->addScript($Path, 'text/javascript', $AddVersion, $Options);
                     continue;
                 }
//.........这里部分代码省略.........
开发者ID:battaglia01,项目名称:vanilla,代码行数:101,代码来源:class.controller.php

示例8: addUpdateCheck

 /**
  * Adds information to the definition list that causes the app to "phone
  * home" and see if there are upgrades available.
  *
  * Currently added to the dashboard only. Nothing renders with this method.
  * It is public so it can be added by plugins.
  */
 public function addUpdateCheck()
 {
     if (c('Garden.NoUpdateCheck')) {
         return;
     }
     // Check to see if the application needs to phone-home for updates. Doing
     // this here because this method is always called when admin pages are
     // loaded regardless of the application loading them.
     $UpdateCheckDate = Gdn::config('Garden.UpdateCheckDate', '');
     if ($UpdateCheckDate == '' || !IsTimestamp($UpdateCheckDate) || $UpdateCheckDate < strtotime("-1 day")) {
         $UpdateData = array();
         // Grab all of the plugins & versions
         $Plugins = Gdn::pluginManager()->availablePlugins();
         foreach ($Plugins as $Plugin => $Info) {
             $Name = val('Name', $Info, $Plugin);
             $Version = val('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Plugin');
             }
         }
         // Grab all of the applications & versions
         $ApplicationManager = Gdn::factory('ApplicationManager');
         $Applications = $ApplicationManager->availableApplications();
         foreach ($Applications as $Application => $Info) {
             $Name = val('Name', $Info, $Application);
             $Version = val('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Application');
             }
         }
         // Grab all of the themes & versions
         $ThemeManager = new Gdn_ThemeManager();
         $Themes = $ThemeManager->availableThemes();
         foreach ($Themes as $Theme => $Info) {
             $Name = val('Name', $Info, $Theme);
             $Version = val('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Theme');
             }
         }
         // Dump the entire set of information into the definition list (jQuery
         // will pick it up and ping the VanillaForums.org server with this info).
         $this->addDefinition('UpdateChecks', Gdn_Format::serialize($UpdateData));
     }
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:52,代码来源:class.settingscontroller.php

示例9: viewHandlers

 /**
  * Get list of defined view handlers
  *
  * @staticvar array $handlers
  * @param boolean $fresh
  * @return array
  */
 public static function viewHandlers($fresh = false)
 {
     static $handlers = null;
     if (is_null($handlers) || $fresh) {
         $factories = Gdn::factory()->search('viewhandler.*');
         $handlers = array_change_key_case($factories);
     }
     return $handlers;
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:16,代码来源:class.assetmodel.php

示例10: structure

 /**
  * Get the database structure class for this database.
  *
  * @return Gdn_DatabaseStructure The database structure class for this database.
  */
 public function structure()
 {
     if (is_null($this->_Structure)) {
         $Name = $this->Engine . 'Structure';
         $this->_Structure = Gdn::factory($Name, $this);
     }
     return $this->_Structure;
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:13,代码来源:class.database.php

示例11: wysiwyg

 /**
  *
  *
  * @param $Mixed
  * @return mixed|string
  */
 public static function wysiwyg($Mixed)
 {
     static $CustomFormatter;
     if (!isset($CustomFormatter)) {
         $CustomFormatter = c('Garden.Format.WysiwygFunction', false);
     }
     if (!is_string($Mixed)) {
         return self::to($Mixed, 'Wysiwyg');
     } elseif (is_callable($CustomFormatter)) {
         return $CustomFormatter($Mixed);
     } else {
         // The text contains html and must be purified.
         $Formatter = Gdn::factory('HtmlFormatter');
         if (is_null($Formatter)) {
             // If there is no HtmlFormatter then make sure that script injections won't work.
             return self::display($Mixed);
         }
         // HTML filter first
         $Mixed = $Formatter->format($Mixed);
         // Links
         $Mixed = Gdn_Format::links($Mixed);
         // Mentions & Hashes
         $Mixed = Gdn_Format::mentions($Mixed);
         $Mixed = Emoji::instance()->translateToHtml($Mixed);
         return $Mixed;
     }
 }
开发者ID:ringoma,项目名称:vanilla,代码行数:33,代码来源:class.format.php

示例12: base_render_before

 /**
  * Fire before every page render.
  *
  * @param Gdn_Controller $Sender
  */
 public function base_render_before($Sender)
 {
     $Session = Gdn::session();
     if ($Sender->MasterView == 'admin') {
         if (val('Form', $Sender)) {
             $Sender->Form->setStyles('bootstrap');
         }
         $Sender->CssClass = htmlspecialchars($Sender->CssClass);
         $Sections = Gdn_Theme::section(null, 'get');
         if (is_array($Sections)) {
             foreach ($Sections as $Section) {
                 $Sender->CssClass .= ' Section-' . $Section;
             }
         }
         // Get our plugin nav items.
         $navAdapter = new NestedCollectionAdapter(DashboardNavModule::getDashboardNav());
         $Sender->EventArguments['SideMenu'] = $navAdapter;
         $Sender->fireEvent('GetAppSettingsMenuItems');
         $Sender->removeJsFile('jquery.popup.js');
         $Sender->addJsFile('vendors/jquery.checkall.min.js', 'dashboard');
         $Sender->addJsFile('dashboard.js', 'dashboard');
         $Sender->addJsFile('jquery.expander.js');
         $Sender->addJsFile('settings.js', 'dashboard');
         $Sender->addJsFile('vendors/tether.min.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/util.js', 'dashboard');
         $Sender->addJsFile('vendors/drop.min.js', 'dashboard');
         $Sender->addJsFile('vendors/moment.min.js', 'dashboard');
         $Sender->addJsFile('vendors/daterangepicker.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/tooltip.js', 'dashboard');
         $Sender->addJsFile('vendors/clipboard.min.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/dropdown.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/collapse.js', 'dashboard');
         $Sender->addJsFile('vendors/bootstrap/modal.js', 'dashboard');
         $Sender->addJsFile('vendors/icheck.min.js', 'dashboard');
         $Sender->addJsFile('jquery.tablejenga.js', 'dashboard');
         $Sender->addJsFile('jquery.fluidfixed.js', 'dashboard');
         $Sender->addJsFile('vendors/prettify/prettify.js', 'dashboard');
         $Sender->addJsFile('vendors/ace/ace.js', 'dashboard');
         $Sender->addJsFile('vendors/ace/ext-searchbox.js', 'dashboard');
         $Sender->addCssFile('vendors/tomorrow.css', 'dashboard');
     }
     // Check the statistics.
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         Gdn::statistics()->check();
     }
     // Inform user of theme previewing
     if ($Session->isValid()) {
         $PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
         $PreviewMobileThemeFolder = htmlspecialchars($Session->getPreference('PreviewMobileThemeFolder', ''));
         $PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', $PreviewThemeFolder));
         $PreviewMobileThemeName = htmlspecialchars($Session->getPreference('PreviewMobileThemeName', $PreviewMobileThemeFolder));
         if ($PreviewThemeFolder != '') {
             $Sender->informMessage(sprintf(t('You are previewing the %s desktop theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
         if ($PreviewMobileThemeFolder != '') {
             $Sender->informMessage(sprintf(t('You are previewing the %s mobile theme.'), wrap($PreviewMobileThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/mobilethemes/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
     }
     if ($Session->isValid()) {
         $Confirmed = val('Confirmed', Gdn::session()->User, true);
         if (UserModel::requireConfirmEmail() && !$Confirmed) {
             $Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
             $Sender->informMessage($Message, '');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     if (in_array($Sender->MasterView, array('', 'default'))) {
         $Exceptions[] = '[NonAdmin]';
     }
     // SignIn popup is a special case
     $SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
     if ($SignInOnly) {
         $Exceptions = array();
     }
     if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID'));
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             if ($SignInOnly) {
                 // Insert special messages even in SignIn popup
                 echo $MessageModule;
             } elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
                 $Sender->addModule($MessageModule);
             }
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::factory('Statistics');
         $Gdn_Statistics->check($Sender);
//.........这里部分代码省略.........
开发者ID:vanilla,项目名称:vanilla,代码行数:101,代码来源:class.hooks.php

示例13: removeTemplateFile

 /**
  * Removes a Template file from the collection.
  *
  * @param string $fileName The Template file to search for.
  */
 public static function removeTemplateFile($fileName)
 {
     $tpls = Gdn::factory('Mustache')->templates;
     foreach ($tpls as $key => $fileInfo) {
         if ($fileInfo['Template'] == $fileName) {
             unset(Gdn::factory('Mustache')->templates[$key]);
             return;
         }
     }
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:15,代码来源:class.mustache.php

示例14: set

 /**
  * Allows the setting of data into one of two serialized data columns on the
  * user table: Preferences and Attributes.
  *
  * The method expects "Name" & "Value" to be in the $_POST collection. This method always
  * saves to the row of the user id performing this action (ie. $Session->UserID). The
  * type of property column being saved should be specified in the url:
  * i.e. /dashboard/utility/set/preference/name/value/transientKey
  * or /dashboard/utility/set/attribute/name/value/transientKey
  *
  * @since 2.0.0
  * @access public
  * @param string $UserPropertyColumn The type of value being saved: preference or attribute.
  * @param string $Name The name of the property being saved.
  * @param string $Value The value of the property being saved.
  * @param string $TransientKey A unique transient key to authenticate that the user intended to perform this action.
  */
 public function set($UserPropertyColumn = '', $Name = '', $Value = '', $TransientKey = '')
 {
     $this->_DeliveryType = DELIVERY_TYPE_BOOL;
     $Session = Gdn::session();
     $Success = false;
     if (in_array($UserPropertyColumn, array('preference', 'attribute')) && $Name != '' && $Value != '' && $Session->UserID > 0 && $Session->validateTransientKey($TransientKey)) {
         $UserModel = Gdn::factory("UserModel");
         $Method = $UserPropertyColumn == 'preference' ? 'SavePreference' : 'SaveAttribute';
         $Success = $UserModel->{$Method}($Session->UserID, $Name, $Value) ? 'TRUE' : 'FALSE';
     }
     if (!$Success) {
         $this->Form->addError('ErrorBool');
     }
     // Redirect back where the user came from if necessary
     if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
         redirect($_SERVER['HTTP_REFERER']);
     } else {
         $this->render();
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:37,代码来源:class.utilitycontroller.php

示例15: base_render_before

 /**
  * Fire before every page render.
  *
  * @param Gdn_Controller $Sender
  */
 public function base_render_before($Sender)
 {
     $Session = Gdn::session();
     // Check the statistics.
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         Gdn::statistics()->check();
     }
     // Enable theme previewing
     if ($Session->isValid()) {
         $PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', ''));
         $PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
         if ($PreviewThemeName != '') {
             $Sender->Theme = $PreviewThemeName;
             $Sender->informMessage(sprintf(t('You are previewing the %s theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/', 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
         }
     }
     if ($Session->isValid()) {
         $Confirmed = val('Confirmed', Gdn::session()->User, true);
         if (UserModel::requireConfirmEmail() && !$Confirmed) {
             $Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
             $Sender->informMessage($Message, '');
         }
     }
     // Add Message Modules (if necessary)
     $MessageCache = Gdn::config('Garden.Messages.Cache', array());
     $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
     $Exceptions = array('[Base]');
     if (in_array($Sender->MasterView, array('', 'default'))) {
         $Exceptions[] = '[NonAdmin]';
     }
     // SignIn popup is a special case
     $SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
     if ($SignInOnly) {
         $Exceptions = array();
     }
     if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) {
         $MessageModel = new MessageModel();
         $MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID'));
         foreach ($MessageData as $Message) {
             $MessageModule = new MessageModule($Sender, $Message);
             if ($SignInOnly) {
                 // Insert special messages even in SignIn popup
                 echo $MessageModule;
             } elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
                 $Sender->addModule($MessageModule);
             }
         }
         $Sender->MessagesLoaded = '1';
         // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
     }
     if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
         $Gdn_Statistics = Gdn::factory('Statistics');
         $Gdn_Statistics->check($Sender);
     }
     // Allow forum embedding
     if ($Embed = c('Garden.Embed.Allow')) {
         // Record the remote url where the forum is being embedded.
         $RemoteUrl = c('Garden.Embed.RemoteUrl');
         if (!$RemoteUrl) {
             $RemoteUrl = GetIncomingValue('remote');
             if ($RemoteUrl) {
                 saveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl);
             }
         }
         if ($RemoteUrl) {
             $Sender->addDefinition('RemoteUrl', $RemoteUrl);
         }
         if ($remoteUrlFormat = c('Garden.Embed.RemoteUrlFormat')) {
             $Sender->addDefinition('RemoteUrlFormat', $remoteUrlFormat);
         }
         // Force embedding?
         if (!IsSearchEngine() && strtolower($Sender->ControllerName) != 'entry') {
             if (IsMobile()) {
                 $forceEmbedForum = c('Garden.Embed.ForceMobile') ? '1' : '0';
             } else {
                 $forceEmbedForum = c('Garden.Embed.ForceForum') ? '1' : '0';
             }
             $Sender->addDefinition('ForceEmbedForum', $forceEmbedForum);
             $Sender->addDefinition('ForceEmbedDashboard', c('Garden.Embed.ForceDashboard') ? '1' : '0');
         }
         $Sender->addDefinition('Path', Gdn::request()->path());
         $get = Gdn::request()->get();
         unset($get['p']);
         // kludge for old index.php?p=/path
         $Sender->addDefinition('Query', http_build_query($get));
         // $Sender->addDefinition('MasterView', $Sender->MasterView);
         $Sender->addDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0');
         if ($Embed === 2) {
             $Sender->addJsFile('vanilla.embed.local.js');
         } else {
             $Sender->addJsFile('embed_local.js');
         }
     } else {
         $Sender->setHeader('X-Frame-Options', 'SAMEORIGIN');
     }
//.........这里部分代码省略.........
开发者ID:R-J,项目名称:vanilla,代码行数:101,代码来源:class.hooks.php


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