예제 #1
0
 /**
  * Get the id of the plan entry which ultimately contains this entry
  */
 public static function get_ancestor_entryid(SimpleXMLElement $entry, PluginImportLeap $importer)
 {
     $entryid = (string) $entry->id;
     if (!isset(self::$ancestors[$entryid])) {
         self::$ancestors[$entryid] = null;
         $child = $entry;
         while ($child) {
             $childid = (string) $child->id;
             if (!isset(self::$parents[$childid])) {
                 self::$parents[$childid] = null;
                 foreach ($child->link as $link) {
                     $href = (string) $link['href'];
                     if ($href != $entryid && $importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'is_part_of') && $importer->entry_has_strategy($href, self::STRATEGY_IMPORT_AS_PLAN, 'plans')) {
                         self::$parents[$childid] = $href;
                         break;
                     }
                 }
             }
             if (!self::$parents[$childid]) {
                 break;
             }
             if ($child = $importer->get_entry_by_id(self::$parents[$childid])) {
                 self::$ancestors[$entryid] = self::$parents[$childid];
             }
         }
     }
     return self::$ancestors[$entryid];
 }