本文整理汇总了PHP中Gdn::PluginManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::PluginManager方法的具体用法?PHP Gdn::PluginManager怎么用?PHP Gdn::PluginManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::PluginManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Gdn_Dispatcher_BeforeDispatch_Handler
/**
* Override the default dashboard page with the new stats one.
*/
public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender)
{
$Enabled = C('Garden.Analytics.Enabled', TRUE);
if ($Enabled && !Gdn::PluginManager()->HasNewMethod('SettingsController', 'Index')) {
Gdn::PluginManager()->RegisterNewMethod('VanillaStatsPlugin', 'StatsDashboard', 'SettingsController', 'Index');
}
}
示例2: GetPluginFolder
public function GetPluginFolder($Absolute = TRUE)
{
$Folder = GetValue('Folder', Gdn::PluginManager()->GetPluginInfo(get_class($this), Gdn_PluginManager::ACCESS_CLASSNAME));
$PathParts = array($Folder);
array_unshift($PathParts, $Absolute ? PATH_PLUGINS : 'plugins');
return implode(DS, $PathParts);
}
示例3: Gdn_Dispatcher_AfterAnalyzeRequest_Handler
/**
* Remove plugins that are not mobile friendly!
*/
public function Gdn_Dispatcher_AfterAnalyzeRequest_Handler($Sender)
{
// Remove plugins so they don't mess up layout or functionality.
if (in_array($Sender->Application(), array('vanilla', 'dashboard', 'conversations'))) {
Gdn::PluginManager()->RemoveMobileUnfriendlyPlugins();
}
}
示例4: IsRemovable
/**
* Is the application/plugin/theme removable?
*
* @param string $Type self::TYPE_APPLICATION or self::TYPE_PLUGIN or self::TYPE_THEME
* @param string $Name
* @return boolean
*/
public static function IsRemovable($Type, $Name)
{
switch ($Type) {
case self::TYPE_APPLICATION:
$ApplicationManager = Gdn::Factory('ApplicationManager');
if ($IsRemovable = !array_key_exists($Name, $ApplicationManager->EnabledApplications())) {
$ApplicationInfo = ArrayValue($Name, $ApplicationManager->AvailableApplications(), array());
$ApplicationFolder = ArrayValue('Folder', $ApplicationInfo, '');
$IsRemovable = IsWritable(PATH_APPLICATIONS . DS . $ApplicationFolder);
}
break;
case self::TYPE_PLUGIN:
if ($IsRemovable = !array_key_exists($Name, Gdn::PluginManager()->EnabledPlugins)) {
$PluginInfo = ArrayValue($Name, Gdn::PluginManager()->AvailablePlugins(), FALSE);
$PluginFolder = ArrayValue('Folder', $PluginInfo, FALSE);
$IsRemovable = IsWritable(PATH_PLUGINS . DS . $PluginFolder);
}
break;
case self::TYPE_THEME:
// TODO
$IsRemovable = FALSE;
break;
}
return $IsRemovable;
}
示例5: Gdn_Dispatcher_AfterAnalyzeRequest_Handler
/**
* Set user's preferred locale.
*
* Moved event from AppStart to AfterAnalyzeRequest to allow Embed to set P3P header first.
*/
public function Gdn_Dispatcher_AfterAnalyzeRequest_Handler($Sender)
{
// Set user preference
if ($TempLocale = $this->GetAlternateLocale()) {
Gdn::Locale()->Set($TempLocale, Gdn::ApplicationManager()->EnabledApplicationFolders(), Gdn::PluginManager()->EnabledPluginFolders());
}
}
示例6: Gdn_Dispatcher_AfterAnalyzeRequest_Handler
/** Remove plugins that are not mobile friendly! */
public function Gdn_Dispatcher_AfterAnalyzeRequest_Handler($Sender)
{
// Remove plugins so they don't mess up layout or functionality.
if (in_array($Sender->Application(), array('vanilla', 'conversations')) || $Sender->Application() == 'dashboard' && in_array($Sender->Controller(), array('Activity', 'Profile', 'Search'))) {
Gdn::PluginManager()->RemoveMobileUnfriendlyPlugins();
}
SaveToConfig('Garden.Format.EmbedSize', '240x135', FALSE);
}
示例7: Refresh
/**
* Reload the locale system
*/
public function Refresh()
{
$LocalName = $this->Current();
$ApplicationWhiteList = Gdn::ApplicationManager()->EnabledApplicationFolders();
$PluginWhiteList = Gdn::PluginManager()->EnabledPluginFolders();
$ForceRemapping = TRUE;
$this->Set($LocalName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping);
}
示例8: RenderNsfw
protected function RenderNsfw(&$Sender)
{
if (!$this->RenderNsfw || Gdn::PluginManager()->CheckPlugin('NBBC')) {
return;
}
$FormatBody =& $Sender->EventArguments['Object']->FormatBody;
$FormatBody = preg_replace('`<div>\\s*(\\[/?nsfw\\])\\s*</div>`', '$1', $FormatBody);
$FormatBody = preg_replace_callback("/(\\[nsfw(?:=(?:")?([\\d\\w_',.? ]+)(?:")?)?\\])/siu", array($this, 'NsfwCallback'), $FormatBody);
$FormatBody = str_ireplace('[/nsfw]', '</div></div>', $FormatBody);
}
示例9: __construct
public function __construct()
{
parent::__construct();
if (Gdn::PluginManager()->CheckPlugin('Reactions') && C('Plugins.QnA.Reactions', TRUE)) {
$this->Reactions = TRUE;
}
if (Gdn::ApplicationManager()->CheckApplication('Reputation') && C('Plugins.QnA.Badges', TRUE)) {
$this->Badges = TRUE;
}
}
示例10: RenderSpoilers
protected function RenderSpoilers(&$Sender)
{
if (!$this->RenderSpoilers || Gdn::PluginManager()->CheckPlugin('NBBC')) {
return;
}
$FormatBody =& $Sender->EventArguments['Object']->FormatBody;
// Fix a wysiwyg but where spoilers
$FormatBody = preg_replace('`<div>\\s*(\\[/?spoiler\\])\\s*</div>`', '$1', $FormatBody);
$FormatBody = preg_replace_callback("/(\\[spoiler(?:=(?:")?([\\d\\w_',.? ]+)(?:")?)?\\])/siu", array($this, 'SpoilerCallback'), $FormatBody);
$FormatBody = str_ireplace('[/spoiler]', '</div></div>', $FormatBody);
}
示例11: Gdn_Autoload
function Gdn_Autoload($ClassName)
{
if (!class_exists('Gdn_FileSystem', FALSE)) {
return false;
}
if (!class_exists('Gdn_LibraryMap', FALSE)) {
return false;
}
if (!class_exists('Gdn', FALSE)) {
return false;
}
if (substr($ClassName, 0, 4) === 'Gdn_') {
$LibraryFileName = 'class.' . strtolower(substr($ClassName, 4)) . '.php';
} else {
$LibraryFileName = 'class.' . strtolower($ClassName) . '.php';
}
if (!is_null($ApplicationManager = Gdn::Factory('ApplicationManager'))) {
$ApplicationWhiteList = Gdn::Factory('ApplicationManager')->EnabledApplicationFolders();
} else {
$ApplicationWhiteList = NULL;
}
$LibraryPath = FALSE;
// If this is a model, look in the models folder(s)
if (strtolower(substr($ClassName, -5)) == 'model') {
$LibraryPath = Gdn_FileSystem::FindByMapping('library', PATH_APPLICATIONS, $ApplicationWhiteList, 'models' . DS . $LibraryFileName);
}
if (Gdn::PluginManager() instanceof Gdn_PluginManager) {
// Look for plugin files.
if ($LibraryPath === FALSE) {
$PluginFolders = Gdn::PluginManager()->EnabledPluginFolders();
$LibraryPath = Gdn_FileSystem::FindByMapping('library', PATH_PLUGINS, $PluginFolders, $LibraryFileName);
}
// Look harder for plugin files.
if ($LibraryPath === FALSE) {
$LibraryPath = Gdn_FileSystem::FindByMapping('plugin', FALSE, FALSE, $ClassName);
}
}
// Look for the class in the applications' library folders.
if ($LibraryPath === FALSE) {
$LibraryPath = Gdn_FileSystem::FindByMapping('library', PATH_APPLICATIONS, $ApplicationWhiteList, "library/{$LibraryFileName}");
}
// Look for the class in the core.
if ($LibraryPath === FALSE) {
$LibraryPath = Gdn_FileSystem::FindByMapping('library', PATH_LIBRARY, array('core', 'database', 'vendors' . DS . 'phpmailer'), $LibraryFileName);
}
// If it still hasn't been found, check for modules
if ($LibraryPath === FALSE) {
$LibraryPath = Gdn_FileSystem::FindByMapping('library', PATH_APPLICATIONS, $ApplicationWhiteList, 'modules' . DS . $LibraryFileName);
}
if ($LibraryPath !== FALSE) {
include_once $LibraryPath;
}
}
示例12: EnabledLocalePacks
public function EnabledLocalePacks($GetInfo = FALSE)
{
$Result = (array) C('EnabledLocales', array());
if ($GetInfo) {
foreach ($Result as $Key => $Locale) {
$InfoPath = PATH_ROOT . "/locales/{$Key}/definitions.php";
if (file_exists($InfoPath)) {
$LocaleInfo = Gdn::PluginManager()->ScanPluginFile($InfoPath, 'LocaleInfo');
$Result[$Key] = current($LocaleInfo);
} else {
unset($Result[$Key]);
}
}
}
return $Result;
}
示例13: CategoryWatch
/**
*
*
* @since 2.0.18
* @access public
* @return array Category IDs.
*/
public static function CategoryWatch()
{
$Categories = self::Categories();
$AllCount = count($Categories);
$Watch = array();
foreach ($Categories as $CategoryID => $Category) {
if ($Category['PermsDiscussionsView'] && $Category['Following'] && !GetValue('HideAllDiscussions', $Category)) {
$Watch[] = $CategoryID;
}
}
Gdn::PluginManager()->EventArguments['CategoryIDs'] =& $Watch;
Gdn::PluginManager()->FireEvent('CategoryWatch');
if ($AllCount == count($Watch)) {
return TRUE;
}
return $Watch;
}
示例14: GetImageSize
/**
* If passed path leads to an image, return size
*
* @param string $Path Path to file.
* @return array [0] => Height, [1] => Width.
*/
public static function GetImageSize($Path)
{
// Static FireEvent for intercepting non-local files.
$Sender = new stdClass();
$Sender->Returns = array();
$Sender->EventArguments = array();
$Sender->EventArguments['Path'] =& $Path;
$Sender->EventArguments['Parsed'] = Gdn_Upload::Parse($Path);
Gdn::PluginManager()->CallEventHandlers($Sender, 'Gdn_Upload', 'CopyLocal');
if (!in_array(strtolower(pathinfo($Path, PATHINFO_EXTENSION)), array('gif', 'jpg', 'jpeg', 'png'))) {
return array(0, 0);
}
$ImageSize = @getimagesize($Path);
if (is_array($ImageSize)) {
if (!in_array($ImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
return array(0, 0);
}
return array($ImageSize[0], $ImageSize[1]);
}
return array(0, 0);
}
示例15: Urls
/**
* Returns the url prefix for a given type.
* If there is a plugin that wants to store uploads at a different location or in a different way then they register themselves by subscribing to the Gdn_Upload_GetUrls_Handler event.
* After that they will be available here.
*
* @param string $Type The type of upload to get the prefix for.
* @return string The url prefix.
*/
public static function Urls($Type = NULL)
{
static $Urls = NULL;
if ($Urls === NULL) {
$Urls = array('' => Asset('/uploads', TRUE));
$Sender = new stdClass();
$Sender->Returns = array();
$Sender->EventArguments = array();
$Sender->EventArguments['Urls'] =& $Urls;
Gdn::PluginManager()->CallEventHandlers($Sender, 'Gdn_Upload', 'GetUrls');
}
if ($Type === NULL) {
return $Urls;
}
if (isset($Urls[$Type])) {
return $Urls[$Type];
}
return FALSE;
}