PHP Class Field, microweber Code Examples

This page contains top rated real world PHP examples of class Field from package microweber extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: FieldFactory.php Project: RichardAnthonyLee/cms-gen
0
 public static function make()
 {
     $itemFactory = new itemFactory();
     $collectionFactory = new ItemCollectionFactory();
     $fields = new Field();
     return $fields->setItemFactory($itemFactory)->setFactory($collectionFactory)->setFormatter(new FieldFormatter());
 }
Example #2
Show file File: Form.class.php Project: Cybercraft/Framework
0
 public function add(Field $field)
 {
     $attr = $field->name();
     $field->setValue($this->entity->{$attr}());
     $this->fields[] = $field;
     return $this;
 }
Example #3
Show file File: Validator.php Project: BoesesGenie/rex-framework
0
 /**
  * Конструктор, нужен для реализации паттерна Observer
  * 
  * @param \REXFramework\forms\Field $field
  * @param mixed $criterion Критерий для валидатора, например, регулярное выражение
  * @param string $message Сообщение об ошибке
  */
 public function __construct(Field $field, $criterion = null, $message = '')
 {
     $this->field = $field;
     $this->criterion = $criterion;
     $this->message = $message;
     $field->attach($this);
 }
Example #4
Show file File: DataObject.php Project: kathynka/Foundation
0
 /**
  * @return mixed
  */
 protected function getKeyKey()
 {
     $n = get_called_class();
     if (!isset(self::$k_cache[$n])) {
         $key = null;
         $r = $this->getReflection();
         //Parse the annotations in a class
         $reader = new \Phalcon\Annotations\Reader();
         $parsing = $reader->parse($r->getName());
         //Create the reflection
         $annotations = new \Phalcon\Annotations\Reflection($parsing);
         if ($annotations->getClassAnnotations()->has('key')) {
             $key = $annotations->getClassAnnotations()->get('key');
         } else {
             foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
                 if (!$property->isPublic() || $property->isStatic()) {
                     continue;
                 }
                 $f = new Field($r, $property);
                 if ($f->isKey()) {
                     $key = $property->getName();
                     break;
                 }
             }
         }
         self::$k_cache[$n] = $key;
     }
     return self::$k_cache[$n];
 }
Example #5
Show file File: Form.php Project: pavelkolomitkin/nigma-blog
0
 public function removeField(Field $field)
 {
     if (isset($this->fields[$field->getName()])) {
         unset($this->fields[$field->getName()]);
     }
     return $this;
 }
Example #6
Show file File: FieldList.php Project: mammothmkiv/php-validator
0
 /**
  * @param Field $field
  * @throws DuplicateFieldException
  */
 public function addField(Field $field)
 {
     if (isset($this->fields[$field->getName()])) {
         throw new DuplicateFieldException('Field `' . $field->getName() . '` already exists');
     }
     $this->fields[$field->getName()] = $field;
 }
Example #7
Show file File: AttributeResolver.php Project: tomaszhanc/form-field-bundle
0
 /**
  * @param Field $field
  *
  * @return array
  */
 public function resolve(Field $field)
 {
     $defaults = ['required' => false, 'label' => $field->getLabel()];
     $definition = $this->registry->findDefinitionFor($field->getDocument());
     $attributes = $definition->getAttributes($field);
     return array_merge($defaults, $this->trim($attributes));
 }
