当前位置: 首页>>代码示例>>PHP>>正文


PHP Block::getByID方法代码示例

本文整理汇总了PHP中Block::getByID方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::getByID方法的具体用法?PHP Block::getByID怎么用?PHP Block::getByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Block的用法示例。


在下文中一共展示了Block::getByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendFormAction

function sendFormAction()
{
    if (empty($_POST['bID'])) {
        return error(t('Invalid form submission (missing bID)'));
    } else {
        $block = Block::getByID($_POST['bID']);
        $blockController = new FormController($block);
        $blockController->noSubmitFormRedirect = true;
        $redirectURL = '';
        // //Handle redirect-on-success...
        if ($blockController->redirectCID > 0) {
            $redirectPage = Page::getByID($blockController->redirectCID);
            if ($redirectPage->cID) {
                $redirectURL = Loader::helper('navigation')->getLinkToCollection($redirectPage, true);
            }
        }
        $blockController->redirectCID = 0;
        //reset this in block controller, otherwise it will exit before returning the data we need!
        try {
            $success = $blockController->action_submit_form($_POST['bID']);
            if ($success != null && $success == false) {
                return error(t('Invalid form submission (invalid block ids)'));
            }
        } catch (Exception $e) {
            return error($e->getMessage());
        }
        $fieldErrors = $blockController->get('errors');
        if (is_array($fieldErrors)) {
            foreach ($fieldErrors as $key => $value) {
                return error($fieldErrors[$key]);
            }
        }
        return success($blockController->thankyouMsg);
    }
}
开发者ID:76interactive,项目名称:c5_ajax_form,代码行数:35,代码来源:responder.php

示例2: outputAutoHeaderItems

		public function outputAutoHeaderItems() {
			$b = Block::getByID($this->bOriginalID);
			$bvt = new BlockViewTemplate($b);
			$headers = $bvt->getTemplateHeaderItems();
			if (count($headers) > 0) {
				foreach($headers as $h) {
					$this->addHeaderItem($h);
				}
			}
		}
开发者ID:nbourguig,项目名称:concrete5,代码行数:10,代码来源:controller.php

示例3: validateBlock

 protected function validateBlock($b)
 {
     $bi = $b->getInstance();
     if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) {
         $_b = \Block::getByID($bi->getOriginalBlockID());
         $bi = $_b->getInstance();
         // for validation
     }
     $e = $bi->validate($_POST);
     return $e;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:11,代码来源:edit.php

