Example #1
0
 public function render()
 {
     View::addCoreLib(array('style.css', 'view:alert.js'));
     $params = array('title' => $this->_obj->getTitle(), 'level' => 'error', 'buttons' => array('confirm' => true), 'labels' => array('confirm' => "Afficher mes livraisons"), 'callbacks' => array('confirm' => "document.location.replace('/livraisons/livraison/validation')"));
     $event = sprintf('new t41.view.alert("%s",%s)', implode('<br/>', $this->_obj->getContent()), \Zend_Json::encode($params));
     View::addEvent($event, 'js');
 }
Example #2
0
 protected function _renderField($name, $value = null, $prefix = null, $boundaries = true)
 {
     $id = str_replace(array('[', ']'), array('_', ''), $name);
     $dispField = 'disp_' . $id;
     $pickerArgs = array('dateFormat' => 'dd/mm/yy', 'firstDay' => 1, 'changeYear' => true, 'changeMonth' => true, 'altField' => '#' . $id, 'altFormat' => 'yy-mm-dd', 'monthNames' => array('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'), 'monthNamesShort' => array('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Aoû', 'Sept', 'Oct', 'Nov', 'Déc'), 'dayNames' => array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'), 'dayNamesMin' => array('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'));
     if ($boundaries) {
         if (is_numeric($this->_obj->getConstraint(Property::CONSTRAINT_DATEMIN))) {
             $pickerArgs['minDate'] = $this->_obj->getConstraint(Property::CONSTRAINT_DATEMIN);
         }
         if (is_numeric($this->_obj->getConstraint(Property::CONSTRAINT_DATEMAX))) {
             $pickerArgs['maxDate'] = (string) $this->_obj->getConstraint(Property::CONSTRAINT_DATEMAX);
         }
     }
     View::addEvent(sprintf('jQuery(function() { jQuery("#%s").datepicker(%s); });', $dispField, \Zend_Json::encode($pickerArgs)), 'js');
     $html = sprintf('%s<input type="hidden" name="%s" id="%s" value="%s"/>', $prefix ? htmlspecialchars($prefix) . '&nbsp;' : null, $name, $id, $value);
     $dispValue = $value ? $this->_obj->formatValue($value, (bool) $this->getParameter(Property::CONSTRAINT_PROTECTED)) : null;
     $html .= sprintf('<input type="text" id="%s" value="%s" size="10" maxlength="10" readonly="readonly" style="color:grey;"/>', $dispField, $dispValue);
     if ($this->_obj->getParameter('enable_quickset') && $this->getParameter('mode') != View\FormComponent::SEARCH_MODE) {
         $buttons = array(array('title' => 'Hier', 'value' => '-1', 'icon' => 'left-arrow'), array('title' => 'Aujourd\'hui', 'value' => '+0d', 'icon' => 'valid'), array('title' => 'Demain', 'value' => '+1', 'icon' => 'right-arrow'));
         foreach ($buttons as $k => $v) {
             $html .= sprintf('<a class="element small icon" title="%s" href="javascript:" onclick="jQuery(\'#%s\').datepicker(\'setDate\', \'%s\'); return false;"><span class="%s"></span></a>', $v['title'], $dispField, $v['value'], $v['icon']);
         }
     }
     return $html;
 }
Example #3
0
 public function render()
 {
     /* bind optional action to field */
     if ($this->_obj->getAction()) {
         $this->_bindAction($this->_obj->getAction());
         View::addEvent(sprintf("jQuery('#%s').focus()", $this->_id), 'js');
     }
     $name = $this->getId();
     if ($this->getParameter('mode') == View\FormComponent::SEARCH_MODE) {
         $name = ViewUri::getUriAdapter()->getIdentifier('search') . '[' . $this->_nametoDomId($name) . ']';
     }
     $extraArgs = '';
     if ($this->getParameter('args')) {
         foreach ($this->getParameter('args') as $argKey => $argVal) {
             $extraArgs .= sprintf(' %s="%s"', $argKey, $argVal);
         }
     }
     $size = $this->getParameter('length');
     $max = $this->_obj->getConstraint(Property::CONSTRAINT_MAXLENGTH);
     if ($this->_obj->getValue()) {
         $html = sprintf('<input type="text" name="%s" id="%s" placeholder="%s" size="%s"%s value="********"%s/>', $name, $this->_obj->getId(), $this->_obj->getHelp(), $max > $size || $max == 0 ? $size : $max, $max ? ' maxlength="' . $max . '"' : null, $extraArgs);
         $html .= sprintf(' <a href="#" onclick="jQuery(\'#%s\').val(\'%s\').focus();this.remove()">Regénérer</a>', $this->_obj->getId(), self::password());
     } else {
         $html = sprintf('<input type="text" name="%s" id="%s" placeholder="%s" size="%s"%s value="%s"%s/>', $name, $this->_obj->getId(), $this->_obj->getHelp(), $max > $size || $max == 0 ? $size : $max, $max ? ' maxlength="' . $max . '"' : null, $this->_obj->getValue(), $extraArgs);
     }
     $this->addConstraintObserver(array(Property::CONSTRAINT_UPPERCASE, Property::CONSTRAINT_LOWERCASE));
     return $html;
 }
Example #4
0
 public function render()
 {
     View::addCoreLib(array('view:table2.js', 'view:action:autocomplete.js'));
     $id = $this->_nametoDomId($this->_obj->getBoundObject()->getId());
     $event = sprintf("t41.view.register('%s', new t41.view.action.autocomplete(%s,'%s'))", $id, \Zend_Json::encode($this->_obj->reduce(array('params' => array(), 'collections' => 1))), $id);
     View::addEvent($event, 'js');
     View::addEvent(sprintf("t41.view.get('%s').init()", $id), 'js');
 }
Example #5
0
 public function render()
 {
     View::addCoreLib(array('view:action:upload.js'));
     $id = $this->_nametoDomId($this->_obj->getId());
     $event = sprintf("t41.view.registry['%s'] = new t41.view.action.uploader(%s,'%s')", $this->_obj->getId(), \Zend_Json::encode($this->_obj->reduce(array('params' => array()))), $this->_obj->getObject()->getId());
     View::addEvent($event, 'js');
     View::addEvent(sprintf("t41.view.registry['%s'].init()", $id), 'js');
 }
Example #6
0
 protected function _contentRendering()
 {
     $p = '<fieldset id="form_fields">';
     $p .= '<legend></legend>';
     $altDecorators = (array) $this->_obj->getParameter('decorators');
     /* @var $val t41_View_Element_Abstract */
     foreach ($this->_obj->getColumns() as $key => $element) {
         $field = $element;
         /* hidden fields treatment */
         if ($element->getConstraint(Element\AbstractElement::CONSTRAINT_HIDDEN) === true) {
             $p .= sprintf('<input type="hidden" name="%s" id="%s" value="%s" />', $field->getAltId(), $field->getAltId(), $field->getValue());
             continue;
         }
         if (!isset($focus) && $element instanceof Element\FieldElement) {
             View::addEvent(sprintf("jQuery('#%s').focus()", $element->getAltId()), 'js');
             $focus = $element;
         }
         $label = '&nbsp;';
         $label = $this->_escape($element->getTitle());
         if ($element->getConstraint(Property::CONSTRAINT_MANDATORY) == true) {
             $class = ' mandatory';
             $mandatory = ' mandatory';
         } else {
             $class = '';
             $mandatory = '';
         }
         $line = sprintf('<div class="clear"></div><div id="label_%s" class="label%s"><label for="%s" data-help="%s">%s</label></div>', $field->getAltId(), $class, $field->getAltId(), $field->getHelp(), $label);
         // value is already defined and can't be changed
         if ($field->getConstraint(Property::CONSTRAINT_PROTECTED) == true && $field->getValue()) {
             if (!is_object($field->getValue()) || $field->getValue() instanceof BaseObject && $field->getValue()->getUri()) {
                 $p .= $line . '<div class="field">' . $field->formatValue($field->getValue()) . '</div>';
                 continue;
             }
         }
         /* look for a required decorator */
         if (isset($altDecorators[$element->getId()])) {
             $element->setDecorator($altDecorators[$element->getId()]);
         }
         $deco = View\Decorator::factory($element);
         $line .= sprintf('<div class="field" id="elem_%s">%s</div>', $element->getId(), $deco->render());
         $p .= $line . "\n";
     }
     $p .= '</fieldset>';
     return $p;
 }
Example #7
0
 public function render()
 {
     /* bind optional action to field */
     if ($this->_obj->getAction()) {
         $this->_bindAction($this->_obj->getAction());
         View::addEvent(sprintf("jQuery('#%s').focus()", $this->_id), 'js');
     }
     $name = $this->getId();
     if ($this->getParameter('mode') == View\FormComponent::SEARCH_MODE) {
         $name = ViewUri::getUriAdapter()->getIdentifier('search') . '[' . $this->_nametoDomId($name) . ']';
     }
     $html = sprintf('<input type="hidden" name="%s" id="%s" value="%s"/>', $name, $this->_obj->getId(), $this->_obj->getValue());
     $zv = new \Zend_View();
     $options = array(null => $this->getParameter('defaultlabel')) + $this->_obj->getEnumValues(TimeProperty::HOUR_PART);
     $html .= $zv->formSelect($name . '_hour', $this->_obj->getValue(TimeProperty::HOUR_PART), null, $options);
     $options = array(null => $this->getParameter('defaultlabel')) + $this->_obj->getEnumValues(TimeProperty::MIN_PART);
     $html .= ' : ' . $zv->formSelect($name . '_minute', $this->_obj->getValue(TimeProperty::MIN_PART), null, $options);
     View::addCoreLib('view:form.js');
     View::addEvent(sprintf("new t41.view.form.timeElement('%s')", $this->_obj->getId()), 'js');
     return $html;
 }
Example #8
0
 public function render()
 {
     /* bind optional action to field */
     if ($this->_obj->getAction()) {
         $this->_bindAction($this->_obj->getAction());
         View::addEvent(sprintf("jQuery('#%s').focus()", $this->_id), 'js');
     }
     $name = $this->getId();
     $value = explode('.', $this->_obj->getValue());
     if ($this->getParameter('mode') == View\FormComponent::SEARCH_MODE) {
         $name = ViewUri::getUriAdapter()->getIdentifier('search') . '[' . $this->_nametoDomId($name) . ']';
     }
     $html = sprintf('<input type="hidden" name="%s" id="%s" value="%s"/>', $name, $this->_obj->getId(), $this->_obj->getValue());
     $html .= sprintf('<input type="text" id="%s_number" size="3" maxlength="4"/>', $this->_obj->getId());
     $options = array('2' => 'Bis', '3' => 'Ter', '4' => 'Quater', 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D');
     $options = array(null => $this->getParameter('defaultlabel')) + $options;
     $zv = new \Zend_View();
     $html .= $zv->formSelect(null, null, array('id' => $this->_obj->getId() . '_ext'), $options);
     View::addCoreLib('view:form.js');
     View::addEvent(sprintf("new t41.view.form.streetNumber('%s')", $this->_obj->getId()), 'js');
     return $html;
 }
Example #9
0
 public function render()
 {
     // set correct name for field name value depending on 'mode' parameter value
     $name = $this->_obj->getId();
     $prefix = Core::getController('medias');
     if (!$prefix) {
         $prefix = '/t41/medias/';
     }
     $uri = $prefix . 'upload';
     View::addCoreLib(array('core.js', 'locale.js', 'view.js', 'uploader.css', 'view:action:upload.js'));
     View::addEvent(sprintf("t41.view.register('%s_ul', new t41.view.action.upload(jQuery('#%s_ul'),'%s'))", $name, $name, $uri), 'js');
     $html = '';
     // @todo code media deletion JS
     if ($this->_obj->getValue() != null) {
         $html .= sprintf('<span><a href="%s" target="_blank">%s %s</a> | <a href="#" onclick="t41.view.get(\'%s_ul\').reset(this)">%s</a></span>', MediaElement::getDownloadUrl($this->_obj->getValue()->getUri()), 'Télécharger', $this->_obj->getValue()->getLabel(), $name, 'Supprimer');
     }
     $html .= sprintf('<div id="%s_ul" class="qq-upload-list"></div>', $this->_nametoDomId($name));
     $html .= sprintf('<input type="hidden" name="%s" id="%s" value="%s" class="hiddenfilename"/>', $name, $this->_nametoDomId($name), $this->_obj->getValue() ? $this->_obj->getValue()->getIdentifier() : null);
     return $html;
     $action = new UploadAction($this->_obj);
     $deco = View\Decorator::factory($action);
     $deco->render();
     return $html . "\n";
 }
Example #10
0
 /**
  * Add a Javascript observer and a callback function to the element if the given constraint is setted
  * @param string $constraints
  */
 protected function addConstraintObserver($constraints)
 {
     $constraints = (array) $constraints;
     foreach ($constraints as $constraint) {
         if (!$this->_obj->getConstraint($constraint)) {
             continue;
         }
         switch ($constraint) {
             case Property::CONSTRAINT_UPPERCASE:
                 View::addEvent(sprintf("t41.view.bindLocal('%s','blur', function() { var f = jQuery('#%s'); f.val(f.val().toUpperCase())})", $this->getId(), $this->getId()), 'js');
                 break;
             case Property::CONSTRAINT_LOWERCASE:
                 View::addEvent(sprintf("t41.view.bindLocal('%s','blur', function() { var f = jQuery('#%s'); f.val(f.val().toLowerCase())})", $this->getId(), $this->getId()), 'js');
                 break;
             case Property::CONSTRAINT_URLSCHEME:
                 break;
             case Property::CONSTRAINT_EMAILADDRESS:
                 break;
         }
     }
 }
Example #11
0
 protected function _headlineRendering()
 {
     $sort = null;
     // build header line
     $line = '<tr>';
     $sortIdentifiers = isset($this->_env[$this->_sortIdentifier]) && is_array($this->_env[$this->_sortIdentifier]) ? $this->_env[$this->_sortIdentifier] : array();
     if ($this->_obj->getParameter('selectable') !== false) {
         $cbid = 'toggler_' . $this->_id;
         $line .= sprintf('<td><input type="checkbox" id="%s"/></td>', $cbid);
         View::addEvent(sprintf('t41.view.bindLocal(jQuery("#%s"), "change", function() { t=jQuery("#%s").attr("checked");jQuery("#%s").find(\':checkbox[id=""]\').each(function(i,o){o.checked=t});})', $cbid, $cbid, $this->_id), 'js');
     }
     foreach ($this->_obj->getColumns() as $val) {
         $line .= sprintf('<th class="tb-%s"><strong>', $val->getId());
         if ($val->getParameter('sortable') == false) {
             $line .= $this->_escape($val->getTitle()) . '</strong></th>';
             continue;
         }
         if (is_object($val) && array_key_exists($val->getId(), $sortIdentifiers)) {
             $by = $sortIdentifiers[$val->getId()] == 'ASC' ? 'DESC' : 'ASC';
             // save correct sorting field reference to re-inject in uri after column construction
             // @todo think twice ! this is crappy as hell!
             $sort = array($val->getId(), $sortIdentifiers[$val->getId()]);
         } else {
             $by = 'ASC';
         }
         if (is_object($val)) {
             $this->_uriAdapter->setArgument($val->getId(), $by, $this->_sortIdentifier);
         }
         $line .= sprintf('<a href="%s">%s</a></strong></th>', $this->_uriAdapter->makeUri(), $this->_escape($val->getTitle()));
         $this->_uriAdapter->unsetArgument(null, $this->_sortIdentifier);
     }
     if (is_array($sort)) {
         $this->_uriAdapter->setArgument($sort[0], $sort[1], $this->_sortIdentifier);
     }
     if (count($this->_obj->getEvents('row')) > 0) {
         $line .= '<th class="tb-actions">&nbsp;</th>';
     } else {
         $line .= '<th class="tb-actions">&nbsp;</th>';
     }
     return $line . "</tr>\n";
 }