本文整理汇总了PHP中elgg_set_viewtype函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_set_viewtype函数的具体用法?PHP elgg_set_viewtype怎么用?PHP elgg_set_viewtype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_set_viewtype函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jpatchwork_page_handler
function jpatchwork_page_handler($page)
{
if (!isset($page[0])) {
$page[0] = 'sample';
}
elgg_set_context('jpatchwork');
$page_type = $page[0];
switch ($page_type) {
case 'sample':
$area2 = elgg_view_title(elgg_echo('jpatchwork:sample_title'));
// Add the form to this section
elgg_set_viewtype('xml');
$area2 .= elgg_view('jpatchwork/sample');
elgg_set_viewtype('default');
break;
case 'frozenbubble':
$area2 = elgg_view_title(elgg_echo('jpatchwork:frozenbubble_title'));
// Add the form to this section
elgg_set_viewtype('xml');
$area2 .= elgg_view('jpatchwork/frozenbubble');
elgg_set_viewtype('default');
break;
default:
return false;
}
// Format page
$body = elgg_view('page/layouts/one_sidebar', array('content' => $area2));
// Draw it
echo elgg_view_page(elgg_echo('jpatchwork:title'), $body);
return true;
}
示例2: mobilize_init
function mobilize_init()
{
$action_path = dirname(__FILE__) . '/actions';
elgg_register_action("mobilize/admin/settings", "{$action_path}/settings.php", 'admin');
elgg_register_admin_menu_item('configure', 'mobilize', 'settings');
elgg_extend_view('css/admin', 'mobilize/admin');
elgg_register_page_handler('about', 'mobilize_expages_page_handler');
elgg_register_page_handler('terms', 'mobilize_expages_page_handler');
elgg_register_page_handler('privacy', 'mobilize_expages_page_handler');
elgg_register_css('elgg.mobilize', '/css/mobilize.css');
detectmobile();
$mobile = detectmobile();
$mobile = true;
if ($mobile == true) {
elgg_set_viewtype('mobile');
elgg_register_plugin_hook_handler('index', 'system', 'index_handler');
elgg_extend_view('js/elgg', 'js/mobilize');
elgg_register_page_handler('dashboard', 'dashboard_page_handler');
if (elgg_get_plugin_setting('use_friendspicker', 'mobilize') == 'yes') {
elgg_unregister_js('elgg.friendspicker');
}
elgg_unregister_js('elgg.tinymce');
elgg_extend_view('page/elements/head', 'mobilize/meta', 1);
elgg_register_js('mobilize', 'mod/mobilize/vendors/js/mobilize.js', 'footer');
elgg_load_js('mobilize');
elgg_register_event_handler('pagesetup', 'system', 'mobilize_setup_handler', 1000);
}
elgg_register_viewtype_fallback('mobile');
elgg_unregister_js("elgg.map");
elgg_register_js('elgg.map', 'mod/mobilize/views/mobile/js/map.js', 'footer');
elgg_load_js('elgg.map');
elgg_unregister_js("elgg.touch");
elgg_register_js('elgg.touch', 'mod/mobilize/views/mobile/js/jquery.ui.touch-punch.min.js', 'footer');
elgg_load_js('elgg.touch');
}
示例3: check_mobile_mode
function check_mobile_mode()
{
global $IS_FROM_APP;
setcookie("51zhaohu_app", "true", time() + 3600);
if ($_COOKIE['51zhaohu_app']) {
$IS_FROM_APP = true;
}
if ($_COOKIE['51zh_desktop']) {
elgg_set_viewtype('default');
return;
}
if ($_COOKIE['51zh_mobile']) {
elgg_set_viewtype('mobile');
return;
}
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
//detect if there is a mobile device
if (preg_match('/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|iemobile|windows ce|nokia|fennec|hiptop|kindle|mot |mot-|webos\\/|samsung|sonyericsson|^sie-|nintendo/', $useragent) || preg_match('/mobile|pda;|avantgo|eudoraweb|minimo|netfront|brew|teleca|lg;|lge |wap;| wap /', $useragent && !strstr($useragent, 'ipad'))) {
//the hack to hide mobile view is below
elgg_set_viewtype('mobile');
//elgg_set_viewtype('default');
} else {
elgg_set_viewtype('default');
}
}
示例4: handle
/**
* {@inheritdoc}
*/
protected function handle()
{
$uri = '/' . ltrim($this->argument('uri'), '/');
$method = $this->argument('method') ?: 'GET';
$add_csrf_tokens = $this->option('tokens');
$site_url = elgg_get_site_url();
$uri = substr(elgg_normalize_url($uri), strlen($site_url));
$path_key = Application::GET_PATH_KEY;
$parameters = [];
$query = trim((string) $this->option('query'), '?');
parse_str($query, $parameters);
if ($add_csrf_tokens) {
$ts = time();
$parameters['__elgg_ts'] = $ts;
$parameters['__elgg_token'] = _elgg_services()->actions->generateActionToken($ts);
}
$request = Request::create("?{$path_key}=" . urlencode($uri), $method, $parameters);
$cookie_name = _elgg_services()->config->getCookieConfig()['session']['name'];
$session_id = _elgg_services()->session->getId();
$request->cookies->set($cookie_name, $session_id);
$request->headers->set('Referer', elgg_normalize_url());
if ($this->option('export')) {
elgg_set_viewtype('json');
$request->headers->set('X-Elgg-Ajax-API', '2');
}
_elgg_services()->setValue('request', $request);
Application::index();
}
示例5: __construct
/**
* Constructor bootstraps the Elgg engine
*/
public function __construct()
{
$this->isAction = $_SERVER['REQUEST_METHOD'] === 'POST';
$this->bootstrapConfig();
$this->bootstrapEngine();
elgg_set_viewtype('installation');
set_error_handler('_elgg_php_error_handler');
set_exception_handler('_elgg_php_exception_handler');
register_translations(dirname(__FILE__) . '/languages/', TRUE);
}
示例6: opensearch_handler
/**
* Handles OpenSearch requests
*
* @param array $page An array of URL elements
* @return bool
*/
function opensearch_handler($page)
{
switch ($page[0]) {
case 'osd.xml':
elgg_set_viewtype('xml');
echo elgg_view_page('', elgg_view('opensearch/description'));
return true;
break;
}
return false;
}
示例7: __construct
/**
* Constructor bootstraps the Elgg engine
*/
public function __construct()
{
$this->isAction = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST';
$this->bootstrapConfig();
$this->bootstrapEngine();
_elgg_services()->setValue('session', new ElggSession(new Elgg\Http\MockSessionStorage()));
elgg_set_viewtype('installation');
set_error_handler('_elgg_php_error_handler');
set_exception_handler('_elgg_php_exception_handler');
register_translations("{$this->getElggRoot()}/install/languages/", TRUE);
}
示例8: __construct
/**
* Constructor bootstraps the Elgg engine
*/
public function __construct()
{
// load ElggRewriteTester as we depend on it
require_once dirname(__FILE__) . "/ElggRewriteTester.php";
$this->isAction = $_SERVER['REQUEST_METHOD'] === 'POST';
$this->bootstrapConfig();
$this->bootstrapEngine();
elgg_set_viewtype('installation');
set_error_handler('_elgg_php_error_handler');
set_exception_handler('_elgg_php_exception_handler');
register_translations(dirname(__FILE__) . '/languages/', TRUE);
}
示例9: __construct
/**
* Constructor bootstraps the Elgg engine
*/
public function __construct()
{
// load ElggRewriteTester as we depend on it
require_once dirname(__FILE__) . "/ElggRewriteTester.php";
$this->isAction = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST';
$this->bootstrapConfig();
$this->bootstrapEngine();
_elgg_services()->setValue('session', new ElggSession(new Elgg_Http_MockSessionStorage()));
elgg_set_viewtype('installation');
set_error_handler('_elgg_php_error_handler');
set_exception_handler('_elgg_php_exception_handler');
register_translations(dirname(__FILE__) . '/languages/', TRUE);
}
示例10: __construct
/**
* Constructor bootstraps the Elgg engine
*/
public function __construct()
{
global $CONFIG;
if (!isset($CONFIG)) {
$CONFIG = new stdClass();
}
$this->CONFIG = $CONFIG;
$this->isAction = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST';
$this->bootstrapConfig();
$this->bootstrapEngine();
_elgg_services()->setValue('session', \ElggSession::getMock());
elgg_set_viewtype('installation');
set_error_handler('_elgg_php_error_handler');
set_exception_handler('_elgg_php_exception_handler');
_elgg_services()->translator->registerTranslations("{$this->getElggRoot()}/install/languages/", TRUE);
}
示例11: serveScraperPages
/**
* Handles scraper pages
*
* @param array $segments URL segments
* @return bool
*/
public static function serveScraperPages($segments)
{
$url = get_input('url');
if (!elgg_is_logged_in()) {
$m = get_input('m');
if (!$m || !elgg_build_hmac($url)->matchesToken($m)) {
return false;
}
}
$viewtype = array_shift($segments);
if (!$viewtype || !elgg_is_registered_viewtype($viewtype)) {
$viewtype = 'default';
}
elgg_set_viewtype($viewtype);
echo elgg_view_resource('scraper/card', ['href' => $url, 'iframe' => get_input('iframe', false)]);
return true;
}
示例12: page_handler
/**
* Handles TinCan pages
*
* @param array $segments URL segments
* @param string $identifier Page ID
* @return boolean
*/
function page_handler($segments, $identifier)
{
$page = elgg_extract(0, $segments);
switch ($page) {
case 'verbs':
elgg_set_viewtype('json');
set_input('verb', $segments[1]);
echo elgg_view('resources/tincan/verbs');
return true;
case 'activities':
elgg_set_viewtype('json');
set_input('activity', $segments[1]);
echo elgg_view('resources/tincan/activities');
return true;
}
return false;
}
示例13: mobile_detect
function mobile_detect()
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
//detect if there is a mobile device
if (preg_match('/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|iemobile|windows ce|nokia|fennec|hiptop|kindle|mot |mot-|webos\\/|samsung|sonyericsson|^sie-|nintendo/', $useragent) || preg_match('/mobile|pda;|avantgo|eudoraweb|minimo|netfront|brew|teleca|lg;|lge |wap;| wap /', $useragent && !strstr($useragent, 'ipad'))) {
$mobile = true;
} else {
$mobile = false;
}
//if there is a mobile device
if ($mobile == true) {
if ($_SESSION['view_desktop']) {
elgg_extend_view('page/elements/head', 'mobile/desktop');
} else {
elgg_set_viewtype('mobile');
}
}
}
示例14: zhaohu_theme_init
function zhaohu_theme_init()
{
// check mobile view
check_mobile_mode();
// include css files of this mod
elgg_extend_view('css/elgg', 'zhaohu_theme/css');
elgg_register_css('elgg.mobile', '/css/mobile.css');
elgg_register_css('elgg.mobilize', '/css/mobilize.css');
elgg_register_action("zhaohu/switch_view", dirname(__FILE__) . "/actions/zhaohu/switch_view.php", "public");
if (elgg_get_viewtype() == "mobile") {
zhaohu_mobile_theme_init();
} else {
// TODO: this needs to be changed to zhaohu_desktop_theme_init() after development is done.
// zhaohu_mobile_theme_init();
// elgg_set_viewtype('mobile');
// Real code
zhaohu_desktop_theme_init();
elgg_set_viewtype('default');
}
}
示例15: handle
/**
* {@inheritdoc}
*/
protected function handle()
{
$action = trim($this->argument('action_name'), '/');
$path_key = Application::GET_PATH_KEY;
$uri = "action/{$action}";
$parameters = [];
$query = trim((string) $this->option('query'), '?');
parse_str($query, $parameters);
$ts = time();
$parameters['__elgg_ts'] = $ts;
$parameters['__elgg_token'] = _elgg_services()->actions->generateActionToken($ts);
$request = Request::create("?{$path_key}=" . urlencode($uri), 'POST', $parameters);
$cookie_name = _elgg_services()->config->getCookieConfig()['session']['name'];
$session_id = _elgg_services()->session->getId();
$request->cookies->set($cookie_name, $session_id);
$request->headers->set('Referer', elgg_normalize_url('cli'));
$request->headers->set('X-Elgg-Ajax-API', 2);
elgg_set_viewtype('json');
_elgg_services()->setValue('request', $request);
Application::index();
}