Example #1
0
 public function addCSRFElement($name, $value)
 {
     $csrf = new \Zend\Form\Element\Hidden($name);
     $csrf->setValue($value);
     $this->form->add($csrf);
     return $this;
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     //Form Attribute
     $this->setName("my-form")->setAttribute("action", "#")->setAttributes(array("enctype" => "multipart/form-data", "class" => "my-form", "novalidate" => "true"));
     //hidden
     $hidden = new \Zend\Form\Element\Hidden("my-hidden");
     $hidden->setValue("123456");
     $this->add($hidden);
     //radio
     // $radio = new \Zend\Form\Element\Radio("my-radio");
     // $radio->setLabel("language")
     // 	   ->setValue("vi")
     // 	   ->setValueOptions(array(
     // 	   		"vi"=>"Vietnam",
     // 	   		"en"=>"English",
     // 	   		"jp"=>"Japan"
     // 	   	));
     // $this->add($radio);
     $this->add(array("name" => "my-radio", "type" => "radio", "attributes" => array("value" => "jp"), "options" => array("value_options" => array("vi" => "Vietnam", "en" => "English", "jp" => "Japan"), "label" => "language")));
     //selecbox
     // $select = new \Zend\Form\Element\Select("my-select");
     // $select->setLabel("List course")
     // 	   ->setEmptyOption("Please choose a course")
     // 	   ->setValue("ci")
     // 	   ->setValueOptions(array(
     // 	   		"Web" => array(
     // 	   			"label" => "web",
     // 	   			"options" => array(
     // 					"zend"   =>"Framework Zend 2",
     // 					"ci"     =>"Framework CodeIgniter",
     // 					"jquery" =>"Lập trình jQuery master"
     // 				)
     // 			),
     // 			"Mobile" => array(
     // 				"label" => "mobile",
     // 				"options" => array(
     // 					"ios"     => "Lập trình IOS",
     // 					"android" => "Lập trình Android"
     // 				)
     // 			)
     // 	   	));
     // $this->add($select);
     $this->add(array("name" => "my-select", "type" => "select", "attributes" => array(), "options" => array("value_options" => array("Web" => array("label" => "web", "options" => array("zend" => "Framework Zend 2", "ci" => "Framework CodeIgniter", "jquery" => "Lập trình jQuery master")), "Mobile" => array("label" => "mobile", "options" => array("ios" => "Lập trình IOS", "android" => "Lập trình Android"))), "label" => "List course", "empty_option" => "Please choose a course")));
     //submit
     $this->add(array("type" => "submit", "name" => "my-submit", "attributes" => array("value" => "Gửi")));
 }
 public function __invoke($entries, $mediasTable = array(), $mediaInUse = array())
 {
     if (empty($entries)) {
         $html = '<p>' . $this->view->translate('No documents or images found') . '</p>';
     } else {
         $url = 'http://' . $this->view->host . '/mcwork/medias/download/';
         $disablefolder = $this->view->disablefolder;
         if (!is_array($disablefolder)) {
             $disablefolder = array('_alternate');
         }
         $cddownload = '';
         if ($this->view->currentFolder) {
             $cddownload = str_replace(DS, $this->view->seperator, $this->view->currentFolder);
         }
         $tableFactory = new HtmlTable(new FactoryTable());
         $tableFactory->setAttributes('class', 'mcworkBackendTable table display');
         $i = 0;
         $iClass = 0;
         $headlines = array('#' => array(), 'Filename' => array('body' => array('class' => 'filename')), 'Size' => array('head' => array('class' => 'hide-for-small text-right'), 'body' => array('class' => 'hide-for-small text-right')), 'Date' => array('head' => array('class' => 'hide-for-small text-right'), 'body' => array('class' => 'hide-for-small text-right')), '&nbsp;' => array('head' => array('class' => 'cellToolbar'), 'body' => array('class' => 'cellToolbar')));
         $ihead = count($headlines);
         foreach ($headlines as $column => $attributes) {
             $columns[] = $this->view->translate($column);
             if (is_array($attributes) && !empty($attributes)) {
                 foreach ($attributes as $area => $attribute) {
                     switch ($area) {
                         case 'head':
                             $tableFactory->setHeadlineAttributtes('class', $attribute['class'], $i);
                             break;
                         case 'body':
                             $tableFactory->setTagAttributtes('class', $attribute['class'], $i);
                             break;
                         default:
                             break;
                     }
                 }
             }
             $i++;
         }
         $tableFactory->setHeadline($columns);
         $i = 0;
         if (null != $this->view->currentFolder) {
             foreach ($entries as $entry) {
                 if ('..' == $entry->filename) {
                     $i++;
                     $rowContent = array();
                     $rowContent[] = '&nbsp;';
                     $up = '';
                     if ($this->view->currentFolder) {
                         $array = explode(DS, $this->view->currentFolder);
                         if (null != array_pop($array)) {
                             $up = implode($this->view->seperator, $array);
                         }
                     }
                     $rowContent[] = '<a href="' . self::MEDIA_DIR_PATH . '/' . $up . '" class="small button"><i class="fa fa-arrow-up"></i></a>';
                     $rowContent[] = '&nbsp;';
                     $rowContent[] = '&nbsp;';
                     $rowContent[] = '&nbsp;';
                     $tableFactory->setHtmlContent($rowContent);
                     break;
                 }
             }
         }
         foreach ($entries as $entry) {
             if ('.' != $entry->filename && '..' != $entry->filename && !in_array($entry->filename, $disablefolder) && 'dir' == $entry->type) {
                 $i++;
                 $rowContent = array();
                 $dataAttribInUse = 'data-inuse="0"';
                 $label = '';
                 $keys = preg_grep('/' . $entry->filename . '/', array_keys($mediasTable));
                 foreach ($keys as $values) {
                     if (!empty($mediaInUse) && isset($mediaInUse[$mediasTable[$values]['id']])) {
                         $label = ' <sup><i class="fa fa-asterisk alizarin-color"></i></sup>';
                         $dataAttribInUse = 'data-inuse="1"';
                         break;
                     }
                 }
                 $numberItems = $label . $this->numbersItems($entry->counts);
                 if (true == $entry->childs && strlen($numberItems) > 0) {
                     $dataAttribChilds = ' data-childs="yes"';
                     $icon = '<i class="fa fa-folder-open"></i>';
                 } else {
                     $dataAttribChilds = ' data-childs="no"';
                     $icon = '<i class="fa fa-folder"></i>';
                 }
                 $rowContent[] = '<input type="checkbox" value="' . $entry->filename . '" name="cb[]" data-type="dir" ' . $dataAttribInUse . $dataAttribChilds . '>';
                 $down = $entry->filename;
                 if ($this->view->currentFolder) {
                     $down = $this->view->currentFolder . DS . $entry->filename;
                 }
                 $rowContent[] = '<a href="' . self::MEDIA_DIR_PATH . '/' . str_replace(DS, $this->view->seperator, $down) . '">' . $icon . ' ' . $entry->filename . '</a>' . $numberItems;
                 $rowContent[] = '&nbsp;';
                 $rowContent[] = date("d.m.Y H:i:s", $entry->time);
                 $btn = '<button class="tbl-info tiny" data-time="' . date("d.m.Y H:i:s", $entry->time) . '" ';
                 $btn .= $dataAttribInUse . ' ';
                 $btn .= 'data-ident="folder" ';
                 if (true == $entry->childs && strlen($numberItems) > 0) {
                     $btn .= 'data-childs="y" ';
                 } else {
                     $btn .= 'data-childs="n" ';
                 }
                 $btn .= 'data-originalname="' . $entry->filename . '" ';
                 $btn .= 'data-crypt="' . $entry->filename . '" data-name="' . $entry->filename . '" ';
                 $btn .= 'data-type="dir" type="button"><i class="fa fa-gear"></i></button>';
                 $rowContent[] = $btn;
                 $tableFactory->setHtmlContent($rowContent);
             }
         }
         foreach ($entries as $entry) {
             if ('.' != $entry->filename && '..' != $entry->filename && 'file' == $entry->type && 'index.html' != $entry->filename) {
                 $i++;
                 $rowContent = array();
                 $label = '';
                 $pathname = \ContentinumComponents\Path\Clean::get($entry->pathname);
                 $compareItem = str_replace($this->view->docroot, '', $pathname);
                 if (isset($mediasTable[$compareItem]['id']) && isset($mediaInUse[$mediasTable[$compareItem]['id']])) {
                     $label = ' <sup><i class="fa fa-asterisk alizarin-color"></i></sup>';
                     $dataAttribInUse = 'data-inuse="1"';
                 } else {
                     $dataAttribInUse = 'data-inuse="0"';
                 }
                 $dataIdent = '';
                 if (isset($mediasTable[$compareItem]) && isset($mediasTable[$compareItem]['id'])) {
                     $dataIdent = 'data-ident="' . $mediasTable[$compareItem]['id'] . '" ';
                 }
                 $rowContent[] = '<input type="checkbox" value="' . $entry->filename . '" name="cb[]" data-type="file" ' . $dataIdent . $dataAttribInUse . '>';
                 switch ($entry->mimetype) {
                     case 'application/zip':
                         $icon = '<i class="fa fa-archive"></i> ';
                         break;
                     case 'image/jpeg':
                         $icon = '<i class="fa fa-picture-o"></i> ';
                         break;
                     default:
                         $icon = '<i class="fa fa-file"></i> ';
                 }
                 switch ($entry->extension) {
                     case 'wmv':
                     case 'mp4':
                     case 'ogv':
                     case 'webm':
                         $icon = '<i class="fa-film"></i> ';
                         break;
                     case 'jpeg':
                     case 'jpg':
                     case 'png':
                     case 'JPG':
                     case 'JPEG':
                         $icon = '<i class="fa fa-picture-o"></i> ';
                         break;
                     default:
                 }
                 $rowContent[] = $icon . $entry->filename . $label;
                 $size = '';
                 if ($entry->width && $entry->height) {
                     $size = '(' . $entry->width . ' x ' . $entry->height . ' px) ';
                 }
                 $filesize = $this->view->filesize($entry->size);
                 $rowContent[] = $size . $filesize;
                 $rowContent[] = date("d.m.Y H:i:s", $entry->time);
                 $btn = '<button class="tbl-info tiny" data-time="' . date("d.m.Y H:i:s", $entry->time) . '" ';
                 $btn .= $dataIdent;
                 if (isset($mediasTable[$compareItem]) && isset($mediasTable[$compareItem]['mediaName'])) {
                     $btn .= 'data-originalname="' . $mediasTable[$compareItem]['mediaName'] . '" ';
                 }
                 $btn .= $dataAttribInUse . ' ';
                 $btn .= 'data-size="' . $filesize . '" ';
                 $btn .= 'data-crypt="' . $entry->filename . '" data-name="' . $entry->filename . '" ';
                 $btn .= 'data-link="' . $pathname . '" ';
                 $btn .= 'data-childs="file" ';
                 $btn .= 'data-download="' . $url . $entry->filename . '/' . $cddownload . '" ';
                 $btn .= 'data-type="' . $entry->mimetype . '" type="button"><i class="fa fa-gear"></i></button>';
                 $rowContent[] = $btn;
                 $tableFactory->setHtmlContent($rowContent);
             }
         }
         $html = $tableFactory->display();
         $element = new \Zend\Form\Element\Hidden('current-folder');
         $element->setAttribute('id', 'current-folder');
         if ($this->view->currentFolder) {
             $element->setValue($this->view->currentFolder);
         }
         $html .= $this->view->formhidden($element);
     }
     return $html;
 }
 protected function getDeleteForm(Paginator $paginator, $data = [])
 {
     $sl = $this->getServiceLocator();
     $form = $sl->get('FormElementManager')->get('Account\\Form\\ListForm');
     $form->setName('accountbatchdelform');
     $form->remove('submit')->addConfirm();
     if ($paginator->count() > 0) {
         // Batch Form
         foreach ($paginator as $entity) {
             $hdn = new \Zend\Form\Element\Hidden("sel[" . $entity->getId() . "]");
             $hdn->setValue('1');
             $form->add($hdn);
         }
     }
     if ($data) {
         $form->setData($data);
         if (!$form->isValid()) {
             $form->setData(array());
         }
     }
     return $form;
 }
