/**
  * Instantiates the block controller.
  *
  * @param BlockType $obj |Block $obj
  */
 public function __construct($obj = null)
 {
     parent::__construct();
     if ($obj instanceof BlockType) {
         $this->identifier = 'BLOCKTYPE_' . $obj->getBlockTypeID();
         $this->btHandle = $obj->getBlockTypeHandle();
     } else {
         if ($obj instanceof Block) {
             $b = $obj;
             $this->identifier = 'BLOCK_' . $obj->getBlockID();
             $this->bID = $b->getBlockID();
             $this->btHandle = $obj->getBlockTypeHandle();
             $this->btCachedBlockRecord = $obj->getBlockCachedRecord();
             $this->setBlockObject($b);
             $this->load();
         }
     }
     $this->set('controller', $this);
 }
Esempio n. 2
0
 /**
  * Gets a full URL to the directory containing all of a block's items, including JavaScript, tools, icons, etc...
  *
  * @param \Concrete\Core\Entity\Block\BlockType\BlockType $bt
  * @param bool|string $file If provided will get the assets url for a file in a block
  *
  * @return string $url
  */
 public function getBlockTypeAssetsURL($bt, $file = false)
 {
     $ff = '';
     if ($file != false) {
         $ff = '/' . $file;
     }
     $url = '';
     if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $bt->getBlockTypeHandle() . $ff)) {
         $url = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
     } elseif ($bt->getPackageID() > 0) {
         $h = $bt->getPackageHandle();
         $dirp = is_dir(DIR_PACKAGES . '/' . $h) ? DIR_PACKAGES . '/' . $h : DIR_PACKAGES_CORE . '/' . $h;
         if (file_exists($dirp . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff)) {
             $url = is_dir(DIR_PACKAGES . '/' . $h) ? DIR_REL : ASSETS_URL;
             $url = $url . '/' . DIRNAME_PACKAGES . '/' . $h . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
         }
     } elseif (file_exists(DIR_FILES_BLOCK_TYPES_CORE . '/' . $bt->getBlockTypeHandle() . $ff)) {
         $url = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
     }
     return $url;
 }