Exemplo n.º 1
0
 /**
  * Get data and build the list for the options in select and choices.
  *
  * @param int $optionId Id of the response option.
  * @param int $langId Id of the language.
  *
  * @return string $html
  */
 public function getOptionsList($optionId, $langId, $value = null)
 {
     $this->_selectResponseOptions($optionId, $langId);
     $nbDefaultLine = count($this->_dataRespOpt);
     if ($nbDefaultLine == 0) {
         $this->_selectResponseOptions($optionId, Cible_Controller_Action::getDefaultEditLanguage());
     }
     if (count($this->_dataRespOpt) == 0 && $langId == Cible_Controller_Action::getDefaultEditLanguage()) {
         $languages = Cible_FunctionsGeneral::getAllLanguage();
         foreach ($languages as $key => $lang) {
             if ($lang['L_ID'] != $langId) {
                 $this->getOptionsList($optionId, $lang['L_ID']);
                 break;
             }
         }
     }
     if (count($this->_dataRespOpt)) {
         $this->_typeName = $this->_dataRespOpt[0]['FRO_Type'];
     }
     if ($this->_typeName == "select") {
         $html = $this->selectValuesList($nbDefaultLine);
     } else {
         $html = $this->choiceValuesList($nbDefaultLine);
     }
     return $html;
 }
Exemplo n.º 2
0
 /**
  * Add a new section to the form
  *
  * @return void
  */
 public function addAction()
 {
     if ($this->view->aclIsAllowed($this->view->current_module, 'edit')) {
         $data = $this->_getAllParams();
         $data['FTI_Text'] = $data['FTI_Text'];
         if ($data['model'] != 'Form') {
             $dataObject = 'Form' . ucfirst($data['model']) . 'Object';
         } else {
             $dataObject = ucfirst($data['model']) . 'Object';
         }
         $oForm = new $dataObject();
         $initData = $oForm->getInitialData($data);
         if (count($initData) > 0) {
             $saved = $oForm->insert($data, $initData['lang']);
             $languages = Cible_FunctionsGeneral::getAllLanguage();
             foreach ($languages as $key => $lang) {
                 if ($lang['L_ID'] != $initData['lang']) {
                     $oForm->save($saved, $data, $lang['L_ID']);
                 }
             }
         } else {
             $saved = '0';
         }
         echo $saved;
     }
     exit;
 }
