/**
     * Returns the HTML for creating a form powered by JavaScript (or straight one).
     * The CSS, JS and other is included.
     *
     * @param Zend_Form $form The form object
     * @param Boolean $jsStayOnPage Should we post as a service and stay on the same page
     * @param String $srvurl The URL to post the data to or NONE will build the URL automatically
     */
    public function FormAdminGeneric(Zend_Form $form, $jsStayOnPage = true, $srvurl = '')
    {
        $formname = $form->getName();
        if ($srvurl == '') {
            $srvurl = '/' . $this->view->moduleName . '/services/edit' . $formname . '/format/json';
        }
        $form->setAction($srvurl);
        $html = '';
        if ($jsStayOnPage) {
            $html .= '
		<script>
		$(function(){
			$(\'#' . $formname . '\').formvalidator({\'url\':\'' . $srvurl . '\'});
		});
		</script>
		';
        }
        $html .= '
		<div class="box">
			<fieldset>
				' . $form . '
			</fieldset>
		</div>
		';
        return $html;
    }
 /** Create assetstore form */
 public function createAssetstoreForm()
 {
     $form = new Zend_Form();
     $action = $this->webroot . '/assetstore/add';
     $form->setAction($action);
     $form->setName('assetstoreForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'assetstoreForm');
     // Name of the assetstore
     $inputDirectory = new Zend_Form_Element_Text('name', array('label' => $this->t('Give a name'), 'id' => 'assetstorename'));
     $inputDirectory->setRequired(true);
     $form->addElement($inputDirectory);
     // Input directory
     $basedirectory = new Zend_Form_Element_Text('basedirectory', array('label' => $this->t('Pick a base directory'), 'id' => 'assetstoreinputdirectory'));
     $basedirectory->setRequired(true);
     $form->addElement($basedirectory);
     // Assetstore type
     $assetstoretypes = array('0' => $this->t('Managed by MIDAS'), '1' => $this->t('Remotely linked'));
     // Amazon support is not yet implemented, don't present it as an option
     //                          '2' => $this->t('Amazon S3'));
     $assetstoretype = new Zend_Form_Element_Select('assetstoretype', array('id' => 'assetstoretype'));
     $assetstoretype->setLabel('Select a type')->setMultiOptions($assetstoretypes);
     // Add a loading image
     $assetstoretype->setDescription('<div class="assetstoreLoading" style="display:none"><img src="' . $this->webroot . '/core/public/images/icons/loading.gif"/></div>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $form->addElement($assetstoretype);
     // Submit
     $addassetstore = new Zend_Form_Element_Submit('addassetstore', $this->t('Add this assetstore'));
     $form->addElement($addassetstore);
     return $form;
 }
 public function editAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $userForm = new Zend_Form($configForm->user);
     $userId = $this->getRequest()->getParam('id', null);
     if ($this->getRequest()->isPost()) {
         if ($userForm->isValid($_POST)) {
             try {
                 $values = $userForm->getValues();
                 unset($values['password_repeat']);
                 $userId = $this->userRepository->saveEntity($values);
                 $this->_helper->systemMessages('notice', 'Nutzer erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Nutzer konnte nicht gespeichert werden');
             }
         }
     } else {
         try {
             $entity = $this->userRepository->fetchEntity($userId);
             $userForm->populate($entity->toArray());
         } catch (\Exception $e) {
             throw new \Exception($e->getMessage(), 404);
         }
     }
     $userForm->setAction('/admin/user/edit/' . $userId);
     $this->view->form = $userForm;
 }
Exemple #4
0
 function form()
 {
     if (!isset($this->form)) {
         $form = new Zend_Form();
         $form->setAction($this->url());
         $form->setMethod('post');
         // Create and configure username element:
         $username = $form->createElement('text', 'username');
         $username->setLabel("Username");
         $username->addValidator('alnum');
         $username->addValidator('regex', false, array('/^[a-z]+/'));
         $username->addValidator('stringLength', false, array(6, 20));
         $username->setRequired(true);
         $username->addFilter('StringToLower');
         // Create and configure password element:
         $password = $form->createElement('password', 'password');
         $password->setLabel("Password");
         $password->addValidator('StringLength', false, array(6));
         $password->setRequired(true);
         // Add elements to form:
         $form->addElement($username);
         $form->addElement($password);
         // use addElement() as a factory to create 'Login' button:
         $form->addElement('submit', 'login', array('label' => 'Login'));
         // Since we're using this outside ZF, we need to supply a default view:
         $form->setView(new Zend_View());
         $this->form = $form;
     }
     return $this->form;
 }
 public function removeAction()
 {
     $form = new Zend_Form();
     $form->setView(new Zend_View());
     $form->setMethod('post');
     $form->setAction('');
     $form->setAttrib('class', 'devel');
     $form->setAttrib('title', 'Remove wizard - ' . $this->getRequest()->getParam('name'));
     $handleOptions = explode(',', $this->getRequest()->getParam('handles'));
     $referenceOptions = explode(',', $this->getRequest()->getParam('references'));
     $handleOptionsUsed = explode(',', $this->getRequest()->getParam('handles_used'));
     $handleOptionsHidden = $form->createElement('hidden', 'handles', array('decorators' => array('ViewHelper')));
     $referenceOptionsHidden = $form->createElement('hidden', 'references', array('decorators' => array('ViewHelper')));
     $handleOptionsUsedHidden = $form->createElement('hidden', 'handles_used', array('decorators' => array('ViewHelper')));
     $handle = $form->createElement('radio', 'handle', array('label' => 'Handle', 'required' => true, 'multiOptions' => array_combine($handleOptions, $handleOptions), 'description' => 'NOTE: This are the handles that this block appears in: ' . $this->getRequest()->getParam('handles_used')));
     $reference = $form->createElement('radio', 'reference', array('label' => 'Reference', 'required' => true, 'multiOptions' => array_combine($referenceOptions, $referenceOptions)));
     $name = $form->createElement('text', 'name', array('label' => 'Name', 'required' => true));
     $submit = $form->createElement('submit', 'submit', array('label' => 'Submit'));
     $form->addElements(array($handleOptionsHidden, $referenceOptionsHidden, $handleOptionsUsedHidden, $handle, $reference, $name, $submit));
     if ($form->isValid($this->getRequest()->getParams())) {
         $localXmlWriter = Mage::getModel('devel/writer_localxml');
         $localXmlWriter->addRemove($form->handle->getValue(), $form->reference->getValue(), $form->name->getValue());
         $localXmlWriter->save();
         die('DONE. You need to reload to see changes!');
     } else {
         $this->loadLayout();
         $this->getLayout()->getUpdate()->load('devel_layout_wizard');
         $this->getLayout()->generateXml();
         $this->loadLayout();
         $this->getLayout()->getBlock('devel_wizard_form')->setForm($form);
         $this->renderLayout();
     }
 }
 public function loginAction()
 {
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $loginForm = new \Zend_Form($configForm->login);
     if ($this->getRequest()->isPost()) {
         if ($loginForm->isValid($_POST)) {
             try {
                 $auth = $this->getInvokeArg('bootstrap')->auth;
                 $auth->setIdentity($loginForm->getValue('login'))->setCredential($loginForm->getValue('password'));
                 $result = \Zend_Auth::getInstance()->authenticate($auth);
                 if ($result->isValid()) {
                     $this->_redirect('/admin');
                 } else {
                     $this->_helper->systemMessages('error', 'Anmeldung verweigert');
                 }
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 $this->_helper->systemMessages('error', 'Fehler bei der Anmeldung');
             }
         }
     }
     $loginForm->setAction('/login');
     $this->view->form = $loginForm;
 }
 public function detailAction()
 {
     $newsUrl = $this->getRequest()->getParam('url', null);
     try {
         $news = $this->newsRepository->fetchEntityByUrl($newsUrl);
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage(), 404);
     }
     $this->view->headTitle($news->headline);
     $this->view->headMeta()->setName('description', $this->_helper->truncate($news->content, 255));
     $configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
     $commentForm = new \Zend_Form($configForm->comment);
     if ($this->getRequest()->isPost()) {
         if ($commentForm->isValid($_POST)) {
             try {
                 $values = $commentForm->getValues();
                 unset($values['csrf']);
                 unset($values['firstname']);
                 # SpamDetection
                 $values['news'] = $news;
                 $this->commentRepository->saveEntity($values);
                 $commentForm->reset();
                 #$this->_helper->systemMessages('notice', 'Kommentar erfolgreich gespeichert');
             } catch (\Exception $e) {
                 $log = $this->getInvokeArg('bootstrap')->log;
                 $log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
                 #$this->_helper->systemMessages('error', 'Kommentar konnte nicht gespeichert werden');
             }
         }
     }
     $commentForm->setAction('/news/' . $newsUrl);
     $this->view->form = $commentForm;
     $this->view->news = $news;
 }
 /**
  * This returns the form for the collections.
  *
  * @return Zend_Form
  * @author Eric Rochester <*****@*****.**>
  **/
 protected function _collectionsForm()
 {
     $ctable = $this->_helper->db->getTable('Collection');
     $private = (int) get_option('solr_search_display_private_items');
     if ($private) {
         $collections = $ctable->findAll();
     } else {
         $collections = $ctable->findBy(array('public' => 1));
     }
     $form = new Zend_Form();
     $form->setAction(url('solr-search/collections'))->setMethod('post');
     $collbox = new Zend_Form_Element_MultiCheckbox('solrexclude');
     $form->addElement($collbox);
     foreach ($collections as $c) {
         $title = metadata($c, array('Dublin Core', 'Title'));
         $collbox->addMultiOption("{$c->id}", $title);
     }
     $etable = $this->_helper->db->getTable('SolrSearchExclude');
     $excludes = array();
     foreach ($etable->findAll() as $exclude) {
         $excludes[] = "{$exclude->collection_id}";
     }
     $collbox->setValue($excludes);
     $form->addElement('submit', 'Exclude');
     return $form;
 }
Exemple #9
0
 /**
  * @issue ZF-7067
  */
 public function testCanSetActionWithGetParams()
 {
     $this->testActionDefaultsToEmptyString();
     $this->form->setAction('/foo.php?bar')->setView(new Zend_View());
     $html = $this->form->render();
     $this->assertContains('action="/foo.php?bar"', $html);
     $this->assertEquals('/foo.php?bar', $this->form->getAction());
 }
Exemple #10
0
 public function formAction()
 {
     $form = new Zend_Form();
     $form->setAction('/resource/process')->setMethod('post');
     $form->setAttrib('id', 'login');
     $form->addElement('text', 'username');
     echo $form;
     exit;
 }
Exemple #11
0
 function indexAction()
 {
     $this->setupCache('default');
     $this->level = 500;
     $this->requirePriviledges();
     $this->toTpl('theInclude', 'profile');
     $data = $this->_request->getParams();
     $this->toTpl('module_title', $this->t('Profile of') . " " . $data['profile']);
     //check if the user is trying to view his profile
     $edit = false;
     if ($data['profile'] == 'me' || !$data['profile'] || $data['profile'] == 'index') {
         $profile = $_SESSION['user']['username'];
         $edit = true;
     } else {
         $profile = $data['profile'];
         $edit = false;
     }
     //try to get the user...
     $user = $this->getUserByName($profile);
     //now we need to get the data for this user
     $user['data'] = $this->getUserData($user['id']);
     //now if the user is viewing his profile, we need to create a nice form in order for him to edit the data
     if ($edit) {
         //get the fields
         $fields = $this->getUserProfileFields();
         $form = new Zend_Form();
         $form->setView($this->tpl);
         $form->setAttrib('class', 'form');
         $form->removeDecorator('dl');
         $form->setAction($this->config->host->folder . '/profiles/update')->setMethod('post');
         foreach ($fields as $k => $v) {
             switch ($v['field_type']) {
                 case "selectbox":
                     $values = explode(",", $v['default_value']);
                     break;
                 default:
                     $values = $v['default_value'];
                     break;
             }
             $form->addElement($this->getFormElement(array('name' => $v['name'], 'value' => $v['field_type'], 'title' => $this->t(ucfirst($v['name'])), 'use_pool' => 'valuesAsKeys', 'pool_type' => $values, 'novalue' => true), $user['data'][$v['name']]));
         }
         $form->addElement($this->getFormElement(array('name' => 'uid', 'value' => 'hidden'), $user['id']));
         $submit = new Zend_Form_Element_Submit('save');
         $submit->setLabel($this->t("Update"));
         $submit->setAttrib('class', "btn btn-primary");
         $form->addElement($submit);
         $form = $this->doQoolHook('pre_assign_user_profile_form', $form);
         $this->toTpl('formTitle', $this->t("Update your profile"));
         $this->toTpl('theForm', $form);
         $user = $this->doQoolHook('pre_assign_profiles_own_user_data', $user);
     } else {
         $user = $this->doQoolHook('pre_assign_profiles_user_data', $user);
     }
     $this->doQoolHook('pre_load_profiles_tpl');
     $this->toTpl('user', $user);
 }
Exemple #12
0
 protected function _getForm()
 {
     $form = new Zend_Form();
     $form->setAction($this->view->baseUrl('/contact'));
     $form->addElement(new Zend_Form_Element_Text('name', array('label' => 'Name', 'required' => true)));
     $form->addElement(new Zend_Form_Element_Text('email', array('label' => 'E-mail', 'required' => true)));
     $form->addElement(new Zend_Form_Element_Textarea('body', array('label' => 'Question / feedback', 'required' => true)));
     $form->addElement(new Zend_Form_Element_Submit('submit', array('label' => 'Send')));
     return $form;
 }
Exemple #13
0
 /**
  * Create create_agreement form.
  *
  * @param  string $community_id
  * @return Zend_Form
  */
 public function createCreateAgreementForm($community_id)
 {
     $form = new Zend_Form();
     $form->setAction($this->webroot . '/communityagreement/community/agreementtab?communityId=' . $community_id)->setMethod('post');
     $agreement = new Zend_Form_Element_Textarea('agreement');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($this->t('Save'));
     $form->addElements(array($agreement, $submit));
     return $form;
 }
 public function testRenderElement()
 {
     $form = new Zend_Form();
     $form->addElement($this->element);
     $view = new Zend_View();
     $view->addHelperPath('Application/View/Helper', 'Application_View_Helper');
     $form->setAction('/foo.php?bar')->setView($view);
     $html = $form->render();
     $this->assertContains('<input type="date" name="foo" id="foo" value="" disabled="1">', $html);
 }
Exemple #15
0
 /** Main form */
 public function createMigrateForm($assetstores)
 {
     // Setup the form
     $form = new Zend_Form();
     $form->setAction('migratemidas2');
     $form->setName('migrateForm');
     $form->setMethod('post');
     $form->setAttrib('class', 'migrateForm');
     // Input directory
     $midas2_hostname = new Zend_Form_Element_Text('midas2_hostname', array('label' => $this->t('MIDAS2 Hostname'), 'size' => 60, 'value' => 'localhost'));
     $midas2_hostname->setRequired(true);
     $form->addElement($midas2_hostname);
     $midas2_port = new Zend_Form_Element_Text('midas2_port', array('label' => $this->t('MIDAS2 Port'), 'size' => 4, 'value' => '5432'));
     $midas2_port->setRequired(true);
     $midas2_port->setValidators(array(new Zend_Validate_Digits()));
     $form->addElement($midas2_port);
     $midas2_user = new Zend_Form_Element_Text('midas2_user', array('label' => $this->t('MIDAS2 User'), 'size' => 60, 'value' => 'midas'));
     $midas2_user->setRequired(true);
     $form->addElement($midas2_user);
     $midas2_password = new Zend_Form_Element_Password('midas2_password', array('label' => $this->t('MIDAS2 Password'), 'size' => 60, 'value' => 'midas'));
     $midas2_password->setRequired(true);
     $form->addElement($midas2_password);
     $midas2_database = new Zend_Form_Element_Text('midas2_database', array('label' => $this->t('MIDAS2 Database'), ' size' => 60, 'value' => 'midas'));
     $midas2_database->setRequired(true);
     $form->addElement($midas2_database);
     $midas2_assetstore = new Zend_Form_Element_Text('midas2_assetstore', array('label' => $this->t('MIDAS2 Assetstore Path'), 'size' => 60, 'value' => 'C:/xampp/midas/assetstore'));
     $midas2_assetstore->setRequired(true);
     $form->addElement($midas2_assetstore);
     // Button to select the directory on the server
     $midas2_assetstore_button = new Zend_Form_Element_Button('midas2_assetstore_button', $this->t('Choose'));
     $midas2_assetstore_button->setDecorators(array('ViewHelper', array('HtmlTag', array('tag' => 'div', 'class' => 'browse-button')), array('Label', array('tag' => 'div', 'style' => 'display:none'))));
     $form->addElement($midas2_assetstore_button);
     // Assetstore
     $assetstoredisplay = array();
     $assetstoredisplay[0] = $this->t('Choose one...');
     // Initialize with the first type (MIDAS)
     foreach ($assetstores as $assetstore) {
         if ($assetstore->getType() == 0) {
             $assetstoredisplay[$assetstore->getAssetstoreId()] = $assetstore->getName();
         }
     }
     $assetstore = new Zend_Form_Element_Select('assetstore');
     $assetstore->setLabel($this->t('MIDAS3 Assetstore'));
     $assetstore->setMultiOptions($assetstoredisplay);
     $assetstore->setDescription(' <a class="load-newassetstore" href="#newassetstore-form" rel="#newassetstore-form" title="' . $this->t('Add a new assetstore') . '"> ' . $this->t('Add a new assetstore') . '</a>')->setDecorators(array('ViewHelper', array('Description', array('escape' => false, 'tag' => false)), array('HtmlTag', array('tag' => 'dd')), array('Label', array('tag' => 'dt')), 'Errors'));
     $assetstore->setRequired(true);
     $assetstore->setValidators(array(new Zend_Validate_GreaterThan(array('min' => 0))));
     $assetstore->setRegisterInArrayValidator(false);
     // This array is dynamic so we disable the validator
     $form->addElement($assetstore);
     // Submit
     $submit = new Zend_Form_Element_Button('migratesubmit', $this->t('Migrate'));
     $form->addElement($submit);
     return $form;
 }
Exemple #16
0
 /** account  form */
 public function createAccountForm($defaultValue = array())
 {
     $form = new Zend_Form();
     $form->setAction($this->webroot . '/user/settings')->setMethod('post');
     $email = new Zend_Form_Element_Text('email');
     $email->setRequired(true)->addValidator('NotEmpty', true)->setAttrib('maxLength', 255)->addValidator('EmailAddress');
     $firstname = new Zend_Form_Element_Text('firstname');
     $firstname->setRequired(true)->addValidator('NotEmpty', true)->setAttrib('maxLength', 255);
     $lastname = new Zend_Form_Element_Text('lastname');
     $lastname->setRequired(true)->addValidator('NotEmpty', true)->setAttrib('maxLength', 255);
     $company = new Zend_Form_Element_Text('company');
     $company->setAttrib('maxLength', 255);
     $city = new Zend_Form_Element_Text('city');
     $city->setAttrib('maxLength', 100);
     $country = new Zend_Form_Element_Text('country');
     $country->setAttrib('maxLength', 100);
     $validator = new Zend_Validate_Callback(array('Zend_Uri', 'check'));
     $website = new Zend_Form_Element_Text('website');
     $website->setAttrib('maxLength', 255)->addValidator($validator);
     $biography = new Zend_Form_Element_Textarea('biography');
     $biography->addValidator(new Zend_Validate_Alnum());
     $submit = new Zend_Form_Element_Submit('modifyAccount');
     $submit->setLabel($this->t('Modify'));
     $privacy = new Zend_Form_Element_Radio('privacy');
     $privacy->addMultiOptions(array(MIDAS_USER_PUBLIC => $this->t('Public (Anyone can see my information, excluding email address)'), MIDAS_USER_PRIVATE => $this->t('Private (User information will be hidden)')))->setRequired(true)->setValue(MIDAS_COMMUNITY_PUBLIC);
     if (isset($defaultValue['email'])) {
         $email->setValue($defaultValue['email']);
     }
     if (isset($defaultValue['firstname'])) {
         $firstname->setValue($defaultValue['firstname']);
     }
     if (isset($defaultValue['lastname'])) {
         $lastname->setValue($defaultValue['lastname']);
     }
     if (isset($defaultValue['company'])) {
         $company->setValue($defaultValue['company']);
     }
     if (isset($defaultValue['privacy'])) {
         $privacy->setValue($defaultValue['privacy']);
     }
     if (isset($defaultValue['city'])) {
         $city->setValue($defaultValue['city']);
     }
     if (isset($defaultValue['country'])) {
         $country->setValue($defaultValue['country']);
     }
     if (isset($defaultValue['website'])) {
         $website->setValue($defaultValue['website']);
     }
     if (isset($defaultValue['biography'])) {
         $biography->setValue($defaultValue['biography']);
     }
     $form->addElements(array($email, $website, $city, $country, $biography, $firstname, $lastname, $company, $privacy, $submit));
     return $form;
 }
Exemple #17
0
 /** create a group */
 public function createCreateGroupForm()
 {
     $form = new Zend_Form();
     $form->setAction($this->webroot . '/community/manage')->setMethod('post');
     $name = new Zend_Form_Element_Text('name');
     $name->setRequired(true)->addValidator('NotEmpty', true);
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($this->t('Save'));
     $form->addElements(array($name, $submit));
     return $form;
 }
Exemple #18
0
 /** create form */
 public function createKeyForm()
 {
     $form = new Zend_Form();
     $form->setAction($this->webroot . '/apikey/usertab')->setMethod('post');
     $appplication_name = new Zend_Form_Element_Text('appplication_name');
     $expiration = new Zend_Form_Element_Text('expiration');
     $submit = new Zend_Form_Element_Submit('createAPIKey');
     $submit->setLabel($this->t('Generate New API Key'));
     $form->addElements(array($appplication_name, $expiration, $submit));
     return $form;
 }
 public function getForm()
 {
     $elementDecorators = array(array('Label'), array('ViewHelper'), array('Errors'));
     $form = new Zend_Form();
     $form->setAction('/student/profile/my-profile/')->setMethod('post');
     $mailSubject = new Zend_Form_Element_Text('subject', array('id' => 'mailsubj', 'label' => 'Subject', 'maxLength' => '30'));
     $mailBody = new Zend_Form_Element_Textarea('mailbody', array('id' => 'mailbody', 'label' => 'Message', 'cols' => 40, 'rows' => 5));
     $mailSend = new Zend_Form_Element_Submit('mailsend', array('id' => 'mailsend', 'label' => 'send'));
     $form->addElements(array($mailSubject, $mailBody, $mailSend));
     return $form;
 }
 public function contactFormAction()
 {
     //create the form
     $form = new Zend_Form();
     //this page should post back to itself
     $form->setAction($_SERVER['REQUEST_URI']);
     $form->setMethod('post');
     $name = $form->createElement('text', 'name');
     $name->setLabel($this->view->getTranslation('Your Name') . ': ');
     $name->setRequired(TRUE);
     $name->addFilter('StripTags');
     $name->addErrorMessage($this->view->getTranslation('Your name is required!'));
     $name->setAttrib('size', 30);
     $email = $form->createElement('text', 'email');
     $email->setLabel($this->view->getTranslation('Your Email') . ': ');
     $email->setRequired(TRUE);
     $email->addValidator('EmailAddress');
     $email->addErrorMessage($this->view->getTranslation('Invalid email address!'));
     $email->setAttrib('size', 30);
     $subject = $form->createElement('text', 'subject');
     $subject->setLabel($this->view->getTranslation('Subject') . ': ');
     $subject->setRequired(TRUE);
     $subject->addFilter('StripTags');
     $subject->addErrorMessage($this->view->getTranslation('The subject is required!'));
     $subject->setAttrib('size', 40);
     $message = $form->createElement('textarea', 'message');
     $message->setLabel($this->view->getTranslation('Message') . ': ');
     $message->setRequired(TRUE);
     $message->addErrorMessage($this->view->getTranslation('The message is required!'));
     $message->setAttrib('cols', 35);
     $message->setAttrib('rows', 10);
     $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->view->getTranslation('Please verify you\'re a human'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 6, 'timeout' => 300)));
     $form->addElement($name);
     $form->addElement($email);
     $form->addElement($subject);
     $form->addElement($message);
     $form->addElement($captcha);
     $form->addElement('submit', 'submitContactForm', array('label' => $this->view->getTranslation('Send Message')));
     $this->view->form = $form;
     if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitContactForm')) {
         if ($form->isValid($_POST)) {
             //get form data
             $data = $form->getValues();
             //get the module data
             $module = new Digitalus_Module();
             $moduleData = $module->getData();
             //render the message
             $this->view->data = $data;
             $htmlMessage = $this->view->render('public/message.phtml');
             $mail = new Digitalus_Mail();
             $this->view->isSent = $mail->send($moduleData->email, array($data['email'], $data['name']), $data['subject'], $htmlMessage);
         }
     }
 }
 /**
  * This function creates a zend form for a login box with the relevant validation
  *
  * @return Zend_Form
  */
 protected function getLoginForm()
 {
     $form = new Zend_Form();
     $form->setAction('/cmsadmin/login')->setMethod('post');
     $username = $form->createElement('text', 'username');
     $username->addValidator('alnum')->addValidator('regex', false, array('/^[a-z]+/'))->addValidator('stringLength', false, array(6, 64))->setRequired(true)->addFilter('StringToLower');
     $password = $form->createElement('password', 'password');
     $password->addValidator('StringLength', false, array(6))->setRequired(true);
     $form->addElement($username)->addElement($password)->addElement('submit', 'login', array('label' => 'Login'));
     return $form;
 }
 public function getForm()
 {
     $elementDecorators = array(array('Label'), array('ViewHelper'), array('Errors'));
     $form = new Zend_Form();
     $form->setAction("/teacher/dashboard/view-student/stid/{$this->_stid}/")->setMethod('post');
     $mailSubject = new Zend_Form_Element_Text('subject', array('id' => 'mailsubj', 'label' => 'Subject'));
     $mailBody = new Zend_Form_Element_Textarea('mailbody', array('id' => 'mailbody', 'label' => 'Message', 'cols' => 40, 'rows' => 5));
     $mailSend = new Zend_Form_Element_Submit('mailsend', array('id' => 'mailsend', 'label' => 'send'));
     $form->addElements(array($mailSubject, $mailBody, $mailSend));
     return $form;
 }
 /**
  * Create and return the login form
  *
  * @return object
  */
 protected function getLoginForm()
 {
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel('Username:'******'password');
     $password->setLabel('Password:'******'login');
     $submit->setLabel('Login');
     $loginForm = new Zend_Form();
     $loginForm->setAction($this->_request->getBaseUrl() . '/login/index/')->setMethod('post')->addElement($username)->addElement($password)->addElement($submit);
     return $loginForm;
 }
