当前位置: 首页>>代码示例>>PHP>>正文


PHP resolve_mediaid函数代码示例

本文整理汇总了PHP中resolve_mediaid函数的典型用法代码示例。如果您正苦于以下问题:PHP resolve_mediaid函数的具体用法?PHP resolve_mediaid怎么用?PHP resolve_mediaid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了resolve_mediaid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: internalmedia

 function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL)
 {
     global $conf;
     global $ID;
     resolve_mediaid(getNS($ID), $src, $exists);
     $link = array();
     $link['class'] = 'media';
     $link['target'] = '_blank';
     $link['title'] = $this->_xmlEntities($src);
     $link['url'] = 'media/' . str_replace(':', '/', $src);
     $link['name'] = $this->_media($src, $title, $align, $width, $height, $cache);
     //output formatted
     $this->doc .= $this->_formatLink($link);
 }
开发者ID:bomberstudios,项目名称:dokuwiki-offline-html,代码行数:14,代码来源:renderer.php

示例2: internalmedia

 public function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL, $return = false)
 {
     global $ID;
     list($src, $hash) = explode('#', $src, 2);
     resolve_mediaid(getNS($ID), $src, $exists);
     $noLink = false;
     $render = $linking == 'linkonly' ? false : true;
     $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
     list($ext, $mime, $dl) = mimetype($src, false);
     if (substr($mime, 0, 5) == 'image' && $render) {
         if ($linking == NULL || $linking == '' || $linking == 'details') {
             $linking = 'direct';
         }
         $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), $linking == 'direct');
     } elseif ($mime == 'application/x-shockwave-flash' && $render) {
         // don't link flash movies
         $noLink = true;
     } else {
         // add file icons
         $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
         $link['class'] .= ' mediafile mf_' . $class;
         $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), true);
         if ($exists) {
             $link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))) . ')';
         }
     }
     if ($hash) {
         $link['url'] .= '#' . $hash;
     }
     //markup non existing files
     if (!$exists) {
         $link['class'] .= ' wikilink2';
     }
     //output formatted
     if ($linking == 'nolink' || $noLink) {
         $this->doc .= $link['name'];
     } else {
         $this->doc .= $this->_formatLink($link);
     }
 }
开发者ID:ssahara,项目名称:dw-plugin-prettyPhoto,代码行数:40,代码来源:renderer.php

示例3: normalize

 function normalize($value, $hint)
 {
     global $ID;
     // strip leading {{ and closing }}
     $value = preg_replace(array('/^\\{\\{/', '/\\}\\}$/u'), '', $value);
     // drop any title and alignment spacing whitespace
     $value = explode('|', $value, 2);
     $value = trim($value[0]);
     if ($this->isExternalMedia($value)) {
         // external image
         // we don't do anything else here
     } else {
         // internal image
         // discard size string and other options
         $pos = strrpos($value, '?');
         if ($pos !== false) {
             $value = substr($value, 0, $pos);
         }
         // resolve page id with respect to selected base
         resolve_mediaid(getNS($ID), $value, $exists);
     }
     return $value;
 }
开发者ID:virk,项目名称:dokuwiki-strata,代码行数:23,代码来源:image.php

示例4: _firstimage

 function _firstimage($src)
 {
     if ($this->firstimage) {
         return;
     }
     global $ID;
     list($src, $hash) = explode('#', $src, 2);
     if (!preg_match('/^https?:\\/\\//i', $src)) {
         resolve_mediaid(getNS($ID), $src, $exists);
     }
     if (preg_match('/.(jpe?g|gif|png)$/i', $src)) {
         $this->firstimage = $src;
     }
 }
开发者ID:lorea,项目名称:Hydra-dev,代码行数:14,代码来源:metadata.php

