public function testSave()
 {
     $bt = BlockType::installBlockType($this->btHandle);
     $btx = BlockType::getByID(1);
     $class = $btx->getBlockTypeClass();
     $btc = new $class();
     $bID = 1;
     foreach ($this->requestData as $type => $requestData) {
         $nb = $bt->add($requestData);
         $data = $this->expectedRecordData[$type];
         $db = Loader::db();
         $r = $db->GetRow('select * from `' . $btc->getBlockTypeDatabaseTable() . '` where bID = ?', array($bID));
         foreach ($data as $key => $value) {
             $this->assertTrue($r[$key] == $value, 'Key `' . $key . '` did not equal expected value `' . $value . '` instead equalled `' . $r[$key] . '` (type `' . $type . '`)');
         }
         $bID++;
         ob_start();
         $bv = new BlockView($nb);
         $bv->render('view');
         $contents = ob_get_contents();
         ob_end_clean();
         $contents = trim($contents);
         if (isset($this->expectedOutput[$type])) {
             $this->assertTrue($this->expectedOutput[$type] == $contents, 'Output `' . $contents . '` did not equal expected output `' . $this->expectedOutput[$type] . '` (type `' . $type . '`)');
         }
     }
 }
Exemple #2
0
 /**
  * displays the Area in the page
  * ex: $a = new Area('Main'); $a->display($c);.
  *
  * @param Page $c
  * @param Block[] $alternateBlockArray optional array of blocks to render instead of default behavior
  *
  * @return bool
  */
 public function display($c = false, $alternateBlockArray = null)
 {
     if (!$c) {
         $c = Page::getCurrentPage();
     }
     $v = View::getRequestInstance();
     if (!is_object($c) || $c->isError()) {
         return false;
     }
     $this->load($c);
     $ap = new Permissions($this);
     if (!$ap->canViewArea()) {
         return false;
     }
     $blocksToDisplay = $alternateBlockArray ? $alternateBlockArray : $this->getAreaBlocksArray();
     $u = new User();
     // now, we iterate through these block groups (which are actually arrays of block objects), and display them on the page
     if ($this->showControls && $c->isEditMode() && $ap->canViewAreaControls()) {
         View::element('block_area_header', array('a' => $this));
     } else {
         View::element('block_area_header_view', array('a' => $this));
     }
     foreach ($blocksToDisplay as $b) {
         $bv = new BlockView($b);
         $bv->setAreaObject($this);
         $p = new Permissions($b);
         if ($p->canViewBlock()) {
             if (!$c->isEditMode()) {
                 echo $this->enclosingStart;
             }
             $bv->render('view');
             if (!$c->isEditMode()) {
                 echo $this->enclosingEnd;
             }
         }
     }
     if ($this->showControls && $c->isEditMode() && $ap->canViewAreaControls()) {
         View::element('block_area_footer', array('a' => $this));
     } else {
         View::element('block_area_footer_view', array('a' => $this));
     }
 }
Exemple #3
0
        }
        ?>
            </div>
        </nav>

        <div id="ccm-stack-container">
            <?php 
        $a = Area::get($stackToEdit, STACKS_AREA_NAME);
        $a->forceControlsToDisplay();
        View::element('block_area_header', array('a' => $a));
        foreach ($blocks as $b) {
            $bv = new BlockView($b);
            $bv->setAreaObject($a);
            $p = new Permissions($b);
            if ($p->canViewBlock()) {
                $bv->render('view');
            }
        }
        //View::element('block_area_footer', array('a' => $a));
        print '</div>';
        // No, we don't include the footer because we don't want all area controls available.
        // But the footer element has a closing DIV we need.
        ?>
        </div>

        <?php 
        if ($deleteLabels !== null) {
            ?>
            <div style="display: none">
                <div id="ccm-dialog-delete-stack" class="ccm-ui">
                    <form method="post" class="form-stacked" style="padding-left: 0px" action="<?php 
Exemple #4
0
 protected function getPageFeedContent(Page $p)
 {
     switch ($this->pfContentToDisplay) {
         case 'S':
             return $p->getCollectionDescription();
         case 'A':
             $a = new \Area($this->getAreaHandleToDisplay());
             $blocks = $a->getAreaBlocksArray($p);
             $r = Request::getInstance();
             $r->setCurrentPage($p);
             ob_start();
             foreach ($blocks as $b) {
                 $bv = new BlockView($b);
                 $bv->render('view');
             }
             $content = ob_get_contents();
             ob_end_clean();
             return $content;
     }
 }
Exemple #5
0
 /**
  * Renders a particular view of a block type, using the public $controller variable as the block type's controller
  *
  * @param string template 'view' for the default
  * @return void
  */
 public function render($view = 'view')
 {
     $bv = new BlockView($this);
     $bv->render($view);
 }
Exemple #6
0
<?php

use Concrete\Core\Block\View\BlockView;
defined('C5_EXECUTE') or die("Access Denied.");
$bo = Block::getByID($bOriginalID);
$bp = new Permissions($bo);
$bo->setProxyBlock($b);
if ($bp->canWrite()) {
    $bv = new BlockView($bo);
    ?>

    <div class="ccm-ui">
        <div class="alert alert-info">
            <?php 
    echo t("This block was copied from another location. Editing it will create a new instance of it.");
    ?>
        </div>
    </div>

    <?php 
    $bv->addScopeItems($view->getScopeItems());
    $bv->render('edit');
}
Exemple #7
0
 public function display($view = 'view')
 {
     if ($this->getBlockTypeID() < 1) {
         return;
     }
     $bv = new BlockView($this);
     $bv->render($view);
 }
Exemple #8
0
 protected function getPageFeedContent(Page $p)
 {
     $content = false;
     switch ($this->pfContentToDisplay) {
         case 'S':
             $content = $p->getCollectionDescription();
             break;
         case 'A':
             $a = new \Area($this->getAreaHandleToDisplay());
             $blocks = $a->getAreaBlocksArray($p);
             $r = Request::getInstance();
             $r->setCurrentPage($p);
             ob_start();
             foreach ($blocks as $b) {
                 $bv = new BlockView($b);
                 $bv->render('view');
             }
             $content = ob_get_contents();
             ob_end_clean();
             break;
     }
     $f = $p->getAttribute('thumbnail');
     if (is_object($f)) {
         $content = '<p><img src="' . $f->getURL() . '" /></p>' . $content;
     }
     return $content;
 }