public function init()
 {
     // Init form
     $this->setTitle('Profile Information');
     $this->setIsCreation(true)->setItem(Engine_Api::_()->user()->getUser(null));
     parent::init();
 }
Exemple #2
0
 public function init()
 {
     // Init form
     $this->setTitle('Profile Information');
     $this->setIsCreation(true)->setItem(Engine_Api::_()->user()->getUser(null));
     parent::init();
     $countriesAssoc = Engine_Api::_()->getDbTable('locations', 'user')->getLocationsAssoc(0);
     $countriesAssoc = array('0' => '') + $countriesAssoc;
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $provincesAssoc = array();
     $country_id = $request->getParam('country_id', 0);
     if ($country_id) {
         $provincesAssoc = Engine_Api::_()->getDbTable('locations', 'user')->getLocationsAssoc($country_id);
         $provincesAssoc = array('0' => '') + $provincesAssoc;
     }
     $this->addElement('Select', 'country_id', array('label' => 'Country', 'multiOptions' => $countriesAssoc, 'value' => $country_id));
     $citiesAssoc = array();
     $province_id = $request->getParam('province_id', 0);
     if ($province_id) {
         $citiesAssoc = Engine_Api::_()->getDbTable('locations', 'user')->getLocationsAssoc($province_id);
         $citiesAssoc = array('0' => '') + $citiesAssoc;
     }
     $this->addElement('Select', 'province_id', array('label' => 'Province/State', 'multiOptions' => $provincesAssoc, 'value' => $province_id));
     $city_id = $request->getParam('city_id', 0);
     $this->addElement('Select', 'city_id', array('label' => 'City', 'multiOptions' => $citiesAssoc, 'value' => $city_id));
     $continent = '';
     $country = Engine_Api::_()->getItem('user_location', $country_id);
     if ($country) {
         $continent = $country->getContinent();
     }
     $this->addElement('Text', 'continent', array('label' => 'Continent', 'value' => $continent, 'disabled' => true));
 }
Exemple #3
0
 public function init()
 {
     // custom classified fields
     if (!$this->_item) {
         $group = new Advgroup_Model_Group(array());
         $this->setItem($group);
     }
     parent::init();
     $this->removeElement('submit');
 }
Exemple #4
0
 public function init()
 {
     // custom classified fields
     if (!$this->_item) {
         $review = new Ynmember_Model_Review(array());
         $this->setItem($review);
     }
     parent::init();
     $this->removeElement('submit');
 }
Exemple #5
0
 public function init()
 {
     // custom classified fields
     if (!$this->_item) {
         $event = new Ynevent_Model_Event(array());
         $this->setItem($event);
     }
     parent::init();
     $this->removeElement('submit');
 }
Exemple #6
0
 public function init()
 {
     // custom classified fields
     if (empty($this->_item)) {
         $idea = new Ynfeedback_Model_Idea(array());
         $this->setItem($idea);
     }
     parent::init();
     $this->removeElement('submit');
 }
Exemple #7
0
 public function init()
 {
     // custom classified fields
     if (!$this->_item) {
         $classified_item = new Classified_Model_Classified(array());
         $this->setItem($classified_item);
     }
     parent::init();
     $this->removeElement('submit');
 }
Exemple #8
0
 public function init()
 {
     parent::init();
     $this->removeElement('submit');
 }
