本文整理汇总了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;
}
示例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();
}
}
}
示例3: test_hidden
function test_hidden()
{
// Reads from test/templates/block-test.php
$block = new Block('test');
$block->hidden = TRUE;
$this->assertEqual('', $block->render());
}
示例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;
}
示例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";
}
示例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]);
}
}
}
示例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();
}
}
示例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;
}
示例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.'));
}
}
示例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');
}
示例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.'));
}
}
示例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();
}
示例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;
}
}
示例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();
}
示例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;
}