Created
June 16, 2017 07:00
-
-
Save hissy/1cabef81ad84a21766eee1487aa009f1 to your computer and use it in GitHub Desktop.
[concrete5] [Legacy] Export only scrapbook proxy blocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* config/site_post.php */ | |
$req = Request::get(); | |
if ($req->getRequestPath() == 'export_scrapbook_proxies') { | |
$root = new SimpleXMLElement("<concrete5-cif></concrete5-cif>"); | |
$root->addAttribute('version', '1.0'); | |
$pages = $root->addChild("pages"); | |
// Get all active scrapbook proxy blocks | |
$db = Loader::db(); | |
$q = 'select bID from Blocks where btID = ? and bIsActive = 1'; | |
$v = array(BlockType::getByHandle(BLOCK_HANDLE_SCRAPBOOK_PROXY)->getBlockTypeID()); | |
$r = $db->GetAll($q, $v); | |
foreach ($r as $item) { | |
// Get the block instance | |
$b = Block::getByID($item['bID']); | |
// var_dump($b); | |
// Get the page that contains this block | |
$c = $b->getBlockCollectionObject(); | |
// var_dump($c); | |
// Get the area that contains this block | |
$q = 'select cvb.arHandle from CollectionVersionBlocks cvb left join CollectionVersions cv' | |
. ' on cvb.cID = cv.cID and cvb.cvID = cv.cvID and cv.cvIsApproved = 1' | |
. ' where cvb.bID = ?'; | |
$v = array($b->getBlockID()); | |
$r = $db->GetOne($q, $v); | |
$a = Area::get($c, $r); | |
// var_dump($a); | |
/** @var CoreScrapbookDisplayBlockController $bi */ | |
$bi = $b->getInstance(); | |
$_bx = Block::getByID($bi->getOriginalBlockID()); | |
$_bx->setBlockAreaObject($a); | |
$_bx->setProxyBlock($b); | |
$_bx->loadNewCollection($c); | |
// var_dump($_bx); | |
// Add page node and set attributes | |
$p = $pages->addChild('page'); | |
$p->addAttribute('name', $c->getCollectionName()); | |
$p->addAttribute('path', $c->getCollectionPath()); | |
$p->addAttribute('filename', $c->getCollectionFilename()); | |
$p->addAttribute('public-date', $c->getCollectionDatePublic()); | |
$p->addAttribute('pagetype', $c->getCollectionTypeHandle()); | |
$p->addAttribute('description', $c->getCollectionDescription()); | |
$p->addAttribute('package', $c->getPackageHandle()); | |
// Add area node | |
$area = $p->addChild('area'); | |
$area->addAttribute('name', $a->getAreaHandle()); | |
// Export original block | |
$_bx->export($area); | |
} | |
header('Content-Type: text/xml'); | |
echo $root->asXML(); | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment