/** * @brief load up the installer lib * * The installer uses a lib that is shared between the frontend and shell * installer. * * @access public */ public function __construct($request = null, $response = null) { parent::__construct($request, $response); InfinitasPlugin::loadForInstaller(); App::uses('InstallerLib', 'Installer.Lib'); $this->InstallerLib = new InstallerLib(); }
public function __construct($stdout = null, $stderr = null, $stdin = null) { $this->setTerminalWidth(); App::import('Core', 'Router'); InfinitasPlugin::loadForInstaller(); parent::__construct($stdout, $stderr, $stdin); $this->__verbose = isset($this->params['verbose']) && $this->params['verbose']; }
public function testGetPlugins() { $_allPlugins = InfinitasPlugin::listPlugins('all'); $allPlugins = array() + array('' => 'None'); foreach ($_allPlugins as $k => $v) { $allPlugins[Inflector::underscore($v)] = $v; } // need to see how to do this //$this->assertEqual(count($this->Infinitas->getPlugins($this->AppModel, true)), count($allPlugins)); }
/** * @brief change the template if there is one available * * If a template is found for the current exception then it is set * * @param string $exceptionClass The name of the exception class * @param string $plugin The plugin the exception belongs to */ private function __changeTemplate($exceptionClass, $plugin) { $view = Inflector::underscore(str_replace(array('Exception', $plugin), '', $exceptionClass)); try { $path = InfinitasPlugin::path($plugin) . 'View' . DS . 'Errors' . DS . $view . '.ctp'; if (is_file($path)) { $this->method = '_infinitasError'; $this->template = sprintf('%s.%s', $plugin, $view); } } catch (Exception $e) { } $path = APP . 'View' . DS . 'Errors' . DS . $view . '.ctp'; if (is_file($path)) { $this->method = '_infinitasError'; $this->template = $view; } }
/** * @brief generate the path to a plugins theme dir * * If the specific theme is available it will return the path to the * theme, if not it will return the path to where the themes for that plugin * are kept * * If no plugin is null, it is assumed that the path for app themes are required * * @access public * * @param string $plugin the name of the plugin * @param string $theme the name of the theme * * @return string the path that is requested */ public static function themePath($plugin = null, $theme = null) { if (!$plugin) { if (!$theme) { return APP . 'View' . DS . 'Themed'; } return APP . 'View' . DS . 'Themed' . DS . $theme; } if (!$theme) { return InfinitasPlugin::path($plugin) . 'View' . DS . 'Themed'; } return InfinitasPlugin::path($plugin) . 'View' . DS . 'Themed' . DS . $theme; }
*/ $cachedConfigs = Cache::read('global_configs'); if (!empty($cachedConfigs)) { foreach ($cachedConfigs as $k => $v) { Configure::write($k, $v); } } unset($cacheEngine, $cachedConfigs); InfinitasPlugin::loadCore(); EventCore::trigger(new StdClass(), 'requireLibs'); /** * @todo cake2.0 * Cache::write('global_configs', Configure::getInstance()); */ configureCache(EventCore::trigger(new StdClass(), 'setupCache')); InfinitasPlugin::loadInstalled(); /** * Make sure the json defines are loaded. */ if (!defined('JSON_ERROR_NONE')) { define('JSON_ERROR_NONE', 0); } if (!defined('JSON_ERROR_DEPTH')) { define('JSON_ERROR_DEPTH', 1); } if (!defined('JSON_ERROR_CTRL_CHAR')) { define('JSON_ERROR_CTRL_CHAR', 3); } if (!defined('JSON_ERROR_SYNTAX')) { define('JSON_ERROR_SYNTAX', 4); }
/** * Build routes for the app. * * Allows other plugins to register routes to be used in the app and builds * the routes from the database. */ private static function __buildRoutes() { App::uses('ClassRegistry', 'Utility'); EventCore::trigger(new StdClass(), 'setupRoutes'); if (InfinitasPlugin::infinitasInstalled()) { $routes = ClassRegistry::init('Routes.Route')->getRoutes(); if (!empty($routes)) { foreach ($routes as $route) { if (false) { debugRoute($route); continue; } call_user_func_array(array('InfinitasRouter', 'connect'), $route['Route']); } } if (!defined('INFINITAS_ROUTE_HASH')) { define('INFINITAS_ROUTE_HASH', md5(serialize($routes))); } } }
/** * @brief get all the places plugins are found and tell cake about them * * Get the paths out of cache if there are any or get them with Folder::read * They are used with App::build() to make any extra folders in APP be plugin * folders. This can help if you want to keep plugins outside of /plugins */ private static function __findPlugins() { if (!empty(self::$__pluginPaths)) { return true; } self::$__pluginPaths = Cache::read('plugin_paths'); if (self::$__pluginPaths === false) { $Folder = new Folder(APP); $folders = $Folder->read(); $folders = array_flip($folders[0]); unset($Folder, $folders['.git'], $folders['Config'], $folders['Locale'], $folders['nbproject'], $folders['Console'], $folders['tmp'], $folders['View'], $folders['Controller'], $folders['Lib'], $folders['webroot'], $folders['Test'], $folders['Model']); self::$__pluginPaths = array(); foreach (array_flip($folders) as $folder) { self::$__pluginPaths[] = APP . $folder . DS; } Cache::write('plugin_paths', self::$__pluginPaths); unset($Folder, $folders); // @todo trigger event to get oter plugin paths } return App::build(array('Plugin' => self::$__pluginPaths)); }
private function __getPlugins() { $plugins = InfinitasPlugin::listPlugins('loaded'); natcasesort($plugins); foreach ($plugins as &$plugin) { $plugin = InfinitasPlugin::path($plugin) . 'webroot' . DS . 'img' . DS; } $plugins[] = APP . DS . 'webroot' . DS . 'img' . DS; return $plugins; }
/** * @brief get a list of themes that are not yet installed * * @access public * * @return array list of themes that are not installed */ public function notInstalled() { App::uses('InstallerLib', 'Installer.Lib'); $installed = $this->installed(); $notInstalled = array(); foreach (InfinitasPlugin::listPlugins('loaded') as $plugin) { foreach (InstallerLib::findThemes($plugin) as $theme) { if (!array_key_exists($theme, $installed)) { $notInstalled[$plugin . '.' . $theme] = Inflector::humanize(Inflector::underscore($plugin . Inflector::camelize($theme))); } } } foreach (InstallerLib::findThemes() as $theme) { if (!linkinfo(InstallerLib::themePath(null, $theme)) && !array_key_exists($theme, $installed)) { $notInstalled[$theme] = Inflector::humanize(Inflector::underscore($theme)); } } return $notInstalled; }
/** * Dispatch Event * * @param string $eventName * @param array $data (optional) * @return array * */ protected static function _dispatchEvent(&$HandlerObject, $scope, $eventName, $data = array()) { $_this = EventCore::getInstance(); $eventHandlerMethod = $_this->_handlerMethodName($eventName); $return = array(); if (isset($_this->_eventHandlerCache[$eventName])) { foreach ($_this->_eventHandlerCache[$eventName] as $eventClass) { $pluginName = EventCore::_extractPluginName($eventClass); $pluginType = 'loaded'; if (isset($_this->__pluginsMap[$eventName])) { $pluginType = $_this->__pluginsMap[$eventName]; } if (!in_array(Inflector::camelize($pluginName), (array) InfinitasPlugin::listPlugins($pluginType))) { continue; } if ($scope == 'Global' || $scope == $pluginName) { EventCore::_loadEventClass($eventClass); $Event = new Event($eventName, $HandlerObject, $pluginName); $return[$pluginName] = call_user_func_array(array($_this->_eventClasses[$eventClass], $eventHandlerMethod), array($Event, $data)); } } } return $return; }