コード例 #1
0
 function createComponentForm($name)
 {
     $f = new MyForm();
     $f->addText('key', 'Názov')->addRule(NForm::FILLED, 'Názov musí byť vyplnený');
     $f->addTextArea('text', 'Popis')->getControlPrototype()->class = 'long';
     $f->addHidden('id_helps');
     $f->addSubmit('btn', 'Uložiť')->getControlPrototype()->class = 'submit';
     $f->onSuccess[] = array($this, 'handleSave');
     return $f;
 }
コード例 #2
0
 function createComponentForm($name)
 {
     $f = new MyForm();
     $f->addText('name', 'Názov')->addRule(NForm::FILLED, 'Názov musí byť vyplnený');
     $f->addText('price', 'Cena')->addRule(NForm::FILLED, 'Cena musí byť vyplená')->addRule(NForm::FLOAT, 'Cena musí byť číslo');
     $f->addTextArea('description', 'Popis')->getControlPrototype()->class = 'long';
     $f->addHidden($this->model->getTableIdName());
     $f->addSubmit('btn', 'Uložiť')->getControlPrototype()->class = 'submit';
     $f->onSuccess[] = array($this, 'handleSave');
     return $f;
 }
コード例 #3
0
ファイル: ContactForm.php プロジェクト: oaki/demoshop
 function createComponentForm($name)
 {
     $form = new MyForm($this, $name);
     $form->addText('name', 'Meno:')->addRule(NForm::FILLED, 'Meno a priezvisko musia byť vyplnené.');
     $form->addText('surname', 'Priezvisko:')->addRule(NForm::FILLED, 'Meno a priezvisko musia byť vyplnené.');
     $form->addText('company', 'Firma:');
     $form->addText('email', 'Email:');
     $form->addText('tel', 'Telefón:');
     $form->addTextarea('text', 'Textová správa:')->addRule(NForm::FILLED, 'Správa musí byť vyplnená.');
     $form->addSubmit('btn_form', 'Odoslať správu');
     $form->addHidden('id_node');
     $form->onSuccess[] = callback($this, 'handleSend');
     return $form;
 }
コード例 #4
0
 protected function createComponentAddToCartForm()
 {
     $presenter = $this;
     return new NMultiplier(function ($id) use($presenter) {
         /* @var $f NForm */
         $f = new MyForm();
         $f->getElementPrototype()->class = 'ajax';
         $f->addText('count', 'Počet')->addRule(NForm::FILLED, 'Počet musí byť vyplnený.')->addRule(NForm::INTEGER, 'Musíte zadať číslo.');
         $f->addSubmit('btn', 'DO KOŠÍKA');
         $f->addHidden('id', $id);
         $f->onSuccess[] = array($presenter, 'handleAddToCart');
         $f->setDefaults(array('count' => 1));
         return $f;
     });
 }
コード例 #5
0
 function createComponentForm($name)
 {
     $f = new MyForm();
     $f->addHidden('id_product_template_group');
     $f->addGroup('Nastavenie skupiny');
     $f->addText('group_name', 'Názov skupiny')->addRule(NForm::FILLED, 'Názov skupiny musí byť vyplnený');
     $f->addCheckbox('default', 'Predvolená skupina?');
     $f->addCheckbox('allow_change_price', 'Možnosť meniť cenu pre jednotlivé parametre?');
     $f->addGroup('Parametre');
     $rows = $this->model->getProductParamRows();
     foreach ($rows as $k => $r) {
         $f->addCheckbox($r, $r);
     }
     $f->addGroup('');
     $f->addSubmit('btn', 'Uložiť');
     $f->onSuccess[] = array($this, 'handleSave');
     return $f;
 }
コード例 #6
0
 function createComponentWidgetForm($name)
 {
     $f = new MyForm();
     $f->addText('identifier', 'Identifikátor')->addRule(NForm::FILLED, 'Identifikátor musí byť vyplnený');
     $f->addText('name', 'Názov');
     $f->addTextarea('template', 'Šablóna')->getControlPrototype()->class = 'long';
     $f->addHidden('id_widget');
     $f->addContainer('params');
     $f->addSubmit('save', 'Uložiť');
     $f->addSubmit('addNewParam', 'Pridať parameter')->onClick[] = callback($this, 'handleAddNewParam');
     $f->onSuccess[] = array($this, 'handleSaveForm');
     $values = (array) $this->getService('Widget')->get($this->getParam('id'));
     foreach ($values['params'] as $k => $p) {
         $container = $f['params']->addContainer($k);
         $container->addText('name', 'Názov');
         $container->addText('value', 'Hodnota');
         //->setDefaultValue(array($p['value']));
         $container->setDefaults((array) $p);
     }
     //		unset($values['params']);
     return $f;
 }
コード例 #7
0
 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;
     }
 }
コード例 #8
0
ファイル: ProductControl.php プロジェクト: oaki/demoshop
 protected function createComponent($name)
 {
     switch ($name) {
         case 'EshopProduct':
             $p = new EshopProductControl();
             $p->invalidateControl();
             return $p;
             break;
         case 'referenceForm':
             $params = NEnvironment::getApplication()->getPresenter()->getParam();
             $form = new MyForm();
             $form->addText('name', 'Meno:');
             $form->addProtection();
             $form->addText('email', 'Email:');
             $form->addTextarea('text', 'Text:');
             if (class_exists('reCAPTCHA')) {
                 $form->addRecaptcha('recaptcha_input', 'Overenie:')->addRule('reCAPTCHA::validate', 'Prosím prepíšte správne text z obrázku.');
             }
             $form->addSubmit('submit', 'Odoslať');
             $form->onSuccess[] = array($this, 'handleSendReference');
             $form->addHidden('id_product');
             $form->setDefaults(array('id_product' => ProductModel::getIdProductByUrl($params['url_identifier'], 1)));
             return $form;
             break;
         default:
             return parent::createComponent($name);
             break;
     }
 }