示例5: gather_data

 /**
  * Gathers all page and media data for given namespaces.
  * 
  * @namespaces array() of namespaces
  * @depth Search depth
  * @include_media Determines if media should be regarded, Values: 'ns','all','none'.
  * @use_cached_pages Determines if only cached pages should be used. If this option is turned off, the operation will cache all non-cached pages within the namespace.
  * @use_first_header Determines if the first header is used for title of the pages.
  * 
  * @return array with pages and media: array('pages'=>pages, 'media'=>media).   
  */
 function gather_data($namespaces, $depth = 0, $include_media = 'none', $use_cached_pages = true, $use_first_header = false)
 {
     global $conf;
     $transplugin = plugin_load('helper', 'translation');
     $pages = array();
     $media = array();
     // Loop through the namespaces
     foreach ($namespaces as $ns) {
         // Get the media of the namespace
         if ($include_media == 'ns') {
             $this->get_media($media, $ns, $depth);
         }
         // Get the pages of the namespace
         $this->get_pages($pages, $ns, $depth, $use_first_header);
     }
     // Loop through the pages to get links and media
     foreach ($pages as $pid => $item) {
         // get instructions
         $ins = p_cached_instructions(wikiFN($pid), $use_cached_pages, $pid);
         // find links and media usage
         foreach ($ins as $i) {
             $mid = null;
             // Internal link?
             if ($i[0] == 'internallink') {
                 $id = $i[1][0];
                 $exists = true;
                 resolve_pageid($item['ns'], $id, $exists);
                 list($id) = explode('#', $id, 2);
                 if ($id == $pid) {
                     continue;
                 }
                 // skip self references
                 if ($exists && isset($pages[$id])) {
                     $pages[$pid]['links'][] = $id;
                 }
                 if (is_array($i[1][1]) && $i[1][1]['type'] == 'internalmedia') {
                     $mid = $i[1][1]['src'];
                     // image link
                 } else {
                     continue;
                     // we're done here
                 }
             }
             if ($i[0] == 'internalmedia') {
                 $mid = $i[1][0];
             }
             if (is_null($mid)) {
                 continue;
             }
             if ($include_media == 'none') {
                 continue;
             }
             // no media wanted
             $exists = true;
             resolve_mediaid($item['ns'], $mid, $exists);
             list($mid) = explode('#', $mid, 2);
             $mid = cleanID($mid);
             if ($exists) {
                 if ($include_media == 'all') {
                     if (!isset($media[$mid])) {
                         //add node
                         $media[$mid] = array('size' => filesize(mediaFN($mid)), 'time' => filemtime(mediaFN($mid)), 'ns' => getNS($mid), 'title' => noNS($mid));
                     }
                     $pages[$pid]['media'][] = $mid;
                 } elseif (isset($media[$mid])) {
                     $pages[$pid]['media'][] = $mid;
                 }
             }
         }
         // clean up duplicates
         $pages[$pid]['links'] = array_unique($pages[$pid]['links']);
         $pages[$pid]['media'] = array_unique($pages[$pid]['media']);
     }
     return array('pages' => $pages, 'media' => $media);
 }
开发者ID:jdtProjects,项目名称:dokuwiki,代码行数:86,代码来源:syntax.php

示例6: _normalize_media

 /**
  * Normalizes a media array.
  */
 function _normalize_media($instruction)
 {
     global $ID;
     // construct media structure based on input
     if (isset($instruction['type'])) {
         $media = $instruction;
     } else {
         list($src, $title, $align, $width, $height, $cache, $linking) = $instruction;
         $media = compact('src', 'title', 'align', 'width', 'height');
         $media['type'] = 'internalmedia';
     }
     // normalize internal media links
     if ($media['type'] == 'internalmedia') {
         list($src, $hash) = explode('#', $media['src'], 2);
         resolve_mediaid(getNS($ID), $src, $exists);
         if ($hash) {
             $src .= '#' . $hash;
         }
         $media['src'] = ':' . $src;
     }
     // render the media structure
     return $this->_mediaSyntax($media);
 }
开发者ID:virk,项目名称:dokuwiki-strata,代码行数:26,代码来源:wiki.php