Example #8
Show file File: Exercise.php Project: rmhdev/Agosto-Minesweeper
0
    public function process($input)
    {
        $id = 0;
        $minesAll  = array();
        while(count($input)>0)
        {           
            $line = array_shift($input);    
            
            if($this->isNewField($line))
            {
                $dim = $this->getFieldDimensions($line);
                $m = $dim[0]; 
                $n = $dim[1]; 
                if(!$this->IsTheEnd($m, $n))
                {
                    if(!$this->isValidDim($m, $n)){
                        throw new Exception ("Error: Invalid field dimensions! $m, $n");
                    }
                    ++$id;
                    $lineNum = 0;
                    $field = new Field($id, $m, $n);
                    $field->setDebug($this->debug);
                    $this->fields[$id] = $field;  
                }             
            }
            else
            {                                
                if( count($this->fields)<=0 ){
                    throw new Exception ("Error something wrong\n");
                }
                $field = $this->getField($id);
                $id = $field->getFieldId();

                /* line data process */
                foreach(str_split($line) as $x=>$cellvalue)
                {
                    $field->addCell($x, $lineNum);
                    /* detecting mines */
                    if($this->isMinedCell($cellvalue)){
                       $minesAll[$id][] = array($x, $lineNum);
                    }
                }
                $this->fields[$id] = $field;
                $lineNum++;
            }
        } 
        
        if(count($minesAll)>0)
        {
            foreach($minesAll as $id=>$mines)
            {
                $field = $this->getField($id); 
                $field = $this->MineField($field, $mines);
            }
            
        }
        
        return $this->getOutput();
    }
Example #9
Show file File: AutoCreator.php Project: xavocvijay/atkschool
0
 function alterField(\Field $field, $add = false)
 {
     $q = $this->db->dsql()->expr('alter table [al_table] add [field_name] [type_expr]');
     $q->setCustom('al_table', $this->table);
     $q->setCustom('field_name', $x = $field->actual_field ?: $field->short_name);
     $q->setCustom('type_expr', $this->db->dsql()->expr($this->resolveFieldType($field->type())));
     $q->execute();
 }
Example #10
Show file File: TestField.php Project: dsopiarz/wp-advanced-search
0
 public function testCanOverrideInvalidRelation()
 {
     $args = array('type' => 'taxonomy', 'taxonomy' => 'category', 'relation' => 'IN');
     $f = new Field($args);
     $defaults = $f->getDefaults();
     $default_relation = $defaults['relation'];
     $this->assertTrue($f->getRelation() == $default_relation);
 }
Example #11
Show file File: table_dataset.php Project: howareyoucolin/demo
0
 /**
  * @param Field $field
  * @return void
  */
 protected function DoAddField($field)
 {
     $sourceTable = $field->GetSourceTable();
     if (!isset($sourceTable) || $sourceTable == '') {
         $sourceTable = $this->tableName;
     }
     $this->GetSelectCommand()->AddField($sourceTable, $field->GetName(), $field->GetEngFieldType(), $field->GetAlias());
 }
Example #12
Show file File: Schema.php Project: mikemirten/ConstructorCMS
0
 /**
  * Add field
  * 
  * @param  Field $field
  * @throws \LogicException
  */
 public function addField(Field $field)
 {
     $name = $field->getName();
     if (isset($this->fields[$name])) {
         throw new \LogicException(sprintf('Field "%s" already exists', $name));
     }
     $this->fields[$name] = $field;
 }
Example #13
Show file File: Cron.php Project: ajbdev/cronlingo
0
 /**
  * Create CRON object from a crontab string
  *
  * @param $string
  */
 public function fromString($string)
 {
     list($minute, $hour, $dayOfMonth, $month, $dayOfWeek) = preg_split('/\\s+/', $string);
     $this->minute->fromCronValue($minute);
     $this->hour->fromCronValue($hour);
     $this->dayOfMonth->fromCronValue($dayOfMonth);
     $this->month->fromCronValue($month);
     $this->dayOfWeek->fromCronValue($dayOfWeek);
 }
Example #14
Show file File: Form.php Project: ChristopheMalo/SiteWeb-POO-PHP
0
 /**
  * Méthode permettant d'ajouter un champ à la liste
  * 
  * @param \OCFram\Field $field
  * @return \OCFram\Form
  */
 public function add(Field $field)
 {
     $attr = $field->name();
     // Récupérer le nom du champ
     $field->setValue($this->entity->{$attr}());
     // Assigner la valeur correspondante au champ
     $this->fields[] = $field;
     // Ajouter le champ passé en argument à la liste des champs
     return $this;
 }
