示例#1
0
 /**
  * Loads system plugins.
  * @param $type
  * @param $pluginXML
  * @param $incSystem
  * @param $excUserPlugins
  */
 public function getAllSystemPlugins($type = "services", $pluginXML = false, $incSystem = false, $excUserPlugins = false, $userID = null)
 {
     //Import the Joomla Folder Library
     jimport('joomla.filesystem.folders');
     //Import the Tuiyo Alias of JParameter
     TuiyoLoader::helper("parameter");
     //Scan the plugin folder
     $plugins = JFolder::folders(TUIYO_PLUGINS);
     $exclude = array("system");
     //If we want to exclude user plugins
     if ($excUserPlugins && isset($userID)) {
         $userPlugins = $this->getAllUserPlugins($userID, $type, false);
         $exclude = array_merge($exclude, (array) $userPlugins);
     }
     $plugins = array_diff($plugins, $exclude);
     if (!$pluginXML) {
         return $plugins;
     }
     //If we have to load the XML files
     $pluginsSpec = array();
     foreach ($plugins as $plugin) {
         $newPluginSpec = array();
         $newPlugin = new stdClass();
         $newPluginID = strtolower($plugin);
         $newPluginXMLf = TUIYO_PLUGINS . DS . $newPluginID . DS . "plugin.xml";
         $newPluginLivePath = TUIYO_LIVE_PATH . '/plugins/' . $newPluginID;
         if (!file_exists($newPluginXMLf)) {
             continue;
         }
         //this is not a plugin
         $newPluginXML = TuiyoAPI::get("xml", $newPluginXMLf);
         $root = $newPluginXML->file->document;
         $rootType = $root->attributes("type");
         if ((string) $rootType != "plugin") {
             continue;
         }
         //this is not a plugin
         //Load data
         $pluginParams = new TuiyoParameter('', $newPluginXMLf);
         $pluginParams->setXML($newPluginXML->file->document);
         $newPluginSpec['serviceID'] = $newPluginID;
         $newPluginSpec['serviceDescription'] = $root->description[0]->_data;
         $newPluginSpec['serviceLivePath'] = $newPluginLivePath;
         $newPluginSpec['serviceExecuteJS'] = $newPluginLivePath . '/' . $newPluginID . '.js';
         $newPluginSpec['settings_default_html'] = $pluginParams->renderHTML("params", "plugin");
         $newPluginSpec['settings_administrator_html'] = $pluginParams->renderHTML("params", "administrator");
         $newPluginSpec['settings_photos_html'] = $pluginParams->renderHTML("params", "photos");
         $newPluginSpec['settings_privacy_html'] = $pluginParams->renderHTML("params", "privacy");
         $pluginsSpec[$newPluginID] = $newPluginSpec;
     }
     return $pluginsSpec;
 }