static function tableize($class_name) { return strtolower(AppInflector::camelize(AppInflector::singularize($class_name))); }
static function Parse($url) { // save 'original' Url::$data['_url'] = $url; // send through routes Url::$data['url'] = Url::DoRoutes($url); // get extension preg_match('/(.*)\\.(\\w{1,4})$/Ui', Url::$data['url'], $matches); if (!empty($matches)) { Url::$data['url'] = $matches[1]; Url::$data['type'] = $matches[2]; } // get parts $parts = explode(DS, Url::$data['url']); // is subdomain? // if (count($host_parts=explode('.', $_SERVER['HTTP_HOST'])) > 2 && $host_parts[0]!='www') { if (($subdomain = Url::GetSubdomain()) != null) { Url::$data['is_subdomain'] = true; Url::$data['subdomain'] = $subdomain; } Url::$data['host'] = 'http' . (array_get($_SERVER, 'HTTPS') ? 's' : '') . '://' . wrap($subdomain, '', '.') . DOMAIN; // d($url);d_arr($parts);d_arr(Url::$data);die; // nothing left? if (array_empty($parts)) { if (Url::GetData('is_admin')) { // is admin $parts = array(ADMIN_DEFAULT_CONTROLLER, ADMIN_DEFAULT_ACTION); } else { // is default $parts = explode(DS, Url::GetData('is_subdomain') ? SUBDOMAIN_DEFAULT_URL : DEFAULT_URL); } } // is execute? if (Url::$data['type'] == 'php') { Url::$data['model'] = 'app'; Url::$data['modelName'] = 'AppModel'; Url::$data['controller'] = EXECUTE_CONTROLLER; Url::$data['controllerName'] = ucfirst(EXECUTE_CONTROLLER) . 'Controller'; Url::$data['action'] = 'include_to_buffer'; // set filename Url::$data['params'] = array('filename' => implode(DS, $parts) . '.php'); } else { // set controller Url::$data['controller'] = array_shift($parts); Url::$data['controllerName'] = AppInflector::classify(Url::$data['controller'], 'controller'); // set model Url::$data['model'] = AppInflector::singularize(Url::$data['controller']); Url::$data['modelName'] = AppInflector::classify(Url::$data['model'], 'model'); // set action Url::$data['action'] = ($action = array_shift($parts)) != null ? $action : 'index'; // add prefix to admin actions if (Url::GetData('is_admin')) { Url::$data['action'] = ADMIN_PREFIX . Url::$data['action']; } // set params while (($value = array_shift($parts)) != null) { Url::$data['params'][] = $value; } } // set request Url::$data['request'] = $_REQUEST; // set domain Url::$data['domain'] = DOMAIN; // d_arr(Url::$data);die; }