Example #15
Show file File: Form.php Project: gbecchio/tp_poo_cache
0
 public function add(Field $field)
 {
     $attr = $field->name();
     // On récupère le nom du champ.
     $field->setValue($this->entity->{$attr}());
     // On assigne la valeur correspondante au champ.
     $this->fields[] = $field;
     // On ajoute le champ passé en argument à la liste des champs.
     return $this;
 }
Example #16
Show file File: FieldMigration.php Project: lostkobrakai/migrations
0
 public function update()
 {
     $f = new Field();
     $f->name = $this->getFieldName();
     $f->type = $this->getFieldType();
     $f->save();
     $this->fieldSetup($f);
     $f->save();
     return $f;
 }
Example #17
Show file File: Constraint.php Project: dennis84/formz
0
 /**
  * Validates the given data against this constraint. If the constraint was
  * already triggered before, then it will return the last result.
  *
  * @param mixed $data The data
  *
  * @return boolean
  */
 public function validate(Field $field, $data)
 {
     if (true === $this->checked) {
         return;
     }
     $this->checked = true;
     if (true === $this->check($data)) {
         return;
     }
     $field->addError(new Error($field->getInternalName(), $this->getMessage()));
 }
Example #18
Show file File: FieldTest.php Project: Adamzynoni/mybb2
0
 public function testSettersAndGettersDoWhatTheyShould()
 {
     $field = new Field('type', 'element', 'label', 'description');
     $field->setOptions(['options' => 'options']);
     $field->setValidationRules('rules');
     $field->setValue('foo');
     $expectations = ['getOptions' => ['options' => 'options'], 'getValidationRules' => 'rules', 'getValue' => 'foo'];
     foreach ($expectations as $method => $value) {
         static::assertEquals($field->{$method}(), $value);
     }
 }
Example #19
Show file File: mysql.php Project: jeanlopes/mostra-ifrs-poa
0
 private function _parseFields($results)
 {
     $response = array();
     foreach ($results as $result) {
         $field = new Field();
         $field->setName($result["Field"]);
         $field->setType($result["Type"]);
         $field->setPk($result["Key"] == 'PRI');
         $response[] = $field;
     }
     return $response;
 }
Example #20
Show file File: postgre.php Project: jeanlopes/mostra-ifrs-poa
0
 private function _parseFields($results, $pk)
 {
     $response = array();
     foreach ($results as $result) {
         $field = new Field();
         $field->setName($result["field"]);
         $field->setType($result["type"]);
         $field->setPk($result["field"] == $pk["col"]);
         $response[] = $field;
     }
     return $response;
 }
Example #21
Show file File: FieldTest.php Project: rmhdev/Agosto-Minesweeper
0
 /**
  * @dataProvider outputProvider
  */  
 public function testPrintField($id, $m, $n, $mines, $r, $msg)
 {
     $field = new Field($id,$m,$n);
     $field->fillClean();
     foreach($mines as $mine)
     {
         $x = $mine[0];
         $y = $mine[1];
         $field->mineCell($x,$y);
     }
     $this->assertEquals($r, $field->printField(),$msg);  
 }
Example #22
Show file File: InputfieldPageTableAjax.php Project: GTuritto/ProcessWire
0
 /**
  * Render the ajax request output directly and halt execution
  * 
  * @param Page $page
  * @param Field $field
  * 
  */
 protected function renderAjax(Page $page, Field $field)
 {
     $inputfield = $field->getInputfield($page);
     if (!$inputfield) {
         return;
     }
     echo $inputfield->render();
     if ($this->notes) {
         echo "<p class='notes'>" . $this->wire('sanitizer')->entities($this->notes) . "</p>";
         $this->notes = '';
     }
     exit;
 }
