本文整理汇总了PHP中utf8_encodeFN函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8_encodeFN函数的具体用法?PHP utf8_encodeFN怎么用?PHP utf8_encodeFN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了utf8_encodeFN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNamespaceFromID
/**
* Returns an utf8 encoded Namespace for a Page and input Namespace
* @param $NS
* @param $PAGE
*/
function getNamespaceFromID($NS, &$PAGE)
{
global $conf;
// Check current page - if its an NS add the startpage
$clean = true;
resolve_pageid(getNS($NS), $NS, $clean);
if (!page_exists($NS) && array_pop(explode(':', $NS)) != strtolower($conf['start'])) {
// Compare to lowercase since clean lowers it.
$NS .= ':' . $conf['start'];
resolve_pageid(getNS($NS), $NS, $clean);
}
$PAGE = noNS($NS);
$NS = getNS($NS);
return utf8_encodeFN(str_replace(':', '/', $NS));
}
示例2: getThreads
/**
* Returns an array of pages with discussion sections, sorted by recent comments
* Note: also used for content by Feed Plugin
*
* @param string $ns
* @param null|int $num
* @param string|bool $skipEmpty
* @return array
*/
function getThreads($ns, $num = null, $skipEmpty = false)
{
global $conf;
require_once DOKU_INC . 'inc/search.php';
$dir = $conf['datadir'] . utf8_encodeFN($ns ? '/' . str_replace(':', '/', $ns) : '');
// returns the list of pages in the given namespace and it's subspaces
$items = array();
search($items, $dir, 'search_allpages', array());
// add pages with comments to result
$result = array();
foreach ($items as $item) {
$id = ($ns ? $ns . ':' : '') . $item['id'];
// some checks
$perm = auth_quickaclcheck($id);
if ($perm < AUTH_READ) {
continue;
}
// skip if no permission
$file = metaFN($id, '.comments');
if (!@file_exists($file)) {
continue;
}
// skip if no comments file
$data = unserialize(io_readFile($file, false));
$status = $data['status'];
$number = $data['number'];
if (!$status || $status == 2 && !$number) {
continue;
}
// skip if comments are off or closed without comments
if ($skipEmpty == 'y' && $number == 0) {
continue;
}
// skip if discussion is empty and flag is set
$date = filemtime($file);
$meta = p_get_metadata($id);
$result[$date . '_' . $id] = array('id' => $id, 'file' => $file, 'title' => $meta['title'], 'date' => $date, 'user' => $meta['creator'], 'desc' => $meta['description']['abstract'], 'num' => $number, 'comments' => $this->td($id, $number), 'status' => $status, 'perm' => $perm, 'exists' => true, 'anchor' => 'discussion__section');
}
// finally sort by time of last comment
krsort($result);
if (is_numeric($num)) {
$result = array_slice($result, 0, $num);
}
return $result;
}
示例3: io_sweepNS
/**
* Removes empty directories
*
* Sends IO_NAMESPACE_DELETED events for 'pages' and 'media' namespaces.
* Event data:
* $data[0] ns: The colon separated namespace path minus the trailing page name.
* $data[1] ns_type: 'pages' or 'media' namespace tree.
*
* @todo use safemode hack
* @author Andreas Gohr <andi@splitbrain.org>
* @author Ben Coburn <btcoburn@silicodon.net>
*/
function io_sweepNS($id, $basedir = 'datadir')
{
global $conf;
$types = array('datadir' => 'pages', 'mediadir' => 'media');
$ns_type = isset($types[$basedir]) ? $types[$basedir] : false;
//scan all namespaces
while (($id = getNS($id)) !== false) {
$dir = $conf[$basedir] . '/' . utf8_encodeFN(str_replace(':', '/', $id));
//try to delete dir else return
if (@rmdir($dir)) {
if ($ns_type !== false) {
$data = array($id, $ns_type);
trigger_event('IO_NAMESPACE_DELETED', $data);
}
} else {
return;
}
}
}
示例4: handle_ajax_call_acl
/**
* AJAX call handler for ACL plugin
*
* @param Doku_Event $event event object by reference
* @param mixed $param empty
* @return void
*/
public function handle_ajax_call_acl(Doku_Event &$event, $param)
{
if ($event->data !== 'plugin_acl') {
return;
}
$event->stopPropagation();
$event->preventDefault();
global $ID;
global $INPUT;
if (!auth_isadmin()) {
echo 'for admins only';
return;
}
if (!checkSecurityToken()) {
echo 'CRSF Attack';
return;
}
$ID = getID();
/** @var $acl admin_plugin_acl */
$acl = plugin_load('admin', 'acl');
$acl->handle();
$ajax = $INPUT->str('ajax');
header('Content-Type: text/html; charset=utf-8');
if ($ajax == 'info') {
$acl->_html_info();
} elseif ($ajax == 'tree') {
$ns = $INPUT->str('ns');
if ($ns == '*') {
$ns = '';
}
$ns = cleanID($ns);
$lvl = count(explode(':', $ns));
$ns = utf8_encodeFN(str_replace(':', '/', $ns));
$data = $acl->_get_tree($ns, $ns);
foreach (array_keys($data) as $item) {
$data[$item]['level'] = $lvl + 1;
}
echo html_buildlist($data, 'acl', array($acl, '_html_list_acl'), array($acl, '_html_li_acl'));
}
}
示例5: listAttachments
/**
* List all media files.
*
* Available options are 'recursive' for also including the subnamespaces
* in the listing, and 'pattern' for filtering the returned files against
* a regular expression matching their name.
*
* @author Gina Haeussge <osd@foosel.net>
*/
function listAttachments($ns, $options = array())
{
global $conf;
global $lang;
$ns = cleanID($ns);
if (!is_array($options)) {
$options = array();
}
if (!isset($options['recursive'])) {
$options['recursive'] = false;
}
if (auth_quickaclcheck($ns . ':*') >= AUTH_READ) {
$dir = utf8_encodeFN(str_replace(':', '/', $ns));
$data = array();
require_once DOKU_INC . 'inc/search.php';
search($data, $conf['mediadir'], 'search_media', array('recursive' => $options['recursive']), $dir);
if (!count($data)) {
return array();
}
$files = array();
foreach ($data as $item) {
if (isset($options['pattern']) && !@preg_match($options['pattern'], $item['id'])) {
continue;
}
$file = array();
$file['id'] = $item['id'];
$file['size'] = $item['size'];
$file['lastModified'] = new IXR_Date($item['mtime']);
$file['isimg'] = $item['isimg'];
$file['writable'] = $item['writeable'];
$file['perms'] = auth_quickaclcheck(getNS($item['id']) . ':*');
array_push($files, $file);
}
return $files;
} else {
return new IXR_Error(1, 'You are not allowed to list media files.');
}
}
示例6: collectExportPages
/**
* Obtain list of pages and title, based on url parameters
*
* @param Doku_Event $event
* @return string|bool
*/
protected function collectExportPages(Doku_Event $event)
{
global $ACT;
global $ID;
global $INPUT;
global $conf;
// list of one or multiple pages
$list = array();
if ($ACT == 'export_odt') {
$list[0] = $ID;
$title = $INPUT->str('book_title');
if (!$title) {
$title = p_get_first_heading($ID);
}
} elseif ($ACT == 'export_odtns') {
//check input for title and ns
if (!($title = $INPUT->str('book_title'))) {
$this->showPageWithErrorMsg($event, 'needtitle');
return false;
}
$docnamespace = cleanID($INPUT->str('book_ns'));
if (!@is_dir(dirname(wikiFN($docnamespace . ':dummy')))) {
$this->showPageWithErrorMsg($event, 'needns');
return false;
}
//sort order
$order = $INPUT->str('book_order', 'natural', true);
$sortoptions = array('pagename', 'date', 'natural');
if (!in_array($order, $sortoptions)) {
$order = 'natural';
}
//search depth
$depth = $INPUT->int('book_nsdepth', 0);
if ($depth < 0) {
$depth = 0;
}
//page search
$result = array();
$opts = array('depth' => $depth);
//recursive all levels
$dir = utf8_encodeFN(str_replace(':', '/', $docnamespace));
search($result, $conf['datadir'], 'search_allpages', $opts, $dir);
//sorting
if (count($result) > 0) {
if ($order == 'date') {
usort($result, array($this, '_datesort'));
} elseif ($order == 'pagename') {
usort($result, array($this, '_pagenamesort'));
}
}
foreach ($result as $item) {
$list[] = $item['id'];
}
} elseif (isset($_COOKIE['list-pagelist']) && !empty($_COOKIE['list-pagelist'])) {
// Here is $ACT == 'export_odtbook'
//is in Bookmanager of bookcreator plugin a title given?
if (!($title = $INPUT->str('book_title'))) {
$this->showPageWithErrorMsg($event, 'needtitle');
return false;
} else {
$list = explode("|", $_COOKIE['list-pagelist']);
}
} else {
//show empty bookcreator message
$this->showPageWithErrorMsg($event, 'empty');
return false;
}
$list = array_map('cleanID', $list);
return array($title, $list);
}
示例7: _getFileBase
/**
* get to-be directory and filename (without extension)
*
* all files are stored in the media directory into 'plugin_abc/<namespaces>/'
* and the filename is a mixture of abc-id and abc-title (e.g. 42_the_title.abc|...)
*
*/
function _getFileBase($src)
{
global $ID;
global $ACT;
global $conf;
$mediadir = $conf['mediadir'];
// where to store the abc media files
$abcdir = $this->getConf('mediaNS') ? $mediadir . '/' . $this->getConf('mediaNS') : $mediadir;
io_makeFileDir($abcdir);
$fileDir = $abcdir . '/' . utf8_encodeFN(str_replace(':', '/', getNS($ID)));
// the abcID is what comes after the 'X:'
preg_match("/\\s?X\\s?:(.*?)\n/se", $src, $matchesX);
$abcID = preg_replace('/\\s?X\\s?:/', '', $matchesX[0]);
// the abcTitle is what comes after the (first) 'T:'
preg_match("/\\s?T\\s?:(.*?)\n/se", $src, $matchesT);
$abcTitle = preg_replace('/\\s?T\\s?:/', '', $matchesT[0]);
$fileName = cleanID($abcID . "_" . $abcTitle);
// no double slash when in root namespace
$slashStr = getNS($ID) ? "/" : "";
// have different fileBase for previewing
$previewPrefix = $ACT != 'preview' ? "" : "x";
$fileBase = $fileDir . $slashStr . $previewPrefix . $fileName;
// unfortunately abcm2ps seems not to be able to handle
// file names (realpath) of more than 120 characters
$realFileBaseLen = strlen(fullpath($abcdir)) - strlen($abcdir) + strlen($fileBase);
$char_len = 114;
if ($realFileBaseLen >= $char_len) {
$truncLen = strlen($fileBase) + ($char_len - $realFileBaseLen);
$fileBase = substr($fileBase, 0, $truncLen);
}
return $fileBase;
}
示例8: _exportContainercontent
function _exportContainercontent($exporter)
{
global $ID, $INFO, $conf;
if ($ID == $conf['start']) {
$title = $conf['title'];
} elseif (isset($INFO['meta']['title'])) {
$title = $INFO['meta']['title'];
} else {
$title = $ID;
}
$exporter->setParameters('Container: ' . $title, getAbsUrl(), getAbsUrl() . 'doku.php?', 'utf-8', $this->agentlink);
// create container object
$wikicontainer = new SIOCDokuWikiContainer($ID, normalizeUri($exporter->siocURL('container', $ID)));
/* container is type=wiki */
if ($ID == $conf['start']) {
$wikicontainer->isWiki();
}
/* sioc:name */
if ($INFO['exists']) {
$wikicontainer->addTitle($INFO['meta']['title']);
}
/* has_parent */
if ($INFO['namespace']) {
$wikicontainer->addParent($INFO['namespace']);
}
// search next level entries (posts, sub containers) in container
require_once DOKU_INC . 'inc/search.php';
$dir = utf8_encodeFN(str_replace(':', '/', $ID));
$entries = array();
$posts = array();
$containers = array();
search($entries, $conf['datadir'], 'search_index', array('ns' => $ID), $dir);
foreach ($entries as $entry) {
if ($entry['type'] === 'f') {
// wikisite
$posts[] = $entry;
} elseif ($entry['type'] === 'd') {
// sub container
$containers[] = $entry;
}
}
// without sub content it can't be a container (so it does not exist as a container)
if (count($posts) + count($containers) == 0) {
$this->_exit("HTTP/1.0 404 Not Found");
}
if (count($posts) > 0) {
$wikicontainer->addArticles($posts);
}
if (count($containers) > 0) {
$wikicontainer->addContainers($containers);
}
//print_r($containers);die();
// add container to exporter
$exporter->addObject($wikicontainer);
return $exporter;
}
示例9: _html_explorer
/**
* Display a tree menu to select a page or namespace
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function _html_explorer()
{
global $conf;
global $ID;
global $lang;
$dir = $conf['datadir'];
$ns = $this->ns;
if (empty($ns)) {
$ns = dirname(str_replace(':', '/', $ID));
if ($ns == '.') {
$ns = '';
}
} elseif ($ns == '*') {
$ns = '';
}
$ns = utf8_encodeFN(str_replace(':', '/', $ns));
$data = $this->_get_tree($ns);
// wrap a list with the root level around the other namespaces
array_unshift($data, array('level' => 0, 'id' => '*', 'type' => 'd', 'open' => 'true', 'label' => '[' . $lang['mediaroot'] . ']'));
echo html_buildlist($data, 'acl', array($this, '_html_list_acl'), array($this, '_html_li_acl'));
}
示例10: mediaFN
/**
* returns the full path to the mediafile specified by ID
*
* The filename is URL encoded to protect Unicode chars
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Kate Arzamastseva <pshns@ukr.net>
*
* @param string $id media id
* @param string|int $rev empty string or revision timestamp
* @return string full path
*/
function mediaFN($id, $rev = '')
{
global $conf;
$id = cleanID($id);
$id = str_replace(':', '/', $id);
if (empty($rev)) {
$fn = $conf['mediadir'] . '/' . utf8_encodeFN($id);
} else {
$ext = mimetype($id);
$name = substr($id, 0, -1 * strlen($ext[0]) - 1);
$fn = $conf['mediaolddir'] . '/' . utf8_encodeFN($name . '.' . (int) $rev . '.' . $ext[0]);
}
return $fn;
}
示例11: die
}
if (!auth_isadmin()) {
die('for admins only');
}
if (!checkSecurityToken()) {
die('CRSF Attack');
}
$ID = getID();
$acl = plugin_load('admin', 'acl');
$acl->handle();
$ajax = $_REQUEST['ajax'];
header('Content-Type: text/html; charset=utf-8');
if ($ajax == 'info') {
$acl->_html_info();
} elseif ($ajax == 'tree') {
global $conf;
global $ID;
$dir = $conf['datadir'];
$ns = $_REQUEST['ns'];
if ($ns == '*') {
$ns = '';
}
$ns = cleanID($ns);
$lvl = count(explode(':', $ns));
$ns = utf8_encodeFN(str_replace(':', '/', $ns));
$data = $acl->_get_tree($ns, $ns);
foreach (array_keys($data) as $item) {
$data[$item]['level'] = $lvl + 1;
}
echo html_buildlist($data, 'acl', array($acl, '_html_list_acl'), array($acl, '_html_li_acl'));
}
示例12: bootstrap_media_nstree
/**
* Build a tree outline of available media namespaces
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function bootstrap_media_nstree($ns)
{
global $conf;
global $lang;
// currently selected namespace
$ns = cleanID($ns);
if (empty($ns)) {
global $ID;
$ns = (string) getNS($ID);
}
$ns_dir = utf8_encodeFN(str_replace(':', '/', $ns));
$data = array();
search($data, $conf['mediadir'], 'search_index', array('ns' => $ns_dir, 'nofiles' => true));
// wrap a list with the root level around the other namespaces
array_unshift($data, array('level' => 0, 'id' => '', 'open' => 'true', 'label' => '[' . $lang['mediaroot'] . ']'));
// insert the current ns into the hierarchy if it isn't already part of it
$ns_parts = explode(':', $ns);
$tmp_ns = '';
$pos = 0;
foreach ($ns_parts as $level => $part) {
if ($tmp_ns) {
$tmp_ns .= ':' . $part;
} else {
$tmp_ns = $part;
}
// find the namespace parts or insert them
while ($data[$pos]['id'] != $tmp_ns) {
if ($pos >= count($data) || $data[$pos]['level'] <= $level + 1 && strnatcmp(utf8_encodeFN($data[$pos]['id']), utf8_encodeFN($tmp_ns)) > 0) {
array_splice($data, $pos, 0, array(array('level' => $level + 1, 'id' => $tmp_ns, 'open' => 'true')));
break;
}
++$pos;
}
}
echo bootstrap_toc_html_buildlist($data, '', 'bootstrap_media_nstree_item', 'bootstrap_media_nstree_li');
}
示例13: _findimages
/**
* Gather all photos matching the given criteria
*/
function _findimages(&$data)
{
global $conf;
$files = array();
// http URLs are supposed to be media RSS feeds
if (preg_match('/^https?:\\/\\//i', $data['ns'])) {
$files = $this->_loadRSS($data['ns']);
$data['_single'] = false;
} elseif (preg_match('/^facebook:/i', $data['ns'])) {
$files = $this->_loadFacebook($data['ns']);
$data['_single'] = false;
} else {
$dir = utf8_encodeFN(str_replace(':', '/', $data['ns']));
// all possible images for the given namespace (or a single image)
if (is_file($conf['mediadir'] . '/' . $dir)) {
require_once DOKU_INC . 'inc/JpegMeta.php';
$files[] = array('id' => $data['ns'], 'isimg' => preg_match('/\\.(jpe?g|gif|png)$/', $dir), 'file' => basename($dir), 'mtime' => filemtime($conf['mediadir'] . '/' . $dir), 'meta' => new JpegMeta($conf['mediadir'] . '/' . $dir));
$data['_single'] = true;
} else {
$depth = $data['recursive'] ? 0 : 1;
search($files, $conf['mediadir'], 'search_media', array('depth' => $depth), $dir);
$data['_single'] = false;
}
}
// done, yet?
$len = count($files);
if (!$len) {
return $files;
}
if ($data['single']) {
return $files;
}
// filter images
for ($i = 0; $i < $len; $i++) {
if (!$files[$i]['isimg']) {
unset($files[$i]);
// this is faster, because RE was done before
} elseif ($data['filter']) {
if (!preg_match($data['filter'], noNS($files[$i]['id']))) {
unset($files[$i]);
}
}
}
if ($len < 1) {
return $files;
}
// random?
if ($data['random']) {
shuffle($files);
} else {
// sort?
if ($data['sort'] == 'date') {
usort($files, array($this, '_datesort'));
} elseif ($data['sort'] == 'mod') {
usort($files, array($this, '_modsort'));
} elseif ($data['sort'] == 'title') {
usort($files, array($this, '_titlesort'));
}
// reverse?
if ($data['reverse']) {
$files = array_reverse($files);
}
}
// limits and offsets?
if ($data['offset']) {
$files = array_slice($files, $data['offset']);
}
if ($data['limit']) {
$files = array_slice($files, 0, $data['limit']);
}
return $files;
}
示例14: _getNamespaceList
/**
* Get a list of namespaces below the given namespace.
* Recursively fetches subnamespaces.
*
* @param string $topns The top namespace
* @return array Multi-dimensional array of all namespaces below $tns
*/
protected function _getNamespaceList($topns = '')
{
global $conf;
$topns = utf8_encodeFN(str_replace(':', '/', $topns));
$excludes = $this->getConf('addpage_exclude');
if ($excludes == "") {
$excludes = array();
} else {
$excludes = @explode(';', strtolower($excludes));
}
$searchdata = array();
search($searchdata, $conf['datadir'], 'search_namespaces', array(), $topns);
$namespaces = array();
foreach ($searchdata as $ns) {
foreach ($excludes as $exclude) {
if (strpos($ns['id'], $exclude) === 0) {
continue 2;
}
}
$namespaces[] = $ns['id'];
}
return $namespaces;
}
示例15: tree
/**
* Build a tree info structure from media or page directories
*
* @param int $type
* @param string $open The hierarchy to open FIXME not supported yet
* @param string $base The namespace to start from
* @return array
*/
public function tree($type = self::TYPE_PAGES, $open = '', $base = '')
{
global $conf;
$opendir = utf8_encodeFN(str_replace(':', '/', $open));
$basedir = utf8_encodeFN(str_replace(':', '/', $base));
$opts = array('pagesonly' => $type == self::TYPE_PAGES, 'listdirs' => true, 'listfiles' => true, 'sneakyacl' => $conf['sneaky_index'], 'showmsg' => false, 'depth' => 1);
$data = array();
if ($type == self::TYPE_PAGES) {
search($data, $conf['datadir'], 'search_universal', $opts, $basedir);
} elseif ($type == self::TYPE_MEDIA) {
search($data, $conf['mediadir'], 'search_universal', $opts, $basedir);
}
return $data;
}