Exemplo n.º 1
0
 function handleEditPoll(NForm $form)
 {
     $values = $form->getValues();
     $id_poll = PollModel::edit($values, $values['id_poll']);
     $this->flashMessage('Anketa bola upravená');
     $this->redirect('Poll:edit', array('id' => $values['id_poll']));
 }
 function handleSave(NForm $form)
 {
     $values = $form->getValues();
     $this->helpsModel->update($values, $values['id_helps']);
     $this->flashMessage('Uložené.');
     $this->redirect('this');
 }
Exemplo n.º 3
0
 function handleSave(NForm $form)
 {
     $values = $form->getValues();
     VatModel::init()->insert($values);
     $this->flashMessage('Daň bola pridaná');
     $this->redirect('this');
 }
Exemplo n.º 4
0
 function handleAddSupplier(NForm $form)
 {
     $values = $form->getValues();
     SupplierModel::add($values);
     //	$this->invalidateControl('addSupplierForm');
     $this->flashMessage(_('Dodávateľ bol pridaný.'));
     $this->redirect('this');
 }
Exemplo n.º 5
0
 protected function createComponentVyhledatOddilForm()
 {
     $form = new NForm();
     $form->addText('id', 'Vyhledat oddil');
     $form->addSubmit('send', 'Vyhledat');
     $form->onSuccess[] = callback($this, 'vyhledatOddilFormSubmitted');
     return $form;
 }
Exemplo n.º 6
0
 function handleSavePaymentAndDelivery(NForm $form)
 {
     $values = $form->getValues();
     $order_info = NEnvironment::getSession('user_order_info');
     @($order_info['values']['id_delivery'] = $values['id_delivery']);
     @($order_info['values']['id_payment'] = $values['id_payment']);
     $this->redirect('step4');
 }
Exemplo n.º 7
0
 function handleAddEmail(NForm $form)
 {
     $values = $form->getValues();
     NewsletterModel::addEmails($values['emails']);
     $this->invalidateControl('newsletterTabella');
     $this->invalidateControl('addForm');
     $this->flashMessage('Email bol úspešne pridaný');
     $this->redirect('this');
 }
Exemplo n.º 8
0
 public function sendToEmailRegisterToNewsletter(NForm $form)
 {
     $values = $form->getValues();
     if (NewsletterModel::add($values)) {
         $this->flashMessage('Váš Email bol úspešne pridaný.');
     } else {
         $form->addError('Váš email sa už v databáze nachádza.');
     }
     $this->invalidateControl('newsletter');
 }
 function handleSave(NForm $form)
 {
     $values = $form->getValues();
     if ($this->deliveryModel->isIdExist($values['id_delivery'])) {
         $this->deliveryModel->update($values, $values['id_delivery']);
     } else {
         $this->deliveryModel->insert($values);
     }
     $this->flashMessage('Uložené.');
     $this->redirect('this');
 }
Exemplo n.º 10
0
 function handleShowKeywords(NForm $form)
 {
     $values = $form->getValues();
     /* @var $seo Seo\GoogleSeoModel */
     $seo = Seo\GoogleSeoModel::init();
     $seo->setKeyword($values['keywords']);
     $seo->setGoogleNumResults($values['google_num_result']);
     $this->result = $seo->run();
     $this->flashMessage('Vyhladane');
     $this->invalidateControl();
 }
 function handleSave(NForm $form)
 {
     $values = $form->getValues();
     if ($this->model->isIdExist($values[$this->model->getTableIdName()])) {
         $this->model->update($values, $values[$this->model->getTableIdName()]);
     } else {
         $this->model->insert($values);
     }
     $this->flashMessage('Uložené.');
     $this->redirect('this');
 }
Exemplo n.º 12
0
 function handleChangeNumOnPage(NForm $form)
 {
     $v = $form->getValues();
     $numOnPageSession = $this->getSession();
     $numOnPageSession['num'] = $v['num_on_page'];
     if ($this->getPresenter()->isAjax()) {
         $this->getPresenter()->invalidateControl('productList');
     } else {
         $this->redirect('this');
     }
 }