Exemplo n.º 3
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     // Title
     $title = new Zend_Form_Element_Text('NR_Title');
     $title->setLabel($this->getView()->getCibleText('form_label_title'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttrib('class', 'stdTextInput');
     $this->addElement($title);
     // Date picker
     $datePicker = new Cible_Form_Element_DatePicker('NR_Date', array('jquery.params' => array('changeYear' => true, 'changeMonth' => true)));
     $datePicker->setLabel($this->getView()->getCibleText('form_extranet_newsletter_label_releaseDate'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator('Date', true, array('messages' => array('dateNotYYYY-MM-DD' => $this->getView()->getCibleText('validation_message_invalid_date'), 'dateInvalid' => $this->getView()->getCibleText('validation_message_invalid_date'), 'dateFalseFormat' => $this->getView()->getCibleText('validation_message_invalid_date'))));
     $this->addElement($datePicker);
     // Language
     $language = new Zend_Form_Element_Select('NR_LanguageID');
     $language->setLabel($this->getView()->getCibleText('form_label_language'))->setAttrib('class', 'largeSelect');
     $languagesData = Cible_FunctionsGeneral::getAllLanguage();
     foreach ($languagesData as $languageData) {
         $language->addMultiOption($languageData['L_ID'], $languageData['L_Title']);
     }
     $this->addElement($language);
     // Category
     $category = new Zend_Form_Element_Select('NR_CategoryID');
     $category->setLabel($this->getView()->getCibleText('form_label_category'))->setAttrib('class', 'largeSelect');
     $categoriesData = $this->getView()->getAllNewsletterCategories();
     foreach ($categoriesData as $categoryData) {
         $category->addMultiOption($categoryData['C_ID'], $categoryData['CI_Title']);
     }
     $this->addElement($category);
     // Model
     $model = new Zend_Form_Element_Select('NR_ModelID');
     $model->setLabel($this->getView()->getCibleText('form_label_model'))->setAttrib('class', 'largeSelect');
     $modelsData = $this->getView()->getAllNewsletterModels();
     foreach ($modelsData as $modelData) {
         $model->addMultiOption($modelData['NMI_NewsletterModelID'], $modelData['NMI_Title']);
     }
     $this->addElement($model);
     //if($this->salutationDefaultText!=""){
     $intro = new Cible_Form_Element_Editor('NR_TextIntro', array('mode' => Cible_Form_Element_Editor::ADVANCED));
     $intro->setLabel($this->getView()->getCibleText('form_label_newsletter_text_intro'))->setAttrib('class', 'largeEditor');
     $this->addElement($intro);
     // show online
     $showOnline = new Zend_Form_Element_Checkbox('NR_Online');
     $showOnline->setLabel($this->getView()->getCibleText('form_label_showOnline'));
     $showOnline->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
     $this->addElement($showOnline);
     // email
     //            $regexValidate = new Cible_Validate_Email();
     //            $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
     $email = new Zend_Form_Element_Text('NR_AdminEmail');
     $email->setLabel($this->getView()->getCibleText('newsletter_form_label_admin_email'))->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->setAttrib('class', 'stdTextInput');
     /*$email->setDecorators(array(
           'ViewHelper',
           array('label', array('placement' => 'prepend')),
           array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'dd_form dd_email'))
       ));*/
     // $email->setAttrib('class', 'newsletter_form_element text_email');
     $this->addElement($email);
 }
Exemplo n.º 4
0
 protected function add($blockID)
 {
     // add text
     $Languages = Cible_FunctionsGeneral::getAllLanguage();
     foreach ($Languages as $Lang) {
         $textData = new Text();
         $text = $textData->createRow();
         $text->TD_BlockID = $blockID;
         $text->TD_LanguageID = $Lang["L_ID"];
         $text->save();
     }
 }
Exemplo n.º 5
0
 public function addResponseOptionAction()
 {
     $data = $this->_getAllParams();
     if ($data['model'] != 'Form') {
         $dataObject = 'Form' . ucfirst($data['model']) . 'Object';
     } else {
         $dataObject = ucfirst($data['model']) . 'Object';
     }
     $oForm = new $dataObject();
     $initData = $oForm->getInitialData($data);
     $saved = $oForm->insert($data, $initData['lang']);
     $languages = Cible_FunctionsGeneral::getAllLanguage();
     foreach ($languages as $key => $lang) {
         if ($lang['L_ID'] != $initData['lang']) {
             $oForm->save($saved, $data, $lang['L_ID']);
         }
     }
     echo $saved;
     exit;
 }
Exemplo n.º 6
0
 private function autogenerateMenuItemFromPageId($itemId, $parentId, $recursive = false)
 {
     $pageObject = new Pages();
     $select = $pageObject->select()->setIntegrityCheck(false)->from('Pages')->joinInner('PagesIndex', 'PI_PageID = P_ID')->where('PI_LanguageID = ?', Zend_Registry::get('languageID'))->where('P_ParentID = ?', $parentId)->order('P_Position');
     $pages = $pageObject->fetchAll($select)->toArray();
     foreach ($pages as $item) {
         $page_id = $item['P_ID'];
         $position = $this->_db->fetchCol("SELECT count(*) FROM MenuItemData WHERE MID_ParentID = '{$itemId}' AND MID_MenuID = '{$this->_id}'");
         $position = $position[0];
         $langs = Cible_FunctionsGeneral::getAllLanguage();
         foreach ($langs as $lang) {
             $page_details = Cible_FunctionsPages::getPageDetails($page_id, $lang['L_ID']);
             $page_title = !empty($page_details['PI_PageTitle']) ? $page_details['PI_PageTitle'] : null;
             if ($page_title != null) {
                 $found_status = $this->autogenerate_checkIfAlreadyExists($itemId, $page_id, $lang['L_ID']);
                 if (!$found_status['data']) {
                     $menuData = new MenuItem();
                     $_data = $menuData->createRow();
                     $_data->setFromArray(array('MID_MenuID' => $this->_id, 'MID_ParentID' => $itemId, 'MID_Position' => $position));
                     $_data->save();
                     $_dataId = $this->_db->lastInsertId();
                     $menuIndex = new MenuItemIndex();
                     $_index = $menuIndex->createRow();
                     $_index->setFromArray(array('MII_LanguageID' => $item['PI_LanguageID'], 'MII_MenuItemDataID' => $_dataId, 'MII_Title' => $page_title, 'MII_Link' => '', 'MII_PageID' => $page_id));
                     $_index->save();
                 } else {
                     if ($found_status['data'] && !$found_status['lang']) {
                         $_dataId = $found_status['dataID'];
                         $menuIndex = new MenuItemIndex();
                         $_index = $menuIndex->createRow();
                         $_index->setFromArray(array('MII_LanguageID' => $lang['L_ID'], 'MII_MenuItemDataID' => $_dataId, 'MII_Title' => $page_title, 'MII_Link' => '', 'MII_PageID' => $page_id));
                         $_index->save();
                     }
                 }
             }
         }
         if ($_dataId != -1 && $recursive) {
             $this->autogenerateMenuItemFromPageId($_dataId, $page_id, $recursive);
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Update or insert data from file to import
  *
  * @param array $params Data for loading process
  */
 protected function _dataProcess($params)
 {
     $onlyData = true;
     if (!empty($this->_indexClass)) {
         $tmpArrayIndex = $params['tmpIndex'];
         $onlyData = false;
     }
     $tmpArray = $params['tmpData'];
     $langId = $params['langId'];
     $nbLines = $params['nbLines'];
     // test if a value already exist
     $exist = $this->recordExists($tmpArray, $langId, $onlyData);
     // insert or update the row
     if ($exist) {
         //update data table
         // and index table for translation if necessary
         if (!empty($this->_indexClass)) {
             $languages = Cible_FunctionsGeneral::getAllLanguage();
             foreach ($languages as $key => $lang) {
                 //set data to update
                 reset($this->_indexColumns);
                 if (isset($tmpArrayIndex[$lang['L_Suffix']])) {
                     $tmpArray[current($this->_indexColumns)] = $tmpArrayIndex[$lang['L_Suffix']];
                 } else {
                     $lang['L_ID'] = $langId;
                 }
                 $this->save($tmpArray[$this->_dataId], $tmpArray, $lang['L_ID']);
             }
         } else {
             $this->save($tmpArray[$this->_dataId], $tmpArray, $langId);
         }
         $nbLines['updated'] = ++$nbLines['updated'];
     } else {
         // and index table for translation if necessary
         if (!empty($this->_indexClass)) {
             $languages = Cible_FunctionsGeneral::getAllLanguage();
             foreach ($languages as $key => $lang) {
                 //set data to update
                 reset($this->_indexColumns);
                 if (isset($tmpArrayIndex[$lang['L_Suffix']])) {
                     $tmpArray[current($this->_indexColumns)] = $tmpArrayIndex[$lang['L_Suffix']];
                 } else {
                     $lang['L_ID'] = $langId;
                 }
                 $this->insert($tmpArray, $lang['L_ID']);
                 if (!isset($tmpArrayIndex[$lang['L_Suffix']])) {
                     break;
                 }
             }
         } else {
             $this->insert($tmpArray, $langId);
         }
         $nbLines['inserted'] = ++$nbLines['inserted'];
     }
     return $nbLines;
 }
Exemplo n.º 8
0
 private function getNewElement($filterOption, $filterID, $filterSetID, $filterValue = '')
 {
     $newElement = '';
     if ($filterOption == 'GP_Language') {
         $newElement = "<select name='filterSet[" . $filterSetID . "][" . $filterID . "][filterValue]'>";
         foreach (Cible_FunctionsGeneral::getAllLanguage() as $lang) {
             if ($filterValue == $lang['L_ID']) {
                 $newElement .= "<option value='" . $lang['L_ID'] . "' selected='selected'>" . $lang['L_Title'] . "</option>";
             } else {
                 $newElement .= "<option value='" . $lang['L_ID'] . "'>" . $lang['L_Title'] . "</option>";
             }
         }
         $newElement .= "</select>";
     } elseif ($filterOption == 'GP_Salutation') {
         $newElement = "<select name='filterSet[" . $filterSetID . "][" . $filterID . "][filterValue]'>";
         $greetings = $this->view->getAllSalutation();
         foreach ($greetings as $greeting) {
             if ($filterValue == $greeting['S_ID']) {
                 $newElement .= "<option value='" . $greeting['S_ID'] . "' selected='selected'>" . $greeting['ST_Value'] . "</option>";
             } else {
                 $newElement .= "<option value='" . $greeting['S_ID'] . "'>" . $greeting['ST_Value'] . "</option>";
             }
         }
         $newElement .= "</select>";
     } elseif ($filterOption == 'NP_Categories') {
         $newElement = "<select name='filterSet[" . $filterSetID . "][" . $filterID . "][filterValue]'>";
         $newsletterCategories = $this->view->GetAllNewsletterCategories();
         foreach ($newsletterCategories as $cat) {
             if ($filterValue == $cat['C_ID']) {
                 $newElement .= "<option value='" . $cat['C_ID'] . "' selected='selected'>" . $cat['CI_Title'] . "</option>";
             } else {
                 $newElement .= "<option value='" . $cat['C_ID'] . "'>" . $cat['CI_Title'] . "</option>";
             }
         }
         $newElement .= "</select>";
     } elseif ($filterOption == 'newFilter') {
         $newElement = "<select name='filterSet[" . $filterSetID . "][" . $filterID . "][filterSet]' id='filterSet-filterSet' class='selectFilterOption'>";
         $newElement .= "<option value='0'>" . $this->view->getCibleText('newsletter_send_filter_selectOne') . "</option>";
         $filterOptionsSelect = new NewsletterFilterProfilesFields();
         $select = $filterOptionsSelect->select();
         $filterOptionsData = $filterOptionsSelect->fetchAll($select)->toArray();
         $cpt = count($filterOptionsData);
         for ($i = 0; $i < $cpt; $i++) {
             $newElement .= "<option value='" . $filterOptionsData[$i]['NFPF_Name'] . "'>" . $this->view->getCibleText('newsletter_send_filter_' . $filterOptionsData[$i]['NFPF_Name']) . "</option>";
         }
         $newElement .= "</select>";
     }
     return $newElement;
 }
Exemplo n.º 9
0
 public static function generateLanguageSwitcher($view)
 {
     $_availableLanguages = Cible_FunctionsGeneral::getAllLanguage();
     $baseUrl = $view->baseUrl();
     $params = $view->params;
     $_module = '';
     $_controller = '';
     $_action = '';
     $_params = '';
     foreach ($params as $_key => $_val) {
         switch ($_key) {
             case 'module':
                 $_module = $_val;
                 break;
             case 'controller':
                 $_controller = $_val;
                 break;
             case 'action':
                 $_action = $_val;
                 break;
             default:
                 if (strtolower($_key) != 'lang' && !isset($_POST[$_key])) {
                     $_params .= "/{$_key}/{$_val}";
                 }
         }
     }
     $_requestURI = "{$baseUrl}/{$_module}/{$_controller}/{$_action}{$_params}";
     $content = '';
     foreach ($_availableLanguages as $_lang) {
         $_selected = false;
         if ($_lang['L_ID'] == Zend_Registry::get('currentEditLanguage')) {
             $_selected = true;
         }
         $content .= '<li>';
         if ($_selected) {
             $content .= $view->link("{$_requestURI}/lang/{$_lang['L_Suffix']}", $_lang['L_Title'], array('class' => 'selected'));
         } else {
             $content .= $view->link("{$_requestURI}/lang/{$_lang['L_Suffix']}", $_lang['L_Title']);
         }
         $content .= '</li>';
     }
     if (!empty($content)) {
         $content = "<ul id='language-switcher'>{$content}</ul>";
     }
     return $content;
 }
Exemplo n.º 10
0
 protected function _languagesSrc(array $meta = array())
 {
     $langs = Cible_FunctionsGeneral::getAllLanguage();
     foreach ($langs as $lang) {
         $this->_srcData[$lang['L_ID']] = $lang['L_Title'];
     }
 }
Exemplo n.º 11
0
 /**
  * Render form element
  * 
  * @param  Zend_View_Interface $view 
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     $_availableLanguages = Cible_FunctionsGeneral::getAllLanguage();
     $_baseUrl = $this->getView()->baseUrl();
     $_module = '';
     $_controller = '';
     $_action = '';
     $_params = '';
     foreach ($this->_params as $_key => $_val) {
         switch ($_key) {
             case 'module':
                 $_module = $_val;
                 break;
             case 'controller':
                 $_controller = $_val;
                 break;
             case 'action':
                 $_action = $_val;
                 break;
             default:
                 if (strtolower($_key) != 'lang' && !isset($_POST[$_key])) {
                     $_params .= "/{$_key}/{$_val}";
                 }
         }
     }
     $_requestURI = "{$_baseUrl}/{$_module}/{$_controller}/{$_action}{$_params}";
     $content = '';
     $first = true;
     foreach ($_availableLanguages as $_lang) {
         $_selected = false;
         $_class = '';
         if ($first) {
             $_class = 'first';
             $first = false;
         }
         if ($_lang['L_ID'] == $this->_lang) {
             $_selected = true;
         }
         if ($_selected) {
             $content .= '<li class="languageSelector_' . $_lang['L_ID'] . '">';
         } else {
             $content .= '<li>';
         }
         if ($_selected) {
             $content .= $this->getView()->link("{$_requestURI}/lang/{$_lang['L_Suffix']}", $_lang['L_Title'], array('class' => $_class . ' selected' . " languageSelector_{$_lang['L_ID']}"));
         } else {
             if ($this->_mode == 'add') {
                 $content .= '<span class="disabled-language">' . $_lang['L_Title'] . '</span>';
             } else {
                 $content .= $this->getView()->link("{$_requestURI}/lang/{$_lang['L_Suffix']}", $_lang['L_Title'], array('class' => $_class));
             }
         }
         $content .= '</li>';
     }
     if (!empty($content)) {
         $content = "<ul id='language-switcher'>{$content}</ul>";
     }
     foreach ($this->getDecorators() as $decorator) {
         $decorator->setElement($this);
         $content = $decorator->render($content);
     }
     return $content;
 }
Exemplo n.º 12
0
 /**
  * Get langages list
  *
  * @return void
  */
 public function getlanguagesAction()
 {
     $languagesList = Cible_FunctionsGeneral::getAllLanguage();
     foreach ($languagesList as $arg => $lang) {
         foreach ($lang as $_key => $data) {
             $tmpData[$_key] = $data;
         }
         $tmp[$arg] = $tmpData;
     }
     echo json_encode($tmp);
     exit;
 }
 function addAction()
 {
     // page title
     $this->view->title = "Ajout d'un groupe d'administrateur";
     // js import
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/js/administrator.js');
     /********** ACTIONS ***********/
     $form = new FormExtranetGroup(array('baseDir' => $this->view->baseUrl()));
     $form->setDecorators(array('PrepareElements', array('ViewScript', array('viewScript' => 'administrator-group/formGroup.phtml'))));
     $returnLink = $this->view->url(array('controller' => 'administrator-group', 'action' => 'index'));
     $form->getElement('cancel')->setAttrib('onclick', 'document.location.href="' . $returnLink . '"');
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($form->isValid($formData)) {
             // validate name is unique
             $findGroup = new ExtranetGroupsIndex();
             $select = $findGroup->select()->where('EGI_Name = ?', $form->getValue('EGI_Name'));
             $findGroupData = $findGroup->fetchAll($select);
             // name is allready use
             if ($findGroupData->count() > 0) {
                 $form->getElement('EGI_Name')->addError('Un autre groupe possède déjà ce nom');
             } else {
                 // create group
                 $groupData = new ExtranetGroups();
                 $row = $groupData->createRow();
                 $row->EG_Status = $form->getValue('EG_Status');
                 $row->save();
                 $groupID = $row->EG_ID;
                 // create index group as many language in the system
                 $languages = Cible_FunctionsGeneral::getAllLanguage();
                 foreach ($languages as $language) {
                     $groupData = new ExtranetGroupsIndex();
                     $row = $groupData->createRow();
                     $row->EGI_GroupID = $groupID;
                     $row->EGI_LanguageID = $language["L_ID"];
                     $row->EGI_Name = $form->getValue('EGI_Name');
                     $row->EGI_Description = $form->getValue('EGI_Description');
                     $row->save();
                 }
                 // get pages data
                 $pagesArray = Cible_FunctionsPages::getAllPagesDetailsArray();
                 // save group pages permissions
                 if (!empty($_POST["submitSave"])) {
                     // save pages access
                     //$this->deleteGroupPagesPermissions($newInsertID);
                     $this->saveGroupPagesPermissions($groupID, $pagesArray, $_POST, "structure");
                     $this->saveGroupPagesPermissions($groupID, $pagesArray, $_POST, "data");
                     // save roles
                     //$this->deleteGroupRoles($newInsertID);
                     $this->saveGroupRoles($groupID, $_POST);
                 }
                 header("location:" . $returnLink);
             }
         }
     }
 }
Exemplo n.º 14
0
    public function __construct($options = null)
    {
        $this->_disabledDefaultActions = true;
        parent::__construct($options);
        $baseDir = $this->getView()->baseUrl();
        if (!empty($options['mode']) && $options['mode'] == 'edit') {
            $this->_mode = 'edit';
        } else {
            $this->_mode = 'add';
        }
        $langId = Zend_Registry::get('languageID');
        $this->setAttrib('id', 'accountManagement');
        //            $addressParams = array(
        //                "fieldsValue" => array(),
        //                "display"   => array(),
        //                "required" => array(),
        //            );
        // Salutation
        $salutation = new Zend_Form_Element_Select('salutation');
        $salutation->setLabel($this->getView()->getCibleText('form_label_salutation'))->setAttrib('class', 'smallSelect')->setAttrib('tabindex', '1')->setOrder(1);
        $greetings = $this->getView()->getAllSalutation();
        foreach ($greetings as $greeting) {
            $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']);
        }
        // Language
        $languages = new Zend_Form_Element_Select('language');
        $languages->setLabel($this->getView()->getCibleText('form_label_language'))->setAttrib('class', 'stdSelect')->setAttrib('tabindex', '9')->setOrder(9);
        foreach (Cible_FunctionsGeneral::getAllLanguage() as $lang) {
            $languages->addMultiOption($lang['L_ID'], $lang['L_Title']);
        }
        // FirstName
        $firstname = new Zend_Form_Element_Text('firstName');
        $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '2')->setOrder(2);
        // LastName
        $lastname = new Zend_Form_Element_Text('lastName');
        $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '3')->setOrder(3);
        // email
        $regexValidate = new Cible_Validate_Email();
        $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
        $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email');
        $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound');
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel($this->getView()->getCibleText('form_label_email'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => 'stdTextInput'))->setAttrib('tabindex', '5')->setOrder(5);
        if ($this->_mode == 'add') {
            $email->addValidator($emailNotFoundInDBValidator);
        }
        // email
        // password
        $password = new Zend_Form_Element_Password('password');
        if ($this->_mode == 'add') {
            $password->setLabel($this->getView()->getCibleText('form_label_password'));
        } else {
            $password->setLabel($this->getView()->getCibleText('form_label_newPwd'));
        }
        $password->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '6')->setRequired(true)->setOrder(6)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))));
        // password
        // password confirmation
        $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation');
        if ($this->_mode == 'add') {
            $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
        } else {
            $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmPwd'));
        }
        //                $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd'));
        $passwordConfirmation->addFilter('StripTags')->addFilter('StringTrim')->setRequired(true)->setOrder(7)->setAttrib('class', 'stdTextInput')->setAttrib('tabindex', '7')->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical'))));
        if (!empty($_POST['identification']['password'])) {
            $passwordConfirmation->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('error_message_password_isEmpty'))));
            $Identical = new Zend_Validate_Identical($_POST['identification']['password']);
            $Identical->setMessages(array('notSame' => $this->getView()->getCibleText('error_message_password_notSame')));
            $passwordConfirmation->addValidator($Identical);
        }
        // password confirmation
        // Company name
        $company = new Zend_Form_Element_Text('company');
        $company->setLabel($this->getView()->getCibleText('form_label_company'))->setRequired(false)->setAttrib('tabindex', '4')->setOrder(4)->setAttribs(array('class' => 'stdTextInput'));
        // Account number
        $account = new Zend_Form_Element_Text('accountNum');
        $account->setLabel($this->getView()->getCibleText('form_label_account'))->setRequired(true)->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setOrder(8)->setAttribs(array('class' => 'stdTextInput'))->setAttrib('tabindex', '8')->setDecorators(array('ViewHelper', 'Errors', array(array('row' => 'HtmlTag'), array('tag' => 'dd')), array('label', array('class' => 'test', 'tag' => 'dt', 'tagClass' => 'alignVertical'))));
        // Text Subscribe
        $textSubscribe = $this->getView()->getCibleText('form_label_subscribe');
        $textSubscribe = str_replace('%URL_PRIVACY_POLICY%', Cible_FunctionsPages::getPageLinkByID($this->_config->privacyPolicy->pageId), $textSubscribe);
        // Newsletter subscription
        $newsletterSubscription = new Zend_Form_Element_Checkbox('newsletterSubscription');
        $newsletterSubscription->setLabel($textSubscribe);
        if ($this->_mode == 'add') {
            $newsletterSubscription->setChecked(1);
        }
        $newsletterSubscription->setAttrib('class', 'long-text');
        $newsletterSubscription->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'subscribeNewsletter', 'class' => 'label_after_checkbox'))));
        if ($this->_mode == 'add') {
            $termsAgreement = new Zend_Form_Element_Checkbox('termsAgreement');
            $termsAgreement->setLabel(str_replace('%URL_TERMS_CONDITIONS%', Cible_FunctionsPages::getPageLinkByID($this->_config->termsAndConditions->pageId), $this->getView()->getClientText('form_label_terms_agreement')));
            $termsAgreement->setAttrib('class', 'long-text');
            $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox'))));
            $termsAgreement->setRequired(true);
            $termsAgreement->addValidator('notEmpty', true, array('messages' => array('isEmpty' => 'You must agree to the terms')));
        } else {
            $termsAgreement = new Zend_Form_Element_Hidden('termsAgreement', array('value' => 1));
        }
        // Submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submitLabel = $this->getView()->getCibleText('form_account_button_submit');
        if ($this->_mode == 'edit') {
            $submitLabel = $this->getView()->getCibleText('button_submit');
        }
        $submit->setLabel($submitLabel)->setAttrib('class', 'stdButton subscribeButton1-' . Zend_Registry::get("languageSuffix"));
        // Captcha
        // Refresh button
        $refresh_captcha = new Zend_Form_Element_Button('refresh_captcha');
        $refresh_captcha->setLabel($this->getView()->getCibleText('button_refresh_captcha'))->setAttrib('onclick', "refreshCaptcha('captcha-id')")->setAttrib('class', 'stdButton')->removeDecorator('Label')->removeDecorator('DtDdWrapper');
        $refresh_captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'dd-refresh-captcha-button'))));
        $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->getView()->getCibleText('form_label_securityCaptcha'), 'captcha' => 'Image', 'captchaOptions' => array('captcha' => 'Word', 'wordLen' => 5, 'fontSize' => 28, 'height' => 67, 'width' => 169, 'timeout' => 300, 'dotNoiseLevel' => 0, 'lineNoiseLevel' => 0, 'font' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/fonts/ARIAL.TTF", 'imgDir' => Zend_Registry::get('application_path') . "/../{$this->_config->document_root}/captcha/tmp", 'imgUrl' => "{$baseDir}/captcha/tmp")));
        $captcha->setAttrib('class', 'stdTextInputCatcha');
        $captcha->setRequired(true);
        $captcha->addDecorators(array(array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'id' => 'dd_captcha'))))->addDecorator('Label', array('class' => 'clear'));
        $french = array('badCaptcha' => 'Veuillez saisir la chaîne ci-dessus correctement.');
        $english = array('badCaptcha' => 'Captcha value is wrong');
        $translate = new Zend_Translate('array', $french, 'fr');
        $this->setTranslator($translate);
        $this->getView()->jQuery()->enable();
        $script = <<<EOS

            function refreshCaptcha(id){
                \$.getJSON('{$this->getView()->baseUrl()}/newsletter/index/captcha-reload',
                    function(data){

                        \$("dd#dd_captcha img").attr({src : data['url']});
                        \$("#"+id).attr({value: data['id']});

                });
            }

