private function getPluginActiveTypesAndFolders() { if ($this->memCache) { $memCacheAllPluginDetails = $this->memCache->read('allPluginDetails'); $memCachePlugins = $this->memCache->read('plugins'); if ($memCacheAllPluginDetails && $memCachePlugins) { $this->allPluginDetails = $memCacheAllPluginDetails; $this->plugins = $memCachePlugins; return true; } } $pluginsRawData = \Hotaru\Models2\Plugin::getAllDetails($this); $this->allPluginDetails['pluginData'] = array(); if ($pluginsRawData) { foreach ($pluginsRawData as $plugin) { $this->allPluginDetails['pluginData'][$plugin->plugin_folder] = $plugin; $this->allPluginDetails['pluginFolderIndexOnClass'][$plugin->plugin_class] = $plugin->plugin_folder; } } // hooks //$h->allPluginDetails['hooks'] = \Hotaru\Models\Pluginhook::getAllEnabled(); $this->allPluginDetails['hooks'] = \Hotaru\Models2\Pluginhook::getAllEnabled($this); // turn this into an index based array as it runs faster than later calling an array_in func // we are going to be using isset funcs later with this // http://nickology.com/2012/07/03/php-faster-array-lookup-than-using-in_array/ if ($this->allPluginDetails['hooks']) { foreach ($this->allPluginDetails['hooks'] as $hook) { $this->allPluginDetails['hookdata'][$hook->plugin_hook][$hook->plugin_folder] = 1; } } // this was the old function here originally just getting the active plugins //$plugins = \Hotaru\Models\Plugin::getAllActiveNames()->toArray(); //$plugins = \Hotaru\Models2\Plugin::getAllActiveNames($this); $plugins = $this->allPluginDetails['pluginData']; //[$plugin->plugin_folder] = $plugin; foreach ($plugins as $plugin) { if ($plugin->plugin_enabled) { if ($plugin->plugin_type) { $this->plugins['activeTypes'][$plugin->plugin_type] = 1; } $this->plugins['activeFolders'][$plugin->plugin_folder] = 1; } } if ($this->memCache) { $this->memCache->write('allPluginDetails', $this->allPluginDetails, 10000); $this->memCache->write('plugins', $this->plugins, 10000); } }
/** * Store all plugin details for ALL PLUGINS info in memory. This is a single query * per page load unless cached. Every thing else then draws what it needs from memory. */ public static function getAllPluginDetails($h) { // to much overhead to call it like this and leave as object. // but if we change to array and make list below as that then we have to convert all other uses to array as well // $pluginsRawData = \Hotaru\Models\Plugin::getAllDetails(); // NB both active and nonactive need to be read in // $sql = "SELECT * FROM " . TABLE_PLUGINS . " ORDER BY plugin_order ASC"; // $pluginsRawData = $h->db->get_results($sql); //print "getAllPluginDetails *** <br/>*****<br/>*** <br/>*****<br/>"; $pluginsRawData = \Hotaru\Models2\Plugin::getAllDetails($h); $h->allPluginDetails['pluginData'] = array(); if ($pluginsRawData) { foreach ($pluginsRawData as $plugin) { $h->allPluginDetails['pluginData'][$plugin->plugin_folder] = $plugin; $h->allPluginDetails['pluginFolderIndexOnClass'][$plugin->plugin_class] = $plugin->plugin_folder; } } // hooks //$h->allPluginDetails['hooks'] = \Hotaru\Models\Pluginhook::getAllEnabled(); $h->allPluginDetails['hooks'] = \Hotaru\Models2\Pluginhook::getAllEnabled($h); //print_r($h->allPluginDetails['hooks']); // turn this into an index based array as it runs faster than later calling an array_in func // we are going to be using isset funcs later with this // http://nickology.com/2012/07/03/php-faster-array-lookup-than-using-in_array/ if ($h->allPluginDetails['hooks']) { foreach ($h->allPluginDetails['hooks'] as $hooks) { $h->allPluginDetails['hookdata'][$hooks->plugin_hook][$hooks->plugin_folder] = 1; } } }