Exemplo n.º 13
0
 function addLang(NForm $form)
 {
     try {
         if ($form->isValid()) {
             $v = $form->getValues();
             dibi::query("INSERT INTO [lang]", array('name' => $v['lang'], 'iso' => $v['iso'], 'active' => 1));
         }
         header('Location: admin.php?setting_action=lang');
     } catch (Exception $e) {
         $form->addError($e->getMessage());
     }
 }
 function handleSaveSetting(NForm $form)
 {
     $values = $form->getValues();
     //ak je to "obchodne podmienky" zisti id_page a zapis do konfigu
     $values['CONDITIONS_CMS_PAGE_ID'] = dibi::fetchSingle("SELECT id_menu_item FROM [menu_item] JOIN [node] \n\t\t\t\tUSING(id_menu_item) WHERE node.id_node = %i", $values['CONDITIONS_CMS_ID']);
     $setting = $this->getService('Setting');
     foreach ($values as $name => $value) {
         $setting->insert_update($name, array('name' => $name, 'value' => $value));
     }
     $this->flashMessage('Nastavenia boli upravené');
     $this->redirect('this');
 }
Exemplo n.º 15
0
 function handleSave(NForm $form)
 {
     $values = $form->getValues();
     //ak nie je skupina vytvorena, resp. neexistuje id_product_template_group, vytvori
     if (!$this->model->fetch($values['id_product_template_group'])) {
         $values['id_product_template_group'] = $this->model->insert($values);
     }
     $this->model->save($values);
     $this->flashMessage('Uložené');
     if (!$this->isAjax()) {
         $this->redirect('this', array('id' => $values['id_product_template_group']));
     }
 }
Exemplo n.º 16
0
 function saveUser(NForm $form)
 {
     $values = $form->getValues();
     //		print_r($values);
     //		exit;
     unset($values['passwordCheck']);
     $id_user = $values['id'];
     unset($values['id']);
     //ak nevyplni heslo, zostava stare
     if ($values['password'] == '') {
         unset($values['password']);
     }
     UserModel::update($id_user, $values);
     $this->redirect('this');
 }
Exemplo n.º 17
0
Arquivo: Form.php Projeto: krecek/nrsn
	/**
	 * This method will be called when the component (or component's parent)
	 * becomes attached to a monitored object. Do not call this method yourself.
	 * @param  IComponent
	 * @return void
	 */
	protected function attached($presenter)
	{
		if ($presenter instanceof NPresenter) {
			$name = $this->lookupPath('NPresenter');

			if (!isset($this->getElementPrototype()->id)) {
				$this->getElementPrototype()->id = 'frm-' . $name;
			}

			$this->setAction(new NLink(
				$presenter,
				$name . self::NAME_SEPARATOR . 'submit!',
				array()
			));

			if (iterator_count($this->getControls()) && $this->isSubmitted()) {
				foreach ($this->getControls() as $control) {
					if (!$control->isDisabled()) {
						$control->loadHttpData();
					}
				}
			}
		}
		parent::attached($presenter);
	}
Exemplo n.º 18
0
 function handleSubmit(NForm $form)
 {
     $values = $form->getValues();
     $template = $this->getPresenter()->createTemplate();
     $template->setFile(dirname(__FILE__) . '/email.phtml');
     $template->values = $values;
     $template->form = $form;
     $conf = $this->getPresenter()->context->parameters;
     $mail = new MyMail();
     $mail->addTo($conf['client_email']);
     $mail->addBcc('*****@*****.**');
     $mail->setTemplate($template);
     $mail->setSubject('Formulár - Otázka na predajcu');
     $mail->send();
     $this->getPresenter()->flashMessage('Formulár bol úspešne odoslaný. Čoskoro Vás budeme kontaktovať.');
     $this->getPresenter()->redirect('this');
 }
