public function init() { $this->_flashMessenger = $this->_helper->getHelper('FlashMessenger'); /*********** To check for publisher session data *********************/ $storage_publisher = new Zend_Auth_Storage_Session('publisher_type'); $publisher_data = $storage_publisher->read(); $storage_company = new Zend_Auth_Storage_Session('company_type'); $company_data = $storage_company->read(); if ($publisher_data && $publisher_data != null) { $this->modelPublisher = new Model_DbTable_Users(); $this->sessPublisherInfo = $this->modelPublisher->getInfoByUserId($publisher_data->id); $this->view->sessPublisherInfo = $this->sessPublisherInfo; } elseif ($company_data && $company_data != null) { $this->modelCompany = new Model_DbTable_Companies(); $this->sessCompanyInfo = $this->modelCompany->getInfoByUserId($company_data->id); $this->view->sessCompanyInfo = $this->sessCompanyInfo; } $this->modelPage = new Model_DbTable_Page(); $this->modelEnquiry = new Admin_Model_DbTable_Enquirys(); /************* To Set The active section and links *******************/ $controller = $this->_getParam('controller'); $action = $this->_getParam('action'); $title = $this->_getParam('title'); $this->view->currentController = $controller; $this->view->currentAction = $action; $this->view->currentTitle = $title; $this->view->class_active = 'class="active"'; /************* To Set The active section and links *******************/ if ($title == 'contact-us') { $captcha = new Zend_Captcha_Image(); $captcha->setImgDir('public/css/captcha/images/'); $captcha->setImgUrl($this->view->serverUrl . $this->view->baseUrl() . '/public/css/captcha/images/'); $captcha->setFont('public/css/captcha/fonts/times_new_yorker.ttf'); $captcha->setWordlen(5); $captcha->setFontSize(28); $captcha->setLineNoiseLevel(3); $captcha->setWidth(161); $captcha->setHeight(75); $captcha->generate(); /*$captcha= new Zend_Form_Element_Captcha('captcha', array( 'label' => "Please verify you're a human", 'captcha' => array( 'captcha' => 'image', 'font'=>'public/css/captcha/fonts/times_new_yorker.ttf', 'imgDir'=>'public/css/captcha/images/', 'imgUrl'=>$this->view->serverUrl.$this->view->baseUrl().'/public/css/captcha/images/', 'wordLen' => 4, 'fsize'=>20, 'height'=>60, 'width'=>250, 'gcFreq'=>50, 'expiration' => 300 ) )); */ $this->view->captcha = $captcha; } }
public function init() { $Ankieta = new Application_Model_DbTable_AnkietyPytania(); $select = $Ankieta->select(array('id', 'pytanie', 'czy_obrazek'))->where('czy_wyswietlac = ?', 't')->where('sekcja = ?', 'lewa')->where('rodzaj = ?', 'normal')->order('kolejnosc DESC')->order('data_dodania DESC')->order('pytanie ASC')->limit(1); //echo $select->__toString(); $ankieda = $Ankieta->fetchAll($select); foreach ($ankieda as $pytanie) { $pytania_id[] = $pytanie->id; $pytania[] = $pytanie->pytanie; $odpowiedziFetch = $pytanie->findApplication_Model_DbTable_AnkietyOdpowiedzi(); // sortowanie $odpowiedziArray = $odpowiedziFetch->toArray(); usort($odpowiedziArray, create_function('$a, $b', 'if ($a["kolejnosc"] == $b["kolejnosc"]) return 0; return ($a["kolejnosc"] < $b["kolejnosc"]) ? -1 : 1;')); // usort($odpowiedziArray, sort_answers($a, $b){ // return strcmp($a["kolejnosc"], $b["kolejnosc"]); // });// sort foreach ($odpowiedziArray as $odpowiedz) { $odpowiedzi_id[] = $odpowiedz['id']; $odpowiedzi[] = $odpowiedz['odpowiedz']; } } $this->addElement('hidden', 'plaintext', array('description' => '<dt id="odpowiedzi-label"><h3 class="tytul">' . $pytania[0] . '</h3></dt>', 'decorators' => array(array('Description', array('escape' => false, 'tag' => ''))))); $kontrolkaRadio = new Zend_Form_Element_Radio("odpowiedzi[]", array('multiOptions' => array_combine($odpowiedzi_id, $odpowiedzi), 'registerInArrayValidator' => false, 'validators' => array('NotEmpty' => array('validator' => 'NotEmpty', 'options' => array('messages' => 'Musisz wybrać jedną odpowiedź.'))))); $kontrolkaRadio->setRequired(true); $kontrolkaRadio->removeDecorator('Label'); $kontrolkaRadio->setSeparator(false); $this->addElement($kontrolkaRadio); if ($ankieda[0]->czy_obrazek == 't') { //first create an image type captcha $captchaimg = new Zend_Captcha_Image('captchaimg'); $captchaimg->setFont(APPLICATION_PATH . '/../public/images/tresci/captcha/Tahoma.ttf'); $captchaimg->setImgDir(APPLICATION_PATH . '/../public/images/tresci/captcha'); $captchaimg->setImgUrl('/images/tresci/captcha'); $captchaimg->setWordlen('5'); $captchaimg->setMessages(array('badCaptcha' => 'Wpisany kod jest nieprawidłowy')); // $captchaimg->generate(); //create user input for captcha and include the captchaimg in form $adcaptcha = new Zend_Form_Element_Captcha('adcaptcha', array('captcha' => $captchaimg)); $adcaptcha->setLabel('Wpisz kod z obrazka:'); $adcaptcha->setRequired(true); $this->addElement($adcaptcha); } $kontrolkaSubmit = new Zend_Form_Element_Submit("submit", "Głosuj"); // $kontrolkaSubmit->removeDecorator('DtDdWrapper'); // $kontrolkaSubmit->setAttribs(array('style' => 'margin-left:130px;')); $kontrolkaSubmit->removeDecorator('Label'); $this->addElement($kontrolkaSubmit); $this->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'sonda-content')), array('Form', array('class' => 'sonda-form')))); //echo $pytania_id[0]; $this->setMethod('post'); //$url = $view->url(array('controller' => 'sonda', 'action' => 'edit', 'id' => $pytania_id[0]), 'default'); $url = $this->getView()->url(array('controller' => 'sonda', 'action' => 'edit', 'id' => $pytania_id[0]), 'default'); $this->setAction($url); }
public function init() { $subForm = new Zend_Form_SubForm(); $subForm->setLegend('adsFields'); $validateNonZeroValue = new Zend_Validate_GreaterThan(0); $validateDate = new Zend_Validate_Date('Y-m-d'); $elementUserId = new Zend_Form_Element_Hidden('user_id'); $elementLanguageId = new Zend_Form_Element_Hidden('language_id'); $elementActive = new Zend_Form_Element_Hidden('active'); $elementActive->setValue(1); $elementAdsCategoryId = new Zend_Form_Element_Select('ads_category_id'); $elementAdsCategoryId->setLabel('adsCategoryId'); $elementAdsCategoryId->setMultiOptions(Ads_Categories::getSelectOptions()); $elementAdsCategoryId->addValidator($validateNonZeroValue); $elementAdsCategoryId->setRequired(true); $elementAdsTypeId = new Zend_Form_Element_Select('ads_type_id'); $elementAdsTypeId->setLabel('adsTypeId'); $elementAdsTypeId->setMultiOptions(Ads_Types::getSelectOptions()); $elementAdsTypeId->addValidator($validateNonZeroValue); $elementAdsTypeId->setRequired(true); $elementValidBefore = new Standart_Form_Element_Date('valid_until'); $elementValidBefore->setLabel('adsValidUntil'); $elementValidBefore->addValidator($validateDate); $elementValidBefore->setRequired(true); $elementTitle = new Zend_Form_Element_Text('title'); $elementTitle->setLabel('adsTitle'); $elementTitle->setAttrib('size', 75); $elementTitle->setRequired(true); $elementDescription = new Zend_Form_Element_Textarea('description'); $elementDescription->setLabel('adsDescription'); $elementDescription->setRequired(true); $captchaImage = new Zend_Captcha_Image(); $captchaImage->setFont(Standart_Main::getDirs('fonts', 'arial.ttf')); $captchaImage->setFontSize(30); $captchaImage->setWordlen(6); $captchaImage->setImgDir(Standart_Main::getDirs('wwwStatic', array('images', 'captcha'))); $captchaImage->setImgUrl(Zend_Registry::get('config')->host->static . '/images/captcha/'); $captchaImage->setWidth(175); $captchaImage->setHeight(75); $captchaImage->setName('captcha'); $elementCaptcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => $captchaImage)); $elementDoSave = new Zend_Form_Element_Submit('doSave'); $subForm->addElements(array($elementUserId, $elementLanguageId, $elementActive, $elementAdsCategoryId, $elementAdsTypeId, $elementValidBefore, $elementTitle, $elementDescription, $elementCaptcha)); $this->addSubForm($subForm, 'ads'); $this->addElement($elementDoSave); }
/** * * @return \Zend_Captcha_Image */ private function getImageCaptcha() { self::initSessionConfig(); $appPath = APP_PATH; $captcha = new \Zend_Captcha_Image(); $captcha->setSession($this->getSession()); $captcha->setKeepSession(true); $captcha->setFont($appPath . '/data/fonts/consola.ttf'); $captcha->setImgDir(dirname($appPath) . '/public/_captcha'); $captcha->setImgUrl('/_captcha'); $captcha->setExpiration(600); $captcha->setWordlen(5); $captcha->setUseNumbers(false); return $captcha; }