/**
  * @param Localization $localization
  * @return array
  */
 private function getLocalizationData(Localization $localization)
 {
     $page = $localization->getMaster();
     $allLocalizationData = array();
     foreach ($page->getLocalizations() as $locale => $pageLocalization) {
         $allLocalizationData[$locale] = $pageLocalization->getId();
     }
     $ancestorIds = Entity::collectIds($localization->getAncestors());
     // abstract localization data
     $localizationData = array('root' => $page->isRoot(), 'tree_path' => $ancestorIds, 'locale' => $localization->getLocaleId(), 'localizations' => $allLocalizationData, 'lock' => $this->getLocalizationEditLockData($localization), 'is_visible_in_menu' => $localization->isVisibleInMenu(), 'is_visible_in_sitemap' => $localization->isVisibleInSitemap(), 'include_in_search' => $localization->isIncludedInSearch(), 'page_change_frequency' => $localization->getChangeFrequency(), 'page_priority' => $localization->getPagePriority(), 'internal_html' => null, 'contents' => array());
     if ($localization instanceof PageLocalization) {
         $creationTime = $localization->getCreationTime();
         $publicationSchedule = $localization->getScheduleTime();
         $localizationData = array_replace($localizationData, array('keywords' => $localization->getMetaKeywords(), 'description' => $localization->getMetaDescription(), 'created_date' => $creationTime->format('Y-m-d'), 'created_time' => $creationTime->format('H:i:s'), 'scheduled_date' => $publicationSchedule ? $publicationSchedule->format('Y-m-d') : null, 'scheduled_time' => $publicationSchedule ? $publicationSchedule->format('H:i:s') : null, 'active' => $localization->isActive(), 'template' => array('id' => $localization->getTemplate()->getId(), 'title' => $localization->getTemplateLocalization()->getTitle())));
     } elseif ($localization instanceof TemplateLocalization) {
         $layoutData = null;
         if ($page->hasLayout($this->getMedia())) {
             $layoutName = $page->getLayoutName($this->getMedia());
             $layout = $this->getActiveTheme()->getLayout($layoutName);
             if ($layout !== null) {
                 $layoutData = array('id' => $layout->getName(), 'title' => $layout->getTitle());
             }
         }
         $localizationData = array_replace($localizationData, array('layouts' => $this->getActiveThemeLayoutsData(), 'layout' => $layoutData));
     }
     return array_replace($this->loadNodeMainData($localization), $localizationData);
 }
 /**
  * Loads main node data array
  * 
  * @param Localization $localization
  * @return array
  */
 protected function loadNodeMainData(Localization $localization)
 {
     $localeId = $this->getCurrentLocale()->getId();
     $isCurrentLocaleLocalization = $localization->getLocaleId() === $localeId;
     $page = $localization->getMaster();
     $nodeData = array('id' => $isCurrentLocaleLocalization ? $localization->getId() : $page->getId(), 'master_id' => $page->getId(), 'type' => $page::DISCRIMINATOR, 'title' => $localization->getTitle(), 'global' => $page->isGlobal(), 'localized' => $isCurrentLocaleLocalization, 'editable' => $isCurrentLocaleLocalization, 'isDraggable' => $isCurrentLocaleLocalization, 'isDropTarget' => true, 'preview' => null, 'droppablePlaces' => array('before' => true, 'after' => true, 'inside' => $isCurrentLocaleLocalization), 'icon' => null);
     if ($localization instanceof PageLocalization) {
         $nodeData = array_merge($nodeData, $this->getPageLocalizationData($localization));
     }
     return $nodeData;
 }
 public function addFilterByChild(Localization $localization, $minDepth = 0, $maxDepth = null)
 {
     $this->setLocale($localization->getLocaleId());
     $this->pageFinder->addFilterByChild($localization->getMaster(), $minDepth, $maxDepth);
 }