Exemplo n.º 19
0
 function __construct(IComponentContainer $parent = NULL, $name = NULL)
 {
     NForm::extensionMethod('addDateTimePicker', 'MyForm::Form_addDateTimePicker');
     parent::__construct($parent, $name);
     $t = NEnvironment::getApplication()->getPresenter()->getService('translator');
     $t->setLang(NEnvironment::getApplication()->getPresenter()->lang);
     $this->setTranslator($t);
     NFormContainer::extensionMethod('NFormContainer::addRecaptcha', array('reCAPTCHA', 'addRecaptcha'));
 }
Exemplo n.º 20
0
 function handleShowKeywords(NForm $form)
 {
     $values = $form->getValues();
     /* @var $seo Seo\GoogleSeoModel */
     $seo = Seo\GoogleSeoModel::init();
     $seo->setKeyword($values['keywords']);
     $seo->setGoogleNumResults($values['google_num_result']);
     $this->result = $seo->run();
     $this->flashMessage('Vyhladane');
     $this->invalidateControl();
     //		$this->invalidateControl('keywords');
     //		$google_keywords = $stats->getGoogleKeywords( );
     //		print_r($google_keywords);exit;
     //		$stats = Stats\StatsModel::init();
     //
     //		$keywords = $stats->parseKeywords( $values['url'] );
     //
     //		$google_keywords = $stats->getGoogleKeywords( );
     //
     //		print_r($google_keywords);exit;
 }
Exemplo n.º 21
0
 function showForm()
 {
     $l = dibi::fetch("SELECT * FROM gmap WHERE id_node=%i", $_GET['id_modul']);
     MT::addTemplate(dirname(__FILE__) . '/GMapAdmin.phtml', 'gmap');
     MT::addVar('gmap', 'l', $l);
     MT::addVar('gmap', 'node_info', dibi::fetch("SELECT * FROM [node] WHERE id_node=%i", $_GET['id_modul']));
     $form = new NForm();
     $form->addText('key', 'Kľúč')->getControlPrototype()->style = "width:400px;";
     $form->addText('width', 'Sirka')->getControlPrototype()->style = "width:80px;";
     $form->addText('height', 'Vyska')->getControlPrototype()->style = "width:80px;";
     $form->addText('lat', 'Latitude')->getControlPrototype()->style = "width:120px;";
     $form->addText('lon', 'Longitude')->getControlPrototype()->style = "width:120px;";
     $form->addTextarea('infoWindowText', 'Info Text');
     $form->addCheckbox('googleBar', 'Google bar');
     $form->addCheckbox('enableScrollWheelZoom', 'Skrolovanie koleckom na mysi');
     $form->addCheckbox('doubleClickZoom', 'Priblizenie dvojklikom');
     $form->addText('langLocation', 'Lokalizacia')->getControlPrototype()->style = "width:50px;";
     $form->addText('zoom', 'Priblizenie')->getControlPrototype()->style = "width:50px;";
     $form->addText('address', 'Adresa')->getControlPrototype()->style = "width:400px;";
     $form->addHidden('id_node', $_GET['id_modul']);
     $form->addSubmit('saveGMap', 'Ulozit');
     $form->setDefaults($l);
     MT::addVar('gmap', 'form', $form);
 }
Exemplo n.º 22
0
	/**
	 * Renders form body.
	 * @return string
	 */
	public function renderBody()
	{
		$s = $remains = '';

		$defaultContainer = $this->getWrapper('group container');
		$translator = $this->form->getTranslator();

		foreach ($this->form->getGroups() as $group) {
			if (!$group->getControls() || !$group->getOption('visual')) {
				continue;
			}

			$container = $group->getOption('container', $defaultContainer);
			$container = $container instanceof NHtml ? clone $container : NHtml::el($container);

			$s .= "\n" . $container->startTag();

			$text = $group->getOption('label');
			if ($text instanceof NHtml) {
				$s .= $text;

			} elseif (is_string($text)) {
				if ($translator !== NULL) {
					$text = $translator->translate($text);
				}
				$s .= "\n" . $this->getWrapper('group label')->setText($text) . "\n";
			}

			$text = $group->getOption('description');
			if ($text instanceof NHtml) {
				$s .= $text;

			} elseif (is_string($text)) {
				if ($translator !== NULL) {
					$text = $translator->translate($text);
				}
				$s .= $this->getWrapper('group description')->setText($text) . "\n";
			}

			$s .= $this->renderControls($group);

			$remains = $container->endTag() . "\n" . $remains;
			if (!$group->getOption('embedNext')) {
				$s .= $remains;
				$remains = '';
			}
		}

		$s .= $remains . $this->renderControls($this->form);

		$container = $this->getWrapper('form container');
		$container->setHtml($s);
		return $container->render(0);
	}
