예제 #1
0
 public function updateField($curData)
 {
     $field = new \Ip\Form\Field\Textarea(array('label' => $this->label, 'name' => $this->field, 'layout' => $this->layout, 'attributes' => $this->attributes));
     if (isset($curData[$this->field])) {
         $field->setValue($curData[$this->field]);
     }
     return $field;
 }
예제 #2
0
 public static function createForm()
 {
     $userId = Null;
     $userName = '';
     $userMail = '';
     $vCode = md5(uniqid(rand(), true));
     $pageId = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     $pageId = 'http://' . parse_url($pageId, PHP_URL_HOST) . parse_url($pageId, PHP_URL_PATH);
     if (ipUser()->isLoggedIn()) {
         $userData = ipUser()->data();
         $userId = $userData['id'];
         $userName = $userData['username'];
         $userMail = $userData['email'];
     }
     $form = new \Ip\Form();
     $form->addClass('commentForm');
     $field = new \Ip\Form\Field\Text(array('name' => 'name', 'label' => __('Name', 'Comments'), 'validators' => array('Required'), 'value' => $userName));
     $form->addField($field);
     $field = new \Ip\Form\Field\Email(array('name' => 'email', 'label' => __('Email', 'Comments'), 'validators' => array('Required'), 'value' => $userMail));
     $form->addField($field);
     $field = new \Ip\Form\Field\Text(array('name' => 'link', 'label' => __('Website', 'Comments')));
     $form->addField($field);
     $field = new \Ip\Form\Field\Textarea(array('name' => 'text', 'label' => __('Comment', 'Comments'), 'validators' => array('Required')));
     $fileValLimits = new ValidateLimits();
     $field->addValidator($fileValLimits);
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'id', 'value' => $userId));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'ip', 'value' => $_SERVER['REMOTE_ADDR']));
     $form->addField($field);
     if (ipGetOption('Comments.requireEmailConfirmation') == 'Yes') {
         $aprFree = 0;
     } else {
         $aprFree = 1;
     }
     $field = new \Ip\Form\Field\Hidden(array('name' => 'approved', 'value' => !empty($userId) ? '1' : $aprFree));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'verification_code', 'value' => $vCode));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'session_id', 'value' => session_id()));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'zone_name', 'value' => $pageId));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'language_id', 'value' => ipContent()->getCurrentLanguage()->getId()));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'wgetId', 'value' => isset($_COOKIE['widGetId']) ? $_COOKIE['widGetId'] : ''));
     $form->addField($field);
     //FIXED NOW 05/26/15
     if (ipGetOption('Comments.requireAdminPermission') == 'Yes') {
         $aFree = 0;
     } else {
         $aFree = 1;
     }
     $field = new \Ip\Form\Field\Hidden(array('name' => 'active', 'value' => $aFree));
     $form->addField($field);
     $field = new \Ip\Form\Field\Hidden(array('name' => 'sa', 'value' => 'Comments.save'));
     $form->addField($field);
     $field = new \Ip\Form\Field\Submit(array('value' => __('Send', 'Comments')));
     $field->addAttribute('onsubmit', 'parent.scrollTo(0, 0); return true');
     $form->addField($field);
     //$form->addField(new \Ip\Form\Field\Submit(array('value' => __('Send', 'Comments'))));
     return $form;
 }