function load_container($bucketid, $blockid) { $elements[$bucketid] = $blockid; $controller = new FrameworkController(); $content = $controller->getContent($elements); return $content; }
/** * This function is to support saving bucket config changes * via Ajax */ protected function handleAjax() { $data['success'] = 0; $framework = new FrameworkController(); $site = $framework->getSite(); if ($GLOBALS['BAC_PAGE_PERMISSIONS']->checkAction('editBucketProperties') > 0) { if (isset($this->post['pageurl']) && isset($this->post['propertiesBucketId'])) { if (!empty($this->post['pageurl']) && $site->hasBucket($this->post['propertiesBucketId'])) { $bucket = $site->getBucket($this->post['propertiesBucketId']); $bucket->setLiveUrl($this->post['pageurl']); $data['success'] = $bucket->writeConfig(); $data['liveUrl'] = $bucket->getLiveUrl(); $data['bucketId'] = $bucket->getBucketId(); } } } else { $data['success'] = 0; } if ($GLOBALS['BAC_PAGE_PERMISSIONS']->checkAction('createBlock') > 0) { if (isset($this->post['newblockid']) && isset($this->post['addBlockBucketId'])) { if (!empty($this->post['newblockid']) && $site->hasBucket($this->post['addBlockBucketId'])) { $bucket = $site->getBucket($this->post['addBlockBucketId']); $newblockConfig = array("type" => BlockTypes::Text, "blockid" => $this->post['newblockid'], "bucketid" => $bucket->getBucketId()); $factory = new BlockFactory(); $newblock = $factory->build($newblockConfig); $data['success'] = $bucket->addBlock($newblock); } } } else { $data['success'] = 0; } if ($GLOBALS['BAC_PAGE_PERMISSIONS']->checkAction('deleteBlock') > 0) { if (isset($this->post['deleteBlock']) && isset($this->post['deleteBlockBlockId']) && isset($this->post['deleteBlockBucketId'])) { if (!empty($this->post['deleteBlockBlockId']) && $site->hasBucket($this->post['deleteBlockBucketId'])) { $bucket = $site->getBucket($this->post['deleteBlockBucketId']); if ($bucket->hasBlock($this->post['deleteBlockBlockId'])) { if ($bucket->removeBlock($this->post['deleteBlockBlockId'])) { $data['success'] = 1; } else { $data['success'] = 0; } } } } } else { $data['success'] = 0; } $ret['ajax'] = true; $ret['data'] = $data; return $ret; }
protected function handlePost() { if (!empty($this->post['block_content']) && !empty($this->post['block']) && !empty($this->post['bucket'])) { $blockid = $this->post['block']; $bucketid = $this->post['bucket']; $framework = new FrameworkController(); $site = $framework->getSite(); $bucket = $site->getBucket($bucketid); $block = $bucket->getBlock($blockid); $block->setValue($this->post['block_content']); $block->saveBlock(); $ret['postSuccess'] = 1; return $ret; } else { $ret['postSuccess'] = 0; return $ret; } }
<?php /**This file is a blog bucket test **/ //include 'auth.php'; require_once __DIR__ . '/../src/framework/classloader.php'; $framework = new FrameworkController(); $site = $framework->getSite(); //$result = $site->addBucket('testBlogBucket', BucketTypes::Blog); $config['entryTemplate'] = "<h1>Title</h1><br /><div style=\"border:1px solid red;\">[entry]</div>"; $config['sortOrder'] = "entryDate"; $result = $site->addBucket('testBlogBucket', BucketTypes::Blog, $config); $blogBucket = $site->getBucket('testBlogBucket'); $entry1 = new EntryBlock(date("Y/m/d"), "Alex", "Test", "entry1"); $entry1->setValue("my awesome blog post 1"); $entry2 = new EntryBlock(date("Y/m/d"), "Alex", "Test", "entry2"); $entry2->setValue("my awesome blog post 2"); $entry3 = new EntryBlock(date("Y/m/d"), "Alex", "Test", "entry3"); $entry3->setValue("my awesome blog post 3"); $blogBucket->addBlock($entry1); $blogBucket->addBlock($entry2); $blogBucket->addBlock($entry3); $blogid = ''; $entrytemplate = ''; $blocklist = ''; $value = $blogBucket->render(''); ?> <html> <body> <table style="border:1px solid black;"> <tr style="border:1px solid black;"><th span="row" style="border:1px solid black;">Blog bucket:</th><td style="border:1px solid black;"><?php
private function build_sitemap_string() { $sitemapstring = ""; $framework = new FrameworkController(); $site = $framework->getSite(); if (!$site) { return; } $bucketlist = $site->getAllBuckets(); if (!$bucketlist) { return; } $maxblocks = 0; $firstbucket = true; foreach ($bucketlist as $bucket) { if ($firstbucket) { $sitemapstring = $sitemapstring . $bucket->getBucketId() . ":"; } else { $sitemapstring = $sitemapstring . '|' . $bucket->getBucketId() . ":"; } $firstbucket = false; $firstblock = true; $blocklist = $bucket->getAllBlocks(); if ($blocklist) { foreach ($blocklist as $block) { if ($firstblock) { $sitemapstring = $sitemapstring . $block->getBlockId(); } else { $sitemapstring = $sitemapstring . ',' . $block->getBlockId(); } $firstblock = false; } } } return $sitemapstring; }