Ejemplo n.º 1
0
 /**
  * Generate the sitemap.
  *
  * For each plugin, it calls dynamically all methods from class
  * `$PLUGIN\Utility\Sitemap`.
  * Each method must be return an array or urls to add to the sitemap.
  * @return string
  * @see MeCms\Utility\Sitemap
  * @uses MeCms\Core\Plugin::all()
  * @uses parse()
  */
 public function generate()
 {
     //Adds the homepage
     $url = [self::parse('/')];
     foreach (Plugin::all() as $plugin) {
         //Sets the class name
         $class = sprintf('\\%s\\Utility\\Sitemap', $plugin);
         //Gets all methods from `$PLUGIN\Utility\Sitemap` class
         $methods = getChildMethods($class);
         if (empty($methods)) {
             continue;
         }
         //Calls all methods
         foreach ($methods as $method) {
             $url = am($url, call_user_func([$class, $method]));
         }
     }
     $xml = Xml::fromArray(['urlset' => ['xmlns:' => 'http://www.sitemaps.org/schemas/sitemap/0.9', 'url' => $url]], ['pretty' => true]);
     return $xml->asXML();
 }
Ejemplo n.º 2
0
 /**
  * Gets a static page
  * @param string $slug Slug
  * @return string|bool Static page or false
  * @uses MeCms\Core\Plugin::all()
  */
 public static function get($slug)
 {
     //Sets the file (partial) name
     $file = implode(DS, af(explode('/', $slug)));
     //Sets the file patterns
     $patterns = [sprintf('%s-%s', $file, I18n::locale()), $file];
     //Checks if the page exists in APP
     foreach ($patterns as $pattern) {
         $file = firstValue(App::path('Template')) . 'StaticPages' . DS . $pattern . '.ctp';
         if (is_readable($file)) {
             return 'StaticPages' . DS . $pattern;
         }
     }
     //Checks if the page exists in all plugins, beginning with MeCms
     foreach (Plugin::all() as $plugin) {
         foreach ($patterns as $pattern) {
             $file = firstValue(App::path('Template', $plugin)) . 'StaticPages' . DS . $pattern . '.ctp';
             if (is_readable($file)) {
                 return sprintf('%s.%s', $plugin, 'StaticPages' . DS . $pattern);
             }
         }
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * System checkup
  * @return void
  * @uses MeCms\Core\Plugin::all()
  * @uses MeCms\Core\Plugin::path()
  * @uses MeTools\Utility\Apache::module()
  * @uses MeTools\Utility\Apache::version()
  */
 public function checkup()
 {
     $checkup['apache'] = ['expires' => Apache::module('mod_expires'), 'rewrite' => Apache::module('mod_rewrite'), 'version' => Apache::version()];
     $checkup['backups'] = ['path' => rtr(Configure::read('MysqlBackup.target') . DS), 'writeable' => folderIsWriteable(Configure::read('MysqlBackup.target'))];
     $checkup['cache'] = Cache::enabled();
     //Checks for PHP's extensions
     foreach (['exif', 'imagick', 'mcrypt', 'zip'] as $extension) {
         $checkup['phpExtensions'][$extension] = extension_loaded($extension);
     }
     $checkup['plugins'] = ['cakephp' => Configure::version(), 'mecms' => trim(file_get_contents(Plugin::path(MECMS, 'version')))];
     //Gets plugins versions
     foreach (Plugin::all(['exclude' => MECMS]) as $plugin) {
         $file = Plugin::path($plugin, 'version', true);
         if ($file) {
             $checkup['plugins']['plugins'][$plugin] = trim(file_get_contents($file));
         } else {
             $checkup['plugins']['plugins'][$plugin] = __d('me_cms', 'n.a.');
         }
     }
     //Checks for temporary directories
     foreach ([LOGS, TMP, Configure::read('Assets.target'), CACHE, LOGIN_LOGS, Configure::read('Thumbs.target')] as $path) {
         $checkup['temporary'][] = ['path' => rtr($path), 'writeable' => folderIsWriteable($path)];
     }
     //Checks for webroot directories
     foreach ([BANNERS, PHOTOS, WWW_ROOT . 'files', WWW_ROOT . 'fonts'] as $path) {
         $checkup['webroot'][] = ['path' => rtr($path), 'writeable' => folderIsWriteable($path)];
     }
     array_walk($checkup, function ($value, $key) {
         $this->set($key, $value);
     });
 }