/** * Load the category model to the permalink. * @return {ae_CategoryModel} The loaded category model. */ public static function getCategoryModel() { if (!self::isCategory()) { $msg = sprintf('[%s] Permalink does not represent a category.', get_class()); throw new Exception($msg); } $model = new ae_CategoryModel(); if (isset($_GET[PERMALINK_GET_CATEGORY]) && ae_Validate::id($_GET[PERMALINK_GET_CATEGORY])) { if (!$model->load($_GET[PERMALINK_GET_CATEGORY])) { return FALSE; } } else { $permalink = mb_substr(self::$urlNoOffset, 1); $permalink = preg_replace(';^' . PERMALINK_BASE_CATEGORY . ';i', '', $permalink); if (!$model->loadFromPermalink($permalink, TRUE)) { return FALSE; } } return $model; }