EOS;
        $this->getView()->headScript()->appendScript($script);
        // Captcha
        /*  Identification sub form */
        $identificationSub = new Cible_Form_SubForm();
        $identificationSub->setName('identification')->removeDecorator('DtDdWrapper');
        $identificationSub->setLegend($this->getView()->getCibleText('form_account_subform_identification_legend'));
        $identificationSub->setAttrib('class', 'identificationClass subFormClass');
        $identificationSub->addElement($languages);
        $identificationSub->addElement($salutation);
        $identificationSub->addElement($lastname);
        $identificationSub->addElement($firstname);
        $identificationSub->addElement($email);
        $identificationSub->addElement($password);
        $identificationSub->addElement($passwordConfirmation);
        $identificationSub->addElement($company);
        $identificationSub->addElement($account);
        $identificationSub->addDisplayGroup(array('salutation', 'firstName', 'company', 'password', 'accountNum'), 'leftColumn');
        $identificationSub->addDisplayGroup(array('lastName', 'email', 'passwordConfirmation', 'language'), 'rightColumn')->removeDecorator('DtDdWrapper');
        $leftColGroup = $identificationSub->getDisplayGroup('leftColumn');
        $rightColGroup = $identificationSub->getDisplayGroup('rightColumn');
        $leftColGroup->removeDecorator('DtDdWrapper');
        $rightColGroup->removeDecorator('DtDdWrapper');
        $this->addSubForm($identificationSub, 'identification');
        // Billing address
        $addressFacturationSub = new Cible_Form_SubForm();
        $addressFacturationSub->setName('addressFact')->removeDecorator('DtDdWrapper');
        $addressFacturationSub->setLegend($this->getView()->getCibleText('form_account_subform_addBilling_legend'));
        $addressFacturationSub->setAttrib('class', 'addresseBillingClass subFormClass');
        $billingAddr = new Cible_View_Helper_FormAddress($addressFacturationSub);
        $billingAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax'));
        $billingAddr->formAddress();
        $addrBill = new Zend_Form_Element_Hidden('addrBill');
        $addrBill->removeDecorator('label');
        $addressFacturationSub->addElement($addrBill);
        $this->addSubForm($addressFacturationSub, 'addressFact');
        /* delivery address */
        $addrShip = new Zend_Form_Element_Hidden('addrShip');
        $addrShip->removeDecorator('label');
        $addressShippingSub = new Cible_Form_SubForm();
        $addressShippingSub->setName('addressShipping')->removeDecorator('DtDdWrapper');
        $addressShippingSub->setLegend($this->getView()->getCibleText('form_account_subform_addShipping_legend'));
        $addressShippingSub->setAttrib('class', 'addresseShippingClass subFormClass');
        $shipAddr = new Cible_View_Helper_FormAddress($addressShippingSub);
        $shipAddr->duplicateAddress($addressShippingSub);
        $shipAddr->setProperty('addScriptState', false);
        $shipAddr->enableFields(array('firstAddress', 'secondAddress', 'cityTxt', 'zipCode', 'country', 'state', 'firstTel', 'secondTel', 'fax'));
        $shipAddr->formAddress();
        $addressShippingSub->addElement($addrShip);
        $this->addSubForm($addressShippingSub, 'addressShipping');
        if ($this->_mode == 'add') {
            $this->getView()->jQuery()->enable();
            $script = <<<EOS

                function refreshCaptcha(id){
                    \$.getJSON('{$this->getView()->baseUrl()}/order/index/captcha-reload',
                        function(data){
                            \$("dd#dd_captcha img").attr({src : data['url']});
                            \$("#"+id).attr({value: data['id']});
                    });
                }

EOS;
            //                $this->getView()->headScript()->appendScript($script);
            //                $this->addElement($refresh_captcha);
            //                $this->addElement($captcha);
            $this->addElement($newsletterSubscription);
            $this->addElement($termsAgreement);
        }
        $this->addElement($submit);
        $submit->setDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'account-submit'))));
        if ($this->_mode == 'add') {
            $termsAgreement->setDecorators(array('ViewHelper', array('label', array('placement' => 'append')), array(array('row' => 'HtmlTag'), array('tag' => 'dd', 'class' => 'label_after_checkbox', 'id' => 'dd-terms-agreement'))));
        }
        $captchaError = array('badCaptcha' => $this->getView()->getCibleText('validation_message_captcha_error'));
        $translate = new Zend_Translate('array', $captchaError, $this->getView()->registryGet('languageSuffix'));
        $this->setTranslator($translate);
    }
