本文整理汇总了PHP中Wiki::initPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Wiki::initPage方法的具体用法?PHP Wiki::initPage怎么用?PHP Wiki::initPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wiki
的用法示例。
在下文中一共展示了Wiki::initPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construction method for the Image class
*
* @access public
* @param Wiki &$wikiClass The Wiki class object
* @param string $title The title of the image
* @param int $pageid The ID of the image page (optional)
* @return Image
*/
public function __construct(Wiki &$wikiClass, $title = null, $pageid = null)
{
$this->wiki =& $wikiClass;
$this->title = $title;
if ($this->wiki->removeNamespace($title) == $title) {
$namespaces = $this->wiki->get_namespaces();
$this->title = $namespaces[6] . ':' . $title;
}
$ii = $this->imageinfo();
if (is_array($ii)) {
$this->title = $ii[0]['canonicaltitle'];
$this->rawtitle = $this->wiki->removeNamespace($this->title);
$this->localname = str_replace(array(' ', '+'), array('_', '_'), urlencode($this->rawtitle));
$this->page =& $this->wiki->initPage($this->title, $pageid);
$this->mime = $ii[0]['mime'];
$this->bitdepth = $ii[0]['bitdepth'];
$this->hash = $ii[0]['sha1'];
$this->size = $ii[0]['size'];
$this->width = $ii[0]['width'];
$this->height = $ii[0]['height'];
$this->url = $ii[0]['url'];
$this->timestamp = $ii[0]['timestamp'];
$this->user = $ii[0]['user'];
if (is_array($ii[0]['metadata'])) {
foreach ($ii[0]['metadata'] as $metadata) {
$this->metadata[$metadata['name']] = $metadata['value'];
}
} else {
$this->exists = false;
}
}
}
示例2: __construct
/**
* Analyzes an RFA. Returns TRUE on success, FALSE on failure
* @param Wiki $wiki Peachy Wiki Class
* @param $page Peachy Page class
* @param null $rawwikitext - raw page text (for use without Peachy)
*/
public function __construct(Wiki $wiki, $page, $rawwikitext = null)
{
if (is_null($rawwikitext)) {
$pageObj = $wiki->initPage($page);
$rawwikitext = $pageObj->get_text();
}
#var_export($rawwikitext);
//Get the page sections & section names
$sections = array();
preg_match_all("/" . "^(\\=[=]?\\s*[^\\/\n]*\\s*\\=[\\=]?)\\s*\$" . "/m", $rawwikitext, $sections);
$splitterRegex = array();
foreach ($sections[1] as $sectionName) {
$sectionClear = trim(str_replace("=", "", $sectionName));
$sectionName = trim($sectionName);
if (preg_match("/^Pro/", $sectionClear) > 0) {
$sectionType["support"] = $sectionName;
}
if (preg_match("/^(?:Kontra|Contra)/", $sectionClear) > 0) {
$sectionType["oppose"] = $sectionName;
}
if (preg_match("/^Enthaltung[en]*/", $sectionClear) > 0) {
$sectionType["neutral"] = $sectionName;
}
if (preg_match("/^Kommentare/", $sectionClear) > 0) {
$sectionType["comments"] = $sectionName;
}
$splitterRegex[] .= "(" . preg_quote($sectionName) . ")";
}
#print_r($sections);die;
$split = preg_split("/" . "(?:" . implode("|", $splitterRegex) . ")" . "/", $rawwikitext, -1, PREG_SPLIT_DELIM_CAPTURE);
#print_r($split);die;
$header = array_shift($split);
//=== Deal with the header ===//
$header = str_ireplace(array('<nowiki>', '</nowiki>'), '', $header);
if (preg_match("/===\\s*\\[\\[User:(.*?)\\|.*?\\]\\]\\s*===/", $header, $matches)) {
$this->username = $matches[1];
} elseif (preg_match("/===\\s*\\[\\[.*?\\|(.*?)\\]\\]\\s*===/", $header, $matches)) {
$this->username = $matches[1];
}
$header = str_replace(array('[[', ']]'), '', $header);
if (preg_match("/(?: endet am) '*(.*) Uhr/i", $header, $matches)) {
$this->enddate = $matches[1];
}
//=== End header stuff ===//
//Now parse through each non-header section, figuring out what they are
//Nothing expected = 0, Support = 1, Oppose = 2, Neutral = 3
$nextsection = 0;
#print_r($sectionType);
#print_r($split);die;
foreach ($split as $i => $splut) {
$splut = trim($splut);
if (empty($splut)) {
continue;
}
if (strcasecmp($splut, $sectionType["support"]) == 0) {
$support = $split[$i + 1];
} elseif (strcasecmp($splut, $sectionType["oppose"]) == 0) {
$oppose = $split[$i + 1];
} elseif (strcasecmp($splut, $sectionType["neutral"]) == 0) {
$neutral = $split[$i + 1];
}
}
if (!isset($support)) {
$this->lasterror = "Support section not found";
return false;
}
if (!isset($oppose)) {
$this->lasterror = "Oppose section not found";
return false;
}
if (!isset($neutral)) {
$this->lasterror = "Neutral section not found";
return false;
}
#print_r($support);
#print_r($oppose);
#print_r($neutral);die;
$this->support = $this->analyzeSection($support);
$this->oppose = $this->analyzeSection($oppose);
$this->neutral = $this->analyzeSection($neutral);
//Merge all votes in one array and sort:
$m = array();
foreach ($this->support as $s) {
if (isset($s['name'])) {
$m[] = $s['name'];
}
}
foreach ($this->oppose as $o) {
if (isset($o['name'])) {
$m[] = $o['name'];
}
}
foreach ($this->neutral as $n) {
if (isset($n['name'])) {
//.........这里部分代码省略.........
示例3: __construct
/**
* Analyzes an RFA. Returns TRUE on success, FALSE on failure
* @param Wiki $wiki
* @param $page
* @param null $rawwikitext
*/
public function __construct(Wiki $wiki, $page, $rawwikitext = null)
{
if (is_null($rawwikitext)) {
$rawwikitext = $wiki->initPage($page)->get_text();
}
$split = preg_split("/^(?:(?:'''|(?:<includeonly><noin<\\/includeonly><includeonly>clude><\\/includeonly>)?={4,5}(?:<includeonly><\\/noin<\\/includeonly><includeonly>clude><\\/includeonly>''')?)" . "\\s*?(Support|Oppose|Neutral|Comments)\\s*?(?:'''|(?:'''<includeonly><noin<\\/includeonly><includeonly>clude><\\/includeonly>)?={4,5}(?:<includeonly><\\/noin<\\/includeonly><includeonly>clude><\\/includeonly>)?)|;\\s*(Support|Oppose|Neutral|Comments))\\s*(?:<br>|<br \\/>)?\\s*\$/im", $rawwikitext, -1, PREG_SPLIT_DELIM_CAPTURE);
$header = array_shift($split);
//=== Deal with the header ===//
$header = str_ireplace(array('<nowiki>', '</nowiki>'), '', $header);
if (preg_match("/===\\s*\\[\\[User:(.*?)\\|.*?\\]\\]\\s*===/", $header, $matches)) {
$this->username = $matches[1];
} elseif (preg_match("/===\\s*\\[\\[.*?\\|(.*?)\\]\\]\\s*===/", $header, $matches)) {
$this->username = $matches[1];
}
$header = str_replace(array('[[', ']]'), '', $header);
if (preg_match("/end(?:ing|ed)?(?: no earlier than)? (.*?) \\(UTC\\)/i", $header, $matches)) {
$this->enddate = $matches[1];
}
//=== End header stuff ===//
//Now parse through each non-header section, figuring out what they are
//Nothing expected = 0, Support = 1, Oppose = 2, Neutral = 3
$nextsection = 0;
foreach ($split as $splut) {
$splut = trim($splut);
if (empty($splut)) {
continue;
}
if (strcasecmp($splut, 'Support') == 0) {
$nextsection = 1;
} elseif (strcasecmp($splut, 'Oppose') == 0) {
$nextsection = 2;
} elseif (strcasecmp($splut, 'Neutral') == 0) {
$nextsection = 3;
} else {
switch ($nextsection) {
case 1:
$support = $splut;
break;
case 2:
$oppose = $splut;
break;
case 3:
$neutral = $splut;
break;
}
$nextsection = 0;
}
}
if (!isset($support)) {
$this->lasterror = "Support section not found";
return false;
}
if (!isset($oppose)) {
$this->lasterror = "Oppose section not found";
return false;
}
if (!isset($neutral)) {
$this->lasterror = "Neutral section not found";
return false;
}
$this->support = $this->analyzeSection($support);
$this->oppose = $this->analyzeSection($oppose);
$this->neutral = $this->analyzeSection($neutral);
//Merge all votes in one array and sort:
$m = array();
foreach ($this->support as $s) {
if (isset($s['name'])) {
$m[] = $s['name'];
}
}
foreach ($this->oppose as $o) {
if (isset($o['name'])) {
$m[] = $o['name'];
}
}
foreach ($this->neutral as $n) {
if (isset($n['name'])) {
$m[] = $n['name'];
}
}
sort($m);
//Find duplicates:
for ($i = 0; $i < count($m); $i++) {
if ($i != count($m) - 1) {
if ($m[$i] == $m[$i + 1]) {
$this->duplicates[] = $m[$i];
}
}
}
return true;
}