Exemple #24
0
 /** create edit bitstream form */
 public function createEditBitstreamForm()
 {
     $form = new Zend_Form();
     $form->setAction($this->webroot . '/item/editbitstream')->setMethod('post');
     $name = new Zend_Form_Element_Text('name');
     $name->setRequired(true)->addValidator('NotEmpty', true);
     $mimetype = new Zend_Form_Element_Text('mimetype');
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($this->t('Save'));
     $form->addElements(array($name, $mimetype, $submit));
     return $form;
 }
Exemple #25
0
 public function loginForm()
 {
     $form = new Zend_Form();
     $form->setAction('user/auth')->setMethod('post');
     // Create and configure username element:
     $username = $form->createElement('text', 'user_username');
     $username->addValidator('alnum')->addValidator('regex', false, array('/^[a-z]+/'))->addValidator('stringLength', false, array(6, 20))->setRequired(true)->addFilter('StringToLower');
     // Create and configure password element:
     $password = $form->createElement('password', 'user_password');
     $password->addValidator('StringLength', false, array(6))->setRequired(true);
     // Add elements to form:
     $form->addElement($username)->addElement($password)->addElement('submit', 'login', array('label' => 'Login'));
 }
 /**
  * @return Zend_Form
  */
 private function getLoginForm()
 {
     $form = new Zend_Form();
     $form->setAction("session/create")->setMethod('post');
     $email = new Zend_Form_Element_Text(array('name' => 'email', 'label' => 'Email Addresse'));
     $email->addValidator(new Zend_Validate_EmailAddress());
     $email->addFilter('StringtoLower');
     $email->setRequired();
     $password = new Zend_Form_Element_Password(array('name' => 'password', 'label' => 'Passwort'));
     $password->setRequired();
     $form->addElement($email)->addElement($password)->addElement('submit', 'login', array('label' => 'Anmelden'));
     return $form;
 }
