本文整理汇总了PHP中api::set方法的典型用法代码示例。如果您正苦于以下问题:PHP api::set方法的具体用法?PHP api::set怎么用?PHP api::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api
的用法示例。
在下文中一共展示了api::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public static function get($url)
{
$url = preg_replace('/^(\\/)/', '', $url);
$new_url = $url;
// REST API
if (preg_match('/\\.([\\-_a-zA-Z]+)$/', $new_url)) {
$split = explode('.', $new_url);
api::set(array_pop($split));
$new_url = implode('.', $split);
}
// Static routes
if (!empty(self::$route[$url])) {
$new_url = self::$route[$url];
}
// Regex routes
$route_keys = array_keys(self::$route);
foreach ($route_keys as $okey) {
$key = '/^' . str_replace('/', '\\/', $okey) . '$/';
if (preg_match($key, $url)) {
if (!is_array(self::$route[$okey])) {
$new_url = preg_replace($key, self::$route[$okey], $url);
} else {
/* Run regex replace on keys */
$new_url = self::$route[$okey];
// Controller
if (isset($new_url['controller'])) {
$new_url['controller'] = preg_replace($key, $new_url['controller'], $url);
}
// Function
if (isset($new_url['function'])) {
$new_url['function'] = preg_replace($key, $new_url['function'], $url);
}
// Arguments
if (isset($new_url['arguments'])) {
$x = 0;
while (isset($new_url['arguments'][$x])) {
$new_url['arguments'][$x] = preg_replace($key, $new_url['arguments'][$x], $url);
$x += 1;
}
}
}
}
}
// If URL is empty use default route
if (empty($new_url) or $new_url == '/') {
$new_url = self::$route['default_route'];
}
// Turn into array
if (!is_array($new_url)) {
// Remove the /index.php/ at the beginning
//$new_url = preg_replace('/^(\/)/','',$url);
$tmp_url = explode('/', $new_url);
$new_url = array('controller' => $tmp_url[0], 'function' => 'index', 'arguments' => array(), 'string' => $new_url, 'segments' => $tmp_url);
// Function
if (!empty($tmp_url[1])) {
$new_url['function'] = $tmp_url[1];
}
// Arguments
$x = 2;
while (isset($tmp_url[$x])) {
$new_url['arguments'][] = $tmp_url[$x];
$x += 1;
}
} else {
// Add missing keys
if (!isset($new_url['function'])) {
$new_url['function'] = 'index';
}
if (!isset($new_url['arguments'])) {
$new_url['arguments'] = array();
}
// Build string key for URL array
// Controller
$s = $new_url['controller'];
// Function
if (isset($new_url['function'])) {
$s .= "/{$new_url['function']}";
}
// Arguments
foreach ($new_url['arguments'] as $arg) {
$s .= "/{$arg}";
}
$new_url['string'] = $s;
// Add segments key
$new_url['segments'] = explode('/', $new_url['string']);
}
// Controller class
$new_url['controller_class'] = explode('/', $new_url['controller']);
$new_url['controller_class'] = end($new_url['controller_class']);
self::$current = $new_url;
return $new_url;
}
示例2: define
// Выходим из обработки, так как AJAX
}
define("URL", "page");
if (!empty($url["url"]) && $url["url"] == ".html") {
$url["url"] = $url["result"] . $url["url"];
} else {
$url["url"] = $url["without_home"];
}
define("APPLICATION_NAME", MAIN . "/" . $applications_store["template"][MAIN]);
define("DIR", TEMPLATE . "applications/" . MAIN . "/" . $applications_store["template"][MAIN]);
# определяем путь к директории приложения
$api = new api(MAIN . "/" . $applications_store["template"][MAIN]);
// создаём объект
require_once PUBLIC_APPLICATIONS . MAIN . "/index.php";
// подключаем
$api->set("{HOME}", HOME);
}
}
}
# подключение модулей и плагинов
// ВРЕМЕННО НЕ РАБОТАЕТ
require_once PUBLIC_MODULES . "index.php";
#############################################
# GLOBAL REPLACE IF NOT REPLASED
#############################################
$api->set("{DIR}", DIR);
$api->set("{TEMPLATE}", TEMPLATE);
$api->set("{MOD_DIR}", MOD_DIR);
$systems_scripts = '<link rel="stylesheet" href="' . TEMPLATE . 'system_library/css/jquery-ui.min.css">
' . "\t" . '<link rel="stylesheet" href="' . TEMPLATE . 'system_library/css/jquery-ui.theme.min.css">
' . "\t" . '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>