/** * This will build a new HTML form element according to the given configuration. * Only name and tag are mandatory, then other values depending on the tag * * @param array $cfg The configuration * @return self */ public function __construct($cfg) { if (is_string($cfg)) { $cfg = ['type' => 'submit', 'text' => $cfg]; } $cfg['tag'] = 'button'; parent::__construct($cfg); return $this; }
public function __construct($theme = False) { parent::__construct(); /* placeholder object, don't output an actual tag */ if ($theme) { $this->theme = $theme; } else { $this->theme = 'default'; } $this->head[] = new Element('meta', array('http-equiv' => 'X-UA-Compatible', 'content' => 'IE=edge')); $this->head[] = new Element('meta', array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1')); $this->head[] = new Element('link', array('rel' => 'stylesheet', 'href' => $this->url('css'), 'type' => 'text/css')); $this->tail[] = new Element('script', array('src' => $this->url('jquery'))); $this->tail[] = new Element('script', array('src' => $this->url('js'))); }
public function __construct($att = array()) { if (isset($att['tag']) && $att['tag'] !== 'form') { throw new RuntimeException('No se puede crear un elemento ' . $att['tag'] . ' con la clase form'); } $att['tag'] = 'form'; if (isset($att['tipo']) && ($att['tipo'] === 'horizontal' || $att['tipo'] === 'inline')) { $this->tipo = $att['tipo']; $this->addAtributo('class', 'form-' . $att['tipo']); } if (isset($att['tipo'])) { unset($att['tipo']); } $this->addAtributo('role', 'form'); parent::__construct($att); }
/** * This will call the initial build for a new instance. It should be called only once from within the script. All subsequent calls to controllers should be done through $this->add($path). * * @param array $cfg The default config for the elements */ public function __construct($cfg) { if ($cfg) { if (is_string($cfg)) { $cfg = ['tag' => 'form', 'attr' => ['action' => $cfg, 'method' => 'post']]; } else { $cfg['tag'] = 'form'; if (!isset($cfg['attr'])) { $cfg['attr'] = []; } if (!isset($cfg['attr']['action'])) { $cfg['attr']['action'] = '.'; } if (!isset($cfg['attr']['method'])) { $cfg['attr']['method'] = 'post'; } } parent::__construct($cfg); } }
public function __construct($att) { if (!is_a($this, 'input') && isset($att['tag']) && $att['tag'] !== 'input') { throw new RuntimeException('No se puede crear un elemento ' . $att['tag'] . ' con la clase input'); } // Solo sobreescribimos el tag en caso que no exista puede ser una clase hija como select que ya pone un TAG if (!isset($att['tag'])) { $att['tag'] = 'input'; } $this->addAtributo('class', 'form-control'); parent::__construct($att); if (isset($att['label']) && is_string($att['label'])) { $this->addLabel($att['label']); } else { if (isset($att['label']) && is_a($att['label'], 'element')) { $this->label = $att['label']; } } unset($att['label']); $this->delAtributo('label'); }
public function __construct(&$theArray) { ENTER("document::document", __LINE__); foreach ($theArray as $aKey => $aValue) { if (array_search($aKey, $this->myOwnFields) !== false) { $this->{$aKey} = $aValue; } } parent::__construct($theArray); }
/** * This will build a new HTML form element according to the given configuration. * Only name and tag are mandatory, then other values depending on the tag * * @param array $cfg The configuration * @return self */ public function __construct($cfg) { if (is_string($cfg)) { $cfg = ['field' => 'text', 'attr' => ['name' => $cfg]]; } parent::__construct($cfg); if ($this->tag) { $mandatory_attr = array(); if (!isset($this->attr['id'])) { $this->attr['id'] = \bbn\str\text::genpwd(20, 15); } $this->script = isset($cfg['script']) ? $cfg['script'] : ''; $this->value = isset($cfg['value']) ? $cfg['value'] : ''; switch ($this->tag) { case "input": array_push($mandatory_attr, "type"); break; case "textarea": array_push($mandatory_attr, "cols", "rows"); break; case "select": array_push($mandatory_attr, "attr"); break; } foreach ($mandatory_attr as $m) { if (!isset($this->attr[$m])) { die("Argument {$m} is missing in your config... Sorry!"); } } } return $this; }
public function __construct() { parent::__construct(); $this->head[] = new Element('style', array('html' => 'img { height: 100%; width: 100%; object-fit: contain; }')); }
public function __construct($gaid) { parent::__construct(); $this->head[] = new Element('script', array('html' => "\n(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');\nga('create', '{$gaid}', 'auto');\nga('send', 'pageview');")); }
public function __construct($kwargs) { parent::__construct(); $this->head[] = new element('meta', $kwargs); }
public function __construct($url) { parent::__construct(); $this->head[] = new element('link', array('rel' => 'icon', 'href' => $url)); }