public function importValue(SimpleXMLElement $akv) { if (isset($akv->value->fID)) { $fIDVal = (string) $akv->value->fID; $fID = ContentImporter::getValue($fIDVal); if ($fID) { return File::getByID($fID); } } }
public function swapContent($options) { if ($this->validateClearSiteContents($options)) { Loader::model("page_list"); Loader::model("file_list"); Loader::model("stack/list"); $pl = new PageList(); $pages = $pl->get(); foreach ($pages as $c) { $c->delete(); } $fl = new FileList(); $files = $fl->get(); foreach ($files as $f) { $f->delete(); } // clear stacks $sl = new StackList(); foreach ($sl->get() as $c) { $c->delete(); } $home = Page::getByID(HOME_CID); $blocks = $home->getBlocks(); foreach ($blocks as $b) { $b->deleteBlock(); } $pageTypes = CollectionType::getList(); foreach ($pageTypes as $ct) { $ct->delete(); } // now we add in any files that this package has if (is_dir($this->getPackagePath() . '/content_files')) { Loader::library('file/importer'); $fh = new FileImporter(); $contents = Loader::helper('file')->getDirectoryContents($this->getPackagePath() . '/content_files'); foreach ($contents as $filename) { $f = $fh->import($this->getPackagePath() . '/content_files/' . $filename, $filename); } } // now we parse the content.xml if it exists. Loader::library('content/importer'); $ci = new ContentImporter(); $ci->importContentFile($this->getPackagePath() . '/content.xml'); } }
public function install_permissions() { $ci = new ContentImporter(); $ci->importContentFile(DIR_BASE_CORE . '/config/install/base/permissions.xml'); }
public function importComposerSettings(SimpleXMLElement $sx) { $db = Loader::db(); if ($sx['method'] == 'PAGE_TYPE') { $ctID = ContentImporter::getValue($sx['pagetype']); $cta = CollectionType::getByID($ctID); $this->saveComposerPublishTargetPageType($cta); } else { if ($sx['method'] == 'PARENT') { $cID = ContentImporter::getValue($sx['parent']); $c = Page::getByID($cID); $this->saveComposerPublishTargetPage($c); } else { $this->saveComposerPublishTargetAll(); } } if (isset($sx->items)) { foreach ($sx->items->children() as $node) { $displayOrder = $db->GetOne('select max(displayOrder) as displayOrder from ComposerContentLayout where ctID = ?', array($this->ctID)); if ($displayOrder !== false) { if ($displayOrder > 0) { $displayOrder++; } else { $displayOrder = 1; } } else { $displayOrder = 0; } if ($node->getName() == 'attributekey') { $ak = CollectionAttributeKey::getByHandle((string) $node['handle']); $v = array($ak->getAttributeKeyID(), $displayOrder, $this->ctID); $db->Execute('insert into ComposerContentLayout (akID, displayOrder, ctID) values (?, ?, ?)', $v); } if ($node->getName() == 'block') { $mcID = $this->getMasterCollectionID(); $bID = $db->GetOne('select Blocks.bID from CollectionVersionBlocks inner join Blocks on CollectionVersionBlocks.bID = Blocks.bID where cID = ? and Blocks.bName = ?', array($mcID, (string) $node['name'])); $v = array($bID, $displayOrder, (string) $node['composer-template'], $this->ctID); $db->Execute('insert into ComposerContentLayout (bID, displayOrder, ccFilename, ctID) values (?, ?, ?, ?)', $v); } } } }
public function import($page, $arHandle, SimpleXMLElement $blockNode) { $args = array(); $db = Loader::db(); // handle the adodb stuff $args = $this->getImportData($blockNode); $bt = BlockType::getByHandle($this->btHandle); $b = $page->addBlock($bt, $arHandle, $args); $b->updateBlockInformation(array('bName' => $blockNode['name'], 'bFilename' => $blockNode['custom-template'])); if ($page->isMasterCollection() && $blockNode['mc-block-id'] != '') { ContentImporter::addMasterCollectionBlockID($b, (string) $blockNode['mc-block-id']); } // now we insert stuff that isn't part of the btTable // we have to do this this way because we need a bID $this->importAdditionalData($b, $blockNode); }
function mk_ajax_import_options() { include_once THEME_DIR . '/demo-importer/engine/content_importer.php'; parse_str($_POST["options"], $options); if (!empty($options['template'])) { $content_importer = new ContentImporter($_POST["options"]); $content_importer->import(); $options['template'] = ''; } }
public function installDashboard() { Loader::library('content/importer'); $ci = new ContentImporter(); $ci->importContentFile(DIR_BASE_CORE . '/config/install/base/dashboard.xml'); }
function abb_import_demo_action() { include_once THEME_DIR . '/demo-importer/content_importer.php'; parse_str($_POST["options"], $options); if (!empty($options['template'])) { $content_importer = new ContentImporter($_POST["options"]); $content_importer->import(); $options['template'] = ''; wp_die(); } }
protected function importAttributeSets(SimpleXMLElement $sx) { if (isset($sx->attributesets)) { foreach($sx->attributesets->attributeset as $as) { $akc = AttributeKeyCategory::getByHandle($as['category']); $pkg = ContentImporter::getPackageObject($as['package']); $set = $akc->addSet((string) $as['handle'], (string) $as['name'], $pkg, $as['locked']); foreach($as->children() as $ask) { $ak = $akc->getAttributeKeyByHandle((string) $ask['handle']); if (is_object($ak)) { $set->addKey($ak); } } } } }
protected function importAdditionalData($b, $blockNode) { if (isset($blockNode->data)) { foreach ($blockNode->data as $data) { if (strtoupper($data['table']) != strtoupper($this->getBlockTypeDatabaseTable())) { $table = (string) $data['table']; if (isset($data->record)) { foreach ($data->record as $record) { $aar = new ADODB_Active_Record($table); $aar->bID = $b->getBlockID(); foreach ($record->children() as $node) { $nodeName = $node->getName(); if (strcasecmp($table, 'btSlideshowImg') === 0 && strcasecmp($nodeName, 'slideshowImgId') === 0) { continue; } $aar->{$nodeName} = ContentImporter::getValue((string) $node); } $aar->Save(); } } } } } }
public function install() { $pkg = parent::install(); $ci = new ContentImporter(); $ci->importContentFile($pkg->getPackagePath() . '/install/blocktypes.xml'); }
public function set_site_permissions() { $ci = new ContentImporter(); $ci->importContentFile(DIR_BASE_CORE. '/config/install/base/permissions.xml'); Loader::model('file_set'); $fs = FileSet::getGlobal(); $g1 = Group::getByID(GUEST_GROUP_ID); $g2 = Group::getByID(REGISTERED_GROUP_ID); $g3 = Group::getByID(ADMIN_GROUP_ID); $fs->setPermissions($g1, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE); $fs->setPermissions($g2, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE); $fs->setPermissions($g3, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL); Config::save('SITE', SITE); Config::save('SITE_APP_VERSION', APP_VERSION); $u = new User(); $u->saveConfig('NEWSFLOW_LAST_VIEWED', 'FIRSTRUN'); $args = array(); $args['cInheritPermissionsFrom'] = 'OVERRIDE'; $args['cOverrideTemplatePermissions'] = 1; $args['collectionRead'][] = 'gID:' . GUEST_GROUP_ID; $args['collectionAdmin'][] = 'gID:' . ADMIN_GROUP_ID; $args['collectionRead'][] = 'gID:' . ADMIN_GROUP_ID; $args['collectionApprove'][] = 'gID:' . ADMIN_GROUP_ID; $args['collectionReadVersions'][] = 'gID:' . ADMIN_GROUP_ID; $args['collectionWrite'][] = 'gID:' . ADMIN_GROUP_ID; $args['collectionDelete'][] = 'gID:' . ADMIN_GROUP_ID; $home = Page::getByID(1, "RECENT"); $home->updatePermissions($args); }