本文整理汇总了PHP中Plugins::getAllPlugins方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugins::getAllPlugins方法的具体用法?PHP Plugins::getAllPlugins怎么用?PHP Plugins::getAllPlugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugins
的用法示例。
在下文中一共展示了Plugins::getAllPlugins方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActivatedPlugins
/**
* Return array of all activated plugins based on plugin files on filesystem
*
* @param none
* @return array
*/
static function getActivatedPlugins()
{
$results = Plugins::getAllPlugins();
foreach ($results as $name => $id) {
if ('-' == $id) {
unset($results[$name]);
}
}
return $results;
}
示例2: update_plugins
function update_plugins()
{
trace(__FILE__, 'update_plugins()');
$plugins = array_var($_POST, 'plugins');
//$plugins = array('invoices' => '1');
if (is_null($plugins)) {
$this->redirectTo('administration', 'plugins');
}
$reference = Plugins::getAllPlugins();
trace(__FILE__, 'update_plugins() - getAllPlugins done');
$errors = array();
foreach ($plugins as $name => $yes_no) {
//If it is not a plugin continue
$plugin_file_path = APPLICATION_PATH . '/plugins/' . $name . '/init.php';
trace(__FILE__, "update_plugins() - plugin_file_path=[{$plugin_file_path}]");
if (!file_exists($plugin_file_path)) {
continue;
}
trace(__FILE__, "update_plugins() - plugin_file_path=[{$plugin_file_path}] exists");
// get existing id
$id = $reference[$name];
$nicename = ucwords(str_replace('_', ' ', $name));
trace(__FILE__, "update_plugins() - id={$id} name={$name} nicename={$nicename}");
if ($yes_no && '-' == $id) {
trace(__FILE__, "update_plugins() - activating [{$name}]");
try {
// Check if plugin exists in database
$plugin = Plugins::findOne(array('conditions' => array('`name` = ?', $name)));
trace(__FILE__, "update_plugins() - findOne");
if ($plugin == NULL) {
$plugin = new Plugin();
}
trace(__FILE__, "update_plugins() - setName");
$plugin->setName($name);
trace(__FILE__, "update_plugins() - setInstalled");
$plugin->setInstalled(true);
DB::beginWork();
trace(__FILE__, "update_plugins() - including [{$plugin_file_path}]");
// get the file loaded here
include $plugin_file_path;
// get activation routine ready
trace(__FILE__, "update_plugins() - activate: {$name}");
$activate = $name . '_activate';
if (function_exists($activate)) {
trace(__FILE__, "update_plugins() - calling: {$activate}");
$activate();
}
// save to db now
$plugin->save();
DB::commit();
} catch (Exception $e) {
trace(__FILE__, 'update_plugins() - ' . $e->getMessage());
DB::rollback();
$errors[] = $nicename . ' (' . $e->getMessage() . ')';
}
} elseif (!$yes_no && '-' != $id) {
try {
trace(__FILE__, "update_plugins() - deactivating [{$name}]");
$plugin = Plugins::findById($id);
DB::beginWork();
$deactivate = $name . '_deactivate';
if (function_exists($deactivate)) {
trace(__FILE__, "update_plugins() - calling {$deactivate}");
//Check if user choose to purge data
if ($plugins[$name . "_data"] == "0") {
trace(__FILE__, "update_plugins() - calling {$deactivate}(true)");
$deactivate(true);
} else {
$deactivate();
}
}
$plugin->setInstalled(false);
$plugin->save();
DB::commit();
} catch (Exception $e) {
DB::rollback();
$errors[] = $nicename . ' (' . $e->getMessage() . ')';
}
}
}
if (count($errors)) {
flash_error(lang('plugin activation failed', implode(", ", $errors)));
} else {
flash_success(lang('plugins updated'));
}
$this->redirectTo('administration', 'plugins');
}