示例4: execute

 public function execute(ActionInterface $action)
 {
     $target = $action->getTarget();
     $subject = $action->getSubject();
     \Cache::disableAll();
     $c = Page::getByID($subject['cID']);
     $db = \Database::connection();
     if (is_object($c) && !$c->isError()) {
         $blocks = $c->getBlocks();
         $nvc = $c->getVersionToModify();
         $isApproved = $c->getVersionObject()->isApproved();
         foreach ($blocks as $b) {
             $controller = $b->getController();
             $pageColumns = $controller->getBlockTypeExportPageColumns();
             if (count($pageColumns)) {
                 $columns = $db->MetaColumnNames($controller->getBlockTypeDatabaseTable());
                 $data = array();
                 $record = $controller->getBlockControllerData();
                 foreach ($columns as $key) {
                     $data[$key] = $record->{$key};
                 }
                 foreach ($pageColumns as $column) {
                     $cID = $data[$column];
                     if ($cID > 0) {
                         $link = Page::getByID($cID, 'ACTIVE');
                         $section = $target->getSection();
                         if (is_object($section)) {
                             $relatedID = $section->getTranslatedPageID($link);
                             if ($relatedID) {
                                 $data[$column] = $relatedID;
                             }
                         }
                     }
                 }
                 unset($data['bID']);
                 $ob = $b;
                 // replace the block with the version of the block in the later version (if applicable)
                 $b2 = \Block::getByID($b->getBlockID(), $nvc, $b->getAreaHandle());
                 if ($b2->isAlias()) {
                     $nb = $ob->duplicate($nvc);
                     $b2->deleteBlock();
                     $b2 = clone $nb;
                 }
                 $b2->update($data);
             }
         }
         if ($isApproved) {
             $nvc->getVersionObject()->approve();
         }
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:51,代码来源:ReplaceBlockPageRelationsTask.php

示例5: getBodyContentFromPage

 public function getBodyContentFromPage($c)
 {
     $searchableAreaNamesInitial = $this->getSavedSearchableAreas();
     foreach ($this->searchableAreaNamesManual as $sm) {
         $searchableAreaNamesInitial[] = $sm;
     }
     $searchableAreaNames = array();
     if ($this->getSearchableAreaAction() == 'blacklist') {
         $areas = Area::getHandleList();
         foreach ($areas as $arHandle) {
             if (!in_array($arHandle, $searchableAreaNamesInitial)) {
                 $searchableAreaNames[] = $arHandle;
             }
         }
     } else {
         $searchableAreaNames = $searchableAreaNamesInitial;
     }
     if (count($searchableAreaNames) == 0) {
         return false;
     }
     $text = '';
     $tagsToSpaces = array('<br>', '<br/>', '<br />', '<p>', '</p>', '</ p>', '<div>', '</div>', '</ div>', '&nbsp;');
     $blarray = array();
     $db = Loader::db();
     $r = $db->Execute('select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ?', array($c->getCollectionID(), $c->getVersionID()));
     $th = Loader::helper('text');
     while ($row = $r->FetchRow()) {
         if (in_array($row['arHandle'], $searchableAreaNames)) {
             $b = Block::getByID($row['bID'], $c, $row['arHandle']);
             if (!is_object($b)) {
                 continue;
             }
             $bi = $b->getInstance();
             $bi->bActionCID = $c->getCollectionID();
             if (method_exists($bi, 'getSearchableContent')) {
                 $searchableContent = $bi->getSearchableContent();
                 if (strlen(trim($searchableContent))) {
                     $text .= $th->decodeEntities(strip_tags(str_ireplace($tagsToSpaces, ' ', $searchableContent)), ENT_QUOTES, APP_CHARSET) . ' ';
                 }
             }
             unset($b);
             unset($bi);
         }
     }
     $returned_text = Events::fire('on_page_body_index', $c, $text);
     if ($returned_text !== null && $returned_text !== false) {
         $text = $returned_text;
     }
     return $text;
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:50,代码来源:indexed_search.php

示例6: edit

 public function edit($cID, $arHandle, $bID, $action)
 {
     $c = \Page::getByID($cID);
     if (is_object($c) && !$c->isError()) {
         $b = \Block::getByID($bID, $c, $arHandle);
         if (is_object($b)) {
             $controller = $b->getController();
             if ($controller->validateEditBlockPassThruAction($b)) {
                 return $this->deliverResponse($controller, $action);
             }
         }
     }
     $response = new Response(t('Access Denied'));
     return $response;
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:15,代码来源:action.php

示例7: edit

 public function edit($cID, $arHandle, $bID, $action)
 {
     $c = \Page::getByID($cID);
     if (is_object($c) && !$c->isError()) {
         $b = \Block::getByID($bID, $c, $arHandle);
         if (is_object($b)) {
             $bp = new \Permissions($b);
             if ($bp->canEditBlock()) {
                 $controller = $b->getController();
                 return $this->deliverResponse($controller, $action);
             }
         }
     }
     $response = new Response(t('Access Denied'));
     return $response;
 }
开发者ID:Remo,项目名称:concrete5-1,代码行数:16,代码来源:action.php

示例8: submit

 public function submit()
 {
     if ($this->validateAction() && $this->canAccess()) {
         $a = \Area::get($this->page, $_GET['arHandle']);
         $c = $this->page;
         if (is_object($a)) {
             $b = \Block::getByID($_GET['bID'], $c, $a);
             $p = new \Permissions($b);
             if ($p->canAdminBlock() && $c->isMasterCollection()) {
                 if (is_array($_POST['cIDs'])) {
                     foreach ($_POST['cIDs'] as $cID) {
                         $nc = \Page::getByID($cID);
                         if (!$b->isAlias($nc)) {
                             $bt = $b->getBlockTypeObject();
                             if ($bt->isCopiedWhenPropagated()) {
                                 $b->duplicate($nc, true);
                             } else {
                                 $b->alias($nc);
                             }
                         }
                     }
                 }
                 // now remove any items that WERE checked and now aren't
                 if (is_array($_POST['checkedCIDs'])) {
                     foreach ($_POST['checkedCIDs'] as $cID) {
                         if (!is_array($_POST['cIDs']) || !in_array($cID, $_POST['cIDs'])) {
                             $nc = \Page::getByID($cID, 'RECENT');
                             $nb = \Block::getByID($_GET['bID'], $nc, $a);
                             if (is_object($nb) && !$nb->isError()) {
                                 $nb->deleteBlock();
                             }
                             $nc->rescanDisplayOrder($_REQUEST['arHandle']);
                         }
                     }
                 }
                 $er = new EditResponse();
                 $er->setPage($this->page);
                 $er->setAdditionalDataAttribute('bID', $b->getBlockID());
                 $er->setAdditionalDataAttribute('aID', $a->getAreaID());
                 $er->setAdditionalDataAttribute('arHandle', $a->getAreaHandle());
                 $er->setMessage(t('Defaults updated.'));
                 $er->outputJSON();
             }
         }
     }
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:46,代码来源:aliasing.php

示例9: testPageStylesBlock

 public function testPageStylesBlock()
 {
     $ps = new \Concrete\Core\StyleCustomizer\Inline\StyleSet();
     $ps->setBackgroundColor('#aaa');
     $ps->save();
     $c = $this->createPage('This is my test page');
     $bt = BlockType::installBlockType('content');
     $b = $c->addBlock($bt, 'Main', array('content' => 'Sample content.'));
     $b->setCustomStyleSet($ps);
     $this->assertEquals(1, $b->getCustomStyleSetID());
     $b2 = Block::getByID(1, $c, 'Main');
     $this->assertEquals(1, $b2->getBlockID());
     $style = $b2->getCustomStyle();
     $this->assertInstanceOf('\\Concrete\\Core\\Block\\CustomStyle', $style);
     $b2->resetCustomStyle();
     $css = $style->getCSS();
     $this->assertEquals('ccm-custom-style-container ccm-custom-style-main-1', $style->getContainerClass());
     $this->assertEquals('.ccm-custom-style-container.ccm-custom-style-main-1{background-color:#aaa}', $css);
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:19,代码来源:BlockStyleTest.php

示例10: execute

 public function execute(ActionInterface $action)
 {
     $target = $action->getTarget();
     $subject = $action->getSubject();
     \Cache::disableAll();
     $c = Page::getByID($subject['cID']);
     if (is_object($c) && !$c->isError()) {
         $blocks = $c->getBlocks();
         $nvc = $c->getVersionToModify();
         $isApproved = $c->getVersionObject()->isApproved();
         foreach ($blocks as $b) {
             if ($b->getBlockTypeHandle() == 'content') {
                 $content = $b->getController()->content;
                 $content = preg_replace_callback('/{CCM:CID_([0-9]+)}/i', function ($matches) use($subject, $target) {
                     $cID = $matches[1];
                     if ($cID > 0) {
                         $link = Page::getByID($cID, 'ACTIVE');
                         $section = $target->getSection();
                         if (is_object($section)) {
                             $relatedID = $section->getTranslatedPageID($link);
                             if ($relatedID) {
                                 return sprintf('{CCM:CID_%s}', $relatedID);
                             }
                         }
                     }
                 }, $content);
                 $ob = $b;
                 // replace the block with the version of the block in the later version (if applicable)
                 $b2 = \Block::getByID($b->getBlockID(), $nvc, $b->getAreaHandle());
                 if ($b2->isAlias()) {
                     $nb = $ob->duplicate($nvc);
                     $b2->deleteBlock();
                     $b2 = clone $nb;
                 }
                 $data = array('content' => $content);
                 $b2->update($data);
             }
         }
         if ($isApproved) {
             $nvc->getVersionObject()->approve();
         }
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:43,代码来源:ReplaceContentLinksTask.php

示例11: purgeOrphanedScrapbooksBlocks

 protected function purgeOrphanedScrapbooksBlocks()
 {
     $db = \Database::connection();
     $orphanedCollectionVersionBlocks = $db->fetchAll('
         select cID, cvID, cvb.bID, arHandle
         from CollectionVersionBlocks cvb
             inner join btCoreScrapbookDisplay btCSD on cvb.bID = btCSD.bID
             inner join Blocks b on b.bID = btCSD.bOriginalID
             left join BlockTypes bt on b.btID = bt.btID
         where bt.btID IS NULL', array());
     foreach ($orphanedCollectionVersionBlocks as $row) {
         $nc = \Page::getByID($row['cID'], $row['cvID']);
         if (!is_object($nc) || $nc->isError()) {
             continue;
         }
         $b = \Block::getByID($row['bID'], $nc, $row['arHandle']);
         if (is_object($b)) {
             $b->deleteBlock();
         }
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:21,代码来源:Version20150515000000.php

示例12: submit_all

 public function submit_all()
 {
     if ($this->validateAction()) {
         if ($this->permissions->canDeleteBlock() && $this->page->isMasterCollection()) {
             $name = sprintf('delete_block_%s', $this->block->getBlockID());
             $queue = \Queue::get($name);
             if ($_POST['process']) {
                 $obj = new \stdClass();
                 $messages = $queue->receive(20);
                 foreach ($messages as $key => $p) {
                     $block = unserialize($p->body);
                     $page = \Page::getByID($block['cID'], $block['cvID']);
                     $b = \Block::getByID($block['bID'], $page, $block['arHandle']);
                     if (is_object($b) && !$b->isError()) {
                         $b->deleteBlock();
                     }
                     $queue->deleteMessage($p);
                 }
                 $obj->totalItems = $queue->count();
                 if ($queue->count() == 0) {
                     $queue->deleteQueue($name);
                 }
                 $obj->bID = $this->block->getBlockID();
                 $obj->aID = $this->area->getAreaID();
                 $obj->message = t('All child blocks deleted successfully.');
                 echo json_encode($obj);
                 $this->app->shutdown();
             } else {
                 $queue = $this->block->queueForDefaultsUpdate($_POST, $queue);
             }
             $totalItems = $queue->count();
             \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d block", "%d blocks", $totalItems)));
             $this->app->shutdown();
         }
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:36,代码来源:delete.php

示例13: defined

<?php

defined('C5_EXECUTE') or die("Access Denied.");
//Permissions Check
$nh = Loader::helper('validation/numbers');
if ($_GET['bID'] && $_GET['cID'] && $nh->integer($_GET['bID']) && $nh->integer($_GET['cID'])) {
    $c = Page::getByID($_GET['cID']);
    if (is_object($c) && !$c->isError()) {
        $a = Area::get($c, $_GET['arHandle']);
        //edit survey mode
        $b = Block::getByID($_GET['bID'], $c, $a);
        if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) {
            $cnt = $b->getController();
            $b = Block::getByID($cnt->getOriginalBlockID());
        }
        $controller = new PageListBlockController($b);
        $rssUrl = $controller->getRssUrl($b);
        $bp = new Permissions($b);
        if ($bp->canViewBlock() && $controller->rss) {
            $cArray = $controller->getPages();
            $nh = Loader::helper('navigation');
            header('Content-type: text/xml');
            echo "<" . "?" . "xml version=\"1.0\"?>\n";
            ?>
			<rss version="2.0">
			  <channel>
				<title><?php 
            echo $controller->rssTitle;
            ?>
</title>
				<link><?php 
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:31,代码来源:blog_rss.php

示例14: defined

<?php

defined('C5_EXECUTE') or die("Access Denied.");
$area = $b->getBlockAreaObject();
$_bx = Block::getByID($bOriginalID);
if (is_object($_bx)) {
    $_bx->setBlockAreaObject($area);
    $c = Page::getCurrentPage();
    $_bx->setProxyBlock($b);
    $_bx->loadNewCollection($c);
    $bv = new \Concrete\Core\Block\View\BlockView($_bx);
    $bv->setController($controller->getScrapbookBlockController());
    $bv->disableControls();
    $bv->render('view');
}
开发者ID:ngreimel,项目名称:kovent,代码行数:15,代码来源:view.php

示例15: stdClass

                     $b->alias($nvc);
                 } else {
                     $b->alias($c);
                 }
             }
         }
     }
 } else {
     if (isset($_REQUEST['bID'])) {
         if ($_REQUEST['globalBlock']) {
             $scrapbookHelper = Loader::helper('concrete/scrapbook');
             $c1 = $scrapbookHelper->getGlobalScrapbookPage();
             $a1 = Area::get($c1, $_REQUEST['globalScrapbook']);
             $b = Block::getByID($_REQUEST['bID'], $c1, $a1);
         } else {
             $b = Block::getByID($_REQUEST['bID']);
         }
         $bt = BlockType::getByHandle($b->getBlockTypeHandle());
         if ($ap->canAddBlock($bt)) {
             $b->setBlockAreaObject($a);
             if (!$bt->includeAll()) {
                 $nvc = $c->getVersionToModify();
                 $b->alias($nvc);
             } else {
                 $b->alias($c);
             }
         }
     }
 }
 $obj = new stdClass();
 $obj->aID = $a->getAreaID();
开发者ID:VonUniGE,项目名称:concrete5-1,代码行数:31,代码来源:process.php


注:本文中的Block::getByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。