Exemple #9
0
 public function generate()
 {
     // get the search structure
     $structure = Engine_Api::_()->getApi('core', 'fields')->getFieldsStructureSearch($this->_fieldType, $this->_topLevelId, $this->_topLevelValue);
     $globalOrderIndex = 100;
     $normalOrderIndex = 1000;
     // Start firing away
     foreach ($structure as $map) {
         $field = $map->getChild();
         // Ignore fields not searchable (even though getFieldsStructureSearch should have skipped it already)
         if (!$field->search) {
             continue;
         }
         $isGlobal = $map->field_id == 0 || $field->search == 2 || $map->field_id == $this->_topLevelId && $map->option_id == $this->_topLevelValue;
         // Get search key
         $key = null;
         if (!empty($field->alias)) {
             $key = $field->alias;
         } else {
             $key = sprintf('field_%d', $field->field_id);
         }
         // Get params
         $params = $field->getElementParams($this->_fieldType, array('required' => false));
         // Add attribs
         if (!@is_array($params['options']['attribs'])) {
             $params['options']['attribs'] = array();
         }
         $params['options']['attribs']['class'] = 'field_toggle' . ' ' . 'parent_' . $map->field_id . ' ' . 'option_' . $map->option_id . ' ' . 'field_' . $map->child_id . ' ';
         if ($isGlobal) {
             $params['options']['attribs']['class'] .= ' field_toggle_nohide';
         }
         $params['options']['attribs']['onchange'] = 'changeFields();';
         //$params['options']['attribs']['id'] = $map->getKey();
         // Remove some stuff
         unset($params['options']['required']);
         unset($params['options']['allowEmpty']);
         unset($params['options']['validators']);
         // Change decorators
         $params['options']['decorators'] = array('ViewHelper', array('Label', array('tag' => 'span')), array('HtmlTag', array('tag' => 'li', 'style' => !$isGlobal ? 'display:none;' : '')));
         // Change order
         if ($isGlobal) {
             $params['options']['order'] = $globalOrderIndex++;
         } else {
             $params['options']['order'] = $normalOrderIndex++;
         }
         // Get generic type
         $info = Engine_Api::_()->fields()->getFieldInfo($field->type);
         $genericType = null;
         if (!empty($info['base'])) {
             $genericType = $info['base'];
         } else {
             $genericType = $field->type;
         }
         $params['type'] = $genericType;
         // For now
         // Hack birthdate->age
         if ($field->type == 'birthdate') {
             $params['type'] = 'Select';
             $params['options']['label'] = Zend_Registry::get('Zend_Translate')->translate('Age');
             $params['options']['disableTranslator'] = true;
             $multiOptions = array('' => ' ');
             $min_age = 13;
             if (isset($field->config['min_age'])) {
                 $min_age = $field->config['min_age'];
             }
             for ($i = $min_age; $i <= 100; $i++) {
                 $multiOptions[$i] = $i;
             }
             $params['options']['multiOptions'] = $multiOptions;
         }
         // Populate country multiOptions
         if ($field->type == 'country') {
             $locale = Zend_Registry::get('Locale');
             $territories = Zend_Locale::getTranslationList('territory', $locale, 2);
             asort($territories);
             // fixes #1279
             $params['options']['multiOptions'] = array_merge(array('' => ''), $territories);
         }
         // Ignored fields (these are hard-coded)
         if (in_array($field->type, array('profile_type', 'first_name', 'last_name'))) {
             continue;
         }
         // Hacks
         switch ($genericType) {
             // Ranges
             case 'date':
             case 'int':
             case 'integer':
             case 'float':
                 // Use subform
                 $subform = new Zend_Form_SubForm(array('description' => $params['options']['label'], 'order' => $params['options']['order'], 'decorators' => array('FormElements', array('Description', array('placement' => 'PREPEND', 'tag' => 'span')), array('HtmlTag', array('tag' => 'li', 'class' => 'browse-range-wrapper', 'style' => !$isGlobal ? 'display:none;' : '')))));
                 Fields_Form_Standard::enableForm($subform);
                 Engine_Form::enableForm($subform);
                 unset($params['options']['label']);
                 unset($params['options']['order']);
                 $params['options']['decorators'] = array('ViewHelper');
                 $subform->addElement($params['type'], 'min', $params['options']);
                 $subform->addElement($params['type'], 'max', $params['options']);
                 $this->addSubForm($subform, $key);
                 break;
                 // Select types
             // Select types
             case 'select':
             case 'radio':
             case 'multiselect':
             case 'multi_checkbox':
                 // Ignore if there is only one/zero option?
                 if (count(@$params['options']['multiOptions']) <= 1 && isset($params['options']['multiOptions'][''])) {
                     continue;
                 } else {
                     if (count(@$params['options']['multiOptions']) <= 0) {
                         continue;
                     }
                 }
                 $this->addElement(Engine_Api::_()->fields()->inflectFieldType($params['type']), $key, $params['options']);
                 break;
                 // Checkbox
             // Checkbox
             case 'checkbox':
                 $params['options']['uncheckedValue'] = null;
                 $params['options']['decorators'] = array('ViewHelper', array('Label', array('placement' => 'APPEND', 'tag' => 'label')), array('HtmlTag', array('tag' => 'li', 'class' => 'browse-range-wrapper', 'style' => !$isGlobal ? 'display:none;' : '')));
                 $this->addElement($params['type'], $key, $params['options']);
                 break;
                 // Normal
             // Normal
             default:
                 $this->addElement($params['type'], $key, $params['options']);
                 break;
         }
         $element = $this->{$key};
         //$element = $this->getElement($key);
         $this->_fieldElements[$key] = $element;
     }
     // Add a separators?
     $this->addElement('Heading', 'separator1', array('order' => $globalOrderIndex++, 'decorators' => array('ViewHelper', array('Label', array('tag' => 'span')), array('HtmlTag', array('tag' => 'li', 'class' => 'browse-separator-wrapper')))));
     $this->addElement('Heading', 'separator2', array('order' => $normalOrderIndex++, 'decorators' => array('ViewHelper', array('Label', array('tag' => 'span')), array('HtmlTag', array('tag' => 'li', 'class' => 'browse-separator-wrapper')))));
 }
Exemple #10
0
 public function init()
 {
     $this->setIsCreation(true)->setItem(Engine_Api::_()->user()->getUser(null));
     parent::init();
 }