本文整理汇总了PHP中Plugin::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::getAll方法的具体用法?PHP Plugin::getAll怎么用?PHP Plugin::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::getAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
adminGateKeeper();
Admintab::deleteAll();
Cache::clear();
Cache::clear();
$plugins = Plugin::getAll();
if ($plugins) {
foreach ($plugins as $plugin) {
$plugin->enable();
}
Cache::clear();
Cache::clear();
Cache::clear();
new SystemMessage("All possible plugins have been enabled.");
}
Systemvariable::set("setup_complete", false);
$translations = getEntities(array("type" => "Translationentity"));
if ($translations) {
foreach ($translations as $translation) {
$translation->delete();
}
}
forward("admin/plugins");
}
示例2: display
/**
* Display the widget
*
* @return string The generated HTML
*/
public function display()
{
// The number of updates
$updates = array();
$titles = array();
$api = new HawkApi();
$plugins = array_map(function ($plugin) {
return $plugin->getDefinition('version');
}, Plugin::getAll(false));
$themes = array_map(function ($theme) {
return $theme->getDefinition('version');
}, Theme::getAll());
try {
$updates = $api->getAllAvailableUpdates($plugins, $themes);
} catch (\Hawk\HawkApiException $e) {
$updates = array();
}
if (!empty($updates)) {
if (!empty($updates['hawk'])) {
\Hawk\Plugins\Main\MenuItem::getByName('admin.settings')->label .= View::make(Plugin::current()->getView('available-updates.tpl'), array('updates' => count($updates['hawk']), 'title' => Lang::get('admin.available-updates-title-core', array('number' => count($updates['hawk'])), count($updates['hawk']))));
}
if (!empty($updates['plugins'])) {
\Hawk\Plugins\Main\MenuItem::getByName('admin.plugins')->label .= View::make(Plugin::current()->getView('available-updates.tpl'), array('updates' => count($updates['plugins']), 'title' => Lang::get('admin.available-updates-title-plugins', array('number' => count($updates['plugins'])), count($updates['plugins']))));
}
if (!empty($updates['themes'])) {
\Hawk\Plugins\Main\MenuItem::getByName('admin.themes')->label .= View::make(Plugin::current()->getView('available-updates.tpl'), array('updates' => count($updates['themes']), 'title' => Lang::get('admin.available-updates-title-plugins', array('number' => count($updates['themes'])), count($updates['themes']))));
}
}
return '';
}
示例3: __construct
public function __construct()
{
adminGateKeeper();
Cache::clear();
Cache::clear();
$plugins = Plugin::getAll();
foreach ($plugins as $plugin) {
$plugin->disable();
}
Admintab::deleteAll();
Setting::updateSettingsTable();
clearCache();
Cache::clear();
Cache::clear();
Cache::clear();
Systemvariable::set("setup_complete", false);
$translations = getEntities(array("type" => "Translationentity"));
if ($translations) {
foreach ($translations as $translation) {
$translation->delete();
}
}
forward("admin/plugins");
}
示例4: scandir
// gestion des thèmes
$themesDir = 'templates/';
$dirs = scandir($themesDir);
foreach ($dirs as $dir) {
if (is_dir($themesDir . $dir) && !in_array($dir, array(".", ".."))) {
$themeList[] = $dir;
}
}
sort($themeList);
$tpl->assign('themeList', $themeList);
$tpl->assign('currentTheme', $configurationManager->get('theme'));
//autres variables de configuration
$tpl->assign('feeds', $feedManager->populate('name'));
$tpl->assign('folders', $folderManager->populate('name'));
$tpl->assign('synchronisationType', $configurationManager->get('synchronisationType'));
$tpl->assign('synchronisationEnableCache', $configurationManager->get('synchronisationEnableCache'));
$tpl->assign('synchronisationForceFeed', $configurationManager->get('synchronisationForceFeed'));
$tpl->assign('articleDisplayAnonymous', $configurationManager->get('articleDisplayAnonymous'));
$tpl->assign('articleDisplayLink', $configurationManager->get('articleDisplayLink'));
$tpl->assign('articleDisplayDate', $configurationManager->get('articleDisplayDate'));
$tpl->assign('articleDisplayAuthor', $configurationManager->get('articleDisplayAuthor'));
$tpl->assign('articleDisplayHomeSort', $configurationManager->get('articleDisplayHomeSort'));
$tpl->assign('articleDisplayFolderSort', $configurationManager->get('articleDisplayFolderSort'));
$tpl->assign('articleDisplayMode', $configurationManager->get('articleDisplayMode'));
$tpl->assign('optionFeedIsVerbose', $configurationManager->get('optionFeedIsVerbose'));
//Suppression de l'état des plugins inexistants
Plugin::pruneStates();
//Récuperation des plugins
$tpl->assign('plugins', Plugin::getAll());
$view = "settings";
require_once 'footer.php';
示例5: disabled
public static function disabled($pluginUid)
{
$plugins = Plugin::getAll();
foreach ($plugins as $plugin) {
if ($plugin->getUid() == $pluginUid) {
Plugin::changeState($plugin->getPath(), false);
$uninstall = dirname($plugin->getPath()) . '/uninstall.php';
if (file_exists($uninstall)) {
require_once $uninstall;
}
}
}
}
示例6: dirname
<?php
require_once dirname(__FILE__) . '/header.php';
if (isset($myUser) && $myUser != false && $myUser->can('configuration', 'r')) {
switch (@$_['section']) {
case 'plugin':
$plugins = Plugin::getAll();
$tpl->assign('plugins', $plugins);
break;
case 'user':
//Gestion de la modification des utilisateurs
if (isset($_['id_user'])) {
$usersManager = new User();
$id_modusers = $_['id_user'];
$selected = $usersManager->getById($id_modusers);
$description = $selected->GetFirstName() . " " . $selected->GetName();
$button = "Modifier";
$tpl->assign('id_modusers', $id_modusers);
$tpl->assign('login', $selected->getLogin());
$tpl->assign('firstname', $selected->getFirstName());
$tpl->assign('lastname', $selected->getName());
$tpl->assign('email', $selected->getMail());
$tpl->assign('userrank', $selected->getRank());
} else {
$description = "Ajout d'un utilisateur";
$button = "Ajouter";
$tpl->assign('userrank', '');
}
$tpl->assign('button', $button);
$tpl->assign('description', $description);
$users = User::getAllUsers();
示例7: create
/**
* Create a new plugin structure
*/
public function create()
{
$form = new Form(array('id' => 'new-plugin-form', 'labelWidth' => '20em', 'fieldsets' => array('form' => array(new HtmlInput(array('name' => 'intro', 'value' => '<div class="alert alert-info">' . Lang::get($this->_plugin . '.new-plugin-intro') . '</div>')), new TextInput(array('name' => 'name', 'required' => true, 'pattern' => '/^[\\w\\-]+$/', 'label' => Lang::get($this->_plugin . '.new-plugin-name-label'))), new TextInput(array('name' => 'title', 'required' => true, 'label' => Lang::get($this->_plugin . '.new-plugin-title-label'))), new TextareaInput(array('name' => 'description', 'label' => Lang::get($this->_plugin . '.new-plugin-description-label'))), new TextInput(array('name' => 'version', 'required' => true, 'pattern' => '/^(\\d+\\.){2,3}\\d+$/', 'label' => Lang::get($this->_plugin . '.new-plugin-version-label'), 'default' => '0.0.1')), new TextInput(array('name' => 'author', 'label' => Lang::get($this->_plugin . '.new-plugin-author-label')))), 'submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button'))), new ButtonInput(array('name' => 'cancel', 'value' => Lang::get('main.cancel-button'), 'onclick' => 'app.dialog("close")')))), 'onsuccess' => 'app.dialog("close"); app.load(app.getUri("manage-plugins"));'));
if (!$form->submitted()) {
// Display the form
return View::make(Theme::getSelected()->getView('dialogbox.tpl'), array('title' => Lang::get($this->_plugin . '.new-plugin-title'), 'icon' => 'plug', 'page' => $form));
} else {
// Create the plugin
if ($form->check()) {
if (in_array($form->getData('name'), Plugin::$forbiddenNames)) {
$message = Lang::get($this->_plugin . '.new-plugin-forbidden-name', array('forbidden' => implode(', ', Plugin::$forbiddenNames)));
$form->error('name', $message);
return $form->response(Form::STATUS_CHECK_ERROR, $message);
}
$namespace = Plugin::getNamespaceByName($form->getData('name'));
// Check the plugin does not exists
foreach (Plugin::getAll(false) as $plugin) {
if ($namespace === $plugin->getNamespace()) {
// A plugin with the same name already exists
$form->error('name', Lang::get($this->_plugin . '.new-plugin-already-exists-error'));
return $form->response(Form::STATUS_CHECK_ERROR, Lang::get($this->_plugin . '.new-plugin-already-exists-error'));
}
}
// The plugin can be created
$dir = PLUGINS_DIR . $form->getData('name') . '/';
try {
// Create the directories structure
if (!mkdir($dir)) {
throw new \Exception('Impossible to create the directory ' . $dir);
}
foreach (array('controllers', 'models', 'lib', 'lang', 'views', 'static', 'static/less', 'static/js', 'static/img', 'widgets') as $subdir) {
if (!mkdir($dir . $subdir, 0755, true)) {
throw new \Exception('Impossible to create the directory ' . $dir . $subdir);
}
}
// Create the file manifest.json
$conf = array('title' => $form->getData('title'), 'description' => $form->getData('description'), 'version' => $form->getData('version'), 'author' => $form->getData('author'), 'dependencies' => array());
if (file_put_contents($dir . Plugin::MANIFEST_BASENAME, json_encode($conf, JSON_PRETTY_PRINT)) === false) {
throw new \Exception('Impossible to create the file ' . Plugin::MANIFEST_BASENAME);
}
$plugin = Plugin::get($form->getData('name'));
$namespace = $plugin->getNamespace();
// Create the file start.php
$start = str_replace(array('{{ $namespace }}', '{{ $name }}'), array($namespace, $plugin->getName()), file_get_contents(Plugin::current()->getRootDir() . 'templates/start.tpl'));
if (file_put_contents($dir . 'start.php', $start) === false) {
throw new \Exceptio('Impossible to create the file start.php');
}
// Create the file Installer.php
$installer = str_replace(array('{{ $namespace }}', '{{ $name }}'), array($namespace, $plugin->getName()), file_get_contents(Plugin::current()->getRootDir() . 'templates/installer.tpl'));
if (file_put_contents($dir . 'Installer.php', $installer) === false) {
throw new \Exception('Impossible to create the file classes/Installer.php');
}
// Create the file BaseController.php
$controller = str_replace('{{ $namespace }}', $namespace, file_get_contents(Plugin::current()->getRootDir() . 'templates/base-controller.tpl'));
if (file_put_contents($dir . 'controllers/BaseController.php', $controller) === false) {
throw new \Exception('Impossible to create the file controllers/BaseController.php');
}
// Create the language file
$language = file_get_contents(Plugin::current()->getRootDir() . 'templates/lang.tpl');
if (file_put_contents($dir . 'lang/' . $plugin->getName() . '.en.lang', $language) === false) {
throw new \Exception('Impossible to create the file lang/' . $plugin->getName() . '.en.lang');
}
// Create the README file
if (touch($dir . 'README.md') === false) {
throw new \Exception('Impossible to create the README file');
}
return $form->response(Form::STATUS_SUCCESS, Lang::get($this->_plugin . '.new-plugin-success'));
} catch (\Exception $e) {
if (is_dir($dir)) {
App::fs()->remove($dir);
}
return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : Lang::get($this->_plugin . '.new-plugin-error'));
}
}
}
}
示例8: load
/**
* Load a file containing the wanted class
*
* @param string $classname The class to load
*/
public static function load($classname)
{
// Load the cache file for the first time the autload is called
if (empty(self::$cache) && is_file(Cache::getInstance()->getCacheFilePath(self::CACHE_FILE))) {
self::$cache = Cache::getInstance()->includeCache(self::CACHE_FILE);
}
// Check the class file is registered in cache
if (isset(self::$cache[$classname])) {
// The file is registered in cache, include it, and exit the function
include self::$cache[$classname];
return true;
}
$parts = explode('\\', $classname);
if (count($parts) > 1) {
$namespace = implode('\\', array_slice($parts, 0, -1));
} else {
$namespace = '';
}
$class = end($parts);
$filename = "{$class}.php";
// The file is not registered in cache, let's find it. Any class file must be as <classname>.php
$dirs = array();
$searchDirectories = array('Hawk' => array(LIB_DIR, CUSTOM_LIB_DIR), 'Hawk\\View\\Plugins' => array(LIB_DIR . 'view-plugins/'), '' => array(LIB_DIR . 'ext', CUSTOM_LIB_DIR));
if (isset($searchDirectories[$namespace])) {
$dirs = $searchDirectories[$namespace];
} elseif (strpos($namespace, 'Hawk\\Plugins\\') === 0) {
// Find the plugins associated to this namespace
$plugins = Plugin::getAll();
foreach ($plugins as $plugin) {
if ($plugin->getNamespace() === $namespace) {
$dirs = array($plugin->getRootDir());
break;
}
}
} else {
// If the class exists, it is in custom-libs directory
$dirs = array(CUSTOM_LIB_DIR, LIB_DIR . 'ext/');
}
// Cross any search folder to find out the class file
foreach ($dirs as $dir) {
$files = FileSystem::getInstance()->find($dir, $filename, FileSystem::FIND_FILE_ONLY);
if (!empty($files)) {
$file = $files[0];
// The class file has been found, include it
include $file;
// Register this file, associated to the class name, in cache
self::$cache[$classname] = $file;
self::$cacheUpdated = true;
return true;
}
}
if (strpos($namespace, 'Hawk\\Plugins\\') === 0) {
// If the class is an hawk class called from a plugin ,
// create an alias from the Hawk class to the plugin namespace
$alias = '\\Hawk\\' . $class;
if (class_exists($alias) || trait_exists($alias)) {
class_alias($alias, $classname);
return true;
}
}
}
示例9: getPlugin
/**
* Get the plugin contaning the controller
*
* @return Plugin The plugin contaning the controller
*/
public final function getPlugin()
{
if (isset($this->_pluginInstance)) {
return $this->_pluginInstance;
}
foreach (Plugin::getAll() as $plugin) {
if ($plugin->getNamespace() == $this->getNamespace()) {
$this->_pluginInstance =& $plugin;
return $plugin;
}
}
return null;
}