function createComponentDeliveryTabella($name) { $model = $this->model; $grid = new Maite\Tabella(array('context' => $this->context, 'source' => $this->model->getFluent(), 'id_table' => $this->model->getTableIdName(), 'order' => 'sequence', 'onSubmit' => function ($post) use($model) { }, 'onDelete' => function ($id) use($model) { $model->delete($id); })); $this->addComponent($grid, $name); $grid->addColumn('Názov', 'name', array('width' => 100, 'editable' => true)); $grid->addColumn('Popis', 'description', array('width' => 200)); $grid->addColumn('Cena', 'price', array('width' => 100)); $presenter = $this->getPresenter(); $grid->addColumn("", "active", array("width" => 20, 'type' => Maite\Tabella::TEXT, "filter" => false, 'order' => false, "renderer" => function ($row) use($presenter) { $el = NHtml::el("td"); $el->add(NHtml::el('a')->href($presenter->link('deleteDelivery!', array('id' => $row->id_payment)))->addClass('deleteIcon ajax')->title('Naozaj chcete zmazať položku?')); /* * link na editaciu produktu */ $el->add(NHtml::el('a')->href($presenter->link('edit', array('id' => $row->id_payment)))->addClass('editIcon')); /* * posuvanie - ak sa spusti posubanie, treba vypnut zoradovanie !!! order=>false */ // $el->add( // NHtml::el( 'a' )->href('#')->addClass( 'moveIcon' ) // ->addId( 'index_'.$row['id_product'] ) // ); return $el; })); }
protected function createComponentSupplierTabella($name) { $datasource = SupplierModel::getFluent()->toDatasource()->orderBy('name'); $grid = new Tabella($datasource, array('id_table' => 'id_product_supplier', 'sorting' => 'id_product_supplier', 'order' => 'id_product_supplier', 'truncate' => 0, "onSubmit" => function ($post) { SupplierModel::save($post, $post['id_product_supplier']); })); $grid->addColumn("Názov", "name", array("width" => 300, "editable" => true)); $grid->addColumn("Počet produktov", "product_count", array("width" => 80, "editable" => false)); $grid->addColumn("", "action", array("width" => 100, 'type' => Tabella::SELECT, "filter" => false, "options" => false, "editable" => true, "renderer" => function ($row) { $el = NHtml::el("td"); /* * link na zmazanie produktu */ $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('delete!', array('id' => $row->id_product_supplier)))->addClass('deleteIcon')); /* * link na editaciu produktu */ // $el->add( // NHtml::el( 'a' )->href( // NEnvironment::getApplication()->getPresenter()->link( 'Product:edit' , array('id'=>$row->id_product_supplier)) // )->addClass( 'editIcon' ) // ); /* * ikona aktivan polozka, neaktivan polozka */ return $el; })); $this->addComponent($grid, $name); }
public function renderEnd() { if (!empty($this->original_css)) { foreach ($this->original_css as $file) { echo '<link href="' . $file . '" rel="stylesheet" type="text/css">'; } } if (!empty($this->original_jscripts)) { foreach ($this->original_jscripts as $file) { echo '<script type="text/javascript" src="' . $file . '"></script>'; } } if (count($this->plain_jscripts) > 0) { echo '<script type="text/javascript">'; foreach ($this->plain_jscripts as $js) { echo $js . "\n"; } echo '</script>'; } if (count($this->texts) > 0) { foreach ($this->texts as $t) { echo $t . "\n"; } } echo NHtml::el('head')->endTag(); }
function createComponentTabella($name) { $model = $this->helpsModel; $grid = new Maite\Tabella(array('context' => $this->context, 'source' => $this->helpsModel->getFluent(), 'id_table' => 'id_helps', 'order' => 'id_helps', 'onSubmit' => function ($post) use($model) { })); $this->addComponent($grid, $name); $grid->addColumn('Názov', 'key', array('width' => 100, 'editable' => true)); $grid->addColumn('Text', 'text', array('width' => 200)); $presenter = $this->getPresenter(); $grid->addColumn("", "active", array("width" => 20, 'type' => Maite\Tabella::TEXT, "filter" => false, 'order' => false, "renderer" => function ($row) use($presenter) { $el = NHtml::el("td"); /* * link na editaciu produktu */ $el->add(NHtml::el('a')->href($presenter->link('edit', array('id' => $row->id_helps)))->addClass('editIcon')); /* * posuvanie - ak sa spusti posubanie, treba vypnut zoradovanie !!! order=>false */ // $el->add( // NHtml::el( 'a' )->href('#')->addClass( 'moveIcon' ) // ->addId( 'index_'.$row['id_product'] ) // ); return $el; })); }
public function __construct($rubriky, $povolene_rubriky = null, $values = null) { $povolit_zmenu_url = TRUE; if (isset($values->zamek) && $values['zamek'] == 'A') { $povolit_zmenu_url = FALSE; } dd($povolit_zmenu_url, 'změna'); parent::__construct(); if (!$povolene_rubriky) { $polozky = $rubriky; } else { foreach ($rubriky as $key => $rubrika) { $zakazano = in_array($key, $povolene_rubriky) ? FALSE : TRUE; $polozky[$key] = NHtml::el('option')->value($key)->setHtml($rubrika)->disabled($zakazano); } } $this->addSelect('rodic', 'Nadřazená rubrika', $polozky)->setPrompt('--- Zvolte rubriku ----')->setRequired('Zvolte nadřazenou rubriku.'); $this->addText('nazev', 'Název', 30)->setRequired('Zadejte název rubriky.'); $this->addText('url', 'Url', 30)->addCondition(NForm::FILLED)->addRule(NForm::PATTERN, 'Url obsahuje nepovolené znaky.', '[0-9a-z][0-9a-z\\-]*'); if (!$povolit_zmenu_url) { $this['url']->setDisabled()->setAttribute('title', 'Adresa je chráněna proti přepsání'); } // $this->addText('url', 'Url', 30)->addRule(NForm::PATTERN, 'Url obsahuje nepovolené znaky.', '[0-9]*'); $this->addSubmit('send', 'Uložit'); if ($values) { $this->setDefaults($values); } }
/** * @param string caption */ public function __construct($caption = NULL) { $this->monitor('NForm'); parent::__construct(); $this->control = NHtml::el('input'); $this->label = NHtml::el('label'); $this->caption = $caption; $this->rules = new NRules($this); }
public function __construct($label = NULL) { if (!@(require_once self::$libPath)) { throw new Exception('The reCAPTCHA library is missing.'); } $this->monitor('Form'); parent::__construct($label); $this->control->type = 'text'; $this->value = ''; $this->control = NHtml::el(); $this->status = NHtml::el('strong'); }
public function __construct() { $this->xml = NHtml::el('are:Ares_dotazy'); $this->xml->__set('xmlns:are', 'http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_request_orrg/v_1.0.0'); $this->xml->__set('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $this->xml->__set('xsi:schemaLocation', 'http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_request_orrg/v_1.0.0'); $this->xml->__set('dotaz_datum_cas', date('Y-m-d\\TH:i:s')); $this->xml->__set('dotaz_typ', 'Basic'); $this->xml->__set('vystup_format', 'XML'); $this->xml->__set('validation_XSLT', 'http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_answer/v_1.0.0/ares_answer.xsl'); $this->xml->__set('user_mail', '*****@*****.**'); $this->xml->__set('answerNamespaceRequired', 'http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_answer_basic/v_1.0.3'); $this->xml->__set('Id', 'Ares_dotaz'); }
function createComponent($name) { switch ($name) { case 'userTabella': $model = new UserModel(); $grid = new Tabella($model->getFluent(false)->toDatasource(), array('sorting' => 'desc', 'order' => 'id_gui_user')); $grid->addColumn("Login/Email", "login", array("width" => 100)); $grid->addColumn("Meno", "name", array("width" => 100)); $grid->addColumn("Priezvisko", "surname", array("width" => 100)); $grid->addColumn("Naposledy prihlásený", "lastvisit", array("width" => 100)); $grid->addColumn("", "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) { $el = NHtml::el("td"); /* * link na zmazanie produktu */ $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteUser!', array('id' => $row->id_gui_user)))->addClass('deleteIcon ajax')); /* * link na editaciu produktu */ $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('edit', array('id' => $row->id_gui_user)))->addClass('editIcon')); /* * ikona aktivan polozka, neaktivan polozka */ $span = NHtml::el('span'); if ($row->activate) { $span->addClass('activeIcon active'); } else { $span->addClass('unactiveIcon active '); } $el->add($span); return $el; })); $this->addComponent($grid, $name); break; case 'userForm': $form = UserModel::baseForm(false); $form->addGroup(''); $form->addText('discount', 'Zľava použivateľa'); $form->addHidden('id'); $form->addSubmit('btn_submit', 'Uložiť'); $form->onSuccess[] = array($this, 'saveUser'); $form->setDefaults(UserModel::get($this->getParam('id'))); return $form; break; default: return parent::createComponent($name); break; } }
/** * Returns link to editor. * @return NHtml */ public static function editorLink($file, $line) { if (NDebugger::$editor && is_file($file)) { $dir = dirname(strtr($file, '/', DIRECTORY_SEPARATOR)); $base = isset($_SERVER['SCRIPT_FILENAME']) ? dirname(dirname(strtr($_SERVER['SCRIPT_FILENAME'], '/', DIRECTORY_SEPARATOR))) : dirname($dir); if (substr($dir, 0, strlen($base)) === $base) { $dir = '...' . substr($dir, strlen($base)); } return NHtml::el('a') ->href(strtr(NDebugger::$editor, array('%file' => rawurlencode($file), '%line' => $line))) ->title("$file:$line") ->setHtml(htmlSpecialChars(rtrim($dir, DIRECTORY_SEPARATOR)) . DIRECTORY_SEPARATOR . '<b>' . htmlSpecialChars(basename($file)) . '</b>'); } else { return NHtml::el('span')->setText($file); } }
function createComponentBaseForm() { // NForm::extensionMethod('NForm::addCBTree', array('CBTree', 'addCBTree')); // // $tree = new TreeView; // // $tree->primaryKey = 'id_category'; // $tree->parentColumn = 'id_parent'; // $tree->useAjax = false; // $tree->addLink(null, 'name', 'id', true, $this->presenter); // $tree->dataSource = CategoryModel::getDatasource()->where("id_lang = %i",$this->getPresenter()->id_lang); //$form->addCBTree('ctree', _('Kategórie'), $tree); $form = new NAppForm(); $renderer = $form->getRenderer(); // budeme generovat formulář jako definiční seznam $renderer->wrappers['controls']['container'] = NHtml::el('table')->addClass('standard'); $langs = Setting::getLangs(); foreach ($langs as $k => $lang) { $form->addGroup($lang['name'])->setOption('container', 'fieldset class=lang_fieldset id=lang_' . $lang['iso']); $form->addText('name' . self::$_separator . $lang['iso'], _('Názov'))->addRule(NFORM::FILLED, 'Názov ' . $lang['iso'] . ' musí byť vyplnený.'); $form->addTextArea('description' . self::$_separator . $lang['iso'], 'Popis'); $form->addText('link_rewrite' . self::$_separator . $lang['iso'], 'URL link')->setDisabled(); $form->addText('meta_title' . self::$_separator . $lang['iso'], 'Titulok'); // $form->addText('meta_keywords'.self::$_separator.$lang['iso'], 'Kľúčové slová'); $form->addText('meta_description' . self::$_separator . $lang['iso'], 'Meta popis'); } //$form->addText('icon','Názov ikony'); $form->addCheckbox('show_on_bottom', 'Zobraziť v spodnej časti'); $form->addGroup(''); $form->addHidden('id_category'); $c = new CategoryModel($this->getPresenter()->id_lang); $select = array('' => 'root'); /* * todo dorobit, aby sa nedala vybrat samu seba categoria */ $c->generateTreeToSelect($select, NULL, NULL); $form->addSelect('id_parent', 'Rodič', $select); // ->addRule(NForm::FILLED, _('Rodič musí byť vyplnený.') ); $form->addSelect('active', 'Aktívny', array(1 => 'Povolený', 0 => 'Zakázaný')); $form->onSuccess[] = array($this, 'categoryAction'); return $form; }
function createComponentWeightTabella($name) { $grid = new Tabella(ProductWeightModel::getFluent()->toDataSource(), array('sorting' => 'asc', 'order' => 'weight_to', 'id_table' => 'id_product_weight', 'limit' => 50, "onSubmit" => function ($post) { // print_r($post);exit; ProductWeightModel::edit($post, $post['id_product_weight']); }, "onDelete" => function ($id) { ProductWeightModel::delete($id); })); $el = NHtml::el("div"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyWeight!'))->addClass('addIcon ajax')); //$grid->addColumn($el, '', array('width'=>20, 'filter'=>NULL, "editable" => false ) ); $grid->addColumn("Váha do", "weight_to", array("width" => 50, "editable" => true)); $grid->addColumn("Cena poštovného", "weight_price", array("editable" => true)); $grid->addColumn($el, "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) { $el = NHtml::el("td"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteWeight!', array('id_product_weight' => $row->id_product_weight)))->addClass('deleteIcon ajax')); return $el; })); $this->addComponent($grid, $name); }
public function __construct($rubriky, $povolene_rubriky = null, $values = null) { dd($povolene_rubriky, 'povolene_rubriky'); parent::__construct(); if (!$povolene_rubriky) { $polozky = $rubriky; } else { foreach ($rubriky as $key => $rubrika) { $zakazano = in_array($key, $povolene_rubriky) ? FALSE : TRUE; $polozky[$key] = NHtml::el('option')->value($key)->setHtml($rubrika)->disabled($zakazano); } } $this->addSelect('rubrika', 'Rubrika', $polozky)->setPrompt('--- Zvolte rubriku ---')->setRequired('Zvolte rubriku.'); $this->addText('nadpis', 'Nadpis:', 95)->setDefaultValue('nadpis')->setRequired('Zadejte název článku')->addRule(NForm::MAX_LENGTH, 'Maximálně %d znaků', 250)->addRule(~NForm::EQUAL, 'Zadejte název článku', 'nadpis')->setHtmlId('clanek_form_nadpis'); $this->addTextArea('perex', 'Perex:', 85, 5)->setDefaultValue('perex')->addRule(NForm::MAX_LENGTH, 'Maximálně %d znaků', 250)->setHtmlId('clanek_form_perex'); $this->addTextArea('obsah', 'Obsah', 85, 25)->setAttribute('class', 'mceEditor'); $this->addSubmit('send', 'Uložit'); if (isset($values)) { $this->setDefaults($values); } }
function createComponentVatTabella($name) { $vat = VatModel::init(); $grid = new Tabella($vat->getFluent()->toDataSource(), array('sorting' => 'asc', 'order' => 'id_vat', 'id_table' => 'id_vat', 'limit' => 50, "onSubmit" => function ($post) use($vat) { if ($post['id_vat'] == 0) { $vat->insert($post); } else { $vat->update($post['id_vat'], $post); } }, "onDelete" => function ($id) use($vat) { $vat->delete($id); })); $el = NHtml::el("div"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyWeight!'))->addClass('addIcon ajax')); //$grid->addColumn($el, '', array('width'=>20, 'filter'=>NULL, "editable" => false ) ); $grid->addColumn("Názov", "name", array("width" => 50, "editable" => true)); $grid->addColumn("Hodnota", "value", array("editable" => true)); $grid->addColumn("Prednadstavená?", "is_default", array("width" => 50, 'type' => Tabella::SELECT, "editable" => true, "filter" => NULL, 'renderer' => function ($row) { $el = NHtml::el("td")->setHtml($row['is_default'] == 1 ? 'áno' : 'nie'); return $el; })); $grid->addColumn("+", Tabella::ADD, array("type" => Tabella::DELETE)); $this->addComponent($grid, $name); }
/** * Renders form end. * @return string */ public static function renderFormEnd($form) { $s = ''; if (strcasecmp($form->getMethod(), 'get') === 0) { $url = explode('?', $form->getElementPrototype()->action, 2); if (isset($url[1])) { foreach (preg_split('#[;&]#', $url[1]) as $param) { $parts = explode('=', $param, 2); $name = urldecode($parts[0]); if (!isset($form[$name])) { $s .= NHtml::el('input', array('type' => 'hidden', 'name' => $name, 'value' => urldecode($parts[1]))); } } } } foreach ($form->getComponents(TRUE, 'NHiddenField') as $control) { if (!$control->getOption('rendered')) { $s .= $control->getControl(); } } if (iterator_count($form->getComponents(TRUE, 'NTextInput')) < 2) { $s .= '<!--[if IE]><input type=IEbug disabled style="display:none"><![endif]-->'; } echo ($s ? "<div>$s</div>\n" : '') . $form->getElementPrototype()->endTag() . "\n"; }
public function generate() { // inic $output = null; // start tag if ($this->writeCopyrightTags()) { $output .= "<!-- @FbTools: Comments --!>\n"; } // div tag $div = NHtml::el("div"); $div->id = "fb-root"; $output .= $div; // script tag $script = NHtml::el("script"); $script->src = "http://connect.facebook.net/en_US/all.js#appId=186670371343644&xfbml=1"; $output .= $script; // facebook tag $fb = NHtml::el("fb:comments"); $fb->href = $this->getUrl(); $fb->num_posts = $this->getNumPosts(); $fb->width = $this->getWidth(); $output .= $fb; // end tag if ($this->writeCopyrightTags()) { $output .= "\n<!-- /@FbTools: Comments --!>\n"; } echo $output; }
/** * Generates control's HTML element. * @return NHtml */ public function getControl() { $selected = $this->getValue(); $selected = is_array($selected) ? array_flip($selected) : array($selected => TRUE); $control = parent::getControl(); $option = NHtml::el('option'); if ($this->prompt !== FALSE) { $control->add($this->prompt instanceof NHtml ? $this->prompt->value('') : (string) $option->value('')->setText($this->translate((string) $this->prompt)) ); } foreach ($this->items as $key => $value) { if (!is_array($value)) { $value = array($key => $value); $dest = $control; } else { $dest = $control->create('optgroup')->label($this->translate($key)); } foreach ($value as $key2 => $value2) { if ($value2 instanceof NHtml) { $dest->add((string) $value2->value($key2) ->selected(isset($selected[$key2]))); } else { $key2 = $this->useKeys ? $key2 : $value2; $dest->add((string) $option->value($key2) ->selected(isset($selected[$key2])) ->setText($this->translate((string) $value2))); } } } return $control; }
protected function createComponent($name) { switch ($name) { case 'JsTree': $tree = new JsTree(); $tree->keyColumn = 'id_category'; $tree->parentColumn = 'id_parent'; $tree->table = "category"; // jméno tabulky, s kterou bude pracovat $tree->titleColumn = "name"; // jméno sloupce pro titulek $tree->orderColumn = "sequence"; // jméno sloupce pro pořadí $tree->numberingFrom = 0; // $tree->parentColumn = "parent"; //$tree->where = array(array("`web`=%i", WEB)); // je možné navěsit podmínky //$tree->defaultValues = array("web"=>WEB); $tree->enableContextmenu = false; $tree->enableDragDrop = true; $tree->enableDragDropOrder = false; $tree->showRoot = false; $tree->enableCheckbox = false; // zobrazení checkboxů $tree->checkboxColumn = "checked"; // sloupec, který ovlivňuje stav checkboxu $tree->onAfterUpdate[] = callback($this, "updateUrl"); $tree->onAfterCreate[] = callback($this, "updateUrl"); $tree->onClick[] = callback($this, "handleClick"); $tree->openAll = true; return $tree; break; case 'changePrice': $f = new MyForm(); $f->addText('coeficient', NHtml::el('p')->add('Upraviť ceny v danej kategórii podľa koeficientu.')->add(NHtml::el('div')->add('Napr. ak chcete zvýšiť cenu o 10 percent, zadáte koeficient 1.10, ak o 25 percent 1.25. Ak chcete ceny znížiť o 10 percent, zadáte 0.90, ak o 15 percent, zadáte 0.85. Želanú kategóriu si zvolíte v ľavom v menu. Cena bude zaokrúhlená!')->addClass('silver')))->addRule(NForm::FILLED, 'Koeficient musí byť vyplnený'); $f->addSubmit('btn_percent', "Prepočitať"); $f->onSuccess[] = array($this, 'handleChangePrice'); return $f; break; case 'addCategoryForm': $c = new CategoryFormControl(); $c->mode = 'add'; return $c; break; case 'editCategoryForm': $c = new CategoryFormControl(); $c->mode = 'edit'; return $c; break; case 'MyTree': $c = new MyTreeControl(); $c->invalidateControl(); return $c; break; default: return parent::createComponent($name); break; } }
/** * @param string * @return NHtml */ protected function getWrapper($name) { $data = $this->getValue($name); return $data instanceof NHtml ? clone $data : NHtml::el($data); }
/** * Get script element * @param string $source * @return Html */ public function getElement($source) { return NHtml::el("script")->type("text/javascript")->src($source); }
public function generate() { // inic $output = null; // settings $settings = array('site' => $this->getUrl(), 'width' => $this->getWidth(), 'height' => $this->getHeight(), 'header' => (bool) $this->getShowHeader(), 'colorscheme' => $this->getColorScheme(), 'border_color' => $this->getBorderColor(), 'recommendations' => (bool) $this->getRecommendations()); $query = http_build_query($settings, '', '&'); // start tag if ($this->writeCopyrightTags()) { $output .= "<!-- @FbTools: ActivityFeed --!>\n"; } // iframe tag $el = NHtml::el("iframe"); $el->src = "http://www.facebook.com/plugins/activity.php?" . $query; $el->scrolling = "no"; $el->frameborder = 0; $el->allowTransparency = "true"; $el->style['border'] = "none"; $el->style['overflow'] = "hidden"; $el->style['width'] = $this->getWidth() . "px"; $el->style['height'] = $this->getHeight() . "px"; $output .= $el; // end tag if ($this->writeCopyrightTags()) { $output .= "\n<!-- /@FbTools: ActivityFeed --!>\n"; } echo $output; }
function createComponent($name) { switch ($name) { // case 'addForm': // $form = $this->baseForm(); // $form->addSubmit('btn', 'Pridať'); //// $values['product_alternative'] = ProductModel::getFluent($this->id_lang)->where('id_category = 5')->fetchPairs("id_product",'id_product'); // //poziadavka klienta - zobrat vsetky produkty z doplnkov // // // $form->setDefaults( array('id_product_template_group'=>$this->getService('ProductTemplateGroupModel')->getIdDefaultTemplate()) ); // // // $form->onSuccess[] = callback($this, 'add'); // return $form; // break; case 'editForm': $id_product = $this->getPresenter()->getParam('id'); $form = $this->baseForm(); $form['id_product']->setValue($id_product); $values = array(); //Titulok - doplnit categoria+ nazov produktu //Kľúčové slová - //Meta popis - doplnit categoria+ nazov produktu + Výkon + Dĺžka Horenia foreach ($this->template->langs as $l) { $val = ProductModel::get($id_product, $l['id_lang']); // ziste ktore komponenty maju jazykovu mutaciu $controls_for_lang = array(); foreach ($form->getComponents() as $control) { if (strpos($control->getName(), CategoryFormControl::$_separator)) { if (strpos($control->getName(), CategoryFormControl::$_separator . $l['iso'])) { list($val_key) = explode(CategoryFormControl::$_separator . $l['iso'], $control->getName()); $values += array($control->getName() => $val[$val_key]); } } else { if (isset($val[$control->getName()])) { $values += array($control->getName() => $val[$control->getName()]); } } } } //print_r(ProductModel::getProductAlternative($id_product));exit; $values['product_alternative'] = ProductModel::getProductAlternative($id_product); // vyriesenie categorii //nacitanie prveho parametru - iba pre jednoparametrove produkty $param = (array) dibi::fetch("SELECT * FROM [product_param] WHERE id_product = %i", $id_product); $form->setDefaults(array_merge($param, $values)); $form->addSubmit('btn_save_and_stay', 'Upraviť a zostať tu'); $form->addSubmit('btn_save', 'Upraviť'); $form->onSuccess[] = callback($this, 'save'); return $form; break; /* * generator */ /* * generator */ case 'generatorForm': //ProductModel::repairMinPrice(); NFormContainer::extensionMethod('NFormContainer::addCheckboxList', array('CheckboxList', 'addCheckboxList')); $sizes = dibi::query("SELECT size FROM [product_param] WHERE size !='' GROUP BY size")->fetchPairs('size', 'size'); $colors = dibi::query("SELECT color FROM [product_param] WHERE color !='' GROUP BY color")->fetchPairs('color', 'color'); $materials = dibi::query("SELECT material FROM [product_param] WHERE material !='' GROUP BY material")->fetchPairs('material', 'material'); $f = new MyForm(); // $f->getElementPrototype()->addClass('ajax'); $renderer = $f->getRenderer(); $renderer->wrappers['controls']['container'] = NHtml::el('div')->addClass('container'); $renderer->wrappers['pair']['container'] = NHtml::el('div')->addClass('pair-container'); $renderer->wrappers['label']['container'] = NHtml::el('h3'); $renderer->wrappers['control']['container'] = NHtml::el('div')->addClass('input-container'); // usort($sizes, 'EshopProductControl::cmp'); $f->addCheckboxList('size', 'Veľkosť', $sizes); $f->addCheckboxList('color', 'Farba', $colors); $f->addCheckboxList('material', 'Material', $materials); //ak je pridavanie a neexistuje id $f->addHidden('id_product', $this->getParam('id')); // // // $renderer = $f->getRenderer(); // $renderer->wrappers['label']['container'] = NULL; // // //ziskaj vsetky mozne velkosti // $sizes = dibi::fetchAll("SELECT size FROM [product_param] GROUP BY size"); // $f->addGroup('Veľkosť'); // foreach($sizes as $k=>$size){ // $f->addCheckbox('size_'.$k, $size['size']); // } // // //ziskaj vsetky mozne farby // $colors = dibi::fetchAll("SELECT color FROM [product_param] GROUP BY color"); // $f->addGroup('Farba'); // foreach($colors as $k=>$color){ // $f->addCheckbox('color_'.$k, $color['color']); // } // // //ziskaj vsetky mozne material // $materials = dibi::fetchAll("SELECT material FROM [product_param] GROUP BY material"); // $f->addGroup('Material'); // foreach($materials as $k=>$material){ // $f->addCheckbox('material_'.$k, $material['material']); // } $f->addGroup()->setOption('container', 'fieldset class=clear'); $f->addSubmit('btn_generate', 'Generovať'); $f->onSuccess[] = array($this, 'handleAddGeneratedParam'); return $f; break; case 'productParams': // $d = ProductModel::getProductParamDatasource( $this->getParam('id'))->fetchAll(); $id_product = $this->getParam('id'); $grid = new Tabella(ProductModel::getProductParamDatasource($id_product), array('sorting' => 'asc', 'order' => 'sequence', 'id_table' => 'id_product_param', 'limit' => 50, "onSubmit" => function ($post) { // print_r($post);exit; ProductModel::setProductParamValue($post, $post['id_product_param']); }, "onDelete" => function ($id) { ProductModel::deleteProductParamValue($id); })); $el = NHtml::el("div"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('addEmptyParam!', array('id_product' => $id_product)))->addClass('addIcon ajax')); $grid->addColumn($el, 'sequence', array('width' => 20, 'filter' => NULL, "editable" => true)); //vytiahnutie template_group pre produkt - ake bude mat parametre if ($id_product) { $id_product_template_group = ProductModel::getFluent(1, false, false)->removeClause('select')->select('id_product_template_group')->where('id_product = %i', $id_product)->fetchSingle(); } else { //ak je id_product NULL jedna sa pridavanie produktu if ($id_product == NULL and $this->getParam('id_product_template_group') != NULL) { $id_product_template_group = $this->getParam('id_product_template_group'); } else { $id_product_template_group = $this->getService('ProductTemplateGroupModel')->getIdDefaultTemplate(); } } $params = $this->getService('ProductTemplateGroupModel')->fetchAssocAllParam($id_product_template_group); foreach ($params as $p) { if ($p['checked']) { $grid->addColumn($this->getService('translator')->translate($p['row_name']), $p['row_name'], array("width" => 50, "editable" => true)); } } $grid->addColumn("Cena", "price", array("width" => 100, "editable" => true)); // _repairPriceForView // // // $grid->addColumn( "Na sklade", "stock", array( "width" => 50, "editable" => true ) ); //// $grid->addColumn( "Farba", "color", array( "width" => 100, "editable" => true ) ); //// $grid->addColumn( "Veľkosť", "size", array( "width" => 100, "editable" => true ) ); //// $grid->addColumn( "Material", "material", array( "width" => 100, "editable" => true ) ); // $grid->addColumn( "Napojenie", "connection", array( "width" => 100, "editable" => true ) ); // $grid->addColumn( "Cena", "price", array( "width" => 100, "editable" => true ) ); $grid->addColumn("", "", array("width" => 30, 'filter' => NULL, "options" => '', "renderer" => function ($row) { $el = NHtml::el("td"); $el->add(NHtml::el('a')->href(NEnvironment::getApplication()->getPresenter()->link('deleteProductParam!', array('id_product_param' => $row->id_product_param)))->addClass('deleteIcon ajax')); return $el; })); $this->addComponent($grid, $name); break; case 'pictogram': $p = new PictogramControl($this, $name); return $p; break; case 'keyword': return new KeywordControl(); break; case 'ajaxtest': return new AjaxTextControl(); break; default: return parent::createComponent($name); break; } }
public function __construct($label = NULL) { parent::__construct($label); $this->control = NHtml::el($this->captcha_element); }
/** * @param $key * @param $value * @return null|NHtml */ public function makeTag($key, $value) { if (empty($value) || empty($key)) { return NULL; } $el = NHtml::el("meta"); $el->property = $key; $el->content = $value; return $el; }
/** * renders the footer * @return string */ public function renderFooter() { $footer = \NHtml::el('div')->class('tabella-footer'); $pages = ceil($this->count / $this->params['limit']); $count = 10; if ($pages > 1) { if ($this->params['offset'] != 1) { $fst = \NHtml::el('a')->href($this->link('reset!', array('offset' => 1))); } else { $fst = \NHtml::el('span'); } $footer->add($fst->add('«')); $range = range(max(1, $this->params['offset'] - $count), min($pages, $this->params['offset'] + $count)); $quotient = ($pages - 1) / $count; for ($i = 0; $i <= $count; $i++) { $range[] = round($quotient * $i) + 1; } sort($range); $range = array_values(array_unique($range)); foreach ($range as $i) { $a = \NHtml::el('a')->add($i)->href($this->link('reset!', array('offset' => $i))); $a->class[] = 'tabella_ajax'; if ($i == $this->params['offset']) { $a->class[] = 'selected'; } $footer->add($a); } if ($this->params['offset'] != $pages) { $last = \NHtml::el('a')->href($this->link('reset!', array('offset' => $pages))); } else { $last = \NHtml::el('span'); } $footer->add($last->add('»')); } return $footer; }
/** * Form constructor. * @param string */ public function __construct($name = NULL) { $this->element = NHtml::el('form'); $this->element->action = ''; // RFC 1808 -> empty uri means 'this' $this->element->method = self::POST; $this->element->id = $name === NULL ? NULL : 'frm-' . $name; $this->monitor(__CLASS__); if ($name !== NULL) { $tracker = new NHiddenField($name); $tracker->unmonitor(__CLASS__); $this[self::TRACKER_ID] = $tracker; } parent::__construct(NULL, $name); }
/** * Render 1 node (+ subnodes) * @param TreeViewNode node * @param control * @param label * @return Nette\Web\Html */ private function renderNode(TreeViewNode $node, $control, $label) { $pcontrol = clone $control; $li = NHtml::el('li'); $nid = $node->getDataRow()->id; $control->id = $label->for = $control->id . '-' . $nid; $ck = $this->checkColumn; /* * Pridal som ze ak neezistuje stlpec, aby nedavalo notice */ if (isset($node->getDataRow()->{$ck}) and $node->getDataRow()->{$ck}) { $control->checked = 'checked'; } else { $control->checked = null; } $control->value = $nid; $nc = $this->nameColumn; $label->setText($node->getDataRow()->{$nc}); $li->add((string) $control . (string) $label); $nodes = $node->getNodes(); if (count($nodes)) { $ul = NHtml::el('ul'); $li->add($ul); foreach ($nodes as $n) { $ul->add($this->renderNode($n, $pcontrol, $label)); } } return $li; }
public function renderRss($channels = NULL) { if ($channels !== NULL) { $this->rssChannels = array(); foreach ($channels as $title => $link) { $this->addRssChannel($title, $link); } } foreach ($this->rssChannels as $channel) { echo NHtml::el('link')->rel('alternate')->type('application/rss+xml')->title($channel['title'])->href(NEnvironment::getApplication()->getPresenter()->link($channel['link'])) . "\n"; } }
/** * Generating */ public function generate() { // inic $output = NULL; // settings $settings = ['href' => $this->getUrl(), 'layout' => $this->getLayout(), 'show_faces' => (bool) $this->getShowFaces(), 'width' => $this->getWidth(), 'action' => $this->getType(), 'font' => $this->getFont(), 'colorscheme' => $this->getColorScheme(), 'height' => $this->getHeight()]; $query = http_build_query($settings, '', '&'); // start tag if ($this->copyright) { $output .= "<!-- @FbTools: LikeButton -->\n"; } // iframe tag $el = NHtml::el("iframe"); $el->src = "http://www.facebook.com/plugins/like.php?" . $query; $el->scrolling = "no"; $el->frameborder = 0; $el->allowTransparency = "true"; $el->style['border'] = "none"; $el->style['overflow'] = "hidden"; $el->style['width'] = $this->getWidth() . "px"; $el->style['height'] = $this->getHeight() . "px"; $output .= $el; // end tag if ($this->copyright) { $output .= "\n<!-- /@FbTools: LikeButton -->\n"; } echo $output; }
function createComponent($name) { switch ($name) { /* * newsletterTabella */ case 'newsletterTabella': $grid = new Tabella(NewsletterModel::getFluent()->toDataSource(), array('sorting' => 'desc', 'order' => 'adddate', 'id_table' => 'id', 'limit' => 100, 'onSuccess' => function ($values) { NewsletterModel::edit($values, $values['id_newsletter_emails']); }, 'onDelete' => function ($id_newsletter_emails) { NewsletterModel::delete($id_newsletter_emails); })); $el = NHtml::el("div"); $session = NEnvironment::getSession('checked_emails'); $grid->addColumn($el, "", array("editable" => false, 'filter' => false, "width" => 20, "renderer" => function ($row) use($session) { $el = NHtml::el("td"); $checked = isset($session->emails[$row['id_newsletter_emails']]) ? 'checked="checked"' : ''; $el->add('<input class="checked_emails" type="checkbox" name="se[]" value="' . $row['id_newsletter_emails'] . '" ' . $checked . '/>'); return $el; })); $grid->addColumn("Id", "id_newsletter_emails", array("width" => 30, 'editable' => false)); $grid->addColumn("Email", "email", array("width" => 50, 'editable' => false)); // $grid->addColumn( "Popis", "description", array( 'editable'=>true ) ); $grid->addColumn("Dátum registrácie ", "adddate", array("width" => 100)); /*$grid->addColumn( "Aktívny", "active", array( "width" => 50, 'type'=> Tabella::SELECT, "editable" => true, "filter" => array( 1=>'áno', 0=>'nie'), 'renderer' => function($row){ $active = ($row['active'] == 1)?'áno':'nie'; $el = NHtml::el( "td" )->setHtml($active); return $el; } ) ); $grid->addColumn("", "", array( "width" => 30, 'filter'=>NULL, "options" => '', "renderer" => function( $row ) { $el = NHtml::el( "td" ); $el->add( NHtml::el( 'a' )->href( NEnvironment::getApplication()->getPresenter()->link( 'deleteEmail!' , array('id'=>$row->id_newsletter_emails)) )->addClass( 'deleteIcon' ) ); $span = NHtml::el('span'); $el->add($span); return $el; } ) ); */ $this->addComponent($grid, $name); break; /* * newslette text */ /* * newslette text */ case 'newsletterTextForm': $last_newsletter = dibi::fetch("SELECT * FROM [newsletter_sended_msg] ORDER BY [date] DESC LIMIT 1"); $f = new MyForm($this, $name); $f->addText('subject', 'Predmet')->addRule(NForm::FILLED, 'Predmet musí byť vyplnený.'); $f->addTextArea('text', ''); $f->addText('my_email', 'Testovací email'); $f->addSubmit('btn_send_emails', 'Odoslať všetkým')->onClick[] = array($this, 'actionSendEmails'); $f->addSubmit('btn_send_to_me', 'Odoslať testovací email')->onClick[] = array($this, 'actionSendTestingEmail'); if (!$last_newsletter) { $email_template = new NFileTemplate(); $email_template->registerFilter(new NLatteFilter()); $email_template->setFile(WWW_DIR . '/newsletter/templates/1/1.phtml'); $email_template->text = ''; $values['text'] = (string) $email_template; } else { $values = $last_newsletter; } $f->setDefaults($values); return $f; break; case 'addForm': $f = new MyForm(); $f->addText('emails', 'Email'); $f->addSubmit('btn', 'Pridať'); $f->onSuccess[] = array($this, 'handleAddEmail'); return $f; break; default: return parent::createComponent($name); break; } }