public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->pagetemplates)) {
         foreach ($sx->pagetemplates->pagetemplate as $pt) {
             $pkg = static::getPackageObject($pt['package']);
             $ptt = Template::getByHandle($pt['handle']);
             if (!is_object($ptt)) {
                 $ptt = Template::add((string) $pt['handle'], (string) $pt['name'], (string) $pt['icon'], $pkg, (string) $pt['internal']);
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $templates = $batch->getObjectCollection('page_template');
     if (!$templates) {
         return;
     }
     foreach ($templates->getTemplates() as $template) {
         if (!$template->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($template->getPackage()) {
                 $pkg = \Package::getByHandle($template->getPackage());
             }
             Template::add($template->getHandle(), $template->getName(), $template->getIcon(), $pkg, $template->getIsInternal());
         }
     }
 }
 protected function installDesktops()
 {
     $this->output(t('Installing Desktops...'));
     $template = Template::getByHandle('desktop');
     if (!is_object($template)) {
         Template::add('desktop', t('Desktop'), FILENAME_PAGE_TEMPLATE_DEFAULT_ICON, null, true);
     }
     $type = \Concrete\Core\Page\Type\Type::getByHandle('core_desktop');
     if (!is_object($type)) {
         \Concrete\Core\Page\Type\Type::add(array('handle' => 'core_desktop', 'name' => 'Desktop', 'internal' => true));
     }
     $category = Category::getByHandle('collection')->getController();
     $attribute = CollectionKey::getByHandle('is_desktop');
     if (!is_object($attribute)) {
         $key = new PageKey();
         $key->setAttributeKeyHandle('is_desktop');
         $key->setAttributeKeyName('Is Desktop');
         $key->setIsAttributeKeyInternal(true);
         $category->add('boolean', $key);
     }
     $attribute = CollectionKey::getByHandle('desktop_priority');
     if (!is_object($attribute)) {
         $key = new PageKey();
         $key->setAttributeKeyHandle('desktop_priority');
         $key->setAttributeKeyName('Desktop Priority');
         $key->setIsAttributeKeyInternal(true);
         $category->add('number', $key);
     }
     $desktop = Page::getByPath('/dashboard/welcome');
     if (is_object($desktop) && !$desktop->isError()) {
         $desktop->moveToTrash();
     }
     $desktop = Page::getByPath('/desktop');
     if (is_object($desktop) && !$desktop->isError()) {
         $desktop->moveToTrash();
     }
     $page = \Page::getByPath("/account/messages");
     if (is_object($page) && !$page->isError()) {
         $page->moveToTrash();
     }
     // Private Messages tweak
     SinglePage::add('/account/messages');
     $ci = new ContentImporter();
     $ci->importContentFile(DIR_BASE_CORE . '/config/install/upgrade/desktops.xml');
     $desktop = Page::getByPath('/dashboard/welcome');
     $desktop->movePageDisplayOrderToTop();
     \Config::save('concrete.misc.login_redirect', 'DESKTOP');
 }