Example #5
0
 private function getFormAntennaModel($id)
 {
     $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $datas = array();
     $form = null;
     if ($id) {
         $antenna = $objectManager->getRepository('Application\\Entity\\Antenna')->find($id);
         if ($antenna) {
             $datas['antenna'] = $antenna;
             $qb = $objectManager->createQueryBuilder();
             $qb->select(array('p', 'c'))->from('Application\\Entity\\PredefinedEvent', 'p')->leftJoin('p.category', 'c')->andWhere('c INSTANCE OF Application\\Entity\\AntennaCategory');
             $models = array();
             foreach ($qb->getQuery()->getResult() as $model) {
                 foreach ($model->getCustomFieldsValues() as $value) {
                     if ($value->getCustomField()->getID() == $model->getCategory()->getAntennaField()->getId()) {
                         if ($value->getValue() == $id) {
                             $models[] = $model;
                         }
                     }
                 }
             }
             $form = new \Zend\Form\Form("model");
             $hidden = new \Zend\Form\Element\Hidden("id");
             $hidden->setValue($id);
             $form->add($hidden);
             $select = new \Zend\Form\Element\Select("models");
             $optionsModels = array();
             foreach ($models as $model) {
                 $optionsModels[$model->getId()] = $model->getName();
             }
             $select->setValueOptions($optionsModels);
             if (count($optionsModels) == 0) {
                 $select->setEmptyOption("Aucun modèle à associer");
             } else {
                 $select->setEmptyOption("Choisir le modèle à associer.");
             }
             $select->setLabel("Modèle : ");
             $form->add($select);
             $datas['form'] = $form;
         }
     }
     return $datas;
 }