/** * (non-PHPdoc) * @see \Simplify\Form\Element::onRender() */ public function onRender(\Simplify\Form\Action $action, $data, $index) { $params = array('formAction' => 'services', 'serviceName' => $this->getName(), 'serviceAction' => 'toggle', \Simplify\Form::ID => $data[\Simplify\Form::ID]); $this->set('ajaxUrl', \Simplify\URL::make(null, $params)->format(\Simplify\URL::JSON)); $this->set('jsName', str_replace(array('[', ']'), array('\\\\[', '\\\\]'), $this->getInputName($index) . '[]')); $this->set('useAjax', $action->show(\Simplify\Form::ACTION_LIST)); return parent::onRender($action, $data, $index); }
/** * (non-PHPdoc) * * @see \Simplify\Form\Action::onCreateItemMenu() */ public function onCreateItemMenu(Menu $menu, Action $action, $data) { if (!$action->show(Form::ACTION_CREATE) && !$action->show(Form::ACTION_EDIT)) { $url = $this->editUrl($data); $item = new MenuItem($this->getName(), $this->getTitle(), Form::ICON_EDIT, $url); $menu->getItemByName('main')->addItem($item); } }
/** * (non-PHPdoc) * * @see \Simplify\Form\Action::onCreateItemMenu() */ public function onCreateItemMenu(\Simplify\Menu $menu, \Simplify\Form\Action $action, $data) { if (!$action->show(\Simplify\Form::ACTION_CREATE)) { $url = $this->form->url()->extend(); $url->set('formAction', $this->getName()); $url->set(Form::ID, $data[Form::ID]); $item = new \Simplify\MenuItem($this->getName(), $this->getTitle(), Form::ICON_DELETE, $url); $menu->getItemByName('main')->addItem($item); } }
/** * (non-PHPdoc) * @see \Simplify\Form\Element::onRenderHeaders() */ public function onRenderHeaders(\Simplify\Form\Action $action, &$headers) { if ($action->show(\Simplify\Form::ACTION_LIST)) { $elements = $this->getElements($action); while ($elements->valid()) { $element = $elements->current(); $element->onRenderHeaders($action, $headers); $elements->next(); } } else { $headers[$this->getName()] = $this->getLabel(); } }
/** * (non-PHPdoc) * @see \Simplify\Form\Element::onRenderControls() */ public function onRenderControls(\Simplify\Form\Action $action, &$line, $data, $index) { $element = array(); if ($this->matchOriginal) { $label = __('Current password'); } else { $label = $action->show(\Simplify\Form::ACTION_CREATE) || $this->exists === false ? __('Senha') : __('Nova senha'); } $this->set('inputNameSufix', '[a]'); $element['id'] = $this->getElementId($index); $element['name'] = $this->getInputName($index); $element['class'] = $this->getElementClass(); $element['label'] = $label; $element['controls'] = $this->onRender($action, $data, $index)->render(); $element['state'] = $this->state; $element['stateMessage'] = $this->stateMessage; $line['elements'][$this->getName() . '_a'] = $element; if ($this->askForConfirmation) { $element = array(); $this->set('inputNameSufix', '[b]'); $element['id'] = $this->getElementId($index); $element['name'] = $this->getInputName($index); $element['class'] = $this->getElementClass(); $element['label'] = __('Confirmação de senha'); $element['controls'] = $this->onRender($action, $data, $index)->render(); $element['state'] = $this->state; $line['elements'][$this->getName() . '_b'] = $element; } }
/** * (non-PHPdoc) * @see \Simplify\Form::onCreateItemMenu() */ public function onCreateItemMenu(\Simplify\Menu $menu, \Simplify\Form\Action $action, $data) { if ($action->show(\Simplify\Form::ACTION_LIST)) { $moveMenu = new \Simplify\Menu('move', null, __('Mover')); $moveMenu->addItem(new \Simplify\MenuItem('move-first', __('Para o começo'), 'fast-backward', $this->url()->extend(null, array('listAction' => self::LIST_ACTION_SORT, 'index' => 'first', \Simplify\Form::ID => $data[\Simplify\Form::ID])))); $moveMenu->addItem(new \Simplify\MenuItem('move-previous', __('Para cima'), 'backward', $this->url()->extend(null, array('listAction' => self::LIST_ACTION_SORT, 'index' => 'previous', \Simplify\Form::ID => $data[\Simplify\Form::ID])))); $moveMenu->addItem(new \Simplify\MenuItem('move-next', __('Para baixo'), 'forward', $this->url()->extend(null, array('listAction' => self::LIST_ACTION_SORT, 'index' => 'next', \Simplify\Form::ID => $data[\Simplify\Form::ID])))); $moveMenu->addItem(new \Simplify\MenuItem('move-last', __('Para o fim'), 'fast-forward', $this->url()->extend(null, array('listAction' => self::LIST_ACTION_SORT, 'index' => 'last', \Simplify\Form::ID => $data[\Simplify\Form::ID])))); $moveItem = new \Simplify\MenuItem('move', __('Mover'), null, null, $moveMenu); $menu->addItem(new \Simplify\Menu('sortable', array($moveItem), __('Mover'))); //$menu->addItem($moveMenu); } parent::onCreateItemMenu($menu, $action, $data); }
/** * (non-PHPdoc) * * @see Simplify\Form\Action::onRender() */ public function onRender() { $elements = $this->getElements(); $headers = array(); foreach ($elements as $element) { $element->onRenderHeaders($this, $headers); } $data = array(); foreach ($this->formData as $index => $row) { $line = new \ArrayObject(); $line[Form::ID] = $row[Form::ID]; $line['name'] = Form::ID . "[]"; $line['menu'] = new Menu('actions'); $line['menu']->addItem(new Menu('main')); //$line['state'] = Form::STATE_WARNING; $line['elements'] = array(); $elements->rewind(); while ($elements->valid()) { $element = $elements->current(); $elements->next(); $element->onRenderLine($this, $line, $row, $index); } $this->form->onCreateItemMenu($line['menu'], $this, $row); $this->form->dispatch('onRenderListRow', $this, $line, $row); $data[] = $line; } $bulk = array(); $this->form->onCreateBulkOptions($bulk); $this->set('headers', $headers); $this->set('data', $data); $this->set('pager', $this->pager); $this->set('bulk', $bulk); return parent::onRender(); }
/** * * @param \Simplify\Form\Action $action * @return \Simplify\Form\Element[] */ public function getElements(Action $action = null) { return new ElementIterator($this->elements, $action ? $action->getActionMask() : Form::ACTION_ALL); }
public function onRender(\Simplify\Form\Action $action) { $data = $action->get('data'); foreach ($data as &$row) { if (sy_get_param($row, \Simplify\Form::ID) == 1) { $row['elements']['groups']['label'] = __('Grupos'); $row['elements']['groups']['controls'] = '<p class="form-control-static">' . __('Este usuário pertence a todos os grupos') . '</p>'; $row['elements']['permissions']['label'] = __('Permissões'); $row['elements']['permissions']['controls'] = '<p class="form-control-static">' . __('Este usuário tem todas as permissões') . '</p>'; } } $action->set('data', $data); }
/** * (non-PHPdoc) * * @see \Simplify\Form::onCreateItemMenu() */ public function onCreateItemMenu(\Simplify\Menu $menu, \Simplify\Form\Action $action, $data) { if ($action->show(\Simplify\Form::ACTION_LIST)) { $children = new \Simplify\MenuItem('children', __('Filhos'), 'folder-open', $this->url()->extend(null, array($this->repository()->parent => $data[\Simplify\Form::ID]))); $moveMenu = new \Simplify\Menu('mptt'); $moveMenu->addItem(new \Simplify\MenuItem('move_top', __('Primeiro'), 'arrow_top', $this->url()->extend(null, array('listAction' => self::LIST_ACTION_SORT, 'index' => 'first', \Simplify\Form::ID => $data[\Simplify\Form::ID])))); $moveMenu->addItem(new \Simplify\MenuItem('move_up', __('Anterior'), 'arrow_up', $this->url()->extend(null, array('listAction' => self::LIST_ACTION_SORT, 'index' => 'previous', \Simplify\Form::ID => $data[\Simplify\Form::ID])))); $moveMenu->addItem(new \Simplify\MenuItem('move_down', __('Próximo'), 'arrow_down', $this->url()->extend(null, array('listAction' => self::LIST_ACTION_SORT, 'index' => 'next', \Simplify\Form::ID => $data[\Simplify\Form::ID])))); $moveMenu->addItem(new \Simplify\MenuItem('move_bottom', __('Último'), 'arrow_bottom', $this->url()->extend(null, array('listAction' => self::LIST_ACTION_SORT, 'index' => 'last', \Simplify\Form::ID => $data[\Simplify\Form::ID])))); $moveItem = new \Simplify\MenuItem('move', 'Move', null, null, $moveMenu); $menu->addItem(new \Simplify\Menu('mptt', array($moveItem, $children))); } parent::onCreateItemMenu($menu, $action, $data); }
/** * (non-PHPdoc) * @see \Simplify\Form\Action::jsonSerialize() */ public function jsonSerialize() { $data = parent::jsonSerialize(); foreach ($data['data'] as $i => $row) { $data['meta'][$i]['actions']['edit'] = $this->editUrl($row)->build(); } $data['actions']['create'] = $this->createUrl()->build(); return $data; }
protected function onLoadData() { $calendarAction = \Simplify::request()->get('calendarAction'); switch ($calendarAction) { case 'create': $this->formData = array(array(Form::ID => null)); break; default: parent::onLoadData(); } }
/** * (non-PHPdoc) * * @see Simplify\Form\Action::onRender() */ public function onRender() { $elements = $this->getElements(); $headers = array(); foreach ($elements as $element) { $element->onRenderHeaders($this, $headers); } $caption = $this->getCaptionElement(); $image = $this->getImageElement(); /* * if (! $caption) { * throw new \Exception(__('A galeria necessita de um campo de tipo texto')); * } */ if (!$image) { throw new \Exception(__('A galeria necessita de um campo de tipo imagem')); } $data = array(); foreach ($this->formData as $index => $row) { $line = array(); $line[Form::ID] = $row[Form::ID]; $line['name'] = Form::ID . "[]"; $line['menu'] = new Menu('actions'); $line['menu']->addItem(new Menu('main')); $line['caption'] = $caption ? $caption->getDisplayValue($this, $row, $index) : false; $imageFile = $image->getValue($row); $line['imageUrl'] = $image->getImageUrl($imageFile); $line['thumbUrl'] = $image->getThumbUrl($imageFile, 340, 340); $line['elements'] = array(); $elements->rewind(); while ($elements->valid()) { $element = $elements->current(); $elements->next(); $element->onRenderLine($this, $line, $row, $index); } $this->form->onCreateItemMenu($line['menu'], $this, $row); $data[] = $line; } $bulk = array(); $this->form->onCreateBulkOptions($bulk); $this->set('data', $data); $this->set('bulk', $bulk); return parent::onRender(); }
/** * (non-PHPdoc) * @see \Simplify\Form\Action::onRender() */ public function onRender() { $elements = $this->getElements(); $data = array(); $line = array(); $line['name'] = \Simplify\Form::ID . "[]"; $line[\Simplify\Form::ID] = null; $line['elements'] = array(); while ($elements->valid()) { $element = $elements->current(); $line['index'] = $element->getName(); //$line['menu'] = new \Simplify\Menu('actions'); //$line['menu']->addItem(new \Simplify\Menu('main')); $element->onRenderControls($this, $line, $this->formData[$element->getName()]['data'], $element->getName()); $elements->next(); } //$this->form->onCreateItemMenu($line['menu'], $this, null); $data[] = $line; $this->set('data', $data); return parent::onRender(); }
/** * On validate callback. * * @param Action $action * current action * @param array $data * form data */ public function onValidate(Action $action, $data) { if ($this->unique && $action->show($this->unique)) { $unique = $this->getError('unique', __('Valor duplicado')); $rule = new \Simplify\Form\Validation\Unique($unique, $this, sy_get_param($data, $this->form->getPrimaryKey())); $rule->validate($this->getValue($data)); } }
/** * (non-PHPdoc) * * @see \Simplify\Form\Action::onCreateItemMenu() */ public function onCreateItemMenu(Menu $menu, Action $action, $data) { if (!$action->show(Form::ACTION_VIEW)) { $url = $this->form->url()->extend(null, array('formAction' => $this->getName(), Form::ID => $data[Form::ID])); $menu->getItemByName('main')->addItem(new MenuItem($this->getName(), $this->getTitle(), 'search', $url)); } }
/** * * @return \Simplify\Form\ElementIterator */ public function getElements(\Simplify\Form\Action $action) { return new \Simplify\Form\ElementIterator($this->elements, $action->getActionMask()); }