本文整理汇总了PHP中Gdn::FactoryInstall方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::FactoryInstall方法的具体用法?PHP Gdn::FactoryInstall怎么用?PHP Gdn::FactoryInstall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::FactoryInstall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: unset
include_once $Gdn_Path;
}
// Include the application's hooks.
$Hooks_Path = PATH_APPLICATIONS . DS . $ApplicationFolder . DS . 'settings' . DS . 'class.hooks.php';
if (file_exists($Hooks_Path)) {
include_once $Hooks_Path;
}
}
unset($Gdn_EnabledApplications);
unset($Gdn_Path);
unset($Hooks_Path);
// If there is a hooks file in the theme folder, include it.
$ThemeName = C('Garden.Theme', 'default');
$ThemeHooks = PATH_THEMES . DS . $ThemeName . DS . 'class.' . strtolower($ThemeName) . 'themehooks.php';
if (file_exists($ThemeHooks)) {
include_once $ThemeHooks;
}
// Set up the plugin manager (doing this early so it has fewer classes to
// examine to determine if they are plugins).
Gdn::FactoryInstall(Gdn::AliasPluginManager, 'Gdn_PluginManager', PATH_LIBRARY . DS . 'core' . DS . 'class.pluginmanager.php', Gdn::FactorySingleton);
Gdn::PluginManager()->IncludePlugins();
Gdn::PluginManager()->RegisterPlugins();
Gdn::FactoryOverwrite($FactoryOverwriteBak);
unset($FactoryOverwriteBak);
Gdn::Authenticator()->StartAuthenticator();
/// Include a user-defined bootstrap.
if (file_exists(PATH_ROOT . DS . 'conf' . DS . 'bootstrap.after.php')) {
require_once PATH_ROOT . DS . 'conf' . DS . 'bootstrap.after.php';
}
// Include "Render" functions now - this way pluggables and custom confs can override them.
require_once PATH_LIBRARY_CORE . DS . 'functions.render.php';
示例3: or
<?php
if (!defined('APPLICATION')) {
exit;
}
/*
Copyright 2008, 2009 Vanilla Forums Inc.
This file is part of Garden.
Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>.
Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com
*/
$PluginInfo['NBBC'] = array('Description' => 'Adapts The New BBCode Parser to work with Vanilla.', 'Version' => '1.1.0', 'RequiredApplications' => array('Vanilla' => '2.0.2'), 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'Author' => "Todd Burry", 'AuthorEmail' => 'todd@vanillaforums.com', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd');
Gdn::FactoryInstall('BBCodeFormatter', 'NBBCPlugin', __FILE__, Gdn::FactorySingleton);
class NBBCPlugin extends Gdn_Plugin
{
public $Class = 'BBCode';
/// CONSTRUCTOR ///
public function __construct($Class = 'BBCode')
{
parent::__construct();
$this->Class = $Class;
}
/// PROPERTIES ///
/// METHODS ///
public function DoAttachment($bbcode, $action, $name, $default, $params, $content)
{
$Medias = $this->Media();
$MediaID = $content;
if (isset($Medias[$MediaID])) {
示例4:
<?php
if (!defined('APPLICATION')) {
exit;
}
// User.
Gdn::FactoryInstall(Gdn::AliasUserModel, 'UserModel');
// Permissions.
Gdn::FactoryInstall(Gdn::AliasPermissionModel, 'PermissionModel');
// Roles.
Gdn::FactoryInstall('RoleModel', 'RoleModel');
// Head.
Gdn::FactoryInstall('Head', 'HeadModule');
// Menu.
Gdn::FactoryInstall('Menu', 'MenuModule');
Gdn::dispatcher()->PassProperty('Menu', Gdn::Factory('Menu'));
示例5: array
if (!defined('APPLICATION')) {
exit;
}
/**********************************************************************************
* This program is free software; you may redistribute it and/or modify it under *
* the terms of the provided license as published by Simple Machines LLC. *
* *
* This program is distributed in the hope that it is and will be useful, but *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* See the "license.txt" file for details of the Simple Machines license. *
**********************************************************************************/
$PluginInfo['SMFCompatibility'] = array('Name' => 'SMF Compatibility', 'Description' => 'Adds some compatibility functionality for forums imported from SMF.', 'Version' => '1.1', 'RequiredApplications' => array('Vanilla' => '2.0.18'), 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'Author' => "Todd Burry", 'AuthorEmail' => 'todd@vanillaforums.com', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd', 'License' => 'Simple Machines license');
Gdn::FactoryInstall('BBCodeFormatter', 'SMFCompatibilityPlugin', __FILE__, Gdn::FactorySingleton);
class SMFCompatibilityPlugin extends Gdn_Plugin
{
/// CONSTRUCTOR ///
public function __construct()
{
require_once dirname(__FILE__) . '/functions.smf.php';
}
/// PROPERTIES ///
/// METHODS ///
public function Base_BeforeDispatch_Handler($Sender)
{
$Request = Gdn::Request();
$Folder = ltrim($Request->RequestFolder(), '/');
$Uri = ltrim($_SERVER['REQUEST_URI'], '/');
// Fix the url in the request for routing.
示例6: SetMetaTags
<?php
if (!defined('APPLICATION')) {
exit;
}
Gdn::FactoryInstall('SectionModel', 'SectionModel', PATH_APPLICATIONS . '/candy/models/class.sectionmodel.php', Gdn::FactorySingleton);
if (!function_exists('SetMetaTags')) {
function SetMetaTags($Page, $Controller = Null)
{
if (!$Controller) {
$Controller = Gdn::Controller();
}
if ($Page->MetaDescription) {
$Controller->Head->AddTag('meta', array('name' => 'description', 'content' => $Page->MetaDescription, '_sort' => 0));
}
if ($Page->MetaKeywords) {
$Controller->Head->AddTag('meta', array('name' => 'keywords', 'content' => $Page->MetaKeywords, '_sort' => 0));
}
if ($Page->MetaRobots) {
$Controller->Head->AddTag('meta', array('name' => 'robots', 'content' => $Page->MetaRobots, '_sort' => 0));
}
if ($Page->MetaTitle) {
$Controller->Head->Title($Page->MetaTitle);
}
$Controller->Head->AddTag('meta', array('http-equiv' => 'content-language', 'content' => Gdn::Locale()->Current()));
$Controller->Head->AddTag('meta', array('http-equiv' => 'content-type', 'content' => 'text/html; charset=utf-8'));
}
}
if (!function_exists('ValidateUrlPath')) {
function ValidateUrlPath($Value, $Field = '')
{
示例7:
<?php
// User.
Gdn::FactoryInstall(Gdn::AliasUserModel, 'Gdn_UserModel', PATH_APPLICATIONS . DS . 'garden' . DS . 'models' . DS . 'class.usermodel.php', Gdn::FactorySingleton);
// Permissions.
Gdn::FactoryInstall(Gdn::AliasPermissionModel, 'Gdn_PermissionModel', PATH_APPLICATIONS . DS . 'garden' . DS . 'models' . DS . 'class.permissionmodel.php', Gdn::FactorySingleton);
// Roles.
Gdn::FactoryInstall('RoleModel', 'Gdn_RoleModel', PATH_APPLICATIONS . DS . 'garden' . DS . 'models' . DS . 'class.rolemodel.php', Gdn::FactorySingleton);
// Head.
Gdn::FactoryInstall('Head', 'Gdn_HeadModule', PATH_APPLICATIONS . DS . 'garden' . DS . 'modules' . DS . 'class.headmodule.php', Gdn::FactorySingleton);
// Menu.
Gdn::FactoryInstall('Menu', 'Gdn_MenuModule', PATH_APPLICATIONS . DS . 'garden' . DS . 'modules' . DS . 'class.menumodule.php', Gdn::FactorySingleton);
Gdn::Dispatcher()->PassProperty('Menu', Gdn::Factory('Menu'));
// Search.
Gdn::FactoryInstall('SearchModel', 'Gdn_SearchModel', PATH_APPLICATIONS . DS . 'garden' . DS . 'models' . DS . 'class.searchmodel.php', Gdn::FactorySingleton);
示例8: or
<?php
if (!defined('APPLICATION')) {
exit;
}
/*
Copyright 2008, 2009 Vanilla Forums Inc.
This file is part of Garden.
Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>.
Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com
*/
$PluginInfo['HtmLawed'] = array('Description' => 'Adapts HtmLawed to work with Vanilla.', 'Version' => '1.0.1', 'RequiredApplications' => NULL, 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'Author' => "Todd Burry", 'AuthorEmail' => 'todd@vanillaforums.com', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd', 'Hidden' => TRUE);
Gdn::FactoryInstall('HtmlFormatter', 'HTMLawedPlugin', __FILE__, Gdn::FactorySingleton);
class HTMLawedPlugin extends Gdn_Plugin
{
/// CONSTRUCTOR ///
public function __construct()
{
require_once dirname(__FILE__) . '/htmLawed/htmLawed.php';
$this->SafeStyles = C('Garden.Html.SafeStyles');
}
/// PROPERTIES ///
public $SafeStyles = TRUE;
/// METHODS ///
public function Format($Html)
{
$Attributes = C('Garden.Html.BlockedAttributes', 'on*');
$Config = array('anti_link_spam' => array('`.`', ''), 'comment' => 1, 'cdata' => 3, 'css_expression' => 1, 'deny_attribute' => $Attributes, 'unique_ids' => 1, 'elements' => '*-applet-form-input-textarea-iframe-script-style-embed-object-select-option-button-fieldset-optgroup-legend', 'keep_bad' => 0, 'schemes' => 'classid:clsid; href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; style: nil; *:file, http, https', 'valid_xhtml' => 0, 'direct_list_nest' => 1, 'balance' => 1);
// Turn embedded videos into simple links (legacy workaround)
示例9: array
$FileUndefinedTranslation =& $UndefinedTranslation[$DefinitionsFile];
if (!is_array($FileUndefinedTranslation)) {
$FileUndefinedTranslation = array();
}
$Index = count($FileUndefinedTranslation);
$FileUndefinedTranslation[$Index]['Path'] = $Path;
$FileUndefinedTranslation[$Index]['Codes'] = $Codes;
++$Count;
if ($MaxScanFiles > 0 && $Count >= $MaxScanFiles) {
break;
}
}
if ($SkipTranslated) {
$T = Gdn::FactoryOverwrite(True);
$DefaultLocale = new Gdn_Locale(C('Garden.Locale'), $Applications, array());
Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', PATH_LIBRARY_CORE . '/class.locale.php', Gdn::FactorySingleton, $DefaultLocale);
Gdn::FactoryOverwrite($T);
}
// save it
foreach ($UndefinedTranslation as $File => $FileUndefinedTranslation) {
$Directory = dirname($File);
if (!is_dir($Directory)) {
mkdir($Directory, 0777, True);
}
$FileContent = '';
foreach ($FileUndefinedTranslation as $Index => $InfoArray) {
$Codes = $InfoArray['Codes'];
if (count($Codes) == 0) {
continue;
}
$RelativePath = $InfoArray['Path'];
示例10: or
}
/*
Copyright 2008, 2009 Vanilla Forums Inc.
This file is part of Garden.
Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>.
Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com
*/
// Define the plugin:
$PluginInfo['LocaleDeveloper'] = array('Name' => 'Locale Developer', 'Description' => 'Contains useful functions for locale developers. When you enable this plugin go to its settings page to change your options. This plugin is maintained at http://github.com/vanillaforums/Addons', 'Version' => '1.0', 'Author' => "Todd Burry", 'AuthorEmail' => 'todd@vanillaforums.com', 'AuthorUrl' => 'http://vanillaforums.org/profile/todd', 'RequiredApplications' => array('Vanilla' => '2.0.11'), 'SettingsUrl' => '/dashboard/settings/localedeveloper', 'SettingsPermission' => 'Garden.Site.Manage');
if (C('Plugins.LocaleDeveloper.CaptureDefinitions')) {
// Install the developer locale.
$_Locale = new DeveloperLocale(Gdn::Locale()->Current(), C('EnabledApplications'), C('EnabledPlugins'));
$tmp = Gdn::FactoryOverwrite(TRUE);
Gdn::FactoryInstall(Gdn::AliasLocale, 'DeveloperLocale', dirname(__FILE__) . DS . 'class.developerlocale.php', Gdn::FactorySingleton, $_Locale);
Gdn::FactoryOverwrite($tmp);
unset($tmp);
}
class LocaleDeveloperPlugin extends Gdn_Plugin
{
public $LocalePath;
/**
* @var Gdn_Form Form
*/
protected $Form;
public function __construct()
{
$this->LocalePath = PATH_UPLOADS . '/LocaleDeveloper';
$this->Form = new Gdn_Form();
parent::__construct();
示例11: Configure
/**
* Allows the configuration of basic setup information in Garden. This
* should not be functional after the application has been set up.
*/
public function Configure($RedirectUrl = '')
{
$Config = Gdn::Factory(Gdn::AliasConfig);
$ConfigFile = PATH_CONF . DS . 'config.php';
// Create a model to save configuration settings
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel('Configuration', $ConfigFile, $Validation);
$ConfigurationModel->SetField(array('Garden.Locale', 'Garden.Title', 'Garden.RewriteUrls', 'Garden.WebRoot', 'Garden.Cookie.Salt', 'Garden.Cookie.Domain', 'Database.Name', 'Database.Host', 'Database.User', 'Database.Password'));
// Set the models on the forms.
$this->Form->SetModel($ConfigurationModel);
// Load the locales for the locale dropdown
// $Locale = Gdn::Locale();
// $AvailableLocales = $Locale->GetAvailableLocaleSources();
// $this->LocaleData = array_combine($AvailableLocales, $AvailableLocales);
// If seeing the form for the first time...
if (!$this->Form->IsPostback()) {
// Force the webroot using our best guesstimates
$ConfigurationModel->Data['Database.Host'] = 'localhost';
$this->Form->SetData($ConfigurationModel->Data);
} else {
// Define some validation rules for the fields being saved
$ConfigurationModel->Validation->AddRule('Connection', 'function:ValidateConnection');
$ConfigurationModel->Validation->ApplyRule('Database.Name', 'Connection');
$ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required');
$ConfigurationFormValues = $this->Form->FormValues();
if ($ConfigurationModel->Validate($ConfigurationFormValues) !== TRUE) {
// Apply the validation results to the form(s)
$this->Form->SetValidationResults($ConfigurationModel->ValidationResults());
} else {
$Host = Gdn_Url::Host();
$Domain = Gdn_Url::Domain();
// Set up cookies now so that the user can be signed in.
$ConfigurationFormValues['Garden.Cookie.Salt'] = RandomString(10);
$ConfigurationFormValues['Garden.Cookie.Domain'] = strpos($Host, '.') === FALSE ? '' : $Host;
// Don't assign the domain if it is a non .com domain as that will break cookies.
$ConfigurationModel->Save($ConfigurationFormValues);
// If changing locale, redefine locale sources:
$NewLocale = 'en-CA';
// $this->Form->GetFormValue('Garden.Locale', FALSE);
if ($NewLocale !== FALSE && Gdn::Config('Garden.Locale') != $NewLocale) {
$ApplicationManager = new Gdn_ApplicationManager();
$PluginManager = Gdn::Factory('PluginManager');
$Locale = Gdn::Locale();
$Locale->Set($NewLocale, $ApplicationManager->EnabledApplicationFolders(), $PluginManager->EnabledPluginFolders(), TRUE);
}
// Set the instantiated config object's db params and make the database use them (otherwise it will use the default values from conf/config-defaults.php).
$Config->Set('Database.Host', $ConfigurationFormValues['Database.Host']);
$Config->Set('Database.Name', $ConfigurationFormValues['Database.Name']);
$Config->Set('Database.User', $ConfigurationFormValues['Database.User']);
$Config->Set('Database.Password', $ConfigurationFormValues['Database.Password']);
$Config->ClearSaveData();
Gdn::FactoryInstall(Gdn::AliasDatabase, 'Gdn_Database', PATH_LIBRARY . DS . 'database' . DS . 'class.database.php', Gdn::FactorySingleton, array(Gdn::Config('Database')));
// Install db structure & basic data.
$Database = Gdn::Database();
$Drop = FALSE;
// Gdn::Config('Garden.Version') === FALSE ? TRUE : FALSE;
$Explicit = FALSE;
try {
include PATH_APPLICATIONS . DS . 'garden' . DS . 'settings' . DS . 'structure.php';
} catch (Exception $ex) {
$this->Form->AddError(strip_tags($ex->getMessage()));
}
if ($this->Form->ErrorCount() > 0) {
return FALSE;
}
// Create the administrative user
$UserModel = Gdn::UserModel();
$UserModel->DefineSchema();
$UserModel->Validation->ApplyRule('Name', 'Username', 'Admin username can only contain letters, numbers, and underscores.');
$UserModel->Validation->ApplyRule('Password', 'Required');
$UserModel->Validation->ApplyRule('Password', 'Match');
if (!$UserModel->SaveAdminUser($ConfigurationFormValues)) {
$this->Form->SetValidationResults($UserModel->ValidationResults());
} else {
// The user has been created successfully, so sign in now
$Authenticator = Gdn::Authenticator();
$AuthUserID = $Authenticator->Authenticate(array('Name' => $this->Form->GetValue('Name'), 'Password' => $this->Form->GetValue('Password'), 'RememberMe' => TRUE));
}
if ($this->Form->ErrorCount() > 0) {
return FALSE;
}
// Assign some extra settings to the configuration file if everything succeeded.
$ApplicationInfo = array();
include CombinePaths(array(PATH_APPLICATIONS . DS . 'garden' . DS . 'settings' . DS . 'about.php'));
$Config->Load($ConfigFile, 'Save');
$Config->Set('Garden.Version', ArrayValue('Version', ArrayValue('Garden', $ApplicationInfo, array()), 'Undefined'));
$Config->Set('Garden.WebRoot', Gdn_Url::WebRoot());
$Config->Set('Garden.RewriteUrls', function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) ? TRUE : FALSE);
$Config->Set('Garden.Domain', $Domain);
$Config->Set('Garden.CanProcessImages', function_exists('gd_info'));
$Config->Set('Garden.Messages.Cache', 'arr:["Garden\\/Settings\\/Index"]');
// Make sure that the "welcome" message is cached for viewing
$Config->Set('EnabledPlugins.HTMLPurifier', 'HtmlPurifier');
// Make sure html purifier is enabled so html has a default way of being safely parsed
$Config->Save();
}
//.........这里部分代码省略.........
示例12: array
* - type:standard to list non extended fields (order how want) other params than name are ignored
* - requiredwith (field that a reliant on other fields)
* - params (passed to link/label vsprintf)
* - labeldefault (locale like vsprintf format string can be overridden by locale MyMeta.Field.Label
* v0.1.5b:Thu Mar 29 16:04:47 BST 2012
* - more amicable link/label default
* v0.1.6b:Sun Apr 8 22:29:46 BST 2012
* - formatting for label default
* v0.1.7b:Sun Apr 8 22:29:46 BST 2012
* - strftime rather than Gnd_Format::Date
* - Date.DefaultFormat
* v0.1.9b:Thu Jun 7 23:57:34 BST 2012
* - view permissions fix
*/
$PluginInfo['MyProfile'] = array('Name' => 'MyProfile', 'Description' => 'Adds an extended and extensible user profile. Uses a simple Yaml Meta Spec to model the desired profile.', 'Version' => '0.1.9b', 'Author' => "Paul Thomas", 'AuthorEmail' => 'dt01pqt_pt@yahoo.com ', 'AuthorUrl' => 'http://vanillaforums.org/profile/x00');
Gdn::FactoryInstall('sfYaml', 'sfYaml', dirname(__FILE__) . DS . 'sfYaml' . DS . 'lib' . DS . 'sfYaml.php', Gdn::FactorySingleton);
class MyProfile extends Gdn_Plugin
{
public function ProfileController_AddProfileTabs_handler($Sender)
{
$Sender->AddProfileTab('MyProfile', "/profile/myprofile/" . $Sender->User->UserID . "/" . Gdn_Format::Url($Sender->User->Name), 'MyProfile', sprintf(T('About %s'), $Sender->User->Name));
}
public function ProfileController_AfterAddSideMenu_Handler($Sender)
{
if (!Gdn::Session()->CheckPermission('Garden.Users.Edit') && $Sender->User->UserID !== Gdn::Session()->UserID) {
return;
}
$SideMenu = $Sender->EventArguments['SideMenu'];
$SessionUserID = Gdn::Session()->UserID;
if ($Sender->User->UserID == $SessionUserID) {
$SideMenu->AddLink('Options', T('My Profile Edit'), '/profile/myprofileedit/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name), FALSE, array('class' => 'Popup'));
示例13: array
return $Result;
}
return array();
}
public static function FormatMentions($Mixed)
{
if (C('Garden.Format.Mentions')) {
$Mixed = preg_replace('/@([\\d\\w_\\x{0800}-\\x{9fa5}]+)/iu', Anchor('@\\1', '/profile/\\1'), $Mixed);
}
if (C('Garden.Format.Hashtags')) {
$Mixed = preg_replace('/(^|[\\s,\\.])\\#([\\S]{1,30}?)#/i', '\\1' . Anchor('#\\2#', '/search?Search=%23\\2%23&Mode=like') . '\\3', $Mixed);
}
return $Mixed;
}
}
Gdn::FactoryInstall('MentionsFormatter', 'Chn_MentionsFormatter', NULL, Gdn::FactoryInstance);
function CountString($Number, $Url = '', $Options = array())
{
if (is_string($Options)) {
$Options = array('cssclass' => $Options);
}
$Options = array_change_key_case($Options);
$CssClass = GetValue('cssclass', $Options, '');
if ($Number === NULL) {
$Number = 0;
}
if ($Number) {
$Result = " <span class=\"Count\">{$Number}</span>";
} else {
$Result = '';
}
示例14: array
<?php
if (!defined('APPLICATION')) {
die;
}
# …
$PluginInfo['UsefulFunctions'] = array('Name' => 'Useful Functions', 'Description' => 'Useful functions for plugin and application developers (ex- PluginUtils).', 'RequiredApplications' => array('Dashboard' => '>=2.0.13'), 'Version' => '3.7.0', 'Date' => 'Winter 2010', 'Updated' => 'Autumn 2011', 'Author' => 'Vanilla Fan');
define('USEFULFUNCTIONS_LIBRARY', dirname(__FILE__) . '/library');
define('USEFULFUNCTIONS_VENDORS', dirname(__FILE__) . '/vendors');
if (class_exists('Gdn', False)) {
Gdn::FactoryInstall('Snoopy', 'Snoopy', USEFULFUNCTIONS_VENDORS . '/Snoopy.class.php', Gdn::FactorySingleton);
Gdn::FactoryInstall('Mailbox', 'ImapMailbox', USEFULFUNCTIONS_LIBRARY . '/class.imapmailbox.php', Gdn::FactorySingleton);
Gdn::FactoryInstall('CssSpriteMap', 'CssSpriteMap', USEFULFUNCTIONS_VENDORS . '/CssSprite.php', Gdn::FactorySingleton);
class UsefulFunctionsPlugin implements Gdn_IPlugin
{
public function Base_Render_Before($Sender)
{
if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
return;
}
$Sender->Head->AddScript('plugins/UsefulFunctions/js/noindex.js', 'text/javascript', array('path' => 'plugins/UsefulFunctions/js/noindex.js', 'sort' => 9999));
}
public function Setup()
{
}
}
}
require USEFULFUNCTIONS_LIBRARY . '/functions.render.php';
require USEFULFUNCTIONS_LIBRARY . '/functions.sql.php';
require USEFULFUNCTIONS_LIBRARY . '/functions.image.php';
require USEFULFUNCTIONS_LIBRARY . '/functions.time.php';
示例15: Translate
public function Translate($Code, $Default = False)
{
$this->EventArguments['Code'] = $Code;
$this->FireEvent('BeforeTranslate');
$Result = parent::Translate($Code, $Default);
return $Result;
}
}
$TcLocale = Gdn::Locale();
if (is_null($TcLocale)) {
$CurrentLocale = C('Garden.Locale', 'en-CA');
$EnabledApplicationFolders = Gdn::ApplicationManager()->EnabledApplicationFolders();
$EnabledPluginFolders = Gdn::PluginManager()->EnabledPluginFolders();
$TcLocale = new TranslationCollectorLocale($CurrentLocale, $EnabledApplicationFolders, $EnabledPluginFolders);
$Overwrite = Gdn::FactoryOverwrite(True);
Gdn::FactoryInstall(Gdn::AliasLocale, 'TranslationCollectorLocale', Null, Gdn::FactorySingleton, $TcLocale);
Gdn::FactoryOverwrite($Overwrite);
}
}
class TranslationCollectorPlugin implements Gdn_IPlugin
{
private $_Definition = array();
private $_EnabledApplication = 'Dashboard';
private $_SkipApplications = array();
public function __construct()
{
$this->_Definition = self::GetLocaleDefinitions();
$this->_SkipApplications = C('Plugins.TranslationCollector.SkipApplications', array());
}
public static function GetLocaleDefinitions()
{