本文整理汇总了PHP中CMS::site方法的典型用法代码示例。如果您正苦于以下问题:PHP CMS::site方法的具体用法?PHP CMS::site怎么用?PHP CMS::site使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMS
的用法示例。
在下文中一共展示了CMS::site方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_for_component
/**
* @param string $component
* @param string $name
* @param array|false $parms
*/
static function get_for_component($component, $name, $p = false)
{
$site = false;
if (is_string($p)) {
$site = $p;
}
if (!$site) {
$site = CMS::site();
}
$var = self::get_var_by_parms($name, $site, strtolower($component));
if (!$var) {
return false;
}
$v = self::$types[$var->vartype];
$value = self::$types[$var->vartype]->get($var, $p);
return $value;
}
示例2: path
protected function path($name = false)
{
$path = self::$dir;
$site = CMS::admin() ? CMS_Admin::site() : CMS::site();
if ($site != '__') {
$path .= "/{$site}";
}
if ($name) {
$name = trim(str_replace('.', '/', $name));
$path .= "/{$name}";
}
return $path;
}
示例3: route
/**
* @param WebKit_HTTP_Request $request
*
* @return WebKit_Controller_Route
*/
public function route($request)
{
$this->request = $request;
$uri = $this->clean_url($request->urn);
$controllers = $this->controllers();
if (Core_Types::is_iterable($controllers)) {
foreach ($controllers as $name => $info) {
if (isset($info['module'])) {
$name = $info['module'];
}
$path = trim($this->admin_path_replace($info['path']));
if ($path != '' && $path[0] == '{') {
$regexp = $path;
} else {
$regexp = '{^(' . $path . ')(.*)$}';
}
$matched = false;
if ($m = Core_Regexps::match_with_results($regexp, $uri)) {
$this->path_prefix = $m[1];
$path = $m[2];
$matched = true;
}
if (isset($info['host'])) {
$host = strtolower(trim($info['host']));
if ($host != '') {
if ($host[0] == '{') {
if (!Core_Regexps::match($host, strtolower($request->host))) {
$matched = false;
}
} else {
if (strtolower($request->host) != $host) {
$matched = false;
}
}
}
}
if (isset($info['site']) && $info['site'] != CMS::site()) {
$matched = false;
}
if ($matched) {
$this->active_controller = $name;
if (isset($info['table-admin']) && $info['table-admin']) {
$rules = array_merge(!empty($info['rules']) ? $info['rules'] : array(), array('{^$}' => array('default', 1, 'func' => 'default', 'parms' => 1), '{^list\\.json$}' => array('list_json', 'func' => 'list_json', 'parms' => 1), '{^([^/]+)/(.*)}' => array('{1}', '{2}', 'func' => '{1}', 'parms' => '{2}')));
} else {
$rules = $info['rules'];
}
if (is_array($rules)) {
foreach ($rules as $rule => $parms) {
$match = false;
if (trim($rule) != '') {
$match = $mr = Core_Regexps::match_with_results(trim($rule), $path);
}
if ($rule == '' && $path == '' || $match) {
foreach ($parms as $key => $value) {
if ($mm = Core_Regexps::match_with_results('/^\\{(\\d+)\\}$/', $value)) {
$parms[$key] = isset($mr[$mm[1]]) ? $mr[$mm[1]] : null;
}
}
$parms['controller'] = $name;
return $parms;
}
}
} else {
return array('controller' => $name, 'path' => $path);
}
}
}
}
return false;
}
示例4: process_app
/**
* @param WebKit_Environment $env
* @param WebKit_HTTP_Response $response
*
* @return Iterator
*/
public function process_app(WS_Environment $env, $response)
{
$uri = $env->request->urn;
$original_uri = $uri;
CMS::$original_uri = $uri;
CMS::$site = CMS::$defsite;
if (isset(CMS::$sites[CMS::$defsite]['page_main'])) {
CMS::$page_main = CMS::$sites[CMS::$defsite]['page_main'];
}
$_defdata = false;
if (isset(CMS::$sites[CMS::$defsite])) {
$_defdata = CMS::$sites[CMS::$defsite];
}
if (isset(CMS::$sites)) {
foreach (CMS::$sites as $site => $data) {
$_host = isset($data['host']) ? trim($data['host']) : '';
$_prefix = isset($data['prefix']) ? trim($data['prefix']) : '';
if ($_host != '' || $_prefix != '') {
$_bhost = false;
$_bprefix = false;
$_uri = $uri;
if ($_prefix != '') {
if ($m = Core_Regexps::match_with_results('{^/' . $_prefix . '/(.*)$}', $uri)) {
$_uri = '/' . $m[1];
$_bprefix = true;
} else {
continue;
}
}
if ($_host != '') {
if ($env->request->host == $_host) {
$_bhost = true;
} else {
if ($_host[0] == '{') {
if (Core_Regexps::match($_host, $env->request->host)) {
$_bhost = true;
} else {
continue;
}
} else {
continue;
}
}
}
if ($_bprefix || $_bhost) {
CMS::$site = $site;
if ($_bprefix) {
CMS::$site_prefix = '/' . $_prefix;
}
$uri = $_uri;
$env->request->uri($uri);
$_defdata = $data;
break;
}
}
}
}
if ($_defdata) {
if (isset($_defdata['page_main'])) {
CMS::$page_main = $_defdata['page_main'];
}
if (isset($_defdata['page_404'])) {
CMS::$page_404 = $_defdata['page_404'];
}
if (isset($_defdata['layout'])) {
CMS::$force_layout = $_defdata['layout'];
}
}
if (CMS::$db) {
$head = CMS::vars()->get('head');
if (isset($head['meta.title'])) {
$env->meta->title($head['meta.title']);
}
if (isset($head['meta.description'])) {
$env->meta->description($head['meta.description']);
}
if (isset($head['meta.keywords'])) {
$env->meta->keywords($head['meta.keywords']);
}
}
$curi = $uri;
if ($m = Core_Regexps::match_with_results('/^([^\\?]+)\\?/', $curi)) {
$curi = $m[1];
}
$use_layout = false;
// Просмотр всех мапперов зарегистрированных в системе
foreach (CMS::mappers() as $name => $mapper) {
// Если срабатывает маппер
if ($route = $mapper->route($env->request)) {
CMS::$current_mapper = $mapper;
CMS::$current_component_name = $name;
CMS::$current_route = $route;
try {
Core::load('Component.' . $name);
//.........这里部分代码省略.........