示例7: relativeLink

 /**
  * Construct a new ID relative to the current page's location
  *
  * Uses a relative link only if the original was relative, too. This function is for
  * pages and media files.
  *
  * @param string $relold the old, possibly relative ID
  * @param string $new    the new, full qualified ID
  * @param string $type 'media' or 'page'
  * @throws Exception on bad argument
  * @return string
  */
 public function relativeLink($relold, $new, $type)
 {
     global $conf;
     if ($type != 'media' && $type != 'page') {
         throw new Exception('Not a valid type');
     }
     // first check if the old link still resolves
     $exists = false;
     $old = $relold;
     if ($type == 'page') {
         resolve_pageid($this->ns, $old, $exists);
     } else {
         resolve_mediaid($this->ns, $old, $exists);
     }
     if ($old == $new) {
         return $relold;
         // old link still resolves, keep as is
     }
     if ($conf['useslash']) {
         $relold = str_replace('/', ':', $relold);
     }
     // check if the link was relative
     if (strpos($relold, ':') === false || $relold[0] == '.') {
         $wasrel = true;
     } else {
         $wasrel = false;
     }
     // if it wasn't relative then, leave it absolute now, too
     if (!$wasrel) {
         if ($this->ns && !getNS($new)) {
             $new = ':' . $new;
         }
         $new = $this->_nsStartCheck($relold, $new, $type);
         return $new;
     }
     // split the paths and see how much common parts there are
     $selfpath = explode(':', $this->ns);
     $goalpath = explode(':', getNS($new));
     $min = min(count($selfpath), count($goalpath));
     for ($common = 0; $common < $min; $common++) {
         if ($selfpath[$common] != $goalpath[$common]) {
             break;
         }
     }
     // we now have the non-common part and a number of uppers
     $ups = max(count($selfpath) - $common, 0);
     $remainder = array_slice($goalpath, $common);
     $upper = $ups ? array_fill(0, $ups, '..:') : array();
     // build the new relative path
     $newrel = join(':', $upper);
     if ($remainder) {
         $newrel .= join(':', $remainder) . ':';
     }
     $newrel .= noNS($new);
     $newrel = str_replace('::', ':', trim($newrel, ':'));
     if ($newrel[0] != '.' && $this->ns && getNS($newrel)) {
         $newrel = '.' . $newrel;
     }
     // if the old link ended with a colon and the new one is a start page, adjust
     $newrel = $this->_nsStartCheck($relold, $newrel, $type);
     // don't use relative paths if it is ridicoulus:
     if (strlen($newrel) > strlen($new)) {
         $newrel = $new;
         if ($this->ns && !getNS($new)) {
             $newrel = ':' . $newrel;
         }
         $newrel = $this->_nsStartCheck($relold, $newrel, $type);
     }
     return $newrel;
 }
开发者ID:xudianyang,项目名称:wiki.phpboy.net,代码行数:82,代码来源:handler.php

示例8: internalmedia

 /**
  * Render an internal media file
  *
  * @param string $src       media ID
  * @param string $title     descriptive text
  * @param string $align     left|center|right
  * @param int    $width     width of media in pixel
  * @param int    $height    height of media in pixel
  * @param string $cache     cache|recache|nocache
  * @param string $linking   linkonly|detail|nolink
  * @param bool   $returnonly whether to return odt or write to doc attribute
  */
 function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL, $returnonly = false)
 {
     global $ID;
     resolve_mediaid(getNS($ID), $src, $exists);
     list(, $mime) = mimetype($src);
     if (substr($mime, 0, 5) == 'image') {
         $file = mediaFN($src);
         if ($returnonly) {
             return $this->_odtAddImage($file, $width, $height, $align, $title, true);
         } else {
             $this->_odtAddImage($file, $width, $height, $align, $title);
         }
     } else {
         /*
                     // FIXME build absolute medialink and call externallink()
                     $this->code('FIXME internalmedia: '.$src);
         */
         //FIX by EPO/Intersel - create a link to the dokuwiki internal resource
         if (empty($title)) {
             $title = explode(':', $src);
             $title = end($title);
         }
         if ($returnonly) {
             return $this->externalmedia(str_replace('doku.php?id=', 'lib/exe/fetch.php?media=', wl($src, '', true)), $title, null, null, null, null, null, true);
         } else {
             $this->externalmedia(str_replace('doku.php?id=', 'lib/exe/fetch.php?media=', wl($src, '', true)), $title, null, null, null, null, null);
         }
         //End of FIX
     }
 }
