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


PHP Plugins::getAllPlugins方法代码示例

本文整理汇总了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;
 }
开发者ID:469306621,项目名称:Languages,代码行数:16,代码来源:Plugins.class.php

示例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');
 }
开发者ID:469306621,项目名称:Languages,代码行数:87,代码来源:AdministrationController.class.php


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