本文整理汇总了PHP中Neuron_Core_Tools::getArrayFirstValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Neuron_Core_Tools::getArrayFirstValue方法的具体用法?PHP Neuron_Core_Tools::getArrayFirstValue怎么用?PHP Neuron_Core_Tools::getArrayFirstValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Neuron_Core_Tools
的用法示例。
在下文中一共展示了Neuron_Core_Tools::getArrayFirstValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseNewFile
private static function parseNewFile($file)
{
$text = Neuron_Core_Text::__getInstance();
$params1 = 'api.php?action=query&prop=revisions&rvprop=timestamp|user|comment|content&format=php&titles=';
$params2 = 'api.php?action=query&prop=imageinfo&iiprop=url&format=php&titles=';
$url = WIKI_GUIDE_URL . $params1 . urlencode($file);
// Load file from wiki
$wiki = file_get_contents($url);
$wiki = unserialize($wiki);
// Get the real content
$content = Neuron_Core_Tools::getArrayFirstValue($wiki['query']['pages']);
if (!isset($content[1]['revisions'])) {
return false;
} else {
$content = Neuron_Core_Tools::getArrayFirstValue($content[1]['revisions']);
$content = $content[1]['*'];
// Search for thze images
$images = array();
//[[Image:Voorbeeld.png]]
// Replace external links
$images = array();
preg_match_all("/\\[\\[Image:([^|]*?)]]/si", $content, $images, PREG_PATTERN_ORDER);
// Fetch all image infos
$imageOut = array();
foreach ($images[1] as $k => $v) {
$imgs = WIKI_GUIDE_URL . $params2 . 'Image:' . addslashes($v);
$imgdata = unserialize(file_get_contents($imgs));
$imgdata = Neuron_Core_Tools::getArrayFirstValue($imgdata['query']['pages']);
if (isset($imgdata[1]['imageinfo'])) {
$sUrl = WIKI_GUIDE_URL . substr($imgdata[1]['imageinfo'][0]['url'], 1);
$content = str_replace($images[0][$k], '***img***' . $sUrl . '***/img***', $content);
}
}
// Replace external links
$content = preg_replace('/([^\\[]{1})' . '\\[' . '([^ \\]]+)' . '\\]' . '([^\\]]{1})' . '/si', '\\1[url]\\2[/url]\\3', $content);
$content = preg_replace('/([^\\[]{1})' . '\\[' . '([^ \\]]+)' . ' ([^\\]]+)' . '\\]' . '([^\\]]{1})' . '/si', '\\1[url=\\2]\\3[/url]\\4', $content);
// Replace code
$content = str_replace('<code>', '[code]', $content);
$content = str_replace('</code>', '[/code]', $content);
$content = str_replace('***img***', '[img align="left"]', $content);
$content = str_replace('***/img***', '[/img]', $content);
// Replace headers
$content = preg_replace("/====([^|]*?)====/si", "[h4]\\1[/h4]", $content);
$content = preg_replace("/===([^|]*?)===/si", "[h3]\\1[/h3]", $content);
$content = preg_replace("/==([^|]*?)==/si", "[h2]\\1[/h2]", $content);
$content = html_entity_decode($content, ENT_NOQUOTES, 'UTF-8');
$content = preg_replace("/\\[\\[([^|]*?)]]/si", '[action title="\\1" data="{\'page\':\\1\'}"]\\1[/action]', $content);
$content = preg_replace("/\\[\\[([^|\\[]*?)\\|([^|\\]]*?)\\]\\]/si", '[action title="\\2" data="{\'page\':\'\\1\'}"]\\2[/action]', $content);
$content = Neuron_Core_Tools::output_text($content);
return $content;
}
}