public function testBuildForm()
 {
     $this->helper->setAttachmentsForm(new AttachmentsForm());
     $this->helper->buildForm(array());
     $this->assertInstanceOf('\\ModelModule\\Model\\Attachments\\AttachmentsForm', $this->helper->getAttachmentsForm());
 }
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $lang = $this->params()->fromRoute('lang');
     $moduleCode = $this->params()->fromRoute('module');
     $referenceId = $this->params()->fromRoute('referenceId');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $userDetails = $this->layout()->getVariable('userDetails');
     try {
         $helper = new AttachmentsFormControllerHelper();
         $helper->setModulesGetterWrapper(new ModulesGetterWrapper(new ModulesGetter($em)));
         $helper->setupModuleRecords($moduleCode);
         $helper->setAttachmentsGetterWrapper(new AttachmentsGetterWrapper(new AttachmentsGetter($em)));
         $helper->setupAttachmentsRecords(array('moduleId' => ModulesContainer::recoverIdFromModuleCode($moduleCode), 'referenceId' => $referenceId, 'orderBy' => 'a.position'));
         $helper->setModuleCode($moduleCode);
         $helper->checkModuleRecords();
         $helper->setupPropertiesGetterClassPath();
         $helper->setupPropertiesGetterClassInstance();
         $helper->getPropertiesGetterClassInstance()->setModuleCode($moduleCode);
         $helper->getPropertiesGetterClassInstance()->setEntityManager($em);
         $helper->getPropertiesGetterClassInstance()->setAttachmentsReferenceId($referenceId);
         $helper->getPropertiesGetterClassInstance()->setupProperties();
         if ($moduleCode == 'albo-pretorio') {
             $alboRettificaColumnDisplay = 1;
         }
         if ($moduleCode == 'atti-concessione') {
             $attiConcessioneColumnDisplayForm = new AttiConcessioneColumnDisplayForm();
             $attiConcessioneColumnDisplayForm->addSubmitButton();
         }
         $this->layout()->setVariables(array('hideBreadcrumb' => 1, 'attachmentsList' => $helper->getAttachmentRecords(), 'articleTitle' => $helper->getPropertiesGetterClassInstance()->getAttachmentFormTitle(), 'attachmentType' => $helper->getModuleCode(), 'moduleCode' => $moduleCode, 'referenceId' => $referenceId, 'formBreadCrumbCategory' => $helper->getPropertiesGetterClassInstance()->getBreadcrumbModule(), 'formBreadCrumbCategoryLink' => $this->url()->fromRoute($helper->getPropertiesGetterClassInstance()->getBreadcrumbRoute(), array('lang' => $lang, 'languageSelection' => $lang, 'modulename' => $moduleCode)), 'alboRettificaColumnDisplay' => isset($alboRettificaColumnDisplay) ? $alboRettificaColumnDisplay : null, 'attiConcessioneCatColumnDisplay' => isset($attiConcessioneColumnDisplayForm) ? 1 : null, 'attiConcessioneColumnDisplayForm' => isset($attiConcessioneColumnDisplayForm) ? $attiConcessioneColumnDisplayForm : null, 'templatePartial' => 'attachments/attachments-summary.phtml'));
     } catch (NullException $e) {
         $this->layout()->setVariables(array('templatePartial' => 'message.phtml', 'messageType' => 'danger', 'messageTitle' => 'Si è verificato un errore', 'messageText' => $e->getMessage()));
     }
     $this->layout()->setTemplate($mainLayout);
 }
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $lang = $this->params()->fromRoute('lang');
     $moduleCode = $this->params()->fromRoute('module');
     $referenceId = $this->params()->fromRoute('referenceId');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     try {
         $helper = new AttachmentsFormControllerHelper();
         $helper->setModulesGetterWrapper(new ModulesGetterWrapper(new ModulesGetter($em)));
         $helper->setupModuleRecords($moduleCode);
         $helper->setAttachmentsGetterWrapper(new AttachmentsGetterWrapper(new AttachmentsGetter($em)));
         $helper->setupAttachmentsRecords(array('moduleId' => $moduleCode, 'referenceId' => $referenceId, 'orderBy' => 'a.position'));
         $helper->setModuleCode($moduleCode);
         $helper->checkModuleRecords();
         $helper->setupPropertiesGetterClassPath();
         $helper->setupPropertiesGetterClassInstance();
         $helper->getPropertiesGetterClassInstance()->setModuleCode($moduleCode);
         $helper->getPropertiesGetterClassInstance()->setEntityManager($em);
         $helper->getPropertiesGetterClassInstance()->setAttachmentsReferenceId($referenceId);
         $helper->getPropertiesGetterClassInstance()->setupProperties();
         $attachmentRecord = $helper->getAttachmentRecords();
         if (empty($attachmentRecord)) {
             throw new NullException("Nessun file allegato trovato");
         }
         $this->layout()->setVariables(array('attachmentsList' => $helper->getAttachmentRecords(), 'articleTitle' => $helper->getPropertiesGetterClassInstance()->getAttachmentFormTitle(), 'attachmentType' => $helper->getModuleCode(), 'moduleCode' => $moduleCode, 'referenceId' => $referenceId, 'formBreadCrumbCategory' => $helper->getPropertiesGetterClassInstance()->getBreadcrumbModule(), 'formBreadCrumbCategoryLink' => $this->url()->fromRoute($helper->getPropertiesGetterClassInstance()->getBreadcrumbRoute(), array('lang' => $lang)), 'records' => $attachmentRecord, 'templatePartial' => 'attachments/attachments-positions.phtml'));
     } catch (NullException $e) {
         $this->layout()->setVariables(array('templatePartial' => 'message.phtml', 'messageType' => 'danger', 'messageTitle' => 'Si è verificato un errore', 'messageText' => $e->getMessage()));
     }
     $this->layout()->setTemplate($mainLayout);
 }
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $lang = $this->params()->fromRoute('lang');
     $languageSelection = $this->params()->fromRoute('languageSelection');
     $moduleCode = $this->params()->fromRoute('module');
     $referenceId = $this->params()->fromRoute('referenceId');
     $attachmentId = $this->params()->fromRoute('attachmentId');
     try {
         if (!function_exists('curl_version')) {
             throw new NullException("L'estensione PHP CURL non è installata nel server in uso");
         }
         $helper = new AttachmentsFormControllerHelper();
         $helper->setModulesGetterWrapper(new ModulesGetterWrapper(new ModulesGetter($em)));
         $helper->setupModuleRecords($moduleCode);
         $helper->setAttachmentsGetterWrapper(new AttachmentsGetterWrapper(new AttachmentsGetter($em)));
         if ($attachmentId) {
             $helper->setupAttachmentsRecords(array('moduleId' => $moduleCode, 'referenceId' => $referenceId, 'status' => 1, 'attachmentId' => $attachmentId));
         }
         $helper->setModuleCode($moduleCode);
         $helper->checkModuleRecords();
         $helper->setupPropertiesGetterClassPath();
         $helper->setupPropertiesGetterClassInstance();
         $helper->getPropertiesGetterClassInstance()->setModuleCode($moduleCode);
         $helper->getPropertiesGetterClassInstance()->setEntityManager($em);
         $helper->getPropertiesGetterClassInstance()->setAttachmentsReferenceId($referenceId);
         $helper->getPropertiesGetterClassInstance()->setupProperties();
         $helper->setAttachmentsForm(new AttachmentsForm());
         $helper->buildForm($helper->getAttachmentRecords());
         $formBasicInput = array('userId' => $this->layout()->getVariable('userDetails')->id, 'referenceId' => $referenceId, 'moduleId' => $helper->recoverModuleId(), 's3_directory' => $moduleCode);
         $attachmentRecord = $helper->getAttachmentRecords();
         if (!empty($attachmentRecord)) {
             $formAction = $this->url()->fromRoute('admin/attachments-update', array('lang' => $lang, 'languageSelection' => $languageSelection, 'modulename' => $moduleCode));
             $formInput = array_merge($formBasicInput, $attachmentRecord[0]);
             $formTitle = 'Modifica allegato';
         } else {
             $formAction = $this->url()->fromRoute('admin/attachments-insert', array('lang' => $lang, 'languageSelection' => $languageSelection, 'modulename' => $moduleCode));
             $formInput = $formBasicInput;
             $formTitle = 'Nuovo allegato';
         }
         $helper->getAttachmentsForm()->setData($formInput);
         $this->layout()->setVariables(array('form' => $helper->getAttachmentsForm(), 'formTitle' => $formTitle, 'formDescription' => 'La dimensione del file non deve superare i <strong>10MB</strong>.', 'formAction' => $formAction, 'hideBreadcrumb' => 1, 'attachmentsList' => $helper->getAttachmentRecords(), 'articleTitle' => $helper->getPropertiesGetterClassInstance()->getAttachmentFormTitle(), 'formBreadCrumbCategory' => $helper->getPropertiesGetterClassInstance()->getBreadcrumbModule(), 'formBreadCrumbCategoryLink' => $this->url()->fromRoute($helper->getPropertiesGetterClassInstance()->getBreadcrumbRoute(), array('lang' => $lang, 'languageSelection' => $lang, 'modulename' => $moduleCode)), 'breadCrumbActiveLabel' => isset($attachmentRecord[0]['title']) ? $attachmentRecord[0]['title'] : 'Nuovo file', 'attachmentType' => $helper->getModuleCode(), 'attachmentRecords' => $helper->getAttachmentRecords(), 'referenceId' => $referenceId, 'moduleCode' => $moduleCode, 'templatePartial' => 'attachments/attachments-form.phtml'));
     } catch (NullException $e) {
         $this->layout()->setVariables(array('templatePartial' => 'message.phtml', 'messageType' => 'danger', 'messageTitle' => 'Si &egrave; verificato un errore', 'messageText' => $e->getMessage()));
     }
     $this->layout()->setTemplate($mainLayout);
 }