コード例 #1
0
 public function run($request)
 {
     // update block/set titles
     // Name field has been reverted back to Title
     // DB::query("update Block set Name = Title");
     // DB::query("update BlockSet set Name = Title");
     // update block areas
     DB::query("\n\t\t\tupdate SiteTree_Blocks\n\t\t\tleft join Block on SiteTree_Blocks.BlockID = Block.ID\n\t\t\tset BlockArea = Block.Area\n\t\t\twhere BlockID = Block.ID\n\t\t");
     // update block sort
     DB::query("\n\t\t\tupdate SiteTree_Blocks\n\t\t\tleft join Block on SiteTree_Blocks.BlockID = Block.ID\n\t\t\tset Sort = Block.Weight\n\t\t\twhere BlockID = Block.ID\n\t\t");
     echo "BlockAreas, Sort updated<br />";
     // migrate global blocks
     $sc = SiteConfig::current_site_config();
     if ($sc->Blocks()->Count()) {
         $set = BlockSet::get()->filter('Title', 'Global')->first();
         if (!$set) {
             $set = BlockSet::create(array('Title' => 'Global'));
             $set->write();
         }
         foreach ($sc->Blocks() as $block) {
             if (!$set->Blocks()->find('ID', $block->ID)) {
                 $set->Blocks()->add($block, array('Sort' => $block->Weight, 'BlockArea' => $block->Area));
                 echo "Block #{$block->ID} added to Global block set<br />";
             }
         }
     }
     // publish blocks
     $blocks = Block::get()->filter('Published', 1);
     foreach ($blocks as $block) {
         $block->publish('Stage', 'Live');
         echo "Published Block #{$block->ID}<br />";
     }
 }
コード例 #2
0
 /**
  * Add the GridFieldAddExistingSearchButton component to this grid config.
  *
  * @return $this
  **/
 public function addExisting()
 {
     $classes = $this->blockManager->getBlockClasses();
     $this->addComponent($add = new GridFieldAddExistingSearchButton());
     $add->setSearchList(Block::get()->filter(array('ClassName' => array_keys($classes))));
     return $this;
 }
コード例 #3
0
 function run($request)
 {
     $data = (require_once __DIR__ . '/../../../BlockFiller.php');
     if ($data) {
         foreach (Block::get() as $block) {
             $block->delete();
         }
     }
     //Loop through all blocks, defined in root/BlockFiller.php
     foreach ($data as $key => $blockData) {
         $block = Block::create($blockData);
         //Find page by classname, so it can link block to page
         $page = Page::get()->filter(['ClassName' => $blockData['ClassName']])->first();
         //If page is found, write block
         if (isset($page->ID)) {
             $block->PageID = $page->ID;
             $block->write();
             //Loop through all blocks translations, which are defined in block section under 'trans'
             foreach ($blockData['trans'] as $key => $translation) {
                 $blockTrans = BlockTranslation::create($translation);
                 $blockTrans->BlockID = $block->ID;
                 $blockTrans->write();
             }
             var_dump($block->Title);
         }
     }
 }
コード例 #4
0
ファイル: Main.php プロジェクト: Assistance-Team/RandomGive
 public function playerInteract(PlayerInteractEvent $event)
 {
     if ($event->getBlock()->getId() == 35 && $event->getBlock()->getDamage() == 1) {
         $block->level->setBlock($block, Block::get(0));
         $player = $event->getPlayer();
         $player->getInventory()->addItem(new Item(ITEM::COOKIE, 0, 1));
         $player->sendPopup(TextFormat::GRAY . "RandomGive:\n" . TextFormat::YELLOW . "> " . TextFormat::GREEN . "You've received a cookie!");
     }
 }
コード例 #5
0
 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->push(TabSet::create('Root', $mainTab = new Tab('Main')));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $sort = 'ParentID';
     if ($this->has_extension('Sortable')) {
         $sort .= ', SortOrder';
     }
     $source = Block::get()->exclude('ClassName', 'VirtualBlock')->sort($sort)->map('ID', 'FullTitle');
     $fields->addFieldsToTab('Root.Main', array(ReadonlyField::create('Title', _t('Block.TITLE', 'Title'), $this->getTitle()), DropdownField::create('OriginalBlockID', _t('VirtualBlock.SELECT_ORIGINAL', 'Select original'), $source)));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #6
0
 public function MultiBlock($name)
 {
     $lang = i18n::get_locale();
     $blocksTrans = [];
     $blocks = Block::get()->filter(['Name' => $name])->sort('ID');
     foreach ($blocks as $key => $block) {
         $trans = $this->fetchBlockTrans($block, $lang);
         //Fallback to english if there is no translation for language
         if (count($trans) === 0) {
             $trans = $this->fetchBlockTrans($block, 'en_US');
         }
         array_push($blocksTrans, $trans);
     }
     return new ArrayList($blocksTrans);
 }
コード例 #7
0
 private function dockedBlocks()
 {
     $blocks = Block::get();
     $IDs = array();
     $ClassName = $this->owner->ClassName;
     $Classes = $blocks->map('ID', 'shownInClass');
     foreach ($Classes as $BlockID => $Class) {
         $listedClasses = explode(',', $Class);
         if (in_array($ClassName, $listedClasses)) {
             $IDs[] = $BlockID;
         }
     }
     $blocks = Block::get()->filter('ID', $IDs)->sort('SortOrder', 'ASC');
     return $blocks;
 }
