public static function get($slug)
    {
        $locale = I18n::getLocale();
        $slug = array_filter(explode('/', $slug));
        $cache = sprintf('page_%s_locale_%s', md5(serialize($slug)), $locale);
        $page = Cache::read($cache, 'static_pages');

        if (empty($page)) {
            //Sets the (partial) filename
            $filename = implode(DS, $slug);

            //Sets the filename patterns
            $patterns = [$filename . '-' . $locale];
            if (preg_match('/^(\w+)_\w+$/', $locale, $matches)) {
                $patterns[] = $filename . '-' . $matches[1];
            }
            $patterns[] = $filename;

            //Checks if the page exists in APP
            foreach ($patterns as $pattern) {
                $filename = self::getAppPath() . $pattern . '.ctp';

                if (is_readable($filename)) {
                    $page = DS . 'StaticPages' . DS . $pattern;

                    break;
                }
            }

            //Checks if the page exists in each plugin
            foreach (Plugin::all() as $plugin) {
                foreach ($patterns as $pattern) {
                    $filename = self::getPluginPath($plugin) . $pattern . '.ctp';

                    if (is_readable($filename)) {
                        $page = $plugin . '.' . DS . 'StaticPages' . DS . $pattern;

                        break;
                    }
                }
            }

            Cache::write($cache, $page, 'static_pages');
        }

        return $page;
    }
public static function get($slug)
    {
        $locale = I18n::getLocale();
        $slug = array_filter(explode('/', $slug));
        $cache = sprintf('page_%s_locale_%s', md5(serialize($slug)), $locale);
        $page = Cache::read($cache, 'static_pages');

        if (empty($page)) {
            //Sets the (partial) filename
            $filename = implode(DS, $slug);

            //Sets the filename patterns
            $patterns = [$filename . '-' . $locale];
            if (preg_match('/^(\w+)_\w+$/', $locale, $matches)) {
                $patterns[] = $filename . '-' . $matches[1];
            }
            $patterns[] = $filename;

            //Checks if the page exists in APP
            foreach ($patterns as $pattern) {
                $filename = self::getAppPath() . $pattern . '.ctp';

                if (is_readable($filename)) {
                    $page = DS . 'StaticPages' . DS . $pattern;

                    break;
                }
            }

            //Checks if the page exists in each plugin
            foreach (Plugin::all() as $plugin) {
                foreach ($patterns as $pattern) {
                    $filename = self::getPluginPath($plugin) . $pattern . '.ctp';

                    if (is_readable($filename)) {
                        $page = $plugin . '.' . DS . 'StaticPages' . DS . $pattern;

                        break;
                    }
                }
            }

            Cache::write($cache, $page, 'static_pages');
        }

        return $page;
    }
public static function get ( $ slug ) { $ locale = I18n :: getLocale ( ) ; $ slug = array_filter ( explode ( '/' , $ slug ) ) ; $ cache = sprintf ( 'page_%s_locale_%s' , md5 ( serialize ( $ slug ) ) , $ locale ) ; $ page = Cache :: read ( $ cache , 'static_pages' ) ; if ( empty ( $ page ) ) { //Sets the (partial) filename $ filename = implode ( DS , $ slug ) ; //Sets the filename patterns $ patterns = [ $ filename . '-' . $ locale ] ; if ( preg_match ( '/^(\w+)_\w+$/' , $ locale , $ matches ) ) { $ patterns [ ] = $ filename . '-' . $ matches [ 1 ] ; } $ patterns [ ] = $ filename ; //Checks if the page exists in APP foreach ( $ patterns as $ pattern ) { $ filename = self :: getAppPath ( ) . $ pattern . '.ctp' ; if ( is_readable ( $ filename ) ) { $ page = DS . 'StaticPages' . DS . $ pattern ; break ; } } //Checks if the page exists in each plugin foreach ( Plugin :: all ( ) as $ plugin ) { foreach ( $ patterns as $ pattern ) { $ filename = self :: getPluginPath ( $ plugin ) . $ pattern . '.ctp' ; if ( is_readable ( $ filename ) ) { $ page = $ plugin . '.' . DS . 'StaticPages' . DS . $ pattern ; break ; } } } Cache :: write ( $ cache , $ page , 'static_pages' ) ; } return $ page ; }
Gets a static page
@param string $slug Slug
@return string|bool Static page or `false`
@uses MeCms\Core\Plugin::all()
@uses getAppPath()
@uses getPluginPath()
Gets a static page