/** * Gets others plugins that have the `InstallShell` class * @return array */ protected function _getOtherPlugins() { //Gets all plugins $plugins = Plugin::all(['exclude' => [METOOLS, MECMS]]); //Returns only the plugins that have the `InstallShell` class return af(array_map(function ($plugin) { return Plugin::path($plugin, 'src' . DS . 'Shell' . DS . 'InstallShell.php', true) ? $plugin : false; }, $plugins)); }
/** * Gets all loaded plugins. * * Available options are: * - `core`, if `false` exclude the core plugins; * - `exclude`, a plugin as string or an array of plugins to be excluded; * - `order`, if `true` the plugins will be sorted. * @param array $options Options * @return array Plugins * @uses MeTools\Core\Plugin::all() */ public static function all(array $options = []) { $options = am(['core' => false, 'except' => [], 'order' => true], $options); $plugins = parent::all($options); if ($options['order']) { $key = array_search(MECMS, $plugins); if ($key) { unset($plugins[$key]); array_unshift($plugins, MECMS); } } return $plugins; }
/** * Renders a layout. Returns output from _render(). Returns false on * error. Several variables are created for use in layout * @param string $content Content to render in a view, wrapped by the * surrounding layout * @param string|null $layout Layout name * @return mixed Rendered output, or false on error * @see http://api.cakephp.org/3.3/class-Cake.View.View.html#_renderLayout * @uses MeCms\View\View\BaseView::renderLayout() * @uses MeTools\Core\Plugin::path() * @uses MeTools\View\Helper\HtmlHelper::meta() * @uses MeTools\View\Helper\LibraryHelper::analytics() * @uses MeTools\View\Helper\LibraryHelper::shareaholic() * @uses _addFacebookTags() * @uses $userbar */ public function renderLayout($content, $layout = null) { $path = 'src' . DS . 'Template' . DS . 'Layout' . DS; if ($this->layoutPath()) { $path .= $this->layoutPath() . DS; } $path .= $layout . '.ctp'; //Uses the APP layout, if exists if (is_readable(ROOT . DS . $path)) { $this->plugin = false; } //Sets the theme and uses the theme layout, if exists if (config('default.theme') && !$this->theme()) { $this->theme(config('default.theme')); if (is_readable(Plugin::path($this->theme()) . $path)) { $this->plugin = $this->theme(); } } //Adds the "theme color" (the toolbar color for some mobile browser) if (config('default.toolbar_color')) { $this->Html->meta('theme-color', config('default.toolbar_color')); } //Adds the meta tag for RSS posts if (config('default.rss_meta')) { $this->Html->meta(__d('me_cms', 'Latest posts'), '/posts/rss', ['type' => 'rss']); } //Adds Google Analytics if (config('default.analytics')) { echo $this->Library->analytics(config('default.analytics')); } //Adds Shareaholic if (config('shareaholic.site_id')) { echo $this->Library->shareaholic(config('shareaholic.site_id')); } //Adds Facebook's tags $this->_addFacebookTags(); //Assign the userbar $this->assign('userbar', implode(PHP_EOL, array_map(function ($element) { return $this->Html->li($element); }, $this->userbar))); return parent::renderLayout($content, $layout); }
/** * Copies the configuration files * @return void * @uses $config * @uses MeTools\Core\Plugin::path() */ public function copyConfig() { foreach ($this->config as $file) { list($plugin, $file) = pluginSplit($file); $file = sprintf('%s.php', $file); $target = ROOT . DS . 'config' . DS . $file; //Checks if the file already exists if (is_readable($target)) { $this->verbose(__d('me_tools', 'File or directory {0} already exists', rtr($target))); continue; } if (copy(Plugin::path($plugin, 'config' . DS . $file), $target)) { $this->verbose(__d('me_tools', 'The file {0} has been copied', rtr($target))); } else { $this->err(__d('me_tools', 'The file {0} has not been copied', rtr($target))); } } }