コード例 #8
0
 public function getCMSFields()
 {
     $fields = FieldList::create();
     $fields->push(TabSet::create('Root', $mainTab = new Tab('Main')));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $blockList = Block::get()->exclude('ClassName', 'VirtualBlock');
     // Apply the allowed blocks config to the virtual-block
     $allowed = $this->Parent()->config()->get('allowed_blocks');
     if (is_array($allowed)) {
         $blockList = $blockList->filter(array('ClassName' => $allowed));
     }
     $source = $blockList->sort('ParentID, SortOrder')->map('ID', 'FullTitle');
     $fields->addFieldsToTab('Root.Main', array(ReadonlyField::create('Title', _t('Block.TITLE', 'Title'), $this->getTitle()), DropdownField::create('OriginalBlockID', _t('VirtualBlock.SELECT_ORIGINAL', 'Select original'), $source)));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #9
0
 public function getDockedBlocks()
 {
     $blocks = Block::get()->filter(array('showBlockbyClass' => true));
     $blocks_map = $blocks->map('ID', 'shownInClass');
     foreach ($blocks_map as $blockID => $Classes) {
         $Classes = explode(',', $Classes);
         if (!in_array($this->owner->ClassName, $Classes)) {
             $blocks = $blocks->exclude('ID', $blockID);
         }
     }
     $published_blocks = new ArrayList();
     foreach ($blocks as $block) {
         if ($block->isPublished()) {
             $published_blocks->push($block);
         }
     }
     return $published_blocks->sort('SortOrder', 'ASC');
 }
コード例 #10
0
 /**
  * Set the allowed blocks for this gridfield
  * @param array $allowedBlocks a set of allowed class names, optionally mapped to titles
  */
 public function setAllowedBlocks(array $allowedBlocks)
 {
     $classes = null;
     if ($mc = $this->getComponentByType('GridFieldAddNewMultiClass')) {
         $search = $this->getComponentByType('GridFieldAddExistingSearchButton');
         $blockClasses = array_values(ClassInfo::subclassesFor('Block'));
         sort($blockClasses);
         if (is_array($allowedBlocks)) {
             $allowedClasses = array();
             foreach ($allowedBlocks as $class => $title) {
                 if (!is_string($class)) {
                     $class = $title;
                 }
                 if (in_array($class, $blockClasses)) {
                     $allowedClasses[] = $class;
                 }
             }
             $mc->setClasses($allowedClasses);
             if ($search) {
                 $search->setSearchList(Block::get()->filter(array('ParentID' => 0, 'ClassName' => $allowedClasses)));
             }
         } else {
             if ($search) {
                 $search->setSearchList(Block::get()->filter(array('ParentID' => 0)));
             }
             $mc->setClasses(null);
         }
     }
 }
コード例 #11
0
ファイル: Main.php プロジェクト: EmreTr1/SkyWarsForPE
 private function startGame($level)
 {
     $this->skywarsstarted == true;
     //put the array to true
     foreach ($this->getServer()->getLevelByName($level)->getPlayers() as $p) {
         //get every single player in the level
         if ($p->getGameMode() == 0) {
             $x = $p->getGroundX;
             $y = $p->getGroundY;
             //get the ground coordinates
             $z = $p->getGroundZ;
             //these are needed to break the glass under the player
             $this->getServer()->getLevelByName($level)->setBlock(new Vector3($x, $y, $z), Block::get(0, 0));
             $p->sendMessage("The game starts NOW!! Good luck!");
             $p->sendMessage("You can exit using: /sk exit");
         }
     }
     return true;
 }
コード例 #12
0
ファイル: Redstone.php プロジェクト: iTXTech/Genisys
 public function __construct($meta = 0, $count = 1)
 {
     $this->block = Block::get(Item::REDSTONE_WIRE);
     parent::__construct(self::REDSTONE, 0, $count, "Redstone");
 }
コード例 #13
0
 /**
  * Add the GridFieldAddExistingSearchButton component to this grid config.
  *
  * @return $this
  **/
 public function addExisting()
 {
     $this->addComponent($add = new GridFieldAddExistingSearchButton());
     $add->setSearchList(Block::get());
     return $this;
 }
 public function OneBlock($id)
 {
     return Block::get()->byID($id);
 }
コード例 #15
0
 function forTemplate()
 {
     $block = Block::get()->filter(['ID' => $this->BlockID])->first();
     return $this->renderWith([$block->Template, 'Block']);
     // Fall back to Block if selected does not exist
 }
 /**
  * Add the GridFieldAddExistingSearchButton component to this grid config.
  *
  * @return $this
  **/
 public function addExisting()
 {
     // EDIT
     //$this->addComponent($add = new GridFieldAddExistingSearchButton());
     $this->addComponent($add = new GridFieldAddExistingSearchButton('buttons-after-right'));
     // /EDIT
     $add->setSearchList(Block::get());
     return $this;
 }