本文整理汇总了PHP中Field::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Field::init方法的具体用法?PHP Field::init怎么用?PHP Field::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field::init方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
function init()
{
parent::init();
$this->defaultValue(false);
$this->type('boolean');
$this->owner->addCondition($this->short_name, false);
}
示例2: init
public function init()
{
parent::init();
if ($this->action == 'edit') {
$this->addJS();
}
}
示例3: init
protected function init()
{
parent::init();
$this->addValidator(function () {
if ($this->multiple && array_diff($this->value, array_keys($this->values))) {
return Lang::trans('SELECT_INVALID_VALUE');
}
});
}
示例4: init
function init()
{
parent::init();
if ($this->json) {
$this->encode = function ($t) {
return json_encode($t);
};
$this->decode = function ($t) {
return json_decode($t, true);
};
}
}
示例5: getField
public function getField($input)
{
global $Database;
if (isset($input['x']) && isset($input['y'])) {
$x = $input['x'];
$y = $input['y'];
} elseif (isset($input['col']) && isset($input['row'])) {
$cols = explode(' ', 'a b c d e f g h i j k l m n o p q r s t u v w x y z');
$x = array_search($input['col'], $cols);
$y = $input['row'] - 1;
}
$id = $Database->getID('fields', array('board_id' => $this->id, 'x' => $x, 'y' => $y));
$Field = new Field();
$Field->id = $id;
$Field->init();
return $Field;
}
示例6: init
/**
* Surcharge de l'initialisation
*
*/
public function init()
{
parent::init();
$this->joinid = $this->value['id'];
$this->joinfieldvalue = $this->value[$this->fieldtoshow];
}
示例7: init
public function init()
{
parent::init();
$this->type('reference_id');
}
示例8: init
public function init()
{
parent::init();
$this->editable(false);
}
示例9: playword
function playword($params)
{
global $Database;
// Check parameter count
if (count($params) < 4) {
die('Wrong parameter count!');
}
// Check if user is logged in
if (!$this->Auth->isLoggedIn()) {
$this->redirect(array('controller' => 'users', 'action' => 'login'));
}
// check game
$Game = new Game();
$Game->id = trim($params[0]);
$Game->init();
if (!empty($Game->data)) {
if ($Game->ActiveUser->id != $this->Auth->User->id) {
$this->redirect(array('controller' => 'games', 'action' => 'view', 'params' => array($Game->id)));
}
}
// check field
$Field = new Field();
$Field->id = trim($params[1]);
$Field->init();
if (!empty($Field->data)) {
if ($Field->data['board_id'] != $Game->Board->id) {
$this->redirect(array('controller' => 'games', 'action' => 'view', 'params' => array($Game->id)));
}
}
// check direction
$direction = substr($params[3], 0, 1);
if ($direction == 'f') {
$direction = 'h';
}
// 'false': *one letter*
if (!in_array($direction, array('h', 'v'))) {
die('Incorrect direction: ' . $direction);
}
// check word for empty
$word = $params[2];
$letters = str_split($word);
if (empty($letters)) {
$this->redirect(array('controller' => 'games', 'action' => 'view', 'params' => array($Game->id)));
}
// get rack tiles
$rack_tiles = $Database->fetchObjects('Tile', "\r\n\t\t\tSELECT `tile_id` FROM `rack_tiles`\r\n\t\t\tWHERE `game_id` = {$Game->id}\r\n\t\t\t AND `user_id` = {$this->Auth->User->id}\r\n\t\t");
// the real, letter by letter, check
$to_update = array();
foreach ($letters as $i => $letter) {
// get x and y for this letter
$x = $Field->data['x'];
$y = $Field->data['y'];
if ($direction == 'h') {
$x += $i;
} elseif ($direction == 'v') {
$y += $i;
}
// check if field exists
$field_id = $Database->getID('fields', array('board_id' => $Game->Board->id, 'x' => $x, 'y' => $y));
// check if word fits in board
if (!$field_id) {
die('Field does not exist!');
}
// (double) check if field exists
$TheField = new Field();
$TheField->id = $field_id;
$TheField->init();
if (empty($TheField->data)) {
die('Field does not exist! o3qaigksd');
}
// check if field is free, if not, if the letter is the specified letter
$placed_tile_id = $Database->getID('placed_tiles', array('game_id' => $Game->Board->id, 'field_id' => $TheField->id));
if ($placed_tile_id) {
$rows = $Database->fetchObjects('Tile', "\r\n\t\t\t\t\tSELECT `tile_id` AS `id` FROM `placed_tiles` WHERE `id` = {$placed_tile_id}\r\n\t\t\t\t");
$Tile = $rows[0];
if (strtoupper($Tile->data['letter']) != strtoupper($letter)) {
die('Field at (' . $x . ', ' . $y . ') already used, and other letter than specified!');
}
// everything's okay for this letter! ..DO NOT put it in the to_update array,
// because letter is already played!
} else {
// check if letter is in rack, and if: what is it's tile id?
$TheTile = false;
foreach ($rack_tiles as $key => $Tile) {
if (strtoupper($Tile->data['letter']) == strtoupper($letter)) {
$TheTile = $Tile;
unset($rack_tiles[$key]);
break;
// let's not use tiles twice.. ;)
}
}
if (!$TheTile) {
die('You do not have the letter ' . strtoupper($letter) . '!');
}
// everything's okay for this letter! ..put it in the to_update array (hooray)!
$to_update[] = "\r\n\t\t\t\t\tDELETE FROM `rack_tiles`\r\n\t\t\t\t\tWHERE `game_id` = {$Game->id}\r\n\t\t\t\t\t AND `user_id` = {$this->Auth->User->id}\r\n\t\t\t\t\t AND `tile_id` = {$TheTile->id}\r\n\t\t\t\t\tLIMIT 1\r\n\t\t\t\t";
$to_update[] = "\r\n\t\t\t\t\tINSERT INTO `placed_tiles` (`game_id`, `tile_id`, `field_id`) VALUES\r\n\t\t\t\t\t({$Game->id}, {$TheTile->id}, {$TheField->id});\r\n\t\t\t\t";
}
}
// wow, did we really survive all the checks?! celebrate!
//.........这里部分代码省略.........
示例10: displayName
<?php
namespace ATPContact\Model;
class Field extends \ATP\ActiveRecord
{
public function displayName()
{
return $this->label;
}
}
Field::init();