本文整理汇总了PHP中elgg_get_viewtype函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_viewtype函数的具体用法?PHP elgg_get_viewtype怎么用?PHP elgg_get_viewtype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_viewtype函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: linkfix
/**
* hook called on view, all
* check if there is an internal link using an old handler
* convert it to a new handler
*
* @param type $hook
* @param type $type
* @param type $returnvalue
* @param type $params
* @return array
*/
function linkfix($hook, $type, $returnvalue, $params)
{
if (elgg_get_viewtype() == 'failsafe') {
return $returnvalue;
}
return handler_replace($returnvalue);
}
示例2: legacy_urls_redirect
/**
* Redirect the requestor to the new URL
* Checks the plugin setting to determine the course of action:
* a) Displays an error page with the new URL
* b) Forwards to the new URL and displays an error message
* c) Silently forwards to the new URL
*
* @param string $url Relative or absolute URL
* @return mixed
*/
function legacy_urls_redirect($url)
{
$method = elgg_get_plugin_setting('redirect_method', 'legacy_urls');
// we only show landing page or queue warning if html generating page
$viewtype = elgg_get_viewtype();
if ($viewtype != 'default' && !elgg_does_viewtype_fallback($viewtype)) {
$method = 'immediate';
}
switch ($method) {
case 'landing':
$content = elgg_view('legacy_urls/message', array('url' => $url));
$body = elgg_view_layout('error', array('content' => $content));
echo elgg_view_page('', $body, 'error');
return true;
break;
case 'immediate_error':
// drop through after setting error message
register_error(elgg_echo('changebookmark'));
case 'immediate':
default:
$url = elgg_normalize_url($url);
header("HTTP/1.1 301 Moved Permanently");
header("Location: {$url}");
exit;
break;
}
}
示例3: linkup_event_handler
/**
* Markup function
*
* Detect linkup patterns and make links where needed.
*
* Matches a marker character followed by printable characters, and
* prefixed to avoid matching CSS DOM IDs. First match is the prefix,
* second the marker, and third is the subject.
*/
function linkup_event_handler($hook, $type, $returnvalue, $params)
{
if (elgg_get_viewtype() != 'default') {
// only mess with html views
return $returnvalue;
}
$html = mb_convert_encoding($returnvalue['content'], 'HTML-ENTITIES', 'UTF-8');
if (empty($html)) {
return $returnvalue;
}
libxml_use_internal_errors(TRUE);
try {
$dom = new DOMDocument();
$dom->loadHTML($html);
foreach ($dom->childNodes as $node) {
linkup_dom_recurse($node, 'linkup_dom_replace');
}
// Remove tags added by DOMDocument
$matches = array('/^\\<\\!DOCTYPE.*?<html[^>]*><body[^>]*>/isu', '|</body></html>$|isu');
$content = preg_replace($matches, '', $dom->saveHTML());
// convert back to original encoding
$returnvalue['content'] = mb_convert_encoding($content, 'UTF-8', 'HTML-ENTITIES');
} catch (Exception $e) {
error_log("===== linkup error {$e->class} {$e->message}");
}
return $returnvalue;
}
示例4: testElggGetViewtype
public function testElggGetViewtype()
{
$this->assertEquals('default', elgg_get_viewtype());
set_input('view', 'foo');
$this->assertEquals('foo', elgg_get_viewtype());
set_input('view', 'a;b');
$this->assertEquals('default', elgg_get_viewtype());
}
示例5: testSettingConfigDoesNotChangeViewtype
public function testSettingConfigDoesNotChangeViewtype()
{
global $CONFIG;
$this->assertEquals('default', elgg_get_viewtype());
$CONFIG->view = 'foo';
$this->assertEquals('default', elgg_get_viewtype());
unset($CONFIG->view);
}
示例6: mobile_init
/**
* Elgg Mobile
* A Mobile Client For Elgg
*
* @package Elgg
* @subpackage Core
* @author kramnorth (Mark Harding)
* @link http://kramnorth.com
*
*/
function mobile_init()
{
//elgg_extend_view('page/elements/head','mobile/metatags');
mobile_detect();
elgg_extend_view('css/elgg', 'mobile/css');
//set our default index page
if (elgg_get_viewtype() == "mobile") {
elgg_register_plugin_hook_handler('index', 'system', 'main_handler');
}
}
示例7: getRoot
/**
* Get the base url for simple cache requests
*
* @return string The simplecache root url for the current viewtype.
* @access private
*/
function getRoot()
{
$viewtype = elgg_get_viewtype();
if (elgg_is_simplecache_enabled()) {
// stored in datalist as 'simplecache_lastupdate'
$lastcache = (int) _elgg_services()->config->get('lastcache');
} else {
$lastcache = 0;
}
return elgg_normalize_url("/cache/{$lastcache}/{$viewtype}/");
}
示例8: reportedcontent_user_hover_menu
/**
* Add report user link to hover menu
*/
function reportedcontent_user_hover_menu($hook, $type, $return, $params)
{
$user = $params['entity'];
$profile_url = urlencode($user->getURL());
$name = urlencode($user->name);
$url = "reportedcontent/add?address={$profile_url}&title={$name}";
if (elgg_is_logged_in() && elgg_get_logged_in_user_guid() != $user->guid && elgg_get_viewtype() == 'default') {
$item = new ElggMenuItem('reportuser', elgg_echo('reportedcontent:user'), $url);
$item->setSection('action');
$return[] = $item;
}
return $return;
}
示例9: view_hook
function view_hook($h, $t, $r, $p)
{
if (elgg_get_viewtype() != 'default') {
return $r;
}
if (strpos($t, 'forms/') !== 0) {
return $r;
}
$actions = get_recaptcha_actions();
$formname = substr($t, 6);
if (in_array($formname, $actions)) {
$r .= elgg_view('input/recaptcha', array('form' => '.elgg-form-' . str_replace('_', '-', str_replace('/', '-', $formname))));
}
return $r;
}
示例10: elgg_dev_tools_outline_views
/**
* Post-process a view to add a wrapper div
*/
function elgg_dev_tools_outline_views($hook, $entity_type, $returnvalue, $params)
{
global $CONFIG;
if (elgg_get_viewtype() != "default") {
return;
}
$excluded_bases = array('css', 'js', 'input', 'output', 'embed', 'pageshells', 'metatags', 'icon');
$excluded_views = array('page_elements/header', 'page_elements/header_contents', 'page_elements/footer', 'riverdashboard/js');
$view = $params['view'];
$view_hierarchy = explode('/', $view);
if (in_array($view_hierarchy[0], $excluded_bases)) {
return;
}
if (in_array($view, $excluded_views)) {
return;
}
$return_data = "<div id=\"view-{$view}\">{$returnvalue}</div>";
return $return_data;
}
示例11: developers_wrap_views
/**
* Post-process a view to add wrapper comments to it
*
* 1. Only process views served with the 'default' viewtype.
* 2. Does not wrap views that begin with js/ or css/ as they are not HTML.
* 3. Does not wrap views that are images (start with icon/). Is this still true?
* 4. Does not wrap input and output views (why?).
* 5. Does not wrap html head or the primary page shells
*
* @warning this will break views in the default viewtype that return non-HTML data
* that do not match the above restrictions.
*/
function developers_wrap_views($hook, $type, $result, $params)
{
if (elgg_get_viewtype() != "default") {
return;
}
$excluded_bases = array('css', 'js', 'input', 'output', 'embed', 'icon');
$excluded_views = array('page/default', 'page/admin', 'page/elements/head');
$view = $params['view'];
$view_hierarchy = explode('/', $view);
if (in_array($view_hierarchy[0], $excluded_bases)) {
return;
}
if (in_array($view, $excluded_views)) {
return;
}
if ($result) {
$result = "<!-- developers:begin {$view} -->{$result}<!-- developers:end {$view} -->";
}
return $result;
}
示例12: 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');
}
}
示例13: wire_init
/**
* The Wire initialization
*/
function wire_init()
{
// register the wire's JavaScript
$wire_js = elgg_get_simplecache_url('js', 'wire');
elgg_register_simplecache_view('js/wire');
elgg_register_js('elgg.wire', $wire_js);
elgg_register_ajax_view('wire/previous');
elgg_register_ajax_view('wire/replyinline');
// add a site navigation item
$item = new ElggMenuItem('wire', elgg_echo('wire'), 'wire/all');
elgg_register_menu_item('site', $item);
// owner block menu
if (elgg_get_viewtype() == 'default') {
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'wire_owner_block_menu');
}
// remove edit and access and add thread, reply, view previous
elgg_register_plugin_hook_handler('register', 'menu:entity', 'wire_setup_entity_menu_items');
// Extend system CSS with our own styles, which are defined in the wire/css view
elgg_extend_view('css/elgg', 'wire/css');
//extend views
elgg_extend_view('activity/wire', 'wire/activity_view');
//elgg_extend_view('profile/status', 'wire/profile_status');
elgg_extend_view('js/initialise_elgg', 'wire/js/textcounter');
// Register a page handler, so we can have nice URLs
elgg_register_page_handler('wire', 'wire_page_handler');
// Register a URL handler for wire posts
elgg_register_entity_url_handler('object', 'wire', 'wire_url');
elgg_register_widget_type('wire', elgg_echo('wire'), elgg_echo("wire:widget:desc"));
// Register for search
elgg_register_entity_type('object', 'wire');
// Register granular notification for this type
register_notification_object('object', 'wire', elgg_echo('wire:notify:subject'));
// Listen to notification events and supply a more useful message
elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'wire_notify_message');
// Register actions
$action_base = elgg_get_plugins_path() . 'wire/actions';
elgg_register_action("wire/add", "{$action_base}/add.php");
elgg_register_action("wire/delete", "{$action_base}/delete.php");
elgg_register_plugin_hook_handler('unit_test', 'system', 'wire_test');
}
示例14: isCacheableView
/**
* @access private
*/
public function isCacheableView($view)
{
$view = $this->canonicalizeViewName($view);
if (isset($this->simplecache_views[$view])) {
return true;
}
// build list of viewtypes to check
$current_viewtype = elgg_get_viewtype();
$viewtypes = array($current_viewtype);
if ($this->doesViewtypeFallback($current_viewtype) && $current_viewtype != 'default') {
$viewtypes[] = 'default';
}
// If a static view file is found in any viewtype, it's considered cacheable
foreach ($viewtypes as $viewtype) {
$file = $this->findViewFile($view, $viewtype);
if ($file && pathinfo($file, PATHINFO_EXTENSION) !== 'php') {
$this->simplecache_views[$view] = true;
return true;
}
}
// Assume not-cacheable by default
return false;
}
示例15: elgg_view
if (!$draw_page) {
echo elgg_view("bookmark_tools/list/bookmarks", array("bmfolder" => $folder, "bookmarks" => $bookmarks, 'sort_by' => $sort_by, 'direction' => $direction));
} else {
// build breadcrumb
elgg_push_breadcrumb(elgg_echo('bookmarks'), "bookmarks/all");
elgg_push_breadcrumb($page_owner->name);
// register title button to add a new bookmark
elgg_register_title_button();
// get data for tree
$folders = bookmark_tools_get_folders($page_owner_guid);
// build page elements
$title_text = elgg_echo("bookmarks:owner", array($page_owner->name));
$body = elgg_view("bookmark_tools/list/bookmarks", array("bmfolder" => $folder, "bookmarks" => $bookmarks, 'sort_by' => $sort_by, 'direction' => $direction));
//$body = "<div id='bookmark_tools_list_bookmarks_container'>" . elgg_view("graphics/ajax_loader", array("hidden" => false)) . "</div>";
//$body = "<div id='bookmark_tools_list_bookmarks_container'>" . elgg_view("bookmark_tools/list/bookmarks", array("bmfolder" => $folder, "bookmarks" => $bookmarks, 'sort_by' => $sort_by, 'direction' => $direction)) . "</div>";
if (elgg_get_viewtype() == 'default') {
$body = "<div id='bookmark_tools_list_bookmarks_container'>" . $body . "</div>";
}
// make sidebar
$sidebar = elgg_view("bookmark_tools/list/tree", array("bmfolder" => $folder, "bmfolders" => $folders));
$sidebar .= elgg_view("bookmark_tools/sidebar/sort_options");
$sidebar .= elgg_view("bookmark_tools/sidebar/info");
$sidebar .= elgg_view('page/elements/tagcloud_block', array('subtypes' => 'bookmarks', 'owner_guid' => elgg_get_page_owner_guid()));
// build page params
$params = array('title' => $title_text, 'content' => $body, 'sidebar' => $sidebar);
if (elgg_instanceof($page_owner, "user")) {
if ($page_owner->guid == elgg_get_logged_in_user_guid()) {
$params["filter_context"] = "mine";
} else {
$params["filter_context"] = $page_owner->username;
}