Example #23
Show file File: class.file.php Project: brendo/bulkimporter
0
 /**
  * Check that the file matches the validator as specified by the field
  *
  * @param Field $field
  * @param string $destination
  * @return boolean
  */
 public function isValid(Field $field, $destination = NULL)
 {
     $this->valid = true;
     // Check if file name length will not exceed maximum allowed by Upload field's database column.
     // Upload field does not check that, so we have to do that here.
     if (!empty($destination)) {
         $this->valid = strlen($destination) < 255 ? true : false;
         if (!$this->valid) {
             $this->errors[] = __("Length of file name chosen in '%s' exceeds maximum allowed for that field.", array($field->get('label')));
         }
     }
     return $this->valid;
 }
Example #24
Show file File: tests.php Project: jeanlopes/mostra-ifrs-poa
0
 /**
  * Generate random table fields to test
  **/
 private function getTableFields()
 {
     require_once APPPATH . "libraries/scaffolder/drivers/field.php";
     $id = new Field();
     $id->setName("id");
     $id->setPk(true);
     $nome = new Field();
     $nome->setName("nome");
     $alias = new Field();
     $alias->setName("alias");
     $estado = new Field();
     $estado->setName("estado_id");
     return array($id, $nome, $alias, $estado);
 }
Example #25
Show file File: EmailAddressField.php Project: platformsh/console-form
0
 public function __construct($name = 'Email', array $config = [])
 {
     parent::__construct($name, $config);
     $this->validators[] = function ($value) {
         return filter_var($value, FILTER_VALIDATE_EMAIL) ? true : "Invalid email address: {$value}";
     };
 }
Example #26
Show file File: class.TextField.php Project: jwiegel/FormHandler
0
 /**
  * TextField::TextField()
  *
  * Constructor: Create a new textfield object
  *
  * @param object &$oForm: The form where this field is located on
  * @param string $sName: The name of the field
  * @return TextField
  * @author Teye Heimans
  * @access public
  */
 function TextField(&$oForm, $sName)
 {
     // call the constructor of the Field class
     parent::Field($oForm, $sName);
     $this->setSize(20);
     $this->setMaxlength(0);
 }
Example #27
Show file File: DateField.php Project: frostiks25/rzwebsys7
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = [$this->attr, 'date', 'format' => $this->dateFormat];
     $rules[] = [$this->attr, 'filter', 'filter' => 'trim'];
     return $rules;
 }
Example #28
Show file File: time.php Project: Akrobate/akrocrm
0
 public function init()
 {
     parent::init();
     if ($this->action == 'edit') {
         $this->addJS();
     }
 }
Example #29
Show file File: join.php Project: Akrobate/akrocrm
0
 /**
  *	@brief	setteur de tous le parametres de champs
  *	@param	fieldname	Nom du champ
  *	@papam	params		Tous le parametres comme decrits dans fields.php
  *	@return	this
  */
 public function setAllFieldsParams($fieldname, $params)
 {
     parent::setAllFieldsParams($fieldname, $params);
     $this->setJoinToModule($params['join']['table']);
     $this->setVisibleField($params['join']['field']);
     return $this;
 }
Example #30
Show file File: Grid.php Project: ekowabaka/wyf
0
 public function getData()
 {
     $nameLenght = strlen($this->name);
     if ($this->isFormSent()) {
         $this->data = array();
         foreach ($_POST as $field => $value) {
             if (is_array($value)) {
                 foreach ($this->columnNames as $i => $columnName) {
                     if ($field == $columnName) {
                         $field = substr($field, $nameLenght - strlen($field) + 1);
                         foreach ($value as $j => $data) {
                             $this->data[$j][$field] = $data;
                         }
                     }
                 }
             }
         }
         foreach ($this->data as $i => $data) {
             $pass = false;
             foreach ($data as $field => $value) {
                 if ($value != "") {
                     $pass = true;
                     break;
                 }
             }
             if (!$pass) {
                 unset($this->data[$i]);
             }
         }
         return array($this->getName() => $this->data);
     } else {
         return parent::getData();
     }
 }
Frequently Used Methods