本文整理汇总了PHP中p_get_first_heading函数的典型用法代码示例。如果您正苦于以下问题:PHP p_get_first_heading函数的具体用法?PHP p_get_first_heading怎么用?PHP p_get_first_heading使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p_get_first_heading函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_first_heading
function get_first_heading($page)
{
$heading = p_get_first_heading($page);
if (!isset($heading)) {
$heading = $page;
}
return $heading;
}
示例2: buildTitle
private function buildTitle($idMainPage, $defaultTitle)
{
if (!is_null($idMainPage)) {
$title = p_get_first_heading($idMainPage, true);
if (!is_null($title) && $this->useTitle) {
return $title;
}
}
return $defaultTitle;
}
示例3: 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))));
}
示例4: indexmenu_search_index
function indexmenu_search_index(&$data, $base, $file, $type, $lvl, $opts)
{
global $conf;
$ret = true;
$item = array();
if ($type == 'f' && !preg_match('#\\.txt$#', $file)) {
// don't add
return false;
}
// get page id by filename
$id = pathID($file);
// check hiddens
if ($type == 'f' && isHiddenPage($id)) {
return false;
}
// bugfix for the
// /ns/
// /<ns>.txt
// case, need to force the 'directory' type
if ($type == 'f' && file_exists(dirname(wikiFN($id . ":" . noNS($id))))) {
$type = 'd';
}
// page target id = global id
$target = $id;
if ($type == 'd') {
// this will check 3 kinds of headpage:
// 1. /<ns>/<ns>.txt
// 2. /<ns>/
// /<ns>.txt
// 3. /<ns>/
// /<ns>/<start_page>
$nsa = array($id . ":" . noNS($id), $id, $id . ":" . $conf['start']);
$nspage = false;
foreach ($nsa as $nsp) {
if (@file_exists(wikiFN($nsp)) && auth_quickaclcheck($nsp) >= AUTH_READ) {
$nspage = $nsp;
break;
}
}
//headpage exists
if ($nspage) {
$target = $nspage;
} else {
// open namespace index, if headpage does not exists
$target = $target . ':';
}
}
$data[] = array('id' => $id, 'date' => @filectime(wikiFN($target)), 'type' => $type, 'target' => $target, 'title' => $conf['useheading'] && ($title = p_get_first_heading($target)) ? $title : $id, 'level' => $lvl);
if (substr_count($id, ":") > 2) {
$ret = 0;
}
return $ret;
}
示例5: tagToName
private function tagToName($t)
{
$exists = false;
$id = $t;
resolve_pageID($this->tagplugin->namespace, $id, $exists);
$name = p_get_first_heading($id, false);
if (empty($name)) {
$name = $t;
} else {
$name = $name;
}
return $name;
}
示例6: CreateDefault
public function CreateDefault()
{
global $ID;
$data = array();
$data['FB']['url'] = wl($ID, null, true);
$data['FB']['title'] = p_get_first_heading($ID);
$text = "";
$data['FB']['description'] = $text;
$data['FB']['site_name'] = "FYKOS";
//var_dump(p_get_metadata($ID,'relation'));
$data['FB']['image'] = ml($this->getConf('default_image'), array('w' => 600, 'h' => 600), true, '&', true);
$data['FB']['type'] = "website";
$data['FB']['locale'] = 'cs_CZ';
return $data;
}
示例7: 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>';
}
示例8: search_universal
//.........这里部分代码省略.........
$return = true;
// get ID and check if it is a valid one
$item['id'] = pathID($file);
if ($item['id'] != cleanID($item['id'])) {
if ($opts['showmsg']) {
msg(hsc($item['id']) . ' is not a valid file name for DokuWiki - skipped', -1);
}
return false;
// skip non-valid files
}
$item['ns'] = getNS($item['id']);
if ($type == 'd') {
// decide if to recursion into this directory is wanted
if (!$opts['depth']) {
$return = true;
// recurse forever
} else {
$depth = substr_count($file, '/');
if ($depth >= $opts['depth']) {
$return = false;
// depth reached
} else {
$return = true;
}
}
if ($return && !preg_match('/' . $opts['recmatch'] . '/', $file)) {
$return = false;
// doesn't match
}
}
// check ACL
if (!$opts['skipacl']) {
if ($type == 'd') {
$item['perm'] = auth_quickaclcheck($item['id'] . ':*');
} else {
$item['perm'] = auth_quickaclcheck($item['id']);
//FIXME check namespace for media files
}
} else {
$item['perm'] = AUTH_DELETE;
}
// are we done here maybe?
if ($type == 'd') {
if (!$opts['listdirs']) {
return $return;
}
if (!$opts['skipacl'] && $opts['sneakyacl'] && $item['perm'] < AUTH_READ) {
return false;
}
//neither list nor recurse
if ($opts['dirmatch'] && !preg_match('/' . $opts['dirmatch'] . '/', $file)) {
return $return;
}
if ($opts['nsmatch'] && !preg_match('/' . $opts['nsmatch'] . '/', $item['ns'])) {
return $return;
}
} else {
if (!$opts['listfiles']) {
return $return;
}
if (!$opts['skipacl'] && $item['perm'] < AUTH_READ) {
return $return;
}
if ($opts['pagesonly'] && substr($file, -4) != '.txt') {
return $return;
}
if (!$conf['showhidden'] && isHiddenPage($id)) {
return $return;
}
if ($opts['filematch'] && !preg_match('/' . $opts['filematch'] . '/', $file)) {
return $return;
}
if ($opts['idmatch'] && !preg_match('/' . $opts['idmatch'] . '/', $item['id'])) {
return $return;
}
}
// still here? prepare the item
$item['type'] = $type;
$item['level'] = $lvl;
$item['open'] = $return;
if ($opts['meta']) {
$item['file'] = basename($file);
$item['size'] = filesize($base . '/' . $file);
$item['mtime'] = filemtime($base . '/' . $file);
$item['rev'] = $item['mtime'];
$item['writable'] = is_writable($base . '/' . $file);
$item['executable'] = is_executable($base . '/' . $file);
}
if ($type == 'f') {
if ($opts['hash']) {
$item['hash'] = md5(io_readFile($base . '/' . $file, false));
}
if ($opts['firsthead']) {
$item['title'] = p_get_first_heading($item['id'], false);
}
}
// finally add the item
$data[] = $item;
return $return;
}
示例9: _getLinkTitle
/**
* Construct a title and handle images in titles
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @param string|array $title either string title or media array
* @param string $default default title if nothing else is found
* @param bool $isImage will be set to true if it's a media file
* @param null|string $id linked page id (used to extract title from first heading)
* @param string $linktype content|navigation
* @return string HTML of the title, might be full image tag or just escaped text
*/
function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content')
{
$isImage = false;
if (is_array($title)) {
$isImage = true;
return $this->_imageTitle($title);
} elseif (is_null($title) || trim($title) == '') {
if (useHeading($linktype) && $id) {
$heading = p_get_first_heading($id);
if ($heading) {
return $this->_xmlEntities($heading);
}
}
return $this->_xmlEntities($default);
} else {
return $this->_xmlEntities($title);
}
}
示例10: get_pages
/**
* Adds all pages of a specific namespace to the pages array.
*
* @param pages pre-initialised pages array.
* @param ns Namespace in which to look for pages.
* @param depth Search depth.
* @param use_first_header (optional) Includes the first header as page title.
*/
function get_pages(&$pages, $ns, $depth = 0, $use_first_header = false)
{
global $conf;
// find pages
$search_results = array();
search($search_results, $conf['datadir'], 'search_universal', array('depth' => $depth, 'listfiles' => true, 'listdirs' => false, 'pagesonly' => true, 'skipacl' => true, 'firsthead' => true, 'meta' => true), str_replace(':', '/', $ns));
// Start page of the namespace
if ($ns && page_exists($ns)) {
// Add to the search results
$search_results[] = array('id' => $ns, 'ns' => getNS($ns), 'title' => p_get_first_heading($ns, false), 'size' => filesize(wikiFN($ns)), 'mtime' => filemtime(wikiFN($ns)), 'perm' => 16, 'type' => 'f', 'level' => 0, 'open' => 1);
}
// loop through the pages
while ($item = array_shift($search_results)) {
// Check that the user is allowed to read the page
if (auth_quickaclcheck($item['id']) > AUTH_READ) {
continue;
}
// Check that the user is allowed to read the page
if (auth_quickaclcheck($item['ns']) > AUTH_READ) {
continue;
}
// Get the create time
$time = (int) p_get_metadata($item['id'], 'date created', false);
if (!$time) {
$time = $item['mtime'];
}
// Get specific language part
$lang = $transplugin ? $transplugin->getLangPart($item['id']) : '';
if ($lang) {
$item['ns'] = preg_replace('/^' . $lang . '(:|$)/', '', $item['ns']);
}
if ($use_first_header) {
$title = $item['title'];
} else {
// Use the last part of the id for the name
$title = ucwords(substr(strrchr(strtr($item['id'], '_', ' '), ':'), 1));
}
// Add the page to the page list
$pages[$item['id']] = array('title' => $title, 'ns' => $item['ns'], 'size' => $item['size'], 'time' => $time, 'links' => array(), 'media' => array(), 'lang' => $lang);
}
}
示例11: idx_addPage
/**
* Adds/updates the search for the given page
*
* This is the core function of the indexer which does most
* of the work. This function needs to be called with proper
* locking!
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function idx_addPage($page)
{
global $conf;
// load known documents
$page_idx = idx_getIndex('page', '');
// get page id (this is the linenumber in page.idx)
$pid = array_search("{$page}\n", $page_idx);
if (!is_int($pid)) {
$pid = count($page_idx);
// page was new - write back
if (!idx_appendIndex('page', '', "{$page}\n")) {
trigger_error("Failed to write page index", E_USER_ERROR);
return false;
}
}
unset($page_idx);
// free memory
idx_saveIndexLine('title', '', $pid, p_get_first_heading($page, false));
$pagewords = array();
// get word usage in page
$words = idx_getPageWords($page);
if ($words === false) {
return false;
}
if (!empty($words)) {
foreach (array_keys($words) as $wlen) {
$index = idx_getIndex('i', $wlen);
foreach ($words[$wlen] as $wid => $freq) {
if ($wid < count($index)) {
$index[$wid] = idx_updateIndexLine($index[$wid], $pid, $freq);
} else {
// New words **should** have been added in increasing order
// starting with the first unassigned index.
// If someone can show how this isn't true, then I'll need to sort
// or do something special.
$index[$wid] = idx_updateIndexLine('', $pid, $freq);
}
$pagewords[] = "{$wlen}*{$wid}";
}
// save back word index
if (!idx_saveIndex('i', $wlen, $index)) {
trigger_error("Failed to write index", E_USER_ERROR);
return false;
}
}
}
// Remove obsolete index entries
$pageword_idx = trim(idx_getIndexLine('pageword', '', $pid));
if ($pageword_idx !== '') {
$oldwords = explode(':', $pageword_idx);
$delwords = array_diff($oldwords, $pagewords);
$upwords = array();
foreach ($delwords as $word) {
if ($word == '') {
continue;
}
list($wlen, $wid) = explode('*', $word);
$wid = (int) $wid;
$upwords[$wlen][] = $wid;
}
foreach ($upwords as $wlen => $widx) {
$index = idx_getIndex('i', $wlen);
foreach ($widx as $wid) {
$index[$wid] = idx_updateIndexLine($index[$wid], $pid, 0);
}
idx_saveIndex('i', $wlen, $index);
}
}
// Save the reverse index
$pageword_idx = join(':', $pagewords) . "\n";
if (!idx_saveIndexLine('pageword', '', $pid, $pageword_idx)) {
trigger_error("Failed to write word index", E_USER_ERROR);
return false;
}
return true;
}
示例12: tpl_pagename
/**
* 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 printed.
*
* based on tpl_pagetitle in inc/template.php
*/
function tpl_pagename($id = null)
{
global $conf;
if (is_null($id)) {
global $ID;
$id = $ID;
}
$name = $id;
if ($conf['useheading']) {
$title = p_get_first_heading($id);
if ($title) {
$name = $title;
}
}
return hsc($name);
}
示例13: 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;
}
示例14: bootstrap3_conf
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*/
// must be run from within DokuWiki
if (!defined('DOKU_INC')) {
die;
}
if (($ACT == 'show' || defined('DOKU_MEDIADETAIL')) && bootstrap3_conf('showPageIcons')) {
global $ID;
$page_icons = bootstrap3_conf('pageIcons');
$social_share = in_array('social-share', $page_icons);
$social_share_providers = bootstrap3_conf('socialShareProviders');
$help_page = false;
$help_title = null;
if (in_array('help', $page_icons)) {
$help_page = page_findnearest('help', bootstrap3_conf('useACL'));
$help_title = hsc(p_get_first_heading($help_page));
}
?>
<div class="dw-page-icons pull-right hidden-print">
<ul class="list-inline pull-right">
<?php
if (in_array('feed', $page_icons)) {
?>
<li>
<a href="<?php
echo DOKU_URL . 'feed.php';
?>
" title="<?php
echo $lang['btn_recent'];
?>
示例15: _search_index
//.........这里部分代码省略.........
//Search optional namespaces
if (!empty($opts['nss'])) {
$nss = $opts['nss'];
for ($a = 0; $a < count($nss); $a++) {
if (preg_match("/^" . $id . "(\$|:.+)/i", $nss[$a][0], $match)) {
//It contains an optional namespace
$isopen = true;
} elseif (preg_match("/^" . $nss[$a][0] . "(:.*)/i", $id, $match)) {
//It's inside an optional namespace
if ($nss[$a][1] == -1 || substr_count($match[1], ":") < $nss[$a][1]) {
$isopen = true;
} else {
$isopen = false;
}
}
}
}
if ($opts['nons']) {
return $isopen;
} elseif ($opts['max'] > 0 && !$isopen && $lvl >= $opts['max']) {
$isopen = false;
//Stop recursive searching
$return = false;
//change type
$type = "l";
} elseif ($opts['js']) {
$return = true;
} else {
$return = $isopen;
}
//Set title and headpage
$title = $this->_getTitle($id, $headpage, $hns);
if (!$hns && $opts['nopg']) {
$hns = $id . ":" . $conf['start'];
}
} else {
//Nopg.Dont show pages
if ($opts['nopg']) {
return false;
}
$return = true;
//Nons.Set all pages at first level
if ($opts['nons']) {
$lvl = 1;
}
//don't add
if (substr($file, -4) != '.txt') {
return false;
}
//check hiddens and acl
if (isHiddenPage($id) || auth_quickaclcheck($id) < AUTH_READ) {
return false;
}
//Skip files in plugin conf
if (!empty($skip_file) && preg_match($skip_file, $id)) {
return false;
}
//Skip headpages to hide
if (!$opts['nons'] && !empty($headpage) && $opts['hide_headpage']) {
if ($id == $conf['start']) {
return false;
}
$ahp = explode(",", $headpage);
foreach ($ahp as $hp) {
switch ($hp) {
case ":inside:":
if (noNS($id) == noNS(getNS($id))) {
return false;
}
break;
case ":same:":
if (@is_dir(dirname(wikiFN($id)) . "/" . utf8_encodeFN(noNS($id)))) {
return false;
}
break;
//it' s an inside start
//it' s an inside start
case ":start:":
if (noNS($id) == $conf['start']) {
return false;
}
break;
default:
if (noNS($id) == cleanID($hp)) {
return false;
}
}
}
}
//Set title
if (!$conf['useheading'] || !($title = p_get_first_heading($id, FALSE))) {
$title = noNS($id);
}
$title = htmlspecialchars($title, ENT_QUOTES);
}
$item = array('id' => $id, 'type' => $type, 'level' => $lvl, 'open' => $isopen, 'title' => $title, 'hns' => $hns, 'file' => $file, 'return' => $return);
$item['sort'] = $this->_setorder($item);
$data[] = $item;
return $return;
}