Example #1
0
 public static function exportList($xml)
 {
     $list = self::getList(false, true);
     $nxml = $xml->addChild('pagetypes');
     foreach ($list as $ct) {
         $type = $nxml->addChild('pagetype');
         $type->addAttribute('handle', $ct->getCollectionTypeHandle());
         $type->addAttribute('name', $ct->getCollectionTypeName());
         $type->addAttribute('internal', $ct->isCollectionTypeInternal());
         $type->addAttribute('icon', $ct->getCollectionTypeIcon());
         $type->addAttribute('package', $ct->getPackageHandle());
         if ($ct->isCollectionTypeIncludedInComposer()) {
             $composer = $type->addChild('composer');
             $composer->addAttribute('method', $ct->getCollectionTypeComposerPublishMethod());
             $parent = '';
             $pagetype = '';
             if ($ct->getCollectionTypeComposerPublishPageTypeID() > 0) {
                 $pagetype = ContentExporter::replacePageTypeWithPlaceHolder($ct->getCollectionTypeComposerPublishPageTypeID());
             }
             if ($ct->getCollectionTypeComposerPublishPageParentID() > 0) {
                 $parent = ContentExporter::replacePageWithPlaceHolder($ct->getCollectionTypeComposerPublishPageParentID());
             }
             $composer->addAttribute('pagetype', $pagetype);
             $composer->addAttribute('parent', $parent);
             $items = $ct->getComposerContentItems();
             if (count($items) > 0) {
                 $itemNode = $composer->addChild('items');
                 foreach ($items as $ci) {
                     $ci->export($itemNode, 'composer');
                 }
             }
         }
         $mcID = $ct->getMasterCollectionID();
         if ($mcID > 0) {
             $mc = Page::getByID($mcID);
             $mc->export($type);
         }
     }
 }
 public function export(SimpleXMLElement $blockNode)
 {
     $tables[] = $this->getBlockTypeDatabaseTable();
     if (isset($this->btExportTables)) {
         $tables = $this->btExportTables;
     }
     $db = Loader::db();
     foreach ($tables as $tbl) {
         if (!$tbl) {
             continue;
         }
         $data = $blockNode->addChild('data');
         $data->addAttribute('table', $tbl);
         $columns = $db->MetaColumns($tbl);
         // remove columns we don't want
         unset($columns['BID']);
         $r = $db->Execute('select * from ' . $tbl . ' where bID = ?', array($this->bID));
         while ($record = $r->FetchRow()) {
             $tableRecord = $data->addChild('record');
             foreach ($record as $key => $value) {
                 if (isset($columns[strtoupper($key)])) {
                     if (in_array($key, $this->btExportPageColumns)) {
                         $tableRecord->addChild($key, ContentExporter::replacePageWithPlaceHolder($value));
                     } else {
                         if (in_array($key, $this->btExportFileColumns)) {
                             $tableRecord->addChild($key, ContentExporter::replaceFileWithPlaceHolder($value));
                         } else {
                             if (in_array($key, $this->btExportPageTypeColumns)) {
                                 $tableRecord->addChild($key, ContentExporter::replacePageTypeWithPlaceHolder($value));
                             } else {
                                 $cnode = $tableRecord->addChild($key);
                                 $node = dom_import_simplexml($cnode);
                                 $no = $node->ownerDocument;
                                 $node->appendChild($no->createCDataSection($value));
                             }
                         }
                     }
                 }
             }
         }
     }
 }