예제 #1
0
 function getG2Tree(&$xmap, &$parent, $params, &$items, &$urlGenerator)
 {
     if (!$items) {
         return null;
     }
     $xmap->changeLevel(1);
     $media = array();
     foreach ($items as $itemId) {
         // Fetch the details for this item
         list($ret, $entity) = GalleryCoreApi::loadEntitiesById($itemId);
         if ($ret) {
             // error, skip and continue, catch this error in next component version
             continue;
         }
         $node = new stdClass();
         $node->id = $entity->getId();
         $node->uid = $parent->uid . 'a' . $entity->getId();
         $node->name = $entity->getTitle();
         $node->pid = $entity->getParentId();
         $node->modified = $entity->getModificationTimestamp();
         $node->link = $urlGenerator->generateUrl(array('view' => 'core.ShowItem', 'itemId' => $node->id), array('forceSessionId' => false, 'forceFullUrl' => false));
         // Fix for the navigator view
         if ($xmap->view == 'navigator') {
             $node->link = str_replace('/administrator/index.php', '', $node->link);
         }
         // If it is an album
         if ($entity->getCanContainChildren()) {
             $node->priority = $params['cat_priority'];
             $node->changefreq = $params['cat_changefreq'];
             $node->expandible = true;
             // Get all child items contained in this album and add them to the tree
             list($ret, $childIds) = GalleryCoreApi::fetchChildItemIdsWithPermission($node->id, 'core.view');
             if ($ret) {
                 // error, skip and continue, catch this error in next component version
                 continue;
             }
             if ($xmap->printNode($node) !== false) {
                 xmap_com_g2bridge::getG2Tree($xmap, $parent, $params, $childIds, $urlGenerator);
             }
         } elseif ($params['include_items']) {
             $node->priority = $params['item_priority'];
             $node->changefreq = $params['item_changefreq'];
             $node->uid = $parent->uid . 'p' . $entity->getId();
             $node->expandible = false;
             $media[] = $node;
         }
     }
     foreach ($media as $pic) {
         $xmap->printNode($pic);
     }
     $xmap->changeLevel(-1);
 }