当前位置: 首页>>代码示例>>PHP>>正文


PHP plugin::resync_plugins方法代码示例

本文整理汇总了PHP中plugin::resync_plugins方法的典型用法代码示例。如果您正苦于以下问题:PHP plugin::resync_plugins方法的具体用法?PHP plugin::resync_plugins怎么用?PHP plugin::resync_plugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plugin的用法示例。


在下文中一共展示了plugin::resync_plugins方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $this->template->content = new View('admin/addons/plugins');
     $this->template->content->title = 'Addons';
     if (isset($_GET['status']) && !empty($_GET['status'])) {
         $status = $_GET['status'];
         if (strtolower($status) == 'a') {
             $filter = 'plugin_active = 1';
         } elseif (strtolower($status) == 'i') {
             $filter = 'plugin_active = 0';
         } else {
             $status = "0";
             $filter = '1=1';
         }
     } else {
         $status = "0";
         $filter = '1=1';
     }
     // Add the hidden plugins to the list of plugins to filter out
     if (count(Kohana::config('plugins.hide_from_list')) != 0) {
         $hide_from_list = array_map(array(Database::instance(), 'escape'), Kohana::config('plugins.hide_from_list'));
         $filter .= ' AND plugin_name NOT IN (' . implode(",", $hide_from_list) . ')';
     }
     $plugins = plugin::resync_plugins();
     // check, has the form been submitted?
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     if ($_POST) {
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('plugin_id.*', 'required', 'numeric');
         if ($post->validate()) {
             if ($post->action == 'a') {
                 // Activate Action
                 foreach (array_unique($post->plugin_id) as $item) {
                     $plugin = ORM::factory('plugin', $item);
                     // Make sure we run the installer if it hasnt been installed yet.
                     // Then mark it as installed
                     if ($plugin->loaded and $plugin->plugin_name) {
                         Kohana::config_set('core.modules', array_merge(Kohana::config('core.modules'), array(PLUGINPATH . $plugin->plugin_name)));
                         // Name of the class (First letter of class should be capitalized)
                         $class = ucfirst($plugin->plugin_name) . '_Install';
                         // Find the Library File
                         $path = plugin::find_install($plugin->plugin_name);
                         if ($path) {
                             include $path;
                             // Run the installer
                             $install = new $class();
                             $install->run_install();
                         }
                         // Mark as Active and Mark as Installed
                         $plugin->plugin_active = 1;
                         $plugin->plugin_installed = 1;
                         $plugin->save();
                     }
                 }
             } elseif ($post->action == 'i') {
                 // Deactivate Action
                 foreach ($post->plugin_id as $item) {
                     $plugin = ORM::factory('plugin', $item);
                     if ($plugin->loaded) {
                         $plugin->plugin_active = 0;
                         $plugin->save();
                     }
                 }
             } elseif ($post->action == 'd') {
                 // Delete Action
                 foreach ($post->plugin_id as $item) {
                     $plugin = ORM::factory('plugin', $item);
                     if ($plugin->loaded and $plugin->plugin_name) {
                         Kohana::config_set('core.modules', array_merge(Kohana::config('core.modules'), array(PLUGINPATH . $plugin->plugin_name)));
                         // Name of the class (First letter of class should be capitalized)
                         $class = ucfirst($plugin->plugin_name) . '_Install';
                         // Find the Library File
                         $path = plugin::find_install($plugin->plugin_name);
                         if ($path) {
                             include $path;
                             // Run the uninstaller
                             $install = new $class();
                             $install->uninstall();
                         }
                         // Mark as InActive and Mark as UnInstalled
                         $plugin->plugin_active = 0;
                         $plugin->plugin_installed = 0;
                         $plugin->save();
                     }
                 }
             }
         } else {
             $form_error = TRUE;
         }
     }
     $plugins = ORM::factory('plugin')->where($filter)->orderby('plugin_name', 'ASC')->find_all();
     $this->template->content->plugins = $plugins;
     $this->template->content->total_items = $plugins->count();
     $this->template->content->form_error = $form_error;
//.........这里部分代码省略.........
开发者ID:niiyatii,项目名称:crowdmap,代码行数:101,代码来源:plugins.php


注:本文中的plugin::resync_plugins方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。