开发者ID:phillip-hopper,项目名称:dokuwiki-plugin-odt,代码行数:42,代码来源:page.php

示例9: internalmedia

 function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL)
 {
     global $conf;
     global $ID;
     resolve_mediaid(getNS($ID), $src, $exists);
     $link = array();
     $link['class'] = 'media';
     $link['style'] = '';
     $link['pre'] = '';
     $link['suf'] = '';
     $link['more'] = '';
     $link['target'] = $conf['target']['media'];
     $link['title'] = $this->_xmlEntities($src);
     list($ext, $mime) = mimetype($src);
     if (substr($mime, 0, 5) == 'image') {
         $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), $linking == 'direct');
     } elseif ($mime == 'application/x-shockwave-flash') {
         // don't link flash movies
         $noLink = TRUE;
     } else {
         // add file icons
         $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
         $link['class'] .= ' mediafile mf_' . $class;
         $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), true);
     }
     $link['name'] = $this->_media($src, $title, $align, $width, $height, $cache);
     //output formatted
     if ($linking == 'nolink' || $noLink) {
         $this->doc .= $link['name'];
     } else {
         $this->doc .= $this->_formatLink($link);
     }
 }
开发者ID:BackupTheBerlios,项目名称:sitebe-svn,代码行数:33,代码来源:xhtml.php

