/** * Load the post model to the permalink. * @return {ae_PostModel} The loaded post model. */ public static function getPostModel() { if (!self::isPost()) { $msg = sprintf('[%s] Permalink does not represent a post.', get_class()); throw new Exception($msg); } $model = new ae_PostModel(); if (isset($_GET[PERMALINK_GET_POST]) && ae_Validate::id($_GET[PERMALINK_GET_POST])) { if (!$model->load($_GET[PERMALINK_GET_POST])) { return FALSE; } } else { $permalink = mb_substr(self::$url, 1); $permalink = preg_replace(';^' . PERMALINK_BASE_POST . ';i', '', $permalink); if (!$model->loadFromPermalink($permalink)) { return FALSE; } } return $model; }