Exemple #27
0
 /** create upload link form */
 public function createUploadLinkForm()
 {
     $form = new Zend_Form();
     $form->setAction($this->webroot . '/upload/savelink')->setMethod('post');
     $validator = new Zend_Validate_Callback(array('Zend_Uri', 'check'));
     $name = new Zend_Form_Element_Text('name');
     $name->setRequired(true);
     $url = new Zend_Form_Element_Text('url');
     $url->setValue('http://')->setRequired(true)->addValidator($validator)->addValidator('NotEmpty', true);
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($this->t('Save Link'))->setAttrib('class', 'globalButton');
     $form->addElements(array($name, $url, $submit));
     return $form;
 }
 public function indexAction()
 {
     $this->view->title = 'admin_title_statistic';
     $years = $this->_statisticsModel->getYears();
     $highest = max($years);
     $selectYear = new Zend_Form_Element_Select('selectedYear', array("multiOptions" => $years, "value" => $highest));
     $selectYear->setRequired(true)->setLabel($this->view->translate('Select_Year_Label'));
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setLabel($this->view->translate('Submit_Button_Label'));
     $form = new Zend_Form();
     $form->setAction($this->view->url(array("controller" => "statistic", "action" => "show")));
     $form->addElements(array($selectYear, $submit));
     $this->view->form = $form;
 }
