本文整理汇总了PHP中waSystem::appExists方法的典型用法代码示例。如果您正苦于以下问题:PHP waSystem::appExists方法的具体用法?PHP waSystem::appExists怎么用?PHP waSystem::appExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waSystem
的用法示例。
在下文中一共展示了waSystem::appExists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
public function dispatch()
{
$url = $this->system->getConfig()->getRequestUrl();
$url = preg_replace("!\\?.*\$!", '', $url);
$url = urldecode($url);
$r = $this->dispatchRoutes($this->getRoutes(), $url);
if (!$r || $r['url'] == '*' && $url && strpos(substr($url, -5), '.') === false && substr($url, -1) !== '/') {
$r2 = $this->dispatchRoutes($this->getRoutes(), $url . '/');
if ($r2 && (!$r || $r2['url'] != '*')) {
$this->system->getResponse()->redirect($this->system->getRootUrl() . $url . '/');
}
}
// if route found and app exists
if ($r && isset($r['app']) && $r['app'] && $this->system->appExists($r['app'])) {
$this->setRoute($r);
// dispatch app routes
$params = waRequest::param();
$u = $r['url'];
if (preg_match_all('/<([a-z_]+):?([^>]*)?>/ui', $u, $match, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
$offset = 0;
foreach ($match as $m) {
$v = $m[1][0];
$s = isset($params[$v]) ? $params[$v] : '';
$u = substr($u, 0, $m[0][1] + $offset) . $s . substr($u, $m[0][1] + $offset + strlen($m[0][0]));
$offset += strlen($s) - strlen($m[0][0]);
}
}
$this->root_url = self::clearUrl($u);
$url = substr($url, strlen($this->root_url));
$this->dispatchRoutes($this->getAppRoutes($r['app'], $r), $url);
}
return $r;
}
示例2: block
public function block($id)
{
if ($id && $this->wa->appExists('site')) {
wa('site');
$model = new siteBlockModel();
$block = $model->getById($id);
if (!$block && strpos($id, '.') !== false) {
list($app_id, $id) = explode('.', $id);
$path = $this->wa->getConfig()->getAppsPath($app_id, 'lib/config/site.php');
if (file_exists($path)) {
$site_config = (include $path);
if (isset($site_config['blocks'][$id])) {
if (!is_array($site_config['blocks'][$id])) {
$block = array('content' => $site_config['blocks'][$id]);
} else {
$block = $site_config['blocks'][$id];
}
}
}
}
if ($block) {
try {
return $this->view->fetch('string:' . $block['content']);
} catch (Exception $e) {
if (waSystemConfig::isDebug()) {
return '<pre class="error">' . htmlentities($e->getMessage(), ENT_QUOTES, 'utf-8') . "</pre>";
} else {
waLog::log($e->__toString());
return '<div class="error">' . _ws('Syntax error at block') . ' ' . $id . '</div>';
}
}
}
}
return '';
}