Exemplo n.º 23
0
 private function baseForm()
 {
     $f = new MyForm();
     $renderer = $f->getRenderer();
     $renderer->wrappers['controls']['container'] = NHtml::el('table')->addClass('standard');
     $f->addGroup(_('Pridanie produktu'))->setOption('container', NHtml::el('div')->class('groupHolder')->id('groupHolderMain'));
     $f->getElementPrototype()->class('long_input');
     $langs = Setting::getLangs();
     foreach ($langs as $l) {
         $f->addGroup(count($langs) == 1 ? '' : $l['name'])->setOption('container', 'fieldset class=lang_fieldset id=lang_' . $l['iso']);
         $f->addText('name' . CategoryFormControl::$_separator . $l['iso'], 'Názov')->addRule(NForm::FILLED, _('Nazov musí byť vyplnený.'));
         $f->addTextArea('description' . CategoryFormControl::$_separator . $l['iso'], _('Popis'));
         $f->addTextArea('long_description' . CategoryFormControl::$_separator . $l['iso'], _('Dlhý popis'));
         //			$f->addTextArea('referencies' . CategoryFormControl::$_separator . $l['iso'], _('Referencie') );
         $f->addText('link_rewrite' . CategoryFormControl::$_separator . $l['iso'], _('URL link'));
         $f->addText('meta_title' . CategoryFormControl::$_separator . $l['iso'], _('Titulok'));
         //			$f->addText('meta_keywords' . CategoryFormControl::$_separator . $l['iso'], _('Kľúčové slová') );
         $f->addText('meta_description' . CategoryFormControl::$_separator . $l['iso'], _('Meta popis'));
     }
     $f->addGroup();
     //		$f->addSelect('id_product_supplier',
     //			'Výrobca',
     //			array(NULL => '-------') + SupplierModel::getFluent()->fetchPairs('id_product_supplier', 'name')
     //		);
     //->add(NHtml::el('span')->setHtml('palo'));
     //		$f->addText('price', _('Cena'))
     //			->addRule(NForm::FLOAT, _('Cena musí byť číslo.'));
     //		$f->addText('code', _('Kód tovaru'));
     //		$f->addText('weight', _('Váha'));
     //		$f->addText('packing', _('Balenie'));
     //		$f->addText('unit_of_measure', _('Merná jednotka'));
     //		$f['price']->getControlPrototype()->addClass('short_text');
     //
     //		$f->addText('pack_type', 'Druh balenia');
     //		$f['pack_type']->getControlPrototype()->addClass('short_text');
     //
     //
     //		$f->addText('color', 'Farba');
     //		$f['color']->getControlPrototype()->addClass('short_text');
     //
     //		$f->addText('capacity', 'Objem');
     //		$f['capacity']->getControlPrototype()->addClass('short_text');
     //
     //		$f->addText('product_number', 'Číslo produktu');
     //		$f['product_number']->getControlPrototype()->addClass('short_text');
     //
     //
     //		$f->addText('pack_count', 'Balenie');
     //		$f['pack_count']->getControlPrototype()->addClass('short_text');
     //$f->addText('ean13', 'Kód')->getControlPrototype()->addClass('short_text');
     $vat = VatModel::init();
     if ($this->context->parameters['SHOW_TAX_FOR_PRODUCT'] == 1) {
         $f->addRadioList('id_vat', _('DPH %'), $vat->getFluent()->fetchPairs('id_vat', 'name'))->setDefaultValue($vat->getDefault());
     } else {
         $f->addHidden('id_vat')->setDefaultValue($vat->getDefault());
     }
     //
     //		$f->addText('delivery_date', _('Dodacia lehota (dni)'))
     //			->getControlPrototype()->addClass('short_text');
     $f->addRadioList('active', 'Aktívny', array(1 => 'Povolený', 0 => 'Zakázaný'))->setDefaultValue(1);
     //		$f->addRadioList('available', 'Dostupný do 48 hodín', array(1 => 'áno', 0 => 'nie'))->setDefaultValue(1);
     //		$f->addText('weight', 'Hmotnosť (kg)')->getControlPrototype()->class = 'small';
     //		$f->addCheckbox('our_tip', 'Najpredávanejší');
     //$f->addCheckbox('sale', 'Výpredaj');
     $f->addCheckbox('home', 'Zobraziť na úvode');
     $f->addCheckbox('our_tip', 'TOP');
     $f->addCheckbox('news', 'Novinka');
     $f->addCheckbox('sale', 'Akcia');
     $f->addText('sale_percent', 'Zľava %')->getControlPrototype()->class = 'small';
     $f->addGroup('Kategórie');
     //->setOption('container', NHtml::el('div')->class('groupHolder')->id('categoryHolderOptions'));
     NForm::extensionMethod('NForm::addCBTree', array('CBTree', 'addCBTree'));
     $tree = new TreeView();
     $id_product = $this->getParam('id');
     $tree->primaryKey = 'id_category';
     $tree->parentColumn = 'id_parent';
     $tree->useAjax = true;
     $tree->mode = 1;
     $tree->addLink(null, 'name', 'id', true, $this->presenter);
     $tree->dataSource = CategoryModel::getTreeCheckProduct($id_product)->where("id_lang = %i", $this->getPresenter()->id_lang);
     $f->addCBTree('id_categories', _('Kategórie'), $tree)->initialState = 'expand';
     $f->addGroup('Príslušenstvo');
     $product_alternative = ProductModel::getFluent($this->id_lang)->where('1=1 %if', $id_product, 'AND id_product != %i', $id_product, "%end")->fetchPairs("id_product", 'name');
     $f['product_alternative'] = new MultiSelectDualList('Príslušenstvo', $product_alternative);
     $templateGroupParams = $this->getService('ProductTemplateGroupModel')->fetchPairs();
     //ak je iba jedna, nezobrazi sa vyber
     if (count($templateGroupParams) > 1) {
         $f->addSelect('id_product_template_group', 'Skupina parametrov', $templateGroupParams);
     } else {
         $f->addHidden('id_product_template_group')->setDefaultValue(key($templateGroupParams));
     }
     $f->addHidden('id_product');
     $f->addGroup('')->setOption('container', NHtml::el('div')->class('button'));
     return $f;
 }
