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
 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 #3
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 #4
0
 /**
  * Render form HTML and trigger t41.view.form() JS object
  * @see \t41\View\SimpleComponent\WebDefault::render()
  */
 public function render()
 {
     View::addCoreLib(array('style.css', 'buttons.css', 'sprites.css'));
     View::addCoreLib(array('core.js', 'view.js', 'view:form.js', 'view:alert.js'));
     // cache object and create its client-side js counterpart
     $reduced = $this->_obj->getSource()->reduce();
     $this->_id = $this->_obj->getId() ? $this->_obj->getId() : 't41_' . md5(time());
     View::addCoreLib(array('buttons.css', 'sprites.css'));
     View::addEvent(sprintf("t41.view.register('%s', new t41.view.form('%s',%s,%s))", $this->_id, $this->_id, \Zend_Json::encode($reduced), \Zend_Json::encode($this->_obj->reduce())), 'js');
     return $this->_headerRendering() . $this->_contentRendering() . $this->_footerRendering();
 }
Example #5
0
 public function render()
 {
     View::addCoreLib('style.css');
     $html = '';
     foreach ($this->_obj->getMenu()->getItems() as $moduleKey => $module) {
         $menu = '';
         foreach ($module->getItems() as $item) {
             $menu .= $this->_renderMenu($item, $moduleKey);
         }
         if ($menu) {
             // top level menu
             $html .= sprintf('<ul><li class="head" data-help="%s"><a class="head">%s</a><div class="drop">%s</div></li></ul>', $this->_escape($module->getHelp()), $this->_escape($module->getLabel()), $menu);
         }
     }
     return '<div class="t41 component menu">' . "\n" . $html . "</div>\n";
 }
Example #6
0
 public function render()
 {
     if (($value = $this->_obj->getValue()) !== false) {
         if (($value instanceof ObjectModel\BaseObject || $value instanceof ObjectModel\DataObject) && $value->getUri()) {
             $value = $this->_obj->getParameter('altkey') ? $value->getProperty($this->_obj->getParameter('altkey'))->getValue() : $value->getUri()->getIdentifier();
         } else {
             if ($value instanceof ObjectModel\ObjectUri) {
                 $value = $value->getIdentifier();
             } else {
                 $value = null;
             }
         }
     }
     $name = $this->_obj->getId();
     // set correct name for field name value depending on 'mode' parameter value
     if ($this->getParameter('mode') == View\FormComponent::SEARCH_MODE) {
         $name = ViewUri::getUriAdapter()->getIdentifier('search') . '[' . $name . ']';
     }
     View::addCoreLib(array('core.js', 'locale.js', 'view.js', 'view:table.js', 'view:action:autocomplete.js'));
     $acfield = new View\FormComponent\Element\FieldElement('_' . $this->_nametoDomId($name));
     $acfield->setValue($value);
     $action = new AutocompleteAction($this->_obj->getCollection());
     $objsearchprops = $this->_obj->getParameter('search') ? $this->_obj->getParameter('search') : $this->_obj->getParameter('display');
     $action->setParameter('searchprops', explode(',', $this->getParameter('searchprops') ? $this->getParameter('searchprops') : $objsearchprops));
     $action->setParameter('searchmode', $this->getParameter('searchmode'));
     $action->setParameter('display', explode(',', $this->_obj->getParameter('display')));
     $action->setParameter('sdisplay', explode(',', $this->_obj->getParameter('sdisplay') ? $this->_obj->getParameter('sdisplay') : $this->_obj->getParameter('display')));
     $action->setParameter('event', 'keyup');
     // if a list of properties to be returned exists, pass it to the action
     if ($this->getParameter('retprops')) {
         $action->setParameter('member_reduce_params', array('props' => explode(',', $this->getParameter('retprops'))));
     }
     $action->setContextData('onclick', 't41.view.element.autocomplete.close');
     $action->setContextData('target', $this->_nametoDomId($name));
     $action->bind($acfield);
     $deco = View\Decorator::factory($acfield);
     $html = $deco->render();
     $deco = View\Decorator::factory($action);
     $deco->render();
     $html .= sprintf('<input type="hidden" name="%s" id="%s" value="%s"/>', $name, $this->_nametoDomId($name), $value);
     return $html . "\n";
 }
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()
 {
     View::addCoreLib(array('style.css', 'buttons.css', 'sprites.css'));
     View::addCoreLib(array('core.js', 'view.js', 'view:alert.js'));
     // @todo temp fix, sorting by headers is only available on page refresh
     if ($this->getParameter('paginator') == false) {
         $this->setParameter('sortable', false);
     }
     // set relevant uri adapter and get some identifiers
     /* @var $_uriAdapter t41\View\ViewUri\AbstractAdapter */
     if (!ViewUri::getUriAdapter() instanceof ViewUri\Adapter\GetAdapter) {
         $tmp = explode('?', $_SERVER['REQUEST_URI']);
         $this->_uriAdapter = new ViewUri\Adapter\GetAdapter($tmp[0]);
     } else {
         $this->_uriAdapter = ViewUri::getUriAdapter();
     }
     $this->_offsetIdentifier = $this->_uriAdapter->getIdentifier('offset');
     $this->_sortIdentifier = $this->_uriAdapter->getIdentifier('sort');
     $this->_searchIdentifier = $this->_uriAdapter->getIdentifier('search');
     $this->_env = $this->_uriAdapter->getEnv();
     if (!$this->_obj->getCollection() instanceof StatsCollection) {
         $this->_obj->query($this->_uriAdapter);
     }
     $tmp = $this->_obj->reduce();
     $this->_uuid = $tmp['uuid'];
     $p = '';
     $p = $this->_headerRendering();
     $p .= sprintf('<table class="t41 list" id="%s">', $this->getId());
     $p .= $this->_headlineRendering();
     $p .= $this->_contentRendering();
     $p .= '</table>';
     // inject extra content
     $p .= '<div class="actions">' . parent::_contentRendering() . '</div>';
     if ($this->getParameter('paginator') !== false) {
         $p .= $this->_footerRendering();
     } else {
         $p .= '</div></div>';
     }
     return $p;
 }
