當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。