本文整理汇总了PHP中Env::getTemplatePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Env::getTemplatePath方法的具体用法?PHP Env::getTemplatePath怎么用?PHP Env::getTemplatePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Env
的用法示例。
在下文中一共展示了Env::getTemplatePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajx_check_login
/**
* Checks whether the user is logged in and if not returns an error response.
*
*/
function ajx_check_login()
{
if (is_ajax_request() && !logged_user() instanceof Contact && (array_var($_GET, 'c') != 'access' || array_var($_GET, 'a') != 'relogin')) {
// error, user not logged in => return error message
$response = AjaxResponse::instance();
$response->setCurrentContent("empty");
$response->setError(SESSION_EXPIRED_ERROR_CODE, lang("session expired error"));
// display the object as json
tpl_assign("object", $response);
$content = tpl_fetch(Env::getTemplatePath("json"));
tpl_assign("content_for_layout", $content);
tpl_display(Env::getLayoutPath("json"));
exit;
}
}
示例2: executeAction
/**
* Contruct controller and execute specific action
*
* @access public
* @param string $controller_name
* @param string $action
* @return null
*/
static function executeAction($controller_name, $action) {
$max_users = config_option('max_users');
if ($max_users && Contacts::count() > $max_users) {
echo lang("error").": ".lang("maximum number of users exceeded error");
return;
}
ajx_check_login();
Env::useController($controller_name);
$controller_class = Env::getControllerClass($controller_name);
if(!class_exists($controller_class, false)) {
throw new ControllerDnxError($controller_name);
} // if
$controller = new $controller_class();
if(!instance_of($controller, 'Controller')) {
throw new ControllerDnxError($controller_name);
} // if
if (is_ajax_request()) {
// if request is an ajax request return a json response
// execute the action
$controller->setAutoRender(false);
$controller->execute($action);
// fill the response
$response = AjaxResponse::instance();
if (!$response->hasCurrent()) {
// set the current content
$response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel());
}
$response->setEvents(evt_pop());
$error = flash_pop('error');
$success = flash_pop('success');
if (!is_null($error)) {
$response->setError(1, clean($error));
} else if (!is_null($success)) {
$response->setError(0, clean($success));
}
// display the object as json
tpl_assign("object", $response);
$content = tpl_fetch(Env::getTemplatePath("json"));
tpl_assign("content_for_layout", $content);
TimeIt::start("Transfer");
if (is_iframe_request()) {
tpl_display(Env::getLayoutPath("iframe"));
} else {
tpl_display(Env::getLayoutPath("json"));
}
TimeIt::stop();
} else {
return $controller->execute($action);
}
} // executeAction
示例3: get_template_path
/**
* Interface to Env::getTemplatePath() function
*
* @access public
* @param string $template Template name
* @param string $controller_name
* @return string
*/
function get_template_path($template, $controller_name = null)
{
return Env::getTemplatePath($template, $controller_name);
}
示例4: executeAction
/**
* Contruct controller and execute specific action
*
* @access public
* @param string $controller_name
* @param string $action
* @return null
*/
static function executeAction($controller_name, $action)
{
$max_users = config_option('max_users');
if ($max_users && Users::count() > $max_users) {
echo lang("error") . ": " . lang("maximum number of users exceeded error");
return;
}
ajx_check_login();
if (isset($_GET['active_project']) && logged_user() instanceof User) {
$dont_update = false;
if (GlobalCache::isAvailable()) {
$option_value = GlobalCache::get('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $success);
if ($success) {
$dont_update = $option_value == $_GET['active_project'];
}
}
if (!$dont_update) {
set_user_config_option('lastAccessedWorkspace', $_GET['active_project'], logged_user()->getId());
if (GlobalCache::isAvailable()) {
GlobalCache::update('user_config_option_' . logged_user()->getId() . '_lastAccessedWorkspace', $_GET['active_project']);
}
}
}
Env::useController($controller_name);
$controller_class = Env::getControllerClass($controller_name);
if (!class_exists($controller_class, false)) {
throw new ControllerDnxError($controller_name);
}
// if
$controller = new $controller_class();
if (!instance_of($controller, 'Controller')) {
throw new ControllerDnxError($controller_name);
}
// if
if (is_ajax_request()) {
// if request is an ajax request return a json response
// execute the action
$controller->setAutoRender(false);
$controller->execute($action);
// fill the response
$response = AjaxResponse::instance();
if (!$response->hasCurrent()) {
// set the current content
$response->setCurrentContent("html", $controller->getContent(), page_actions(), ajx_get_panel());
}
$response->setEvents(evt_pop());
$error = flash_pop('error');
$success = flash_pop('success');
if (!is_null($error)) {
$response->setError(1, clean($error));
} else {
if (!is_null($success)) {
$response->setError(0, clean($success));
}
}
// display the object as json
tpl_assign("object", $response);
$content = tpl_fetch(Env::getTemplatePath("json"));
tpl_assign("content_for_layout", $content);
TimeIt::start("Transfer");
if (is_iframe_request()) {
tpl_display(Env::getLayoutPath("iframe"));
} else {
tpl_display(Env::getLayoutPath("json"));
}
TimeIt::stop();
} else {
return $controller->execute($action);
}
}