本文整理汇总了PHP中WebPage::setOrderPosition方法的典型用法代码示例。如果您正苦于以下问题:PHP WebPage::setOrderPosition方法的具体用法?PHP WebPage::setOrderPosition怎么用?PHP WebPage::setOrderPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebPage
的用法示例。
在下文中一共展示了WebPage::setOrderPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readInChildNode
/**
* Reads the child node along with the settings specified in the index the adds it to the tree.
*
* @param \DOMNode $node
* @param WebPage $parentPage
*/
private function readInChildNode(\DOMNode $node, WebPage $parentPage = null)
{
$webPage = $parentPage;
$settings = new WebPageSettings();
if (strcmp($node->nodeName, 'document') == 0) {
$attributes = $node->attributes;
$title = null;
$src = null;
$tag = array();
$order = null;
$category = array();
if (isset($attributes)) {
for ($i = 0; $i < $attributes->length; $i++) {
$attribute = $attributes->item($i)->nodeName;
switch ($attribute) {
case 'title':
$title = $attributes->item($i)->nodeValue;
break;
case 'src':
$src = $attributes->item($i)->nodeValue;
if ($src[0] != '/') {
$src = basename($this->retriever->getFullFilePath($src));
}
break;
case 'category':
// if category is set in XML, then overrides the web settings
// TODO: should have a setting for if to use xml or web settings
$category = explode(',', $attributes->item($i)->nodeValue);
break;
// case 'tag':
// $tag = explode( ',', $attributes->item( $i )->nodeValue );
// break;
// case 'tag':
// $tag = explode( ',', $attributes->item( $i )->nodeValue );
// break;
case 'order':
$order = $attributes->item($i)->nodeValue;
break;
// /* future cases
// case 'overwrite-existing':
// break;
// */
// /* future cases
// case 'overwrite-existing':
// break;
// */
default:
break;
}
}
}
if (!is_null($category) && is_array($category)) {
foreach ($category as $index => $cat) {
$cat_id = wp_create_category(trim($cat));
$settings->addCategory(intval($cat_id));
}
}
/* if ( !is_null( $tag ) && is_array( $tag ) ) {
foreach ( $tag as $t ) {
//TODO: support tags
}
}*/
$webPage = new WebPage($this->retriever, $title, $src, null, $settings);
$webPage->setOrderPosition($order);
if (is_null($parentPage)) {
$this->trees[] = $webPage;
} else {
$parentPage->addChild($webPage);
}
}
$children = $node->childNodes;
if (isset($children)) {
for ($i = 0; $i < $children->length; $i++) {
$this->readInChildNode($children->item($i), $webPage);
}
}
}