Exemplo n.º 15
0
 protected function addBlock($formData, $pageID, $moduleID)
 {
     $zone = $formData['B_ZoneID'];
     $position = $formData['B_Position'];
     $title = $formData['BI_BlockTitle'];
     $showHeader = $formData['B_ShowHeader'];
     $secured = $formData['B_Secured'];
     // create new row in block table
     $block = new Blocks();
     $row = $block->createRow();
     $row->B_PageID = $pageID;
     $row->B_ModuleID = $moduleID;
     $row->B_Position = $position;
     $row->B_Secured = $secured;
     $row->B_ZoneID = $zone;
     $row->save();
     // get the new block id
     $blockID = $row->B_ID;
     // create new row in blockindex table for each language of the website
     $Languages = Cible_FunctionsGeneral::getAllLanguage();
     foreach ($Languages as $Lang) {
         $blockIndex = new BlocksIndex();
         $rowBlockIndex = $blockIndex->createRow();
         $rowBlockIndex->BI_BlockID = $blockID;
         $rowBlockIndex->BI_LanguageID = $Lang["L_ID"];
         if ($Lang["L_ID"] == Zend_Registry::get("languageID")) {
             $rowBlockIndex->BI_BlockTitle = $title;
         } else {
             $rowBlockIndex->BI_BlockTitle = $title . "_" . $Lang["L_Suffix"];
         }
         $rowBlockIndex->save();
     }
     // update position of all block in the same page
     $db = Zend_Registry::get("db");
     $where = "(B_Position >= " . $position . ") AND B_PageID = " . $pageID . " AND B_ID <> " . $blockID . " AND B_ZoneID = " . $zone;
     $db->update('Blocks', array('B_Position' => new Zend_Db_Expr('B_Position + 1')), $where);
     return $blockID;
 }