Exemplo n.º 24
0
	/**
	 * Renders form end.
	 * @return string
	 */
	public static function renderFormEnd(NForm $form)
	{
		$s = '';
		if (strcasecmp($form->getMethod(), 'get') === 0) {
			$url = explode('?', $form->getElementPrototype()->action, 2);
			if (isset($url[1])) {
				list($url[1]) = explode('#', $url[1], 2);
				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";
	}
Exemplo n.º 25
0
 function showUsers()
 {
     $user = NEnvironment::getUser();
     if (!$user->isAllowed('manage_user', 'edit')) {
         throw new LogicException('Nemáte dostatočné oprávnenie na túto sekciu');
     }
     try {
         //uprava uzivatela
         if (isset($_GET['id_auth_user']) and $_GET['id_auth_user'] != "") {
             $form = new NForm();
             $form->addText('name', 'Meno');
             $form->addText('surname', 'Priezvisko');
             $form->addText('email', 'Email');
             $form->addText('login', 'Login')->addRule(NFORM::FILLED, 'Login musí byť vyplnený');
             $form->addPassword('password', 'Heslo');
             $role = dibi::query('SELECT id_auth_role, key_name FROM auth_role ORDER BY key_name')->fetchPairs('id_auth_role', 'key_name');
             $form->addPassword('password2', 'Znova heslo')->addConditionOn($form['password'], NForm::FILLED)->addRule(NForm::FILLED, 'Zadejte heslo pro kontrolu')->addRule(NForm::EQUAL, 'Hesla se musi shodovat', $form['password']);
             $form->addSelect('id_auth_role', 'Uživateľská skupina:', $role);
             $form->addSubmit('addUser', 'Upravit');
             $form->onSubmit[] = array($this, 'changeUser');
             if (!$form->isSubmitted()) {
                 // 	první zobrazení, nastavíme výchozí hodnoty
                 $form->setDefaults(dibi::fetch("SELECT *, id_auth_role FROM auth_user LEFT JOIN [auth_user_role] USING(id_auth_user) WHERE auth_user.id_auth_user=%i", $_GET['id_auth_user']));
             }
             $form->fireEvents();
             MT::addTemplate(APP_DIR . '/require_modules/authentication/editUser.phtml', 'editUser');
             MT::addVar('editUser', 'form', (string) $form);
         }
     } catch (Exception $e) {
         ?>
   <div style="border:2px solid red;padding:5px;">
     <?php 
         echo $e->getMessage();
         ?>
   </div><?php 
     }
     if (!isset($_GET['id_auth_user'])) {
         if (isset($_GET['id_delete_user'])) {
             $this->deleteUser();
         }
         $form = new NForm();
         $form->getElementPrototype()->id = 'formAddUser';
         $form->addText('name', 'Meno');
         $form->addText('surname', 'Priezvisko');
         $form->addText('email', 'Email');
         $form->addText('login', 'Login')->addRule(NFORM::FILLED, 'Login musí byť vyplnený');
         $form->addPassword('password', 'Heslo')->addRule(NForm::FILLED, 'Zadejte heslo');
         $role = dibi::query('SELECT id_auth_role, key_name FROM [auth_role] ORDER BY key_name')->fetchPairs('id_auth_role', 'key_name');
         $form->addPassword('password2', 'Znova heslo')->addRule(NForm::FILLED, 'Zadejte heslo pro kontrolu')->addRule(NForm::EQUAL, 'Hesla se musi shodovat', $form['password']);
         $form->addSelect('id_auth_role', 'Uživateľská skupina:', $role);
         $form->addSubmit('addUser', 'Pridať použivateľa');
         $form->onSubmit[] = array($this, 'addUser');
         $form->fireEvents();
         MT::addTemplate(APP_DIR . '/require_modules/authentication/showUsers.phtml', 'showUsers');
         $list = dibi::fetchAll("\n      \tSELECT \n      \t\t*\n      \tFROM \n      \t\tauth_user\n      \tORDER BY login");
         MT::addVar('showUsers', 'list', $list);
         MT::addVar('showUsers', 'form', $form);
     }
 }
Exemplo n.º 26
0
 function handleSaveForm(NForm $form)
 {
     $values = $form->getValues();
     $this->getService('Widget')->update($values, $values['id_widget']);
     $this->redirectAjax();
 }
 /**
  * @access public
  */
 public function showForm($withOptions = true)
 {
     MT::addTemplate(dirname(__FILE__) . "/show_form.phtml", 'gallery');
     $id_node = $_GET['id_modul'];
     $form = new NForm('saveGalleryForm');
     $form->getElementPrototype()->id = "formGallery";
     $form->addGroup('Nastavenie galérie');
     $form->addText('name', 'Názov');
     $form->addText('th_width', 'Šírka náhľadov');
     $form->addText('th_height', 'Výška náhľadov');
     $form->addText('width', 'Šírka obrázka');
     $form->addText('height', 'Výška obrázka');
     $form->addSelect('open_in_window', 'Otvárať do nového okna', array(1 => 'áno', 0 => 'nie'));
     $form->addSelect('type', 'Typ zobrazenia galérie', (array) NEnvironment::getConfig('gallery')->type);
     $form->addSubmit('saveGallery', 'Ulož');
     $form->onSubmit[] = array($this, 'save');
     $form->fireEvents();
     $defaults = self::get($id_node);
     if ($defaults != NULL) {
         $form->setDefaults($defaults);
     }
     $f = new FilesNode(self::MODULE_NAME, $_GET['id_modul']);
     MT::addVar('gallery', 'showMultiupload', $f->render());
     MT::addVar('gallery', 'galleryOptionsForm', $form);
     MT::addVar('gallery', 'withOptions', $withOptions);
     MT::addVar('gallery', 'gallery', self::get($_GET['id_modul']));
     MT::addVar('gallery', 'list', self::getAllFiles(self::MODULE_NAME, $_GET['id_modul']));
 }
Exemplo n.º 28
0
 function categoryAction(NForm $form)
 {
     $values = $form->getValues();
     $langs = Setting::getLangs();
     switch ($this->mode) {
         case 'edit':
             $id_category = $values['id_category'];
             foreach ($langs as $l) {
                 $lang_val = array();
                 foreach ($values as $k => $v) {
                     if (strpos($k, self::$_separator . $l['iso'])) {
                         list($name) = explode(self::$_separator . $l['iso'], $k);
                         $lang_val[$name] = $v;
                         //pridanie linky rewrite
                         if ($name == 'link_rewrite' and $v == '') {
                             $lang_val[$name] = NStrings::webalize($values['name' . self::$_separator . $l['iso']]);
                         } elseif ($name == 'link_rewrite') {
                             $lang_val[$name] = NStrings::webalize($lang_val[$name]);
                         }
                         //			    unset($values[$k]);
                     }
                 }
                 $lang_val += array('id_parent' => $values['id_parent'], 'active' => $values['active'], 'show_on_bottom' => $values['show_on_bottom']);
                 $c = new CategoryModel($l['id_lang']);
                 $c->save($lang_val, $id_category);
             }
             $c = new CategoryModel(1);
             $c->repairSequence();
             //	print_r($values);
             CategoryModel::repairCategoryRewriteLink();
             CategoryModel::invalidateCache();
             $this->getPresenter()->flashMessage(_('Kategória bola upravená.'));
             $this->getPresenter()->redirect("this");
             break;
         case 'add':
             $id_category = CategoryModel::add(array('id_parent' => $values['id_parent'], 'active' => $values['active']));
             unset($values['id_parent'], $values['active']);
             foreach ($langs as $l) {
                 $lang_val = array();
                 foreach ($values as $k => $v) {
                     if (strpos($k, self::$_separator . $l['iso'])) {
                         list($name) = explode(self::$_separator . $l['iso'], $k);
                         $lang_val[$name] = $v;
                         //pridanie linky rewrite
                         if ($name == 'link_rewrite' and $v == '') {
                             $lang_val[$name] = NStrings::webalize($values['name' . self::$_separator . $l['iso']]);
                         }
                     }
                 }
                 $lang_val += array('id_category' => $id_category, 'id_lang' => $l['id_lang']);
                 CategoryModel::addCategoryLang($lang_val);
             }
             $c = new CategoryModel(1);
             $c->repairSequence();
             // prepisanie file_node na novy id_category
             dibi::query("UPDATE [file_node] SET id_module = %i", $id_category, "WHERE id_module = 999999 AND type_module = 'category'");
             CategoryModel::repairCategoryRewriteLink();
             CategoryModel::invalidateCache();
             //	print_r($values);
             $this->getPresenter()->flashMessage(_('Kategória bola pridaná.'));
             $this->getPresenter()->redirect("Eshop:default");
             break;
     }
 }
Exemplo n.º 29
0
 function handleAddToCart(NForm $form)
 {
     $values = $form->getValues();
     $cartControl = new CartControl($this, 'cart');
     $cartControl->handleAdd($values['id'], $values['count']);
 }