示例10: __fetchAndReplaceLink

 /**
  * Deep Fetch and replace of links inside the texts matched by __getInternalLinks
  **/
 function __fetchAndReplaceLink($DATA)
 {
     global $conf, $currentID;
     $noDeepReplace = true;
     $newAdditionalParameters = $this->functions->settings->additionalParameters;
     $newDepth = $this->functions->settings->depth;
     $hadBase = false;
     // Clean data[2], remote ' and "
     $DATA[2] = preg_replace("/^\\s*?['\"]?(.*?)['\"]?\\s*?\$/", '\\1', trim($DATA[2]));
     $this->functions->debug->message("Starting Link Replacement", $DATA, 2);
     // $DATA[2] = urldecode($DATA[2]); // Leads to problems because it does not re-encode the url
     // External and mailto links
     if (preg_match("%^(https?://|mailto:|javascript:|data:)%", $DATA[2])) {
         $this->functions->debug->message("Don't like http, mailto, data or javascript links here", null, 1);
         return $this->__rebuildLink($DATA, "");
     }
     //if ( preg_match("%^(https?://|mailto:|" . DOKU_BASE . "/_export/)%", $DATA[2]) ) { return $this->__rebuildLink($DATA, ""); }
     // External media - this is deep down in the link, so we have to grep it out
     if (preg_match("%media=(https?://.*?\$)%", $DATA[2], $matches)) {
         $DATA[2] = $matches[1];
         $this->functions->debug->message("This is an HTTP like somewhere else", $DATA, 1);
         return $this->__rebuildLink($DATA, "");
     }
     // reference only links won't have to be rewritten
     if (preg_match("%^#.*?\$%", $DATA[2])) {
         $this->functions->debug->message("This is a refercence only", null, 1);
         return $this->__rebuildLink($DATA, "");
     }
     // strip all things out
     // changed Data
     $PARAMS = @parse_url($DATA[2], PHP_URL_QUERY);
     $ANCHOR = @parse_url($DATA[2], PHP_URL_FRAGMENT);
     $DATA[2] = @parse_url($DATA[2], PHP_URL_PATH);
     // 2010-08-25 - fix problem with relative movement in links ( "test/../test2" )
     $tmpData2 = '';
     while ($tmpData2 != $DATA[2]) {
         $tmpData2 = $DATA[2];
         $DATA[2] = preg_replace("#/(?!\\.\\.)[^\\/]*?/\\.\\./#", '/', $DATA[2]);
     }
     $temp = preg_replace("%^" . DOKU_BASE . "%", "", $DATA[2]);
     if ($temp != $DATA[2]) {
         $DATA[2] = $temp;
         $hadBase = true;
         // 2010-08-23 Check if there has been a rewrite here that will have to be considered later on
     }
     $this->functions->debug->message("URL before rewriting option for others than 1", array($DATA, $PARAMS, $hadBase), 1);
     // Handle rewrites other than 1 - just for non-lib-files
     // if ( !preg_match('$^/?lib/$', $DATA[2]) ) {
     if (!preg_match('$^(' . DOKU_BASE . ')?lib/$', $DATA[2])) {
         $this->functions->debug->message("Did not match '\$^(" . DOKU_BASE . ")?lib/\$' userewrite == ", $conf['userewrite'], 2);
         if ($conf['userewrite'] == 2) {
             $DATA[2] = $this->__getInternalRewriteURL($DATA[2]);
         } elseif ($conf['userewrite'] == 0) {
             $this->__getParamsAndDataRewritten($DATA, $PARAMS);
         }
     } else {
         $this->functions->debug->message("This file must be inside lib ...", null, 2);
     }
     $this->functions->debug->message("URL before rewriting option", array($DATA, $PARAMS), 2);
     $ORIGDATA2 = $DATA;
     //        $ORIGDATA2 = $DATA[2]; // 08/10/2010 - this line required a $this->functions->wl which may mess up with the base URL
     $this->functions->debug->message("OrigDATA is:", $ORIGDATA2, 1);
     // Generate ID
     $DATA[2] = str_replace('/', ':', $DATA[2]);
     // If Data was empty this must be the same file!;
     if (empty($DATA[2])) {
         $DATA[2] = $currentID;
     }
     $ID = $DATA[2];
     $MEDIAMATCHER = "#(_media(/|:)|media=|_detail(/|:)|_export(/|:)|do=export_)#i";
     // 2010-10-23 added "(/|:)" for the ID may not contain slashes anymore
     $ID = $this->functions->cleanID($DATA[2], null, preg_match($MEDIAMATCHER, $DATA[2]));
     //        $ID = $this->functions->cleanID($DATA[2], null, strstr($DATA[2], 'media') ); // Export anpassung nun weiter unten
     //        $IDexists = page_exists($ID); // 08/10/2010 - Not needed. This will be done in the next block.
     //        $this->functions->debug->message("Current ID: '$ID' exists: '" . ($IDexists ? 'true' : 'false') . "' (will be set to 'false' anyway)", null, 1);
     $IDifIDnotExists = $ID;
     // 08/10/2010 - Save ID - with possible upper cases to preserve them
     $IDexists = false;
     $this->functions->debug->message("Resolving ID: '{$ID}'", null, 2);
     if (preg_match($MEDIAMATCHER, $DATA[2])) {
         resolve_mediaid(null, $ID, $IDexists);
         $this->functions->debug->message("Current mediaID to filename: '" . mediaFN($ID) . "'", null, 2);
     } else {
         resolve_pageid(null, $ID, $IDexists);
         $this->functions->debug->message("Current ID to filename: '" . wikiFN($ID) . "'", null, 2);
     }
     $this->functions->debug->message("Current ID after resolvement: '{$ID}' the ID does exist: '" . ($IDexists ? 'true' : 'false') . "'", null, 2);
     //        $ORIGDATA2 = @parse_url($this->functions->wl($ORIGDATA2, null, true)); // What was the next 2 line for? It did mess up with links from {{jdoc>}}
     //        $this->functions->debug->message("OrigData ID after parse:", $ORIGDATA2, 1); // 08/10/2010 - The lines are obsolete when the $ORIGDATA2 = $DATA. $ORIGDATA is only for fallback
     // 08/10/2010 - If the ID does not exist, we may have a problem here with upper cases - they will all be lower by now!
     if (!$IDexists) {
         $ID = $IDifIDnotExists;
         // there may have been presevered Upper cases. We will need them!
     }
     // $this->functions->cleanID($DATA[2], null, strstr($DATA[2], 'media') || strstr($DATA[2], 'export') );
     if (substr($ID, -1) == ':' || empty($ID)) {
         $ID .= $conf['start'];
//.........这里部分代码省略.........
开发者ID:omusico,项目名称:isle-web-framework,代码行数:101,代码来源:ajax.php

示例11: internalmedia

 function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL)
 {
     global $conf;
     global $ID;
     $filename = mediaFN($src);
     resolve_mediaid(getNS($ID), $src, $exists);
     list($ext, $mime) = mimetype($src);
     if (substr($mime, 0, 5) == 'image') {
         $img = $this->mediatops($filename, $title, $align, $width, $height, $cache, $linking);
         $this->put($img);
         return;
     }
     if ($title == NULL) {
         $title = basename($filename);
     }
     array_push($this->dokulinks, array('id' => $filename, 'name' => $title, 'type' => 'file'));
     $this->putcmd('hyperref[');
     $this->put(md5($filename));
     $this->put(']{');
     $this->putent($title);
     $this->put('}');
     //    $this->unformatted('unkown '. $filename . '('. $mime . '=>' . $ext . ')');
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:23,代码来源:latex.php

示例12: internalmedia

 function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL)
 {
     global $conf;
     global $ID;
     resolve_mediaid(getNS($ID), $src, $exists);
     list($ext, $mime) = mimetype($src);
     if (substr($mime, 0, 5) == 'image') {
         $file = mediaFN($src);
         $this->_odtAddImage($file, $width, $height, $align, $title);
     } else {
         // FIXME build absolute medialink and call externallink()
         $this->code('FIXME internalmedia: ' . $src);
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:14,代码来源:renderer.php

示例13: _imageTitle

 /**
  * Returns HTML code for images used in link titles
  *
  * @author Andreas Gohr <andi@splitbrain.org>
  * @param array $img
  * @return string HTML img tag or similar
  */
 function _imageTitle($img)
 {
     global $ID;
     // some fixes on $img['src']
     // see internalmedia() and externalmedia()
     list($img['src']) = explode('#', $img['src'], 2);
     if ($img['type'] == 'internalmedia') {
         resolve_mediaid(getNS($ID), $img['src'], $exists, $this->date_at, true);
     }
     return $this->_media($img['src'], $img['title'], $img['align'], $img['width'], $img['height'], $img['cache']);
 }
开发者ID:sawachan,项目名称:dokuwiki,代码行数:18,代码来源:xhtml.php

示例14: internalmedia

 public function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL)
 {
     global $ID;
     resolve_mediaid(getNS($ID), $src, $exists);
     $noLink = false;
     $render = $linking == 'linkonly' ? false : true;
     $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
     list($ext, $mime) = mimetype($src);
     if (substr($mime, 0, 5) == 'image' && $render) {
         $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), $linking == 'direct');
     } elseif ($mime == 'application/x-shockwave-flash') {
         // don't link flash movies
         $noLink = true;
     } else {
         // add file icons
         $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
         $link['class'] .= ' mediafile mf_' . $class;
         $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), true);
     }
     //var_dump($link);
     //output formatted
     if ($linking == 'nolink' || $noLink) {
         $this->doc .= $link['name'];
     } else {
         $this->doc .= $this->_formatLink($link);
     }
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:27,代码来源:xhtml.php

