Пример #1
0
 /**
  *
  * @param String $offerType 'resources' or 'researches'
  * @param array  $items
  * @param int    $range OPTIONAL (default=0: only offers on own planet)
  */
 public function __construct($offerType = 'resources', $items, $range = 0)
 {
     if (empty($offerType)) {
         return false;
     }
     parent::__construct('offerType-' . $offerType);
     $this->setAttribute('method', 'post');
     $this->setAttribute('name', 'newOfferForm');
     if ($offerType == 'resources') {
         $this->setAttribute('action', '/trade/add-resource-offer');
     } else {
         $this->setAttribute('action', '/trade/add-research-offer');
     }
     $this->add(array('type' => 'hidden', 'name' => 'form_name', 'attributes' => array('value' => 'new_offer')));
     $this->add(array('type' => 'hidden', 'name' => 'item_type', 'attributes' => array('value' => $offerType)));
     $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'direction', 'options' => array('id' => 'direction', 'value_options' => array(0 => 'i search', 1 => 'i sell'))));
     $this->add(array('type' => 'text', 'name' => 'amount', 'options' => array(), 'attributes' => array('id' => 'amount', 'class' => 'input-small', 'placeholder' => 'units')));
     $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'item_id', 'options' => array('id' => 'item_id', 'value_options' => $this->getSelectOptions($items))));
     $options = array();
     for ($i = 0; $i <= $range; $i++) {
         if ($i < 2) {
             $options[$i] = $i == 1 ? "in this system" : "on this planet";
         } else {
             $options[$i] = $i . " Systeme";
         }
     }
     $this->add(array('type' => 'text', 'name' => 'price', 'options' => array(), 'attributes' => array('id' => 'price', 'class' => 'input-small', 'placeholder' => 'price per unit')));
     # distance = $range * $system_size
     #        $this->add(array(
     #            'type' => 'Zend\Form\Element\Select',
     #            'name' => 'range',
     #            'options' => array(
     #                'id' => 'range',
     #                'value_options' => $options,
     #            )
     #        ));
     #        $this->add(array(
     #            'type' => 'Zend\Form\Element\Select',
     #            'name' => 'restriction',
     #            'options' => array(
     #                'id' => 'restriction',
     #                #'label' => 'restriction'
     #                'value_options' => array(
     #                    0 => 'no restriction',
     #                    1 => 'only my group',
     #                    2 => 'only my faction',
     #                    3 => 'only my race',
     #                )
     #             ),
     #//             'attributes' => array(
     #//                 'disabled' => 'disabled'
     #//             )
     #        ));
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'create offer', 'class' => 'btn btn-primary')));
 }
Пример #2
0
 /**
  * @param String $search  Search item type
  * @param array  $items   Items to fill select options
  * @param int    $range   OPTIONAL (default=0: only offers on own planet)
  */
 public function __construct($search = 'resources', $items, $range = 0)
 {
     if (empty($search)) {
         return false;
     }
     parent::__construct('search-' . $search);
     $this->setAttribute('method', 'post');
     $this->setAttribute('name', 'searchForm');
     $this->add(array('type' => 'hidden', 'name' => 'form_name', 'attributes' => array('value' => 'search')));
     $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'direction', 'options' => array('id' => 'direction', 'value_options' => array(1 => 'i search', 0 => 'i sell'))));
     $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'item_id', 'options' => array('id' => 'item_id', 'value_options' => $this->getSelectOptions($items), 'empty_option' => 'all'), 'attributes' => array('value' => '0')));
     $options = array();
     for ($i = 0; $i <= $range; $i++) {
         if ($i < 2) {
             $options[$i] = $i == 1 ? "in this system" : "on this planet";
         } else {
             $options[$i] = $i . " Systeme";
         }
     }
     # distance = $range * $system_size
     $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'range', 'options' => array('id' => 'range', 'value_options' => $options)));
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'send', 'class' => 'btn btn-primary')));
 }