Exemple #29
0
 /**
  * Create and return the login form
  *
  * @return object
  */
 protected function getLoginForm()
 {
     $username = new Zend_Form_Element_Text('username');
     $username->setLabel('Username:'******'ViewScript', array('viewScript' => '_form/text.phtml', 'placement' => false))));
     $username->setOptions(array('placeholder' => 'username...', 'inputtype' => 'text'));
     $password = new Zend_Form_Element_Password('password');
     $password->setLabel('Password:'******'ViewScript', array('viewScript' => '_form/text.phtml', 'placement' => false))));
     $password->setOptions(array('placeholder' => 'password...', 'inputtype' => 'password'));
     $submit = new Zend_Form_Element_Submit('login');
     $submit->setLabel('Login');
     $loginForm = new Zend_Form();
     $loginForm->setAction($this->_request->getBaseUrl() . '/login/index/')->setMethod('post')->addElement($username)->addElement($password)->addElement($submit);
     return $loginForm;
 }
 public function indexAction()
 {
     /*
      *
      *	@todo email site admin when inserted
      *
      */
     $this->_model = new Joobsbox_Model_Jobs();
     // <createForm>
     $form = new Zend_Form();
     $form->setAction($_SERVER['REQUEST_URI'])->setMethod('post')->setAttrib("id", "formPublish");
     $title = $form->createElement('text', 'title')->setLabel('Job title:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setDescription('Ex: "Flash Designer" or "ASP.NET Programmer"')->setRequired(true);
     $company = $form->createElement('text', 'company')->setLabel('Company:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setRequired(true);
     $location = $form->createElement('text', 'location')->setLabel('Location:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setDescription('Example: "London, Paris, Berlin, New York"')->setRequired(true);
     $categories[0] = $this->view->translate("Choose...");
     foreach ($this->_model->fetchCategories()->getIndexNamePairs() as $key => $value) {
         $categories[$key] = $value;
     }
     $greaterThan = new Zend_Validate_GreaterThan(false, array('0'));
     $greaterThan->setMessage($this->view->translate("Choosing a category is mandatory."));
     $category = $form->createElement('select', 'category')->setLabel('Category:')->addValidator('notEmpty')->addValidator($greaterThan)->setRequired(true)->setMultiOptions($categories);
     $description = $form->createElement('textarea', 'description')->setLabel('Job description:')->setDescription('HTML code is not accepted. Length must be less than 4000 characters.')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setRequired(true);
     $application = $form->createElement('text', 'application')->setLabel('Means of application:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setDescription('Ex: "Send CV to email ..." or "Apply online at URL ..."')->setRequired(true);
     $submit = $form->createElement('submit', 'submit')->setLabel("Add");
     $form->addElement($title)->addElement($company)->addElement($location)->addElement($category)->addElement($description)->addElement($application);
     $publishNamespace = new Zend_Session_Namespace('PublishJob');
     if (isset($publishNamespace->editJobId)) {
         $jobData = $this->_model->fetchJobById($publishNamespace->editJobId);
         $title->setValue($jobData['title']);
         $company->setValue($jobData['company']);
         $location->setValue($jobData['location']);
         $category->setValue($jobData['categoryid']);
         $description->setValue($jobData['description']);
         $application->setValue($jobData['toapply']);
         $exp = $form->createElement('text', 'expirationdate')->setLabel('Expiration date:')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('notEmpty')->setRequired(true)->setValue(date("m/d/Y", $jobData['expirationdate']));
         $form->addElement($exp);
         $submit->setLabel('Modify');
     }
     $form->addElement($submit);
     $this->form = $form;
     // </createForm>
     // Render the form
     $this->view->form = $form->render;
     if ($this->getRequest()->isPost()) {
         $this->validateForm();
         return;
     }
     $this->view->form = $this->form->render();
 }