當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Block類代碼示例

本文整理匯總了PHP中Block的典型用法代碼示例。如果您正苦於以下問題:PHP Block類的具體用法?PHP Block怎麽用?PHP Block使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Block類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onActivate

 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($this->meta === AIR) {
         if ($target instanceof LiquidBlock) {
             $level->setBlock($target, new AirBlock(), true, false, true);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = $target instanceof WaterBlock ? WATER : LAVA;
             }
             return true;
         }
     } elseif ($this->meta === WATER) {
         //Support Make Non-Support Water to Support Water
         if ($block->getID() === AIR || $block instanceof WaterBlock && ($block->getMetadata() & 0x7) != 0x0) {
             $water = new WaterBlock();
             $level->setBlock($block, $water, true, false, true);
             $water->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = 0;
             }
             return true;
         }
     } elseif ($this->meta === LAVA) {
         if ($block->getID() === AIR) {
             $level->setBlock($block, new LavaBlock(), true, false, true);
             if (($player->gamemode & 0x1) === 0) {
                 $this->meta = 0;
             }
             return true;
         }
     }
     return false;
 }
開發者ID:ungarscool1,項目名稱:Multicraft,代碼行數:32,代碼來源:Bucket.php

示例2: setPermissionObject

 public function setPermissionObject(Block $b)
 {
     $this->permissionObject = $b;
     // if the area overrides the collection permissions explicitly (with a one on the override column) we check
     if ($b->overrideAreaPermissions()) {
         $this->permissionObjectToCheck = $b;
     } else {
         $a = $b->getBlockAreaObject();
         if (is_object($a)) {
             if ($a->overrideCollectionPermissions()) {
                 $this->permissionObjectToCheck = $a;
             } elseif ($a->getAreaCollectionInheritID()) {
                 $mcID = $a->getAreaCollectionInheritID();
                 $mc = Page::getByID($mcID, 'RECENT');
                 $ma = Area::get($mc, $a->getAreaHandle());
                 if ($ma->overrideCollectionPermissions()) {
                     $this->permissionObjectToCheck = $ma;
                 } else {
                     $this->permissionObjectToCheck = $ma->getAreaCollectionObject();
                 }
             } else {
                 $this->permissionObjectToCheck = $a->getAreaCollectionObject();
             }
         } else {
             $this->permissionObjectToCheck = Page::getCurrentPage();
         }
     }
 }
開發者ID:ojalehto,項目名稱:concrete5-legacy,代碼行數:28,代碼來源:block.php

示例3: test_hidden

 function test_hidden()
 {
     // Reads from test/templates/block-test.php
     $block = new Block('test');
     $block->hidden = TRUE;
     $this->assertEqual('', $block->render());
 }
開發者ID:bufvc,項目名稱:bufvc-potnia-framework,代碼行數:7,代碼來源:testBlock.php

示例4: parseBlock

 protected function parseBlock($lines, $current = 0)
 {
     //printf("parseBlock: line %s\n", $current);
     $rootBlock = new Block('[root]');
     for ($i = $current, $count = count($lines); $i < $count; $i++) {
         $line = trim($lines[$i]);
         $line = $this->stripComment($line);
         if ($line === '' || $line[0] === '#') {
             //printf("parseBlock: skip line %s\n", $i);
             continue;
         }
         if ($line[strlen($line) - 1] === '{') {
             list($block, $i) = $this->parseBlock($lines, ++$i);
             if ($block !== false) {
                 list($name, $value) = $this->parseLine($line);
                 $block->name = $name;
                 $block->value = $value;
                 $rootBlock->addBlock($block);
             }
             continue;
         }
         if ($line === '}') {
             return [$rootBlock, $i];
         }
         list($property, $i) = $this->parseProperty($lines, $i);
         if ($property !== false) {
             $rootBlock->addProperty($property);
         }
     }
     return $rootBlock;
 }
開發者ID:gitstream,項目名稱:nginx-parser,代碼行數:31,代碼來源:Parser.php

示例5: headerNav

 function headerNav()
 {
     include "config/site.php";
     require_once 'model/Block.php';
     $block = new Block();
     $blocks = $block->getBlocks();
     require "{$tpl_root}/_header_nav.php";
 }
開發者ID:puregamexyz,項目名稱:bitdesign.github.io,代碼行數:8,代碼來源:HomeController.php

示例6: removeBlock

 /**
  * Remove block from composition
  *
  * @param Block $blockToRemove
  */
 public function removeBlock(Block $blockToRemove)
 {
     foreach ($this->blocks as $key => $block) {
         if ($block->getName() === $blockToRemove->getName()) {
             unset($this->blocks[$key]);
         }
     }
 }
開發者ID:konopelkosergeyv,項目名稱:test,代碼行數:13,代碼來源:CompositeBlock.php

示例7: renderBlocks

 private function renderBlocks()
 {
     $this->aRenderedBlocks = array();
     foreach ($this->aBlocks as $sBlock) {
         // New block object
         $oBlock = new Block($sBlock, $this->aPageConfig, $this->sConfigFile);
         $this->aRenderedBlocks[$oBlock->getName()] = $oBlock->render();
     }
 }
