Ejemplo n.º 1
0
 /**
  * @param Form $form
  */
 protected function configure(Form $form)
 {
     $form->addText('name', 'Name');
     $form->addSelect('file', 'File')->setItems($this->templateManager->getLayouts());
     $form->setCurrentGroup();
     $form->addSaveButton('Save');
 }
Ejemplo n.º 2
0
 public function handleAttached(Form $form)
 {
     $path = $this->moduleHelpers->expandPath($form->data, 'Resources/layouts');
     $type = $this->getTypeByKey($form->data);
     if ($path && !is_writable($path)) {
         $form->addError("File '{$path}' is not writable.");
     }
     if ($form->data && $type === self::TYPE_TEMPLATE) {
         $module = $this->getModuleByKey($form->data);
         $form['layout']->setItems(array_keys($this->templateManager->getLayoutsByModule($module)), FALSE)->setPrompt('-- All --');
     }
 }
Ejemplo n.º 3
0
 /**
  * @param IModule $module
  */
 public function uninstall(IModule $module)
 {
     if (!$this->context->hasService('doctrine') || !$this->context->doctrine->createCheckConnection()) {
         throw new \Exception('Database connection not found!');
     }
     $layouts = $this->templateManager->getLayoutsByModule($module->getName());
     $repository = $this->getTemplateRepository();
     foreach ($layouts as $path => $name) {
         foreach ($repository->findBy(array('file' => $path)) as $entity) {
             $repository->delete($entity);
         }
     }
 }
Ejemplo n.º 4
0
 public function getTemplates()
 {
     $data = array();
     foreach ($this->presenter->context->parameters['modules'] as $moduleName => $val) {
         if (!count($this->templateManager->getLayoutsByModule($moduleName))) {
             continue;
         }
         $item = array('title' => $moduleName, 'key' => $moduleName, 'isFolder' => TRUE, 'isLazy' => TRUE);
         if ($this->getState($moduleName)) {
             $item['expand'] = TRUE;
         }
         $data2 = array();
         foreach ($this->templateManager->getLayoutsByModule($moduleName) as $name => $key) {
             $s = array('isFolder' => TRUE, 'title' => '@' . $name . ' <small class="muted">' . $this->template->translate('layout') . '</small>', 'key' => $key);
             foreach ($this->templateManager->getTemplatesByModule($moduleName, $name) as $name => $key) {
                 $item2 = array('title' => $name . ' <small class="muted">' . $this->template->translate('template') . '</small>', 'key' => $key);
                 $s['children'][] = $item2;
             }
             if ($this->getState($key)) {
                 $s['expand'] = TRUE;
             }
             $data2[] = $s;
         }
         foreach ($this->templateManager->getTemplatesByModule($moduleName) as $name => $key) {
             $data2[] = array('title' => $name . ' <small class="muted">' . $this->template->translate('template') . '</small>', 'key' => $key);
         }
         $item['children'] = $data2;
         $data[] = $item;
     }
     return $data;
 }
Ejemplo n.º 5
0
 public function handleAttached(Form $form)
 {
     $presenters = array();
     foreach ($form->presenter->context->findByTag('presenter') as $name => $item) {
         if (substr($name, -7) === 'Factory') {
             $name = substr($name, 0, -7);
         }
         $presenter = $this->presenterFactory->formatPresenterFromServiceName($name);
         $class = $this->presenterFactory->getPresenterClass($presenter);
         if (!is_subclass_of($class, '\\CmsModule\\Content\\Presenters\\PagePresenter')) {
             continue;
         }
         $name = substr($name, 0, -9);
         $name = explode('.', $name);
         $name = implode(':', $name);
         $presenters[$name] = $name;
     }
     $components = array();
     foreach ($this->widgetManager->getWidgets() as $name => $factory) {
         $components[$factory['class']] = ucfirst($name) . 'Control';
     }
     $form['presenter']->setItems($presenters);
     $form['component']->setItems($components);
     $module = $form['target']->value ? $form['target']->value : key($this->modules);
     $form['layout']->setItems(array_keys($this->templateManager->getLayoutsByModule($module)), FALSE)->setDisabled(FALSE)->setPrompt('-- All --');
 }
Ejemplo n.º 6
0
 protected function getScannedLayouts()
 {
     if ($this->_layouts === NULL) {
         $this->_layouts = array();
         foreach ($this->context->parameters['modules'] as $name => $item) {
             $this->_layouts[$name] = $this->templateManager->getLayouts($name);
         }
     }
     return $this->_layouts;
 }