Exemplo n.º 16
0
 public function __construct($options = null)
 {
     //        $this->_disabledDefaultActions = true;
     //        $this->_object = $options['object'];
     unset($options['object']);
     parent::__construct($options);
     $langId = 1;
     if (!empty($options['mode']) && $options['mode'] == 'edit') {
         $this->_mode = 'edit';
     }
     if (!empty($options['langId'])) {
         $langId = $options['langId'];
     }
     //        $this->getView()->headScript()->appendFile("{$this->getView()->baseUrl()}/js/jquery/jquery.maskedinput-1.2.2.min.js");
     //        // email
     $regexValidate = new Cible_Validate_Email();
     $regexValidate->setMessage($this->getView()->getCibleText('validation_message_emailAddressInvalid'), 'regexNotMatch');
     $emailNotFoundInDBValidator = new Zend_Validate_Db_NoRecordExists('GenericProfiles', 'GP_Email');
     $emailNotFoundInDBValidator->setMessage($this->getView()->getClientText('validation_message_email_already_exists'), 'recordFound');
     $email = new Zend_Form_Element_Text('GP_Email');
     $email->setLabel($this->getView()->getCibleText('form_label_email'))->addFilter('StripTags')->addFilter('StringTrim')->addFilter('StringToLower')->addValidator($regexValidate)->setAttribs(array('maxlength' => 50, 'class' => ' email stdTextInput'));
     if ($this->_mode == 'add') {
         $email->addValidator($emailNotFoundInDBValidator);
     }
     $this->addElement($email);
     if ($this->_mode == 'edit') {
         // Salutation
         $salutation = new Zend_Form_Element_Select('GP_Salutation');
         $salutation->setLabel('Salutation :')->setAttrib('class', 'largeSelect');
         $greetings = $this->getView()->getAllSalutation();
         foreach ($greetings as $greeting) {
             $salutation->addMultiOption($greeting['S_ID'], $greeting['ST_Value']);
         }
         $this->addElement($salutation);
         //FirstName
         $firstname = new Zend_Form_Element_Text('GP_FirstName');
         $firstname->setLabel($this->getView()->getCibleText('form_label_fName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('maxlength' => 20, 'class' => 'required stdTextInput'));
         $this->addElement($firstname);
         // LastName
         $lastname = new Zend_Form_Element_Text('GP_LastName');
         $lastname->setLabel($this->getView()->getCibleText('form_label_lName'))->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => $this->getView()->getCibleText('validation_message_empty_field'))))->setAttribs(array('maxlength' => 20, 'class' => 'required stdTextInput'));
         $this->addElement($lastname);
         $languages = new Zend_Form_Element_Select('GP_Language');
         $languages->setLabel($this->getView()->getCibleText('form_label_language'));
         foreach (Cible_FunctionsGeneral::getAllLanguage() as $lang) {
             $languages->addMultiOption($lang['L_ID'], $lang['L_Title']);
         }
         $this->addElement($languages);
     }
     // new password
     $password = new Zend_Form_Element_Password('GP_Password');
     $password->setLabel($this->getView()->getCibleText('form_label_newPwd'))->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setAttrib('autocomplete', 'off');
     // password confirmation
     $passwordConfirmation = new Zend_Form_Element_Password('passwordConfirmation');
     $passwordConfirmation->setLabel($this->getView()->getCibleText('form_label_confirmNewPwd'))->addFilter('StripTags')->addFilter('StringTrim')->setAttrib('class', 'stdTextInput')->setAttrib('autocomplete', 'off');
     if (Zend_Registry::get('pwdOn')) {
         $this->addElement($password);
         $this->addElement($passwordConfirmation);
     }
     $this->setAttrib('id', 'genericProfile');
 }