開發者ID:rbnvrw,項目名稱:crispus,代碼行數:9,代碼來源:Theme.php

示例8: append

 public function append(Block $block)
 {
     if ($this->numBlocks > 0) {
         $last = $this->numBlocks - 1;
         $this->blocks[$last]->setNextHash($block->getHash());
     }
     $this->numBlocks++;
     $this->blocks[] = $block;
 }
開發者ID:csirac2,項目名稱:asgard-client,代碼行數:9,代碼來源:BlockChain.php

示例9: action_theme_activated

 /**
  * On theme activation, activate some default blocks
  */
 public function action_theme_activated()
 {
     $blocks = $this->get_blocks('primary', '', $this);
     if (count($blocks) == 0) {
         $block = new Block(array('title' => _t('Posts'), 'type' => 'grayposts'));
         $block->add_to_area('primary');
         Session::notice(_t('Added default blocks to theme areas.'));
     }
 }
開發者ID:habari-extras,項目名稱:gray,代碼行數:12,代碼來源:theme.php

示例10: test_delete_block

 public function test_delete_block()
 {
     $params = array('title' => $this->title, 'type' => $this->type);
     $block = new Block($params);
     $block->insert();
     $count = DB::get_value('SELECT count(*) FROM {blocks}');
     $block->delete();
     $this->assert_equal($count - 1, DB::get_value('SELECT count(*) FROM {blocks}'), 'Count of blocks should decrease by one');
 }
開發者ID:habari,項目名稱:tests,代碼行數:9,代碼來源:test_block.php

示例11: action_theme_activated

 /**
  * Add the K2 menu block to the nav area upon theme activation if there's nothing already there
  */
 public function action_theme_activated()
 {
     $blocks = $this->get_blocks('nav', 0, $this);
     if (count($blocks) == 0) {
         $block = new Block(array('title' => _t('K2 Menu'), 'type' => 'k2_menu'));
         $block->add_to_area('nav');
         Session::notice(_t('Added K2 Menu block to Nav area.'));
     }
 }
開發者ID:ringmaster,項目名稱:system,代碼行數:12,代碼來源:theme.php

示例12: addDBData

 public function addDBData()
 {
     for ($i = 1; $i <= 4; $i++) {
         $this->localUsers[] = $this->getMutableTestUser()->getUser();
     }
     $sysop = static::getTestSysop()->getUser();
     $block = new Block(['address' => $this->localUsers[2]->getName(), 'by' => $sysop->getId(), 'reason' => __METHOD__, 'expiry' => '1 day', 'hideName' => false]);
     $block->insert();
     $block = new Block(['address' => $this->localUsers[3]->getName(), 'by' => $sysop->getId(), 'reason' => __METHOD__, 'expiry' => '1 day', 'hideName' => true]);
     $block->insert();
 }
開發者ID:claudinec,項目名稱:galan-wiki,代碼行數:11,代碼來源:LocalIdLookupTest.php

示例13: place

 public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if (($target->isTransparent === false or $target->getID() === SLAB) and $face !== 0 and $face !== 1) {
         $faces = array(2 => 0, 3 => 1, 4 => 2, 5 => 3);
         $this->meta = $faces[$face] & 0x3;
         if ($fy > 0.5) {
             $this->meta |= 0x8;
         }
         $this->level->setBlock($block, $this, true, false, true);
         return true;
     }
 }
開發者ID:ungarscool1,項目名稱:Multicraft,代碼行數:12,代碼來源:Trapdoor.php

示例14: indexAction

 public function indexAction()
 {
     $collection = $this->getModel()->getCollection();
     $params = $this->getParams();
     $list = new Block('templates/' . $params['controller'] . '/index.php');
     $list->setVar('collection', $collection);
     $labels = $this->getEntityLabels();
     $layout = $this->layout;
     $layout->setVar('title', $labels[1]);
     $layout->setChild('body', $list);
     $layout->render();
 }
開發者ID:Jaleko,項目名稱:php-framework,代碼行數:12,代碼來源:CrudController.php

示例15: getBlockInfo

 /**
  * Get basic info about a given block
  * @param Block $block
  * @return array Array containing several keys:
  *  - blockid - ID of the block
  *  - blockedby - username of the blocker
  *  - blockedbyid - user ID of the blocker
  *  - blockreason - reason provided for the block
  *  - blockedtimestamp - timestamp for when the block was placed/modified
  *  - blockexpiry - expiry time of the block
  */
 public static function getBlockInfo(Block $block)
 {
     global $wgContLang;
     $vals = array();
     $vals['blockid'] = $block->getId();
     $vals['blockedby'] = $block->getByName();
     $vals['blockedbyid'] = $block->getBy();
     $vals['blockreason'] = $block->mReason;
     $vals['blockedtimestamp'] = wfTimestamp(TS_ISO_8601, $block->mTimestamp);
     $vals['blockexpiry'] = $wgContLang->formatExpiry($block->getExpiry(), TS_ISO_8601, 'infinite');
     return $vals;
 }
開發者ID:D66Ha,項目名稱:mediawiki,代碼行數:23,代碼來源:ApiQueryUserInfo.php


注:本文中的Block類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。