本文整理汇总了PHP中useHeading函数的典型用法代码示例。如果您正苦于以下问题:PHP useHeading函数的具体用法?PHP useHeading怎么用?PHP useHeading使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了useHeading函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajax_qsearch
/**
* Searches for matching pagenames
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function ajax_qsearch()
{
global $conf;
global $lang;
global $INPUT;
$query = $INPUT->post->str('q');
if (empty($query)) {
$query = $INPUT->get->str('q');
}
if (empty($query)) {
return;
}
$query = urldecode($query);
$data = ft_pageLookup($query, true, useHeading('navigation'));
if (!count($data)) {
return;
}
print '<strong>' . $lang['quickhits'] . '</strong>';
print '<ul>';
foreach ($data as $id => $title) {
if (useHeading('navigation')) {
$name = $title;
} else {
$ns = getNS($id);
if ($ns) {
$name = noNS($id) . ' (' . $ns . ')';
} else {
$name = $id;
}
}
echo '<li>' . html_wikilink(':' . $id, $name) . '</li>';
}
print '</ul>';
}
示例2: js_out
/**
* Output all needed JavaScript
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function js_out()
{
global $conf;
global $lang;
global $config_cascade;
// The generated script depends on some dynamic options
$cache = new cache('scripts' . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.js');
$cache->_event = 'JS_CACHE_USE';
// load minified version for some files
$min = $conf['compress'] ? '.min' : '';
// array of core files
$files = array(DOKU_INC . "lib/scripts/jquery/jquery{$min}.js", DOKU_INC . 'lib/scripts/jquery/jquery.cookie.js', DOKU_INC . "lib/scripts/jquery/jquery-ui{$min}.js", DOKU_INC . "lib/scripts/fileuploader.js", DOKU_INC . "lib/scripts/fileuploaderextended.js", DOKU_INC . 'lib/scripts/helpers.js', DOKU_INC . 'lib/scripts/delay.js', DOKU_INC . 'lib/scripts/cookie.js', DOKU_INC . 'lib/scripts/script.js', DOKU_INC . 'lib/scripts/tw-sack.js', DOKU_INC . 'lib/scripts/qsearch.js', DOKU_INC . 'lib/scripts/tree.js', DOKU_INC . 'lib/scripts/index.js', DOKU_INC . 'lib/scripts/drag.js', DOKU_INC . 'lib/scripts/textselection.js', DOKU_INC . 'lib/scripts/toolbar.js', DOKU_INC . 'lib/scripts/edit.js', DOKU_INC . 'lib/scripts/editor.js', DOKU_INC . 'lib/scripts/locktimer.js', DOKU_INC . 'lib/scripts/linkwiz.js', DOKU_INC . 'lib/scripts/media.js', DOKU_INC . 'lib/scripts/compatibility.js', DOKU_INC . 'lib/scripts/behaviour.js', DOKU_INC . 'lib/scripts/page.js', tpl_incdir() . 'script.js');
// add possible plugin scripts and userscript
$files = array_merge($files, js_pluginscripts());
if (isset($config_cascade['userscript']['default'])) {
$files[] = $config_cascade['userscript']['default'];
}
$cache_files = array_merge($files, getConfigFiles('main'));
$cache_files[] = __FILE__;
// check cache age & handle conditional request
// This may exit if a cache can be used
$cache_ok = $cache->useCache(array('files' => $cache_files));
http_cached($cache->cache, $cache_ok);
// start output buffering and build the script
ob_start();
// add some global variables
print "var DOKU_BASE = '" . DOKU_BASE . "';";
print "var DOKU_TPL = '" . tpl_basedir() . "';";
// FIXME: Move those to JSINFO
print "var DOKU_UHN = " . (int) useHeading('navigation') . ";";
print "var DOKU_UHC = " . (int) useHeading('content') . ";";
// load JS specific translations
$json = new JSON();
$lang['js']['plugins'] = js_pluginstrings();
echo 'LANG = ' . $json->encode($lang['js']) . ";\n";
// load toolbar
toolbar_JSdefines('toolbar');
// load files
foreach ($files as $file) {
echo "\n\n/* XXXXXXXXXX begin of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
js_load($file);
echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
}
// init stuff
if ($conf['locktime'] != 0) {
js_runonstart("dw_locktimer.init(" . ($conf['locktime'] - 60) . "," . $conf['usedraft'] . ")");
}
// init hotkeys - must have been done after init of toolbar
# disabled for FS#1958 js_runonstart('initializeHotkeys()');
// end output buffering and get contents
$js = ob_get_contents();
ob_end_clean();
// compress whitespace and comments
if ($conf['compress']) {
$js = js_compress($js);
}
$js .= "\n";
// https://bugzilla.mozilla.org/show_bug.cgi?id=316033
http_cached_finish($cache->cache, $js);
}
示例3: ajax_qsearch
/**
* Searches for matching pagenames
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function ajax_qsearch()
{
global $conf;
global $lang;
$query = $_POST['q'];
if (empty($query)) {
$query = $_GET['q'];
}
if (empty($query)) {
return;
}
$data = ft_pageLookup($query, true, useHeading('navigation'));
if (!count($data)) {
return;
}
print '<strong>' . $lang['quickhits'] . '</strong>';
print '<ul>';
foreach ($data as $id => $title) {
if (useHeading('navigation')) {
$name = $title;
} else {
$ns = getNS($id);
if ($ns) {
$name = shorten(noNS($id), ' (' . $ns . ')', 30);
} else {
$name = $id;
}
}
echo '<li>' . html_wikilink(':' . $id, $name) . '</li>';
}
print '</ul>';
}
示例4: getSiteTitle
/**
* get the Title for the page
**/
public function getSiteTitle($ID)
{
if (useHeading('content') && $ID) {
$heading = p_get_first_heading($ID, true);
if ($heading) {
return $this->xmlEntities($heading);
}
}
return ucwords($this->xmlEntities(array_pop(explode(':', $ID))));
}
示例5: render
function render($mode, &$R, &$T, $value, $hint)
{
$heading = null;
// only use heading if allowed by configuration
if (useHeading('content')) {
$titles = $T->fetchTriples($value, $this->util->getTitleKey());
if ($titles) {
$heading = $titles[0]['object'];
}
}
// render internal link
// (':' is prepended to make sure we use an absolute pagename,
// internallink resolves page names, but the name is already resolved.)
$R->internallink(':' . $value, $heading);
}
示例6: ajax_qsearch
/**
* Searches for matching pagenames
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function ajax_qsearch()
{
global $lang;
global $INPUT;
$maxnumbersuggestions = 50;
$query = $INPUT->post->str('q');
if (empty($query)) {
$query = $INPUT->get->str('q');
}
if (empty($query)) {
return;
}
$query = urldecode($query);
$data = ft_pageLookup($query, true, useHeading('navigation'));
if (!count($data)) {
return;
}
print '<strong>' . $lang['quickhits'] . '</strong>';
print '<ul>';
$counter = 0;
foreach ($data as $id => $title) {
if (useHeading('navigation')) {
$name = $title;
} else {
$ns = getNS($id);
if ($ns) {
/* Displays the Header of the Namespace-Page or of namespace:start as the Name of the NS */
$ns_name = p_get_first_heading(getNS($id));
if (!$ns_name) {
$ns_name = p_get_first_heading(getNS($id) . ':start');
}
$name = shorten(' [' . $ns_name . ']', 30);
} else {
$name = $id;
}
}
echo '<li>' . html_wikilink(':' . $id, $name) . '</li>';
$counter++;
if ($counter > $maxnumbersuggestions) {
echo '<li>...</li>';
break;
}
}
print '</ul>';
}
示例7: _custom_delete_page
function _custom_delete_page($id, $summary)
{
global $ID, $INFO, $conf;
// mark as nonexist to prevent indexerWebBug
if ($id == $ID) {
$INFO['exists'] = 0;
}
// delete page, meta and attic
$file = wikiFN($id);
$old = @filemtime($file);
// from page
if (file_exists($file)) {
unlink($file);
}
$opts['oldname'] = $this->_FN(noNS($id));
$opts['oldns'] = $this->_FN(getNS($id));
if ($opts['oldns']) {
$opts['oldns'] .= '/';
}
$this->_locate_filepairs($opts, 'metadir', '/^' . $opts['oldname'] . '\\.(?!mlist)\\w*?$/');
$this->_locate_filepairs($opts, 'olddir', '/^' . $opts['oldname'] . '\\.\\d{10}\\.txt(\\.gz|\\.bz2)?$/');
$this->_apply_deletes($opts);
io_sweepNS($id, 'datadir');
io_sweepNS($id, 'metadir');
io_sweepNS($id, 'olddir');
// send notify mails
notify($id, 'admin', $old, $summary);
notify($id, 'subscribers', $old, $summary);
// update the purgefile (timestamp of the last time anything within the wiki was changed)
io_saveFile($conf['cachedir'] . '/purgefile', time());
// if useheading is enabled, purge the cache of all linking pages
if (useHeading('content')) {
$pages = ft_backlinks($id);
foreach ($pages as $page) {
$cache = new cache_renderer($page, wikiFN($page), 'xhtml');
$cache->removeCache();
}
}
}
示例8: js_out
/**
* Output all needed JavaScript
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function js_out()
{
global $conf;
global $lang;
global $config_cascade;
// The generated script depends on some dynamic options
$cache = getCacheName('scripts' . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.js');
// array of core files
$files = array(DOKU_INC . 'lib/scripts/helpers.js', DOKU_INC . 'lib/scripts/events.js', DOKU_INC . 'lib/scripts/delay.js', DOKU_INC . 'lib/scripts/cookie.js', DOKU_INC . 'lib/scripts/script.js', DOKU_INC . 'lib/scripts/tw-sack.js', DOKU_INC . 'lib/scripts/ajax.js', DOKU_INC . 'lib/scripts/index.js', DOKU_INC . 'lib/scripts/drag.js', DOKU_INC . 'lib/scripts/textselection.js', DOKU_INC . 'lib/scripts/toolbar.js', DOKU_INC . 'lib/scripts/edit.js', DOKU_INC . 'lib/scripts/linkwiz.js', DOKU_INC . 'lib/scripts/media.js', DOKU_INC . 'lib/scripts/subscriptions.js', DOKU_TPLINC . 'script.js');
// add possible plugin scripts and userscript
$files = array_merge($files, js_pluginscripts());
if (isset($config_cascade['userscript']['default'])) {
$files[] = $config_cascade['userscript']['default'];
}
// check cache age & handle conditional request
header('Cache-Control: public, max-age=3600');
header('Pragma: public');
if (js_cacheok($cache, $files)) {
http_conditionalRequest(filemtime($cache));
if ($conf['allowdebug']) {
header("X-CacheUsed: {$cache}");
}
// finally send output
if ($conf['gzip_output'] && http_gzip_valid($cache)) {
header('Vary: Accept-Encoding');
header('Content-Encoding: gzip');
readfile($cache . ".gz");
} else {
if (!http_sendfile($cache)) {
readfile($cache);
}
}
return;
} else {
http_conditionalRequest(time());
}
// start output buffering and build the script
ob_start();
// add some global variables
print "var DOKU_BASE = '" . DOKU_BASE . "';";
print "var DOKU_TPL = '" . DOKU_TPL . "';";
print "var DOKU_UHN = " . (int) useHeading('navigation') . ";";
print "var DOKU_UHC = " . (int) useHeading('content') . ";";
// load JS specific translations
$json = new JSON();
$lang['js']['plugins'] = js_pluginstrings();
echo 'LANG = ' . $json->encode($lang['js']) . ";\n";
// load toolbar
toolbar_JSdefines('toolbar');
// load files
foreach ($files as $file) {
echo "\n\n/* XXXXXXXXXX begin of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
js_load($file);
echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
}
// init stuff
js_runonstart("addEvent(document,'click',closePopups)");
js_runonstart('addTocToggle()');
js_runonstart("initSizeCtl('size__ctl','wiki__text')");
js_runonstart("initToolbar('tool__bar','wiki__text',toolbar)");
if ($conf['locktime'] != 0) {
js_runonstart("locktimer.init(" . ($conf['locktime'] - 60) . ",'" . js_escape($lang['willexpire']) . "'," . $conf['usedraft'] . ")");
}
js_runonstart('scrollToMarker()');
js_runonstart('focusMarker()');
// init hotkeys - must have been done after init of toolbar
# disabled for FS#1958 js_runonstart('initializeHotkeys()');
// end output buffering and get contents
$js = ob_get_contents();
ob_end_clean();
// compress whitespace and comments
if ($conf['compress']) {
$js = js_compress($js);
}
$js .= "\n";
// https://bugzilla.mozilla.org/show_bug.cgi?id=316033
// save cache file
io_saveFile($cache, $js);
if (function_exists('gzopen')) {
io_saveFile("{$cache}.gz", $js);
}
// finally send output
if ($conf['gzip_output']) {
header('Vary: Accept-Encoding');
header('Content-Encoding: gzip');
print gzencode($js, 9, FORCE_GZIP);
} else {
print $js;
}
}
示例9: search
/**
* List all pages in the given namespace (and below)
*/
function search($query)
{
$regex = '';
$data = ft_pageSearch($query, $regex);
$pages = array();
// prepare additional data
$idx = 0;
foreach ($data as $id => $score) {
$file = wikiFN($id);
if ($idx < FT_SNIPPET_NUMBER) {
$snippet = ft_snippet($id, $regex);
$idx++;
} else {
$snippet = '';
}
$pages[] = array('id' => $id, 'score' => intval($score), 'rev' => filemtime($file), 'mtime' => filemtime($file), 'size' => filesize($file), 'snippet' => $snippet, 'title' => useHeading('navigation') ? p_get_first_heading($id) : $id);
}
return $pages;
}
示例10: tpl_pagetitle
/**
* Prints or returns the name of the given page (current one if none given).
*
* If useheading is enabled this will use the first headline else
* the given ID is used.
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string $id page id
* @param bool $ret return content instead of printing
* @return bool|string
*/
function tpl_pagetitle($id = null, $ret = false)
{
global $ACT, $INPUT, $conf, $lang;
if (is_null($id)) {
global $ID;
$id = $ID;
}
$name = $id;
if (useHeading('navigation')) {
$first_heading = p_get_first_heading($id);
if ($first_heading) {
$name = $first_heading;
}
}
// default page title is the page name, modify with the current action
switch ($ACT) {
// admin functions
case 'admin':
$page_title = $lang['btn_admin'];
// try to get the plugin name
/** @var $plugin DokuWiki_Admin_Plugin */
if ($plugin = plugin_getRequestAdminPlugin()) {
$plugin_title = $plugin->getMenuText($conf['lang']);
$page_title = $plugin_title ? $plugin_title : $plugin->getPluginName();
}
break;
// user functions
// user functions
case 'login':
case 'profile':
case 'register':
case 'resendpwd':
$page_title = $lang['btn_' . $ACT];
break;
// wiki functions
// wiki functions
case 'search':
case 'index':
$page_title = $lang['btn_' . $ACT];
break;
// page functions
// page functions
case 'edit':
$page_title = "✎ " . $name;
break;
case 'revisions':
$page_title = $name . ' - ' . $lang['btn_revs'];
break;
case 'backlink':
case 'recent':
case 'subscribe':
$page_title = $name . ' - ' . $lang['btn_' . $ACT];
break;
default:
// SHOW and anything else not included
$page_title = $name;
}
if ($ret) {
return hsc($page_title);
} else {
print hsc($page_title);
return true;
}
}
示例11: _getLinkTitle
/**
* Construct a title and handle images in titles
*
* @author Harry Fuecks <hfuecks@gmail.com>
*/
function _getLinkTitle($title, $default, $id = NULL)
{
global $conf;
$isImage = false;
if (is_null($title)) {
if (useHeading('content') && $id) {
$heading = p_get_first_heading($id, false);
if ($heading) {
return $heading;
}
}
return $default;
} else {
if (is_string($title)) {
return $title;
} else {
if (is_array($title)) {
return '[' . $title['title'] . ']';
}
}
}
}
示例12: bootstrap3_conf
/**
* Simple wrapper for tpl_getConf
*
* @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
*
* @param string $key
* @param mixed $default value
* @return mixed
*/
function bootstrap3_conf($key, $default = false)
{
global $ACT, $INFO, $ID, $conf;
$value = tpl_getConf($key, $default);
switch ($key) {
case 'showTools':
case 'showSearchForm':
case 'showPageTools':
return $value !== 'never' && ($value == 'always' || !empty($_SERVER['REMOTE_USER']));
case 'showIndividualTool':
case 'hideInThemeSwitcher':
case 'tableStyle':
return explode(',', $value);
case 'showAdminMenu':
return $value && $INFO['isadmin'];
case 'hideLoginLink':
return !$value || !empty($_SERVER['REMOTE_USER']);
case 'browserTitle':
if (bootstrap3_conf('browserTitleShowNS')) {
$ns_parts = explode(':', $ID);
$ns_pages = array();
$ns_titles = array();
$ns_separator = sprintf(' %s ', bootstrap3_conf('browserTitleCharSepNS'));
if (useHeading('navigation')) {
foreach ($ns_parts as $ns_part) {
$ns_page .= "{$ns_part}:";
$ns_pages[] = $ns_page;
}
$ns_pages = array_unique($ns_pages);
foreach ($ns_pages as $ns_page) {
resolve_pageid(getNS($ns_page), $ns_page, $exists);
$ns_page_title_heading = hsc(p_get_first_heading($ns_page));
$ns_page_title_page = noNSorNS($ns_page);
$ns_page_title = $ns_page_title_heading ? $ns_page_title_heading : $ns_page_title_page;
$ns_titles[] = $ns_page_title;
}
$ns_titles[] = tpl_pagetitle($ID, true);
$ns_titles = array_unique($ns_titles);
} else {
$ns_titles = $ns_parts;
}
if (bootstrap3_conf('browserTitleOrderNS') == 'normal') {
$ns_titles = array_reverse($ns_titles);
}
$browser_title = implode($ns_separator, $ns_titles);
} else {
$browser_title = tpl_pagetitle($ID, true);
}
return str_replace(array('@WIKI@', '@TITLE@'), array(strip_tags($conf['title']), $browser_title), $value);
case 'showSidebar':
return page_findnearest($conf['sidebar']) && $ACT == 'show';
case 'showRightSidebar':
return page_findnearest(tpl_getConf('rightSidebar')) && $ACT == 'show';
case 'landingPages':
return sprintf('/%s/', $value);
}
//$type = bootstrap3_metadata($key);
//if ($type[0] == 'regex') {
// return sprintf('/%s/', $value);
//}
return $value;
}
示例13: handle_tpl_act_render
public function handle_tpl_act_render(&$event, $param)
{
global $ID, $ACT;
if ($ACT != 'show' && $ACT != '') {
return;
}
if (!$this->getConf('show_note')) {
return;
}
if (isset($_GET['redirect']) && $_GET['redirect'] > 0 && $_GET['redirect'] < 6) {
if (isset($_SESSION[DOKU_COOKIE]['redirect']) && $_SESSION[DOKU_COOKIE]['redirect'] != '') {
// we were redirected from another page, show it!
$page = cleanID($_SESSION[DOKU_COOKIE]['redirect']);
$title = hsc(useHeading('navigation') && p_get_first_heading($page) ? p_get_first_heading($page) : $page);
echo '<div class="noteredirect">' . sprintf($this->getLang('redirected_from'), '<a href="' . wl(':' . $page, array('redirect' => 'no'), TRUE, '&') . '" class="wikilink1" title="' . $page . '">' . $title . '</a>') . '</div><br/>';
unset($_SESSION[DOKU_COOKIE]['redirect']);
return true;
}
}
return true;
}
示例14: _resolveData
/**
* Resolve a value according to its column settings
*
* This function is registered as a SQL function named DATARESOLVE
*/
function _resolveData($value, $colname)
{
// resolve pre and postfixes
$column = $this->_column($colname);
$value = $this->_addPrePostFixes($column['type'], $value);
// for pages, resolve title
$type = $column['type'];
if (is_array($type)) {
$type = $type['type'];
}
if ($type == 'title' || $type == 'page' && useHeading('content')) {
$value = p_get_first_heading($value);
}
return $value;
}
示例15: tpl_pageName
function tpl_pageName($id)
{
// page names
$name = noNSorNS($id);
if (useHeading('navigation')) {
// get page title
$title = p_get_first_heading($id, METADATA_RENDER_USING_SIMPLE_CACHE);
if ($title) {
$name = $title;
}
}
return $name;
}