示例15: gather_data

/**
 * Find all the node and edge data for the given namespaces
 */
function gather_data($namespaces, $depth = 0, $incmedia = 'ns')
{
    global $conf;
    $transplugin = plugin_load('helper', 'translation');
    $pages = array();
    $media = array();
    foreach ($namespaces as $ns) {
        // find media
        if ($incmedia == 'ns') {
            $data = array();
            search($data, $conf['mediadir'], 'search_universal', array('depth' => $depth, 'listfiles' => true, 'listdirs' => false, 'pagesonly' => false, 'skipacl' => true, 'keeptxt' => true, 'meta' => true), str_replace(':', '/', $ns));
            // go through all those media files
            while ($item = array_shift($data)) {
                $media[$item['id']] = array('title' => noNS($item['id']), 'size' => $item['size'], 'ns' => getNS($item['id']), 'time' => $item['mtime']);
            }
        }
        // find pages
        $data = array();
        search($data, $conf['datadir'], 'search_universal', array('depth' => $depth, 'listfiles' => true, 'listdirs' => false, 'pagesonly' => true, 'skipacl' => true, 'firsthead' => true, 'meta' => true), str_replace(':', '/', $ns));
        // ns start page
        if ($ns && page_exists($ns)) {
            $data[] = 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);
        }
        // go through all those pages
        while ($item = array_shift($data)) {
            $time = (int) p_get_metadata($item['id'], 'date created', false);
            if (!$time) {
                $time = $item['mtime'];
            }
            $lang = $transplugin ? $transplugin->getLangPart($item['id']) : '';
            if ($lang) {
                $item['ns'] = preg_replace('/^' . $lang . '(:|$)/', '', $item['ns']);
            }
            $pages[$item['id']] = array('title' => $item['title'], 'ns' => $item['ns'], 'size' => $item['size'], 'time' => $time, 'links' => array(), 'media' => array(), 'lang' => $lang);
        }
    }
    // now get links and media
    foreach ($pages as $pid => $item) {
        // get instructions
        $ins = p_cached_instructions(wikiFN($pid), false, $pid);
        // find links and media usage
        foreach ($ins as $i) {
            $mid = null;
            if ($i[0] == 'internallink') {
                $id = $i[1][0];
                $exists = true;
                resolve_pageid($item['ns'], $id, $exists);
                list($id) = explode('#', $id, 2);
                if ($id == $pid) {
                    continue;
                }
                // skip self references
                if ($exists && isset($pages[$id])) {
                    $pages[$pid]['links'][] = $id;
                }
                if (is_array($i[1][1]) && $i[1][1]['type'] == 'internalmedia') {
                    $mid = $i[1][1]['src'];
                    // image link
                } else {
                    continue;
                    // we're done here
                }
            }
            if ($i[0] == 'internalmedia') {
                $mid = $i[1][0];
            }
            if (is_null($mid)) {
                continue;
            }
            if ($incmedia == 'none') {
                continue;
            }
            // no media wanted
            $exists = true;
            resolve_mediaid($item['ns'], $mid, $exists);
            list($mid) = explode('#', $mid, 2);
            $mid = cleanID($mid);
            if ($exists) {
                if ($incmedia == 'all') {
                    if (!isset($media[$mid])) {
                        //add node
                        $media[$mid] = array('size' => filesize(mediaFN($mid)), 'time' => filemtime(mediaFN($mid)), 'ns' => getNS($mid), 'title' => noNS($mid));
                    }
                    $pages[$pid]['media'][] = $mid;
                } elseif (isset($media[$mid])) {
                    $pages[$pid]['media'][] = $mid;
                }
            }
        }
        // clean up duplicates
        $pages[$pid]['links'] = array_unique($pages[$pid]['links']);
        $pages[$pid]['media'] = array_unique($pages[$pid]['media']);
    }
    return array('pages' => $pages, 'media' => $media);
}
开发者ID:splitbrain,项目名称:dokuwiki-grapher,代码行数:98,代码来源:grapher.php


注:本文中的resolve_mediaid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。