コード例 #1
0
 protected function startup()
 {
     parent::startup();
     $captcha = new CaptchaBase();
     $captcha->setExtension(new SeznamCaptcha());
     //$captcha->setExtension(new reCaptcha());
     NFormContainer::extensionMethod('addCaptcha', [$captcha, 'captcha']);
 }
コード例 #2
0
ファイル: MyForm.php プロジェクト: oaki/demoshop
 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'));
 }
コード例 #3
0
ファイル: nette.php プロジェクト: kacer/FakturoidPairing
 function getValues()
 {
     $values = parent::getValues();
     unset($values[self::TRACKER_ID], $values[self::PROTECTOR_ID]);
     return $values;
 }
コード例 #4
0
ファイル: reCAPTCHA.php プロジェクト: oaki/demoshop
        $control->add($this->getRecaptchaHTML($error));
        $control->add($this->getError($error));
        return $control;
    }
    protected function getRecaptchaHTML(&$error)
    {
        return recaptcha_get_html(self::$publicKey, $error);
    }
    protected function getError(&$error)
    {
        $status = clone $this->status;
        $status->class('error');
        $status->setText($error);
        return $status;
    }
    public function getInput()
    {
        $control = parent::getControl();
        $control->value = $this->value === '' ? $this->emptyValue : $this->tmpValue;
        return $control;
    }
    public static function validate(IFormControl $control)
    {
        $response = recaptcha_check_answer(self::$privateKey, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
        return $response->is_valid;
    }
}
reCAPTCHA::$libPath = dirname(__FILE__) . '/reCaptchaLib.php';
/** add Nette\FormContainer method */
NFormContainer::extensionMethod('NFormContainer::addRecaptcha', array('reCAPTCHA', 'addRecaptcha'));
コード例 #5
0
ファイル: Form.php プロジェクト: krecek/nrsn
	/**
	 * Returns the values submitted by the form.
	 * @return NArrayHash|array
	 */
	public function getValues($asArray = FALSE)
	{
		$values = parent::getValues($asArray);
		unset($values[self::TRACKER_ID], $values[self::PROTECTOR_ID]);
		return $values;
	}
コード例 #6
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;
     }
 }