Example #9
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 #10
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 #11
0
 public function _contentRendering()
 {
     $p = '<fieldset>';
     foreach ($this->_obj->getColumns() as $key => $element) {
         $field = $element;
         $p .= '<span class="field">';
         $p .= sprintf('<span class="label"><label for="%s[%s]">%s</label></span>', $this->_searchIdentifier, $field->getId(), $field->getTitle() ? $field->getTitle() : 'ID');
         // get current field value from env
         if (isset($this->_env[$this->_searchIdentifier][$field->getId()])) {
             $field->setValue($this->_env[$this->_searchIdentifier][$field->getId()]);
         }
         // Reset default value to empty
         $field->setDefaultValue('');
         $data = isset($this->_env[$this->_searchIdentifier]) ? $this->_env[$this->_searchIdentifier] : null;
         $deco = Decorator::factory($field, array('mode' => FormComponent::SEARCH_MODE, 'data' => $data));
         $p .= '&nbsp;' . $deco->render();
         $p .= '</span>';
     }
     if ($this->_obj->getParameter('buttons') != false) {
         View::addCoreLib(array('buttons.css', 'sprites.css'));
         $p .= sprintf('<div class="clear"><a class="element button medium icon" onclick="jQuery(\'#t41sf\').submit()"><span class="search-blue"></span>Rechercher</a>' . '<a class="element button medium icon" onclick="jQuery(\'#t41sf\').find(\':input\').each(function() {jQuery(this).val(null)})"><span class="refresh"></span>RAZ</a></div>', $this->_obj->getParameter('baseurl'));
     }
     $p .= '</fieldset></form>';
     return $p;
 }
Example #12
0
 public function render()
 {
     // add CSS libraries
     View::addCoreLib(array('sprites.css', 'buttons.css'));
     $extraHtml = array();
     $class = explode(' ', $this->getParameter('css'));
     if ($this->getParameter('nolabel') != true) {
         $class[] = 'button';
     }
     if ($this->getParameter('size')) {
         $class[] = $this->getParameter('size');
     }
     if ($this->getParameter('color')) {
         $class[] = $this->getParameter('color');
     }
     /* bind optional action to button */
     if ($this->_obj->getAction()) {
         $this->_bindAction($this->_obj->getAction());
     } else {
         if ($this->_obj->getLink()) {
             $link = $this->_obj->getLink();
             $uri = $this->_obj->getParameter('uri');
             if ($uri instanceof ObjectUri && substr($link, 0, 1) == '/') {
                 $link .= '/id/' . rawurlencode($uri->getIdentifier());
             }
             if (substr($link, 0, 4) == 't41.') {
                 $extraHtml[] = sprintf("onclick=\"%s\"", $link);
             } else {
                 $extraHtml[] = sprintf("onclick=\"t41.view.link('%s', jQuery('#%s'))\"", $link, $this->getId());
             }
         } else {
             $data = $this->getParameter('data');
             $adapter = ViewUri::getUriAdapter();
             $args = array();
             foreach ((array) $this->_obj->getParameter('identifiers') as $key => $identifier) {
                 $identifierKey = is_numeric($key) ? $identifier : $key;
                 $args[$identifierKey] = $data[$identifier];
             }
             $onclick = "document.location='" . "/";
             //$this->_obj->getUri();
             $onclick .= count($args) > 0 ? $adapter->makeUri($args, true) . "'" : "'";
         }
     }
     if ($this->_obj->getParameter('disabled')) {
         $class[] = 'disabled';
     }
     if ($this->getParameter('pairs')) {
         foreach ($this->getParameter('pairs') as $key => $val) {
             $extraHtml[] = sprintf('%s="%s"', $key, $val);
         }
     }
     if ($this->getParameter('icon')) {
         $class[] = 'icon';
     }
     $value = $this->getParameter('nolabel') ? '' : $this->_escape($this->_obj->getTitle());
     foreach ((array) $this->getParameter('data') as $key => $val) {
         $extraHtml[] = sprintf('data-%s="%s"', $key, $val);
     }
     $html = sprintf('<a class="%s" id="%s" data-help="%s" %s><span class="%s"></span>%s</a>', implode(' ', $class), $this->_id, '', implode(' ', $extraHtml), $this->getParameter('icon') ? $this->getParameter('icon') : null, $value);
     return $html;
 }
Example #13
0
 public function render()
 {
     View::addCoreLib('style.css');
     return $this->_headerRendering() . $this->_contentRendering() . $this->_footerRendering();
 }
Example #14
0
 public function init()
 {
     parent::init();
     View::addRequiredLib('http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', 'js');
     View::addCoreLib('core.js');
 }