本文整理汇总了PHP中BreadCrumb::getRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP BreadCrumb::getRoot方法的具体用法?PHP BreadCrumb::getRoot怎么用?PHP BreadCrumb::getRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BreadCrumb
的用法示例。
在下文中一共展示了BreadCrumb::getRoot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transform
public function transform(BreadCrumb $breadCrumb)
{
$result = $breadCrumb->getRoot();
$isFirst = true;
foreach ($breadCrumb->getNodes() as $node) {
if ($isFirst) {
$isFirst = false;
if ($breadCrumb->getDepth() > 1) {
$result .= "/" . $node->getPropertyName();
}
continue;
}
$result .= "/" . $node->getTemplateName();
if ($node->getTemplateIndex() != 0) {
$result .= "/" . $node->getTemplateIndex();
}
}
return $result;
}
示例2: myGenerate
/**
* This function returns two results:
* [triples: the generated triples, metaTriples: meta triples 2: the used templates]
*
* Unfortunately I haven't renamed the variables yet - result
* is the array containing the result TRIPLES!! - its not this
* 2 element.
*
*/
private function myGenerate(BreadCrumb $breadCrumb, $value)
{
// result is the array containing: triples, meta triples, used templates
$result = array(array(), array(), array());
$rootSubjectUri = RDFTriple::page($breadCrumb->getRoot());
// this array is only relevant on depth 0
$relatedClasses = array();
//$metaTriples = array();
//$usedTemplateNames = array();
// 'parent' means the parent of the value - thus subject and predicate
$parentName = $this->breadCrumbTransformer->transform($breadCrumb);
$parentResource = RDFTriple::page($parentName);
$parentPropertyName = null;
$tmp = $breadCrumb->peekTop(0);
if (isset($tmp)) {
$parentPropertyName = $tmp->getPropertyName();
}
// Get all templates on this site, indexed by name
// (there may be multiple templates with the same name)
$nameToTemplates = SimpleWikiTemplateMatcher::match($value);
//print_r($value);
//print_r($nameToTemplates);
//echo "NOW COMES THE STORM\n";
foreach ($nameToTemplates as $templateName => $templates) {
if (strlen($templateName) < 1) {
continue;
}
//echo "GOT TEMPLATE NAME $templateName\n";
$templateName = $this->mediaWikiUtil->toCanonicalWikiCase($templateName);
if (!$this->templateNameFilter->doesAccept($templateName)) {
continue;
}
$templateUri = RDFTriple::URI(DB_TEMPLATE_NS . $templateName, false);
$result[2][$templateName] = 1;
// Get annotations for the template - if there are any
$lookupName = "Template:{$templateName}/doc";
if ($breadCrumb->getDepth() == 0) {
$ta = $this->templateDb->getTemplateAnnotation($lookupName);
// Create the triples for "relatesToClass"
// But only for the page itself (not for sub templates)
// if no related class exists, default to rdf:type owl:Thing
if (isset($ta)) {
foreach ($ta->getRelatedClasses() as $item) {
$relatedClasses[$item] = 1;
}
}
}
foreach ($templates as $templateIndex => $template) {
//echo "GOT TEMPLATE INDEX $templateIndex\n";
// Iterate over all arguments
$arguments = $template->getArguments();
foreach ($arguments as $argumentName => $values) {
//echo "GOT ARGUMENT NAME $argumentName\n";
// propertyNs defaults to DB_PROPERTY_NS unless there
// exists a mapping in the templatedb. In that case it will
// be set to DB_ONTOLOGY_NS
$propertyNs = DB_PROPERTY_NS;
$pa = null;
if (isset($ta)) {
$pas = $ta->getPropertyAnnotations();
if (array_key_exists($argumentName, $pas)) {
$pa = $pas[$argumentName];
$propertyNs = DB_ONTOLOGY_NS;
}
}
//print_r($ta);
//echo "PROPERTY NS : $lookupName - $argumentName = $propertyNs\n";
// Fake a property mapping if there was none in the db
// This maps argumentName back to iteself
if (!isset($pa)) {
// If there was no mapping we might ignore it
// depending on an option (We can prevent this extractor
// to generate triples with properties in the
// dbp:property namespace
// We allow such triples on subResources though.
if ($this->allowUnmappedProperties != true && $breadCrumb->getDepth() == 0) {
continue;
}
// If there was no mapping, also rename numeric
// argument names (e.g. 1 becomes property1)
// this is just cosmetic for the result
if (is_numeric($argumentName)) {
$argumentName = "property{$argumentName}";
}
$pa = new PropertyAnnotation($argumentName);
$pa->addMapping(new PropertyMapping($argumentName));
}
foreach ($pa->getMappings() as $pm) {
$parseHint = $pm->getParseHint();
//echo "Mapping $argumentName : {$pm->getRenamedValue()}\n\n";
// if the renamed value is not set, use the original
//.........这里部分代码省略.........