本文整理汇总了PHP中Plugin::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::save方法的具体用法?PHP Plugin::save怎么用?PHP Plugin::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin
的用法示例。
在下文中一共展示了Plugin::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Overview for plugins
* Copied from PluginsController 2015-10-02
*/
public function index()
{
$oPluginManager = App()->getPluginManager();
// Scan the plugins folder.
$aDiscoveredPlugins = $oPluginManager->scanPlugins();
$aInstalledPlugins = $oPluginManager->getInstalledPlugins();
$aInstalledNames = array_map(function ($installedPlugin) {
return $installedPlugin->name;
}, $aInstalledPlugins);
// Install newly discovered plugins.
foreach ($aDiscoveredPlugins as $discoveredPlugin) {
if (!in_array($discoveredPlugin['pluginClass'], $aInstalledNames)) {
$oPlugin = new Plugin();
$oPlugin->name = $discoveredPlugin['pluginClass'];
$oPlugin->active = 0;
$oPlugin->save();
}
}
$aoPlugins = Plugin::model()->findAll();
$data = array();
foreach ($aoPlugins as $oPlugin) {
/* @var $plugin Plugin */
if (array_key_exists($oPlugin->name, $aDiscoveredPlugins)) {
$aPluginSettings = App()->getPluginManager()->loadPlugin($oPlugin->name, $oPlugin->id)->getPluginSettings(false);
$data[] = array('id' => $oPlugin->id, 'name' => $aDiscoveredPlugins[$oPlugin->name]['pluginName'], 'description' => $aDiscoveredPlugins[$oPlugin->name]['description'], 'active' => $oPlugin->active, 'settings' => $aPluginSettings, 'new' => !in_array($oPlugin->name, $aInstalledNames));
} else {
// This plugin is missing, maybe the files were deleted but the record was not removed from the database
// Now delete this record. Depending on the plugin the settings will be preserved
App()->user->setFlash('pluginDelete' . $oPlugin->id, sprintf(gT("Plugin '%s' was missing and is removed from the database."), $oPlugin->name));
$oPlugin->delete();
}
}
$this->_renderWrappedTemplate('pluginmanager', 'index', array('data' => $data));
}
示例2: scanPlugins
function scanPlugins()
{
$plugins = array();
$dir = ROOT . "/plugins";
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (is_dir($dir . "/" . $file) && $file != "." && $file != "..") {
if (file_exists($dir . "/" . $file . "/info.php")) {
$plugin_info = (include_once $dir . "/" . $file . "/info.php");
array_push($plugins, $plugin_info);
}
}
}
closedir($dh);
}
usort($plugins, 'plugin_sort');
foreach ($plugins as $plg) {
if (!Plugins::instance()->findOne(array("conditions" => "name = '" . $plg['name'] . "'"))) {
$plugin = new Plugin();
//if ( isset($plg["id"]) && is_numeric($plg["id"]) ) {
//$plugin->setId($plg['id']);
//}
$plugin->setName($plg["name"]);
$plugin->setIsActivated(0);
$plugin->setIsInstalled(0);
$plugin->setVersion(array_var($plg, 'version'));
$plugin->save();
}
}
}
示例3: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aPlugin !== null) {
if ($this->aPlugin->isModified() || $this->aPlugin->isNew()) {
$affectedRows += $this->aPlugin->save($con);
}
$this->setPlugin($this->aPlugin);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例4: index
public function index()
{
$db_plugins = dm_column(Plugin::factory()->get(), 'slug');
$fs_plugins = PluginManager::list_all();
foreach ($fs_plugins as $plg) {
if (!in_array($plg, $db_plugins)) {
$pl = PluginManager::plugin($plg);
$pli = $pl->get_info();
$dbp = new Plugin();
$dbp->name = $pli['name'];
$dbp->url = $pli['url'];
$dbp->slug = $pli['slug'];
$dbp->version = $pli['version'];
$dbp->author = $pli['author'];
$dbp->author_url = $pli['author_url'];
$dbp->description = $pli['description'];
$dbp->active = false;
$dbp->save();
$pl->install();
}
}
$this->templatemanager->assign('db_plugins', $db_plugins);
$this->templatemanager->assign('fs_plugins', $fs_plugins);
$this->templatemanager->show_template('plugins_list');
}
示例5: install
function install($pattern)
{
_apply($pattern, function ($id) {
$tmp = new Plugin();
$tmp->setId($id);
// check if plugin files exist
if (!file_exists($tmp->getPath())) {
print "No plugin found with that name. Skipping.\n";
return false;
}
if (!file_exists($tmp->getPath() . 'package.json')) {
print "Path exists, but no package.json found. Skipping.\n";
return false;
}
// check if plugin is already installed
$plugin = PluginQuery::create()->findPk($id);
if ($plugin) {
_loadPluginClass($plugin)->install();
print "Re-installed plugin {$id}.\n";
} else {
$plugin = new Plugin();
$plugin->setId($id);
$plugin->save();
_loadPluginClass($plugin)->install();
print "Installed plugin {$id}.\n";
}
});
exit;
}
示例6: createPlugin
/**
* Cria um novo plugin
* @param int $menu_id id do menu ao qual o plugin se refere
* @param string $plugin_name nome do plugin
* @return boolean Verdadeiro caso sucesso ou falso caso ocorra alguma falha
*/
public function createPlugin($menu_id, $plugin_name)
{
$plugin = new Plugin();
$plugin->menu_id = $menu_id;
$plugin->plugin_name = $plugin_name;
$return = $plugin->save();
return $return;
}
示例7: Plugin
function save_data()
{
if (class_exists('Plugin')) {
$p = new Plugin();
$p->where('path', $this->get_key())->get();
$p->data = serialize((array) $this->get_data());
$p->save();
} else {
return false;
}
}
示例8: actionIndex
public function actionIndex()
{
// список всех плагинов
$plugins = Yii::app()->getPlugins();
// все плагины регистрируем в бд
// TODO если в базе нашлись плагины, которых уже нет, то помечаем их как удаленные
// список плагинов, зарегистрированных в системе
$pluginsDb = Plugin::model()->findAll();
$finded = array();
foreach ($plugins as $code => $config) {
if (is_int($code)) {
$code = $config;
$config = array();
}
if (!isset($config['class'])) {
$config['class'] = $code;
}
foreach ($pluginsDb as $plugin) {
if ($plugin->code == $code) {
if ($plugin->class_name != $config['class']) {
$plugin->class_name = $config['class'];
$plugin->save();
}
$finded[] = $code;
continue 2;
}
}
// плагина ещё нет в базе
$newPlugin = new Plugin();
$newPlugin->code = $code;
$newPlugin->status = Plugin::STATUS_NEW;
$newPlugin->class_name = $config['class'];
//-------------------
$newPlugin->name = $newPlugin->getName();
// нигде не используется, исключительно для легкого чтения таблицы
//-------------------
$finded[] = $code;
$newPlugin->save();
}
foreach ($pluginsDb as $plugin) {
if (!in_array($plugin->code, $finded)) {
// пропавшие плагины просто удаляем из базы
try {
$plugin->deactivate($plugin);
} catch (Exception $e) {
}
$plugin->delete();
Yii::app()->compilePluginsConfig();
}
}
$plugins = Plugin::model()->notDeleted()->findAll(array('order' => 'name'));
$this->render('/index', array('plugins' => $plugins));
}
示例9: store
/**
* Store a newly created resource in storage.
* POST /plugin
*
* @return Response
*/
public function store()
{
$rules = ['name' => 'required|min:3'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator->messages());
}
$plugin = new Plugin();
$plugin->name = Input::get('name');
$plugin->docurl = Input::get('docurl');
$plugin->save();
return Redirect::action('plugin.version.create', [$plugin->id]);
}
示例10: install
/**
* Enable the plugin,
* Check if there is a static folder,
* Copy the content to www/static/plugins/<plugin_name>/
*/
public function install()
{
$plugin = PluginQuery::create()->findPK($this->getName());
if (empty($plugin)) {
$plugin = new Plugin();
$plugin->setId($this->getName());
}
$plugin->setEnabled(true);
$plugin->setInstalledAt(time());
$plugin->save();
$this->copyStaticFiles();
$this->copyTemplates();
}
示例11: setUp
public function setUp()
{
parent::setUp();
$plugin = $this->db->getTable('Plugin')->find(1);
if ($plugin) {
$plugin->delete();
}
$plugin = new Plugin();
$plugin->setDirectoryName(self::PLUGIN_NAME);
$plugin->setActive(true);
$plugin->setDbVersion('1.0');
$plugin->save();
$this->plugin = $plugin;
}
示例12: plugin_activate
public function plugin_activate($slug)
{
$plugin = Plugin::where('slug', '=', $slug)->first();
$plugin_data = Plugins::get_plugin($slug);
if (!empty($plugin->slug)) {
$plugin->active = 1;
$plugin->save();
} else {
$new_plugin = new Plugin();
$new_plugin->name = $plugin_data['name'];
$new_plugin->description = $plugin_data['description'];
$new_plugin->version = $plugin_data['version'];
$new_plugin->slug = $slug;
$new_plugin->active = 1;
$new_plugin->save();
}
return Redirect::to('admin#plugins')->with(array('note' => 'Successfully Activated ' . $plugin_data['name'], 'note_type' => 'success'));
}
示例13: index
/**
* Overview for plugins
* Copied from PluginsController 2015-10-02
*/
public function index()
{
$oPluginManager = App()->getPluginManager();
// Scan the plugins folder.
$aDiscoveredPlugins = $oPluginManager->scanPlugins();
$aInstalledPlugins = $oPluginManager->getInstalledPlugins();
$aInstalledNames = array_map(function ($installedPlugin) {
return $installedPlugin->name;
}, $aInstalledPlugins);
// Install newly discovered plugins.
foreach ($aDiscoveredPlugins as $discoveredPlugin) {
if (!in_array($discoveredPlugin['pluginClass'], $aInstalledNames)) {
$oPlugin = new Plugin();
$oPlugin->name = $discoveredPlugin['pluginClass'];
$oPlugin->active = 0;
$oPlugin->save();
}
}
$aoPlugins = Plugin::model()->findAll(array('order' => 'name'));
$data = array();
foreach ($aoPlugins as $oPlugin) {
/* @var $plugin Plugin */
if (array_key_exists($oPlugin->name, $aDiscoveredPlugins)) {
$aPluginSettings = App()->getPluginManager()->loadPlugin($oPlugin->name, $oPlugin->id)->getPluginSettings(false);
$data[] = array('id' => $oPlugin->id, 'name' => $aDiscoveredPlugins[$oPlugin->name]['pluginName'], 'description' => $aDiscoveredPlugins[$oPlugin->name]['description'], 'active' => $oPlugin->active, 'settings' => $aPluginSettings, 'new' => !in_array($oPlugin->name, $aInstalledNames));
} else {
// This plugin is missing, maybe the files were deleted but the record was not removed from the database
// Now delete this record. Depending on the plugin the settings will be preserved
App()->user->setFlash('pluginDelete' . $oPlugin->id, sprintf(gT("Plugin '%s' was missing and is removed from the database."), $oPlugin->name));
$oPlugin->delete();
}
}
if (Yii::app()->request->getParam('pageSize')) {
Yii::app()->user->setState('pageSize', intval(Yii::app()->request->getParam('pageSize')));
}
$aData['fullpagebar']['returnbutton']['url'] = 'index';
$aData['fullpagebar']['returnbutton']['text'] = gT('Return to admin home');
$aData['data'] = $data;
$this->_renderWrappedTemplate('pluginmanager', 'index', $aData);
if (!Permission::model()->hasGlobalPermission('settings', 'read')) {
Yii::app()->setFlashMessage(gT("No permission"), 'error');
$this->getController()->redirect(array('/admin'));
}
}
示例14: registerPlugin
public function registerPlugin(Bc_Application_Plugin_Descriptor $descriptor)
{
if ($this->isPluginRegistered($descriptor->getId())) {
return;
}
if (is_dir($descriptor->getModelsPath())) {
try {
Doctrine::createTablesFromModels($descriptor->getModelsPath());
} catch (Exception $e) {
var_dump($e);
}
}
$plugin = new Plugin();
$plugin->name = $descriptor->getId();
$plugin->description = $descriptor->getDescription();
$plugin->title = $descriptor->getName();
$plugin->active = true;
$plugin->save();
}
示例15: install
function install($pattern)
{
_apply($pattern, function ($id) {
$tmp = new Plugin();
$tmp->setId($id);
// check if plugin files exist
if (!file_exists($tmp->getPath())) {
global $plugin_urls;
if ($plugin_urls) {
if (isset($plugin_urls[$id])) {
print "Found " . $id . " in plugins.json.\n";
install($plugin_urls[$id]);
// try installing from git repository
return true;
// cancel apply loop
}
}
print "No plugin found with that name. Skipping.\n";
return true;
// cancel apply loop
}
if (!file_exists($tmp->getPath() . 'package.json')) {
print "Path exists, but no package.json found. Skipping.\n";
return true;
// cancel apply loop
}
// check if plugin is already installed
$plugin = PluginQuery::create()->findPk($id);
if ($plugin) {
_loadPluginClass($plugin)->install();
print "Re-installed plugin {$id}.\n";
} else {
$plugin = new Plugin();
$plugin->setId($id);
$plugin->setInstalledAt(time());
$plugin->save();
_loadPluginClass($plugin)->install();
print "Installed plugin {$id}.\n";
}
global $argv;
if ($argv[count($argv) - 1] == '--private') {
$plugin->setIsPrivate(true);
$plugin->save();
print "Set plugin {$id} to private.\n";
}
});
}