Exemple #1
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     $roles = $parent->getModelAcl()->getRolesSelectData();
     $this->addText('login', 'Login')->addRule(Form::FILLED, 'Zadejte login');
     $this->addText('email', 'E-mail')->addRule(Form::FILLED, 'Zadejte email')->addRule(Form::EMAIL);
     $this->addSelect('role', 'Role', $roles)->setRequired('Vyberte roli');
     $this->addPassword('password', 'Heslo');
     $this->addPassword('passwordVerify', 'Heslo znovu');
     switch ($this->getPresenter()->getAction()) {
         case 'add':
             $this->addSubmit('send', 'Vytvořit');
             $this['password']->addRule(Form::FILLED);
             $this['passwordVerify']->setRequired('Zadejte prosím heslo ještě jednou pro kontrolu')->addRule(Form::EQUAL, 'Hesla se neshodují', $this['password']);
             $validatorParams = array('userId' => NULL);
             $this['login']->addRule(callback($this, 'loginUniqueValidator'), 'Login musí být unikátní', $validatorParams);
             $this->onSuccess[] = array($this, 'addformSubmited');
             break;
         case 'edit':
             // edit
             $this['passwordVerify']->addConditionOn($this['password'], Form::FILLED, TRUE)->addRule(Form::EQUAL, 'Hesla se neshodují', $this['password']);
             $userId = $this->presenter->getParam('user_id');
             $this->addHidden('user_id', $userId);
             $validatorParams = array('userId' => $this['user_id']->value);
             $this['login']->addRule(callback($this, 'loginUniqueValidator'), 'Login musí být unikátní', $validatorParams);
             $defaults = $this->getPresenter()->getModelUser()->getUserDefaults($userId);
             $this->addSubmit('send', 'Upravit');
             $this->onSuccess[] = array($this, 'editFormSubmited');
             $this->setDefaults($defaults);
             break;
     }
     $this['send']->getControlPrototype()->class = "submit";
 }
Exemple #2
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     $choosedRole = $parent->getParam('role');
     $acl = $parent->context->resourceManager->getAcl();
     $aclTitles = $parent->context->resourceManager->getAclTitles();
     $roles = $parent->context->authorizator->getRoles();
     $this->addGroup('Vyberte roli');
     $this->addSelect('role', 'Role', $roles)->setPrompt('--- Vyberte roli ---');
     foreach ($acl as $resourceName => $privileges) {
         $this->addGroup($aclTitles[$resourceName]);
         $this->addContainer($resourceName);
         foreach ($privileges as $privilegeName => $privilegeValue) {
             $this[$resourceName]->addCheckbox($privilegeName, $aclTitles[$resourceName . ':' . $privilegeName]);
         }
     }
     $this->addGroup('_send');
     $this->removeGroup('_send');
     $this->addSubmit('send', 'Uložit');
     switch ($this->getPresenter()->getAction()) {
         case 'default':
             $this->onSuccess[] = array($this, 'editFormSubmited');
             $defaults = $parent->getModelAcl()->loadFormValues($choosedRole);
             $defaults['role'] = $choosedRole;
             $this->setDefaults($defaults);
             break;
     }
     $this['send']->getControlPrototype()->class = "submit";
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     // $this->getElementPrototype()->class("ajax");  //nemuze to byt ajax kvuli mfu!
     $editorId = $this->getPresenter()->getUser()->getId();
     $this->addMultipleFileUpload('upload', '', 999);
     $this->addSubmit('send', 'Přidat');
     $this->addHidden('editor_id', $editorId);
     $this->addHidden('gallery_id', $parent->gid);
     $this->onSuccess[] = array($this, 'formSubmited');
     $this['send']->getControlPrototype()->class = "submit";
 }
Exemple #4
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     /* PREPARE DATA */
     //$pageId = $this->getPresenter()->getParam('id');
     //dump($labelId);
     $extProperties = $this->presenter->configLoaderService->loadLabelExtentsionProperties();
     $extSelectData = array();
     if (!empty($extProperties) && isset($extProperties['properties'])) {
         foreach ($extProperties['properties'] as $propertyName => $property) {
             $key = 'Formulářové prvky';
             if (isset($property['engine'])) {
                 switch ($property['engine']) {
                     case 'media':
                         $key = 'Virtuální disk';
                         break;
                     default:
                         $key = $property['engine'];
                 }
             }
             $extSelectData[$key][$propertyName] = $property['label'];
         }
     }
     $this->addText('title', 'Titulek')->setRequired();
     $this->addText('identifier', 'Identifikátor')->setRequired();
     $this->addSelect('name', 'Typ', $extSelectData)->setPrompt(':: Vyberte typ ::')->setRequired();
     $labelId = $this->presenter->getParam('labelId');
     $this->addHidden('label_id', $labelId);
     switch ($this->getPresenter()->getAction()) {
         case 'addExt':
             $this->addSubmit('send', 'Vytvořit');
             $this->onSuccess[] = array($this, 'addformSubmited');
             break;
         case 'editExt':
             // edit
             $this->addSubmit('send', 'Uložit');
             $extId = $this->presenter->getParam('ext_id');
             //                dump($extId);
             //                die();
             $this->addHidden('ext_id', $extId);
             //                dump($extId);
             //                die();
             //$this['is_global']->setDisabled();
             $defaults = $this->presenter->labelModel->getExtension($extId);
             //                dump($defaults);
             //                die();
             $this->onSuccess[] = array($this, 'editFormSubmited');
             $this->setDefaults((array) $defaults);
             break;
     }
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     // $this->getElementPrototype()->class("ajax");  //nemuze to byt ajax kvuli mfu!
     $editorId = $this->getPresenter()->getUser()->getId();
     $id = $this->getPresenter()->getParam('id');
     $this->addText('name', 'Název galerie')->setRequired('Název galerie musí být vyplněn ');
     $this->addMultipleFileUpload('upload', '', 999);
     $this->addSubmit('send', 'Uložit');
     $this->addHidden('editor_id', $editorId);
     $this['name']->getControlPrototype()->class[] = "input";
     $this->onSuccess[] = array($this, 'formSubmited');
     $this['send']->getControlPrototype()->class = "submit";
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     $identifier = $this->presenter->getParam('identifier');
     $config = $this->presenter->pageManagerService->getExtPropertiesByIdentifier($identifier);
     $selectData = $config['tags'];
     $this->addSelect('tag', 'Vyberte tag', $selectData)->setPrompt(':: Vyberte tag ::')->setRequired();
     $this->addSubmit('send', 'Řadit atributy');
     $this->onSuccess[] = array($this, 'editFormSubmited');
     $treeNodeId = $this->presenter->getParam('id');
     $labelId = $this->presenter->getParam('labelId');
     $this->addHidden('label_id', $labelId);
     $this->addHidden('tree_node_id', $treeNodeId);
     $this->addHidden('identifier', $identifier);
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     //$this->getElementPrototype()->class("ajax");
     $editorId = $this->getPresenter()->getUser()->getId();
     $fid = $parent->fid;
     $this->addMultipleFileUpload('upload', '', 999);
     //$id = $this->getPresenter()->getParam('id');
     //$fid = $this->getPresenter()->getParam('fid');
     $this->addSubmit('send', 'Uložit');
     $this->addHidden('editor_id', $editorId);
     $this->addHidden('parent', $fid);
     $this->addHidden('id', false);
     $this->onSuccess[] = array($this, 'formSubmited');
     $this['send']->getControlPrototype()->class = "submit";
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     $allModules = $this->parent->getAllModules();
     //        dump($allModules);
     //        die();
     $selectData = array();
     if (!empty($allModules)) {
         foreach ($allModules as $moduleName => $moduleData) {
             $selectData[$moduleName] = $moduleData['title'];
         }
     }
     $defaultValue = $this->parent->getActualModule();
     $this->addSelect('moduleName', '', $selectData)->setDefaultValue($defaultValue);
     $this->addSubmit('send', 'Přepnout');
     $this->onSuccess[] = array($this, 'editformSubmited');
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     // getLanguages
     $langs = $this->presenter->langManagerService->getLangs();
     //        dump($langs);
     //        die();
     $tagContainer = $this->addContainer('tags');
     foreach ($this->presenter->tags as $tagName => $tagCaption) {
         $tagContainer->addCheckbox($tagName, $tagCaption);
     }
     $langForms = array();
     // language containers
     foreach ($langs as $langCode => $language) {
         // !! create language section
         $langForms[$langCode] = $this->addContainer($langCode);
         $formItem = $langForms[$langCode]->addText('param_name', 'Jméno parametru');
     }
     $labelId = $this->presenter->getParam('labelId');
     $this->addHidden('label_id', $this->presenter->getParam('labelId'));
     $this->addHidden('tree_node_id', $this->presenter->getParam('id'));
     $this->addHidden('identifier', $this->presenter->getParam('identifier'));
     switch ($this->getPresenter()->getAction()) {
         case 'addParam':
             $this->addSubmit('send', 'Vytvořit');
             $this->onSuccess[] = array($this, 'addformSubmited');
             break;
         case 'editParam':
             // edit
             $this->addSubmit('send', 'Uložit');
             $extTreeNodeId = $this->presenter->getParam('ext_tree_node_id');
             //                dump($extId);
             //                die();
             $this->addHidden('ext_tree_node_id', $extTreeNodeId);
             //                dump($extId);
             //                die();
             //$this['is_global']->setDisabled();
             $defaults = $this->presenter->extModel->getParam($extTreeNodeId, $this->presenter->tags);
             //                dump($defaults);
             //                die();
             $this->onSuccess[] = array($this, 'editFormSubmited');
             $this->setDefaults((array) $defaults);
             break;
     }
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     /* PREPARE DATA */
     //$pageId = $this->getPresenter()->getParam('id');
     //dump($labelId);
     $entityConfig = $this->presenter->configLoaderService->loadEntityConfig('page');
     foreach ($entityConfig['properties'] as $entityParamName => $entityParam) {
         $this->addGroup($entityParam['label']);
         $cont = $this->addContainer($entityParamName);
         $cont->addText('label', 'Titulek')->setRequired('Zadejte titulek pro parametr');
         $cont->addCheckbox('exclude', 'Nezobrazovat');
     }
     $this->setCurrentGroup(NULL);
     $this->addSubmit('send', 'Uložit');
     $defaults = $this->presenter->extModel->getDefaultsForEntityParamForm($this->presenter->labelId, $entityConfig);
     $this->setDefaults($defaults);
     //        dump($defaults);
     //        die();
     $this->onSuccess[] = array($this, 'formSubmited');
 }
Exemple #11
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     $acl = $parent->context->resourceManager->getAcl();
     $aclTitles = $parent->context->resourceManager->getAclTitles();
     foreach ($acl as $resourceName => $privileges) {
         $this->addGroup($aclTitles[$resourceName]);
         $this->addContainer($resourceName);
         foreach ($privileges as $privilegeName => $privilegeValue) {
             $this[$resourceName]->addCheckbox($privilegeName, $aclTitles[$resourceName . ':' . $privilegeName]);
         }
     }
     $this->addGroup('_send');
     $this->removeGroup('_send');
     $this->addSubmit('send', 'Uložit');
     $userId = $this->presenter->getParam('user_id');
     $this->addHidden('user_id', $userId);
     $this->onSuccess[] = array($this, 'editFormSubmited');
     $defaults = $parent->getModelAcl()->loadFormValuesForUser($userId);
     $this->setDefaults($defaults);
     $this['send']->getControlPrototype()->class = "submit";
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     // getLanguages
     $langs = $this->presenter->langManagerService->getLangs();
     $langForms = array();
     $parentData = array(0 => 'Nejvyšší úroveň');
     $identifier = $this->presenter->getParam('identifier');
     $treeNodeId = $this->presenter->getParam('id');
     //        $this->addHidden('tree_node_id', $this->presenter->getParam('id'));
     //        $this->addHidden('identifier', $this->presenter->getParam('identifier'));
     // identifier and treeNodeId serve as clues to find all parent attribs
     // current ext_tree_node_id (is any) must be excluded
     //dump();
     $structuredParamsParentSelectData = $this->presenter->extModel->getStructuredParamsParentSelectData($identifier, $treeNodeId, $this->presenter->langManagerService->getDefaultLanguage(), $this->presenter->getParam('ext_tree_node_id'));
     //dump($structuredParamsParentSelectData);
     $this->addSelect('parent', 'Rodičovský parametr', $parentData + $structuredParamsParentSelectData);
     $this->addText('x_coord', 'X');
     $this->addText('y_coord', 'Y');
     $this->addTextArea('image', 'Obrázek')->getControlPrototype()->class = 'wysiwyg';
     //dump($langs);
     // language containers
     foreach ($langs as $langCode => $language) {
         // !! create language section
         $langForms[$langCode] = $this->addContainer($langCode);
         $langForms[$langCode]->addText('param_name', 'Jméno parametru');
         $langForms[$langCode]->addTextArea('text', 'Text')->getControlPrototype()->class = 'wysiwyg';
     }
     //dump($langForms);
     $labelId = $this->presenter->getParam('labelId');
     $this->addHidden('label_id', $this->presenter->getParam('labelId'));
     $this->addHidden('tree_node_id', $this->presenter->getParam('id'));
     $this->addHidden('identifier', $this->presenter->getParam('identifier'));
     switch ($this->getPresenter()->getAction()) {
         case 'addStructuredParam':
             $this->addSubmit('send', 'Vytvořit');
             $this->onSuccess[] = array($this, 'addformSubmited');
             break;
         case 'editStructuredParam':
             // edit
             $this->addSubmit('send', 'Uložit');
             $extTreeNodeId = $this->presenter->getParam('ext_tree_node_id');
             $this->addHidden('ext_tree_node_id', $extTreeNodeId);
             $defaults = $this->presenter->extModel->getParam($extTreeNodeId, $this->presenter->tags);
             //                dump($extTreeNodeId);
             //                dump($defaults);
             //                die();
             foreach ($langs as $langCode => $lang) {
                 if (isset($defaults[$langCode])) {
                     if (isset($defaults[$langCode]['param_value'])) {
                         //                            dump((array)\Bubo\Utils\MultiValues::unserialize($defaults[$langCode]['param_value']));
                         //                            die();
                         $defaults['parent'] = isset($defaults[$langCode]['parent']) ? $defaults[$langCode]['parent'] : NULL;
                         $defaults[$langCode] = (array) $defaults[$langCode] + (array) \Bubo\Utils\MultiValues::unserialize($defaults[$langCode]['param_value']);
                         $defaults['x_coord'] = isset($defaults[$langCode]['x_coord']) ? $defaults[$langCode]['x_coord'] : '';
                         $defaults['y_coord'] = isset($defaults[$langCode]['y_coord']) ? $defaults[$langCode]['y_coord'] : '';
                         $defaults['image'] = isset($defaults[$langCode]['image']) ? $defaults[$langCode]['image'] : '';
                     }
                 }
             }
             //                dump($defaults);
             //                die();
             $this->onSuccess[] = array($this, 'editFormSubmited');
             $this->setDefaults((array) $defaults);
             break;
     }
 }
Exemple #13
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     $treeNodeId = $this->presenter->getParam('id');
     $labelId = $this->presenter->getParam('labelId');
     $entity = $this->presenter->getParam('entity');
     if ($entity === NULL) {
         // determine entity by $treeNodeId
         if ($treeNodeId === NULL) {
             throw new \Nette\InvalidArgumentException("Unable to determine entity");
         }
         $entity = $this->presenter->pageModel->getEntity($treeNodeId);
     }
     // load page configuration
     $entityConfig = $this->presenter->configLoaderService->loadEntityConfig($entity);
     $this->properties = $this->presenter->extModel->filterEntityProperties($entityConfig['properties'], $labelId);
     $this->createUrl = TRUE;
     if (isset($entityConfig['entityMeta']) && isset($entityConfig['entityMeta']['createUrl'])) {
         if (!$entityConfig['entityMeta']['createUrl']) {
             $this->createUrl = FALSE;
         }
     }
     $labelProperties = array();
     $label = NULL;
     // for proper form generation...$labelId must be known
     if (!empty($labelId)) {
         // load all label extensions
         $allExtensions = $this->presenter->configLoaderService->loadLabelExtentsionProperties();
         $labelProperties = $this->presenter->pageManagerService->intersectLabelProperties($labelId, $allExtensions);
         $this->properties = array_merge($this->properties, $labelProperties);
         // sort properties
         $extSortOrder = $this->presenter->extModel->loadExtSorting($labelId);
         if ($extSortOrder) {
             $extSorting = NULL;
             if ($extSorting = \Bubo\Utils\MultiValues::unserialize($extSortOrder)) {
                 uksort($this->properties, function ($a, $b) use($extSorting) {
                     $aPos = array_search(str_replace('_', '*', $a), $extSorting);
                     $bPos = array_search(str_replace('_', '*', $b), $extSorting);
                     if ($aPos !== FALSE && $bPos !== FALSE) {
                         return $aPos - $bPos;
                     } else {
                         if ($aPos === FALSE) {
                             return -1;
                         } else {
                             return 1;
                         }
                     }
                 });
             }
         }
         $label = $this->presenter->pageManagerService->getLabel($labelId);
     }
     // getLanguages
     $langs = $originalLangs = $this->presenter->langManagerService->getLangs();
     $alienLangs = array();
     $referencingPages = NULL;
     if ($treeNodeId !== NULL) {
         //$defaults = $this->presenter->pageManagerService->getDefaults($treeNodeId, $this->presenter->getParam('waiting'));
         $referencingPages = $this->presenter->pageModel->getReferencingPages($treeNodeId);
         $alienLangs = $this->presenter->langManagerService->getAlienLangs($referencingPages, $langs);
         $langs = $langs + $alienLangs;
     }
     $pageNameListeners = array('title', 'link_title', 'menu_title', 'page_title', 'url_name');
     if ($this->presenter->preselectedParent !== NULL) {
         if (is_array($this->presenter->preselectedParent)) {
             $this->addSelect('parent', "Parent", $this->presenter->preselectedParent)->setPrompt(':: Vyberte předka ::')->setRequired('Musíte vybrat předka');
             $this['parent']->getControlPrototype()->style = 'font-family:monospace;float:right;z-index:250;font-size:12px;';
         } else {
             $this->addHidden('parent', $this->presenter->preselectedParent);
         }
     } else {
         // parent select
         //dump($entityConfig);
         $disablePagesWithNoUrl = isset($entityConfig['entityMeta']['createUrl']) ? $entityConfig['entityMeta']['createUrl'] : FALSE;
         //dump($disablePagesWithNoUrl);
         $st = new \BuboApp\AdminModule\Components\SelectTraverser($this->presenter, $treeNodeId, NULL, $disablePagesWithNoUrl);
         $selectData = $st->getSelectMenu($this->presenter['structureManager']->getLanguage());
         $this->addSelect('parent', "Parent", $selectData)->setPrompt(':: Vyberte předka ::')->setRequired('Musíte vybrat předka');
         $this['parent']->getControlPrototype()->style = 'font-family:monospace;float:right;z-index:250;font-size:12px;';
     }
     $this->addHidden('entity');
     $identity = $this->presenter->getUser()->getIdentity();
     $editorId = $identity ? $identity->id : NULL;
     $mandatoryProperties = $this->presenter->configLoaderService->loadMandatoryProperties();
     $langForms = array();
     if (!empty($this->properties)) {
         // container with checkboxes
         $publishContainer = $this->addContainer('lang_versions');
         foreach ($langs as $langCode => $language) {
             $publishContainer->addCheckbox($langCode);
         }
         // language containers
         foreach ($langs as $langCode => $language) {
             // !! create language section
             $langForms[$langCode] = $this->addContainer($langCode);
             //                dump($mandatoryProperties);
             //                die();
             // mandatory parameters (will be in all pageForms??)
             foreach ($mandatoryProperties as $key => $array) {
                 $formItem = NULL;
                 switch ($array['type']) {
                     case 'text':
                         $formItem = $langForms[$langCode]->addText($key, $array['label']);
                         break;
                     case 'textArea':
                         $formItem = $langForms[$langCode]->addTextArea($key, $array['label']);
                         break;
                 }
                 if ($formItem !== NULL) {
                     if (isset($array['class'])) {
                         $formItem->getControlPrototype()->class[] = $array['class'];
                     }
                     $formItem->getLabelPrototype()->title = '_' . $key;
                 }
                 // manage classes for name and its listeners
                 if ($key == 'name') {
                     $formItem->getControlPrototype()->class[] = '_page_name_' . $langCode;
                 } else {
                     if (in_array($key, $pageNameListeners)) {
                         $formItem->getControlPrototype()->class[] = '_page_name_listener_' . $langCode;
                     }
                 }
             }
             $langForms[$langCode]->addText('parent_url')->addConditionOn($langForms[$langCode]['name'], Form::FILLED)->addRule(~Form::EQUAL, 'Předek je duch. Pro uložení stránky v této mutaci je potřeba nejprve vytvořit předka.', '_undefin@_');
             //                dump($labelProperties);
             //                die();
             // parameters loaded from page configuration
             foreach ($this->properties as $propertyName => $property) {
                 $formItem = NULL;
                 if (isset($property['engine'])) {
                     switch ($property['engine']) {
                         case 'media':
                             switch ($property['type']) {
                                 case 'mediaFile':
                                     $formItem = $langForms[$langCode]->addMediaFile($propertyName, $property['label']);
                                     break;
                                 case 'mediaGallery':
                                     $formItem = $langForms[$langCode]->addMediaFile($propertyName, $property['label']);
                                     break;
                             }
                             break;
                         case 'label':
                             $currentLanguage = $this->presenter['structureManager']->getLanguage();
                             $st = new \BuboApp\AdminModule\Components\SelectTraverser($this->presenter);
                             $label = $this->presenter->pageManagerService->getLabelByName($property['bind']['labelName']);
                             $selectData = array();
                             if ($label !== NULL) {
                                 $labelRoots = $this->presenter->pageManagerService->getLabelRoots($label['label_id'], $currentLanguage);
                                 $myRoot = reset($labelRoots);
                                 $st->setTopLevelPage($myRoot);
                                 $st->hideRootElement();
                                 $selectData = $st->getSelectMenu($currentLanguage);
                             }
                             $formItem = $langForms[$langCode]->addSelect($propertyName, $property['label'], $selectData);
                             if (isset($property['prompt'])) {
                                 $formItem->setPrompt($property['prompt']);
                             }
                             $formItem->getControlPrototype()->style = 'font-family:monospace;font-size:12px;';
                     }
                 } else {
                     switch ($property['type']) {
                         case 'text':
                         case 'external_url':
                             $formItem = $langForms[$langCode]->addText($propertyName, $property['label']);
                             if (isset($property['class'])) {
                                 $formItem->getControlPrototype()->class = $property['class'];
                             }
                             break;
                         case 'textArea':
                             $formItem = $langForms[$langCode]->addTextArea($propertyName, $property['label']);
                             if (isset($property['class'])) {
                                 $formItem->getControlPrototype()->class = $property['class'];
                             }
                             break;
                         case 'checkbox':
                             $formItem = $langForms[$langCode]->addCheckbox($propertyName, $property['label']);
                             if (isset($property['class'])) {
                                 $formItem->getControlPrototype()->class = $property['class'];
                             }
                             break;
                         case 'select':
                             $selectData = isset($property['data']) ? $property['data'] : call_user_func_array(array($this->presenter, $property['method']), array());
                             $formItem = $langForms[$langCode]->addSelect($propertyName, $property['label'], $selectData);
                             if (isset($property['prompt'])) {
                                 $formItem->setPrompt($property['prompt']);
                             }
                             if (isset($property['required'])) {
                                 $formItem->setRequired($property['required']);
                             }
                             break;
                         case 'color':
                             $formItem = $langForms[$langCode]->addText($propertyName, $property['label']);
                             $formItem->getControlPrototype()->type = 'color';
                             break;
                     }
                 }
                 if ($formItem !== NULL) {
                     $formItem->getLabelPrototype()->title = '_' . $propertyName;
                 }
             }
         }
     }
     $this->addSubmit('send', 'Proveď');
     $this->addSubmit('cancel', 'Cancel')->setValidationScope(FALSE);
     $whatToPublish = array('none' => 'Uložit a nepublikovat nic', 'selected' => 'Uložit a publikovat vybrané', 'all' => 'Uložit a publikovat vše');
     $this->addSelect('what_to_publish', '', $whatToPublish)->addRule(array($this, 'draftNotInFuture'), 'Draft nemůže mít odloženou publikaci', $this)->addRule(array($this, 'atLeastOnePageFilled'), 'Vyplňte alespoň jednu stránku', $this)->getControlPrototype()->style = 'display: inline;';
     // load templates -> get only existing and with nice names (if possible)
     $loadTemplatesWithUrl = TRUE;
     if (isset($entityConfig['entityMeta']) && isset($entityConfig['entityMeta']['createUrl'])) {
         $loadTemplatesWithUrl = $entityConfig['entityMeta']['createUrl'];
     } else {
         throw new Nette\InvalidArgumentException("Missing parameter 'createUrl' in entity config");
     }
     $_templates = $this->presenter->projectManagerService->getListOfTemplates($loadTemplatesWithUrl);
     $templateConfig = $this->presenter->configLoaderService->loadLayoutConfig();
     $res = \Nette\Utils\Arrays::mergeTree($templateConfig['layouts'], $_templates);
     $templates = array_intersect_key($res, $_templates);
     // any entity template restriction?
     if (isset($entityConfig['templates']) && isset($entityConfig['templates']['restrict'])) {
         $templates = array_intersect_key($templates, array_flip($entityConfig['templates']['restrict']));
         if (empty($templates)) {
             throw new \Nette\InvalidStateException('Template restriction is empty.');
         }
     }
     // any entity template exclusion?
     if (isset($entityConfig['templates']) && isset($entityConfig['templates']['exclude'])) {
         $templates = array_diff_key($templates, array_flip($entityConfig['templates']['exclude']));
         if (empty($templates)) {
             throw new \Nette\InvalidStateException('Template exlusion is empty.');
         }
     }
     //        dump($templates);
     //        die();
     //
     //        dump($templates, $entityConfig);
     //        die();
     //        if (isset($_templates['headless'])) {
     //            $res = \Nette\Utils\Arrays::mergeTree($templateConfig['layouts'], $_templates['headless']);
     //            $templates['Stránky bez url'] = array_intersect_key($res, $_templates['headless']);
     //        }
     $this->addSelect('layout', 'Šablona', $templates);
     //        dump($label);
     //        die();
     if ($label && $label['lock_layout'] == 1) {
         $this['layout']->setDisabled();
         //            dump($label);
         //            die();
     }
     $this['send']->getControlPrototype()->class = "submit";
     $this['cancel']->getControlPrototype()->class = "submit";
     //$this['send']->addRule(callback($this, 'newUrlUniqueValidator'), '', $this);
     //        if (!$isEditable) {
     //            foreach ($this->getComponents() as $component) {
     //                $component->setDisabled();
     //            }
     //        }
     $this->getElementPrototype()->onsubmit('tinyMCE.triggerSave()');
     switch ($this->getPresenter()->getAction()) {
         case 'default':
             // edit
             $this->addSubmit('move_to_trash', 'Hodit do koše')->setValidationScope(FALSE);
             $this->onSuccess[] = array($this, 'editFormSubmited');
             if (!$this->isSubmitted()) {
                 //                    dump($alienLangs);
                 //                    die();
                 $defaults = $this->presenter->pageManagerService->getDefaults($treeNodeId, $this->presenter->getParam('waiting'), array_keys($alienLangs));
                 //\Nette\Diagnostics\Debugger::$maxDepth = 8;
                 //                    dump($defaults);
                 //                    die();
                 $currentDefault = reset($defaults);
                 //                    $currentDefault = current($ccurrentDefault);
                 //$allLanguages = $this->presenter->langManagerService->getLangs();
                 $defaultLanguage = $this->presenter->langManagerService->getDefaultLanguage();
                 $urls = $this->presenter->pageModel->getPagesUrls($currentDefault['parent'], array_keys($originalLangs), $defaultLanguage);
                 $alienUrls = $this->presenter->pageModel->getAlienPagesUrls($referencingPages, $alienLangs, $this->presenter->langManagerService);
                 $alienTabUrls = $this->presenter->pageModel->getAlienTabUrls($alienLangs, $alienUrls);
                 //dump($referencingPages);
                 //                    dump($referencingPages, $alienUrls);
                 //                    $this->presenter->pageModel->getAllAlienUrls($referencingPages, $alienUrls, $this->presenter->langManagerService);
                 //                    die();
                 //                    die();
                 $urls = $urls + $alienTabUrls;
                 // add urls to defauls (even to nonexisting lang sections!)
                 if (!empty($urls)) {
                     foreach ($urls as $langCode => $parentUrl) {
                         $defaults[$langCode]['parent_url'] = $urls[$langCode]['parent_url'];
                     }
                 }
                 //                    dump($currentDefault);
                 $defaults['parent'] = $currentDefault['parent'];
                 $defaults['layout'] = $currentDefault['layout'];
                 $defaults['entity'] = $entity;
                 // expand extended values
                 $identifiers = array();
                 foreach ($langs as $langCode => $langName) {
                     if (isset($defaults[$langCode]) && isset($defaults[$langCode]['time_zone'])) {
                         foreach ($defaults[$langCode]['time_zone'] as $timeZoneFlag => $timeZone) {
                             foreach ($timeZone as $status => $labels) {
                                 foreach ($labels as $labelId => $pageData) {
                                     //                                        unset($defaults[$langCode]['time_zone'][$timeZoneFlag][$status][$labelId]['ext_identifier']);
                                     //                                        unset($defaults[$langCode]['time_zone'][$timeZoneFlag][$status][$labelId]['ext_value']);
                                     if (!empty($pageData['ext_identifier'])) {
                                         foreach ($pageData['ext_identifier'] as $extIdentifier => $d) {
                                             if ($extIdentifier != "") {
                                                 if (isset($labelProperties) && isset($labelProperties['ext_' . $extIdentifier])) {
                                                     $identifiers[$langCode]['ext_' . $extIdentifier] = $d['ext_value'];
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 //                    dump($defaults);
                 //                    die();
                 //                    dump($allExtensions, $identifiers);
                 //                    die();
                 $newDefaults = \Nette\Utils\Arrays::mergeTree($defaults, $identifiers);
                 //dump($newDefaults);
                 $this->setDefaults($newDefaults);
             }
             //$defaults = $this->presenter->pageManagerService->getDefaults($treeNodeId);
             break;
         case 'addPage':
         case 'addScrap':
             $this->onSuccess[] = array($this, 'addformSubmited');
             if (!$this->isSubmitted()) {
                 //$allLanguages = $this->presenter->langManagerService->getLangs();
                 $defaultLanguage = $this->presenter->langManagerService->getDefaultLanguage();
                 $defaults = $this->presenter->pageModel->getPagesUrls(NULL, array_keys($langs), $defaultLanguage);
                 $defaults['entity'] = $entity;
                 //                    dump($entity);
                 //                    die();
                 if ($label) {
                     //dump($label);
                     $defaults['layout'] = $label['layout'];
                 }
                 if ($this->presenter->preselectedParent !== NULL && !is_array($this->presenter->preselectedParent)) {
                     //$this->addHidden('parent', $this->presenter->preselectedParent);
                     $urls = $this->presenter->pageModel->getPagesUrls($this->presenter->preselectedParent, array_keys($langs), $defaultLanguage);
                     // add urls to defauls (even to nonexisting lang sections!)
                     if (!empty($urls)) {
                         foreach ($urls as $langCode => $parentUrl) {
                             $defaults[$langCode]['parent_url'] = $urls[$langCode]['parent_url'];
                         }
                     }
                 }
                 $this->setDefaults($defaults);
             }
             break;
     }
     $this->onError[] = array($this, 'invalidSubmit');
 }
Exemple #14
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     /* PREPARE DATA */
     //$pageId = $this->getPresenter()->getParam('id');
     //        dump($labelId);
     //$this->addHidden('label_id');
     $this->addGroup('Jméno a typ');
     $this->addText('name', 'Jméno štítku')->addRule(Form::FILLED, 'Zadejte jméno štítku.');
     $this->addHidden('color', '0000ff');
     $this->addHidden('module', $this->presenter->pageManagerService->getCurrentModule());
     $selectData = array(NULL => 'Single', '1' => '1. úroveň', '2' => '2. úroveň', '3' => '3. úroveň', '4' => '4. úroveň', '0' => 'Celý podstrom');
     $this->addSelect('depth_of_recursion', 'Typ', $selectData);
     $this->addGroup('Konfigurace');
     $this->addCheckBox('create_button', 'Vytvářet tlačítko');
     //                                  ->addConditionOn($this['is_singleton'], Form::EQUAL, NULL)
     //                                  ->addRule(Form::EQUAL, 'Tlačítko lze vytvořit pouze u jedináčka', FALSE);
     //                                ->addConditionOn($this['depth_of_recursion'], ~Form::EQUAL, NULL)
     //->addRule(Form::EQUAL, 'Rekurzivní štítek nemůže být jedináček', FALSE);
     $this->addCheckBox('show_button', 'Zobrazit tlačítko');
     // load templates -> get only existing and with nice names (if possible)
     $_templates = $this->presenter->projectManagerService->getListOfTemplates(TRUE);
     //        dump($_templates);
     //        die();
     //        $templateConfig = $this->presenter->configLoaderService->loadLayoutConfig();
     //        $res = \Nette\Utils\Arrays::mergeTree($templateConfig['layouts'], $_templates['head']);
     //        $templates['Normální stránky'] = array_intersect_key($res, $_templates['head']);
     //        if (isset($_templates['headless'])) {
     //            $res = \Nette\Utils\Arrays::mergeTree($templateConfig['layouts'], $_templates['headless']);
     //            $templates['Stránky bez url'] = array_intersect_key($res, $_templates['headless']);
     //        }
     $templateConfig = $this->presenter->configLoaderService->loadLayoutConfig();
     $res = \Nette\Utils\Arrays::mergeTree($templateConfig['layouts'], $_templates);
     $templates = array_intersect_key($res, $_templates);
     $this->addSelect('layout', 'Šablona', $templates);
     $entities['Stránky'] = $this->presenter->pageManagerService->getAllPageEntities();
     $entities['Útržky'] = $this->presenter->pageManagerService->getAllScrapEntities();
     $this->addSelect('entity', 'Entita', $entities);
     $this->addCheckbox('lock_layout', 'Uzamknout šablonu');
     //        $this->addCheckBox('is_resource','Chráněný zdroj');
     //$this->addCheckBox('is_singleton', 'Jedináček');
     $this->addGroup('Jazyky');
     //$this->addSelect('is_global', 'Viditelnost', $visibilityData);
     $langs = $this->addContainer('langs');
     foreach ($this->presenter->langManagerService->getLangs() as $langCode => $langTitle) {
         $c = \Nette\Utils\Html::el();
         $el = $c->create('img');
         $el->src = $this->presenter->baseUri . '/images/flags/' . strtolower($langCode) . '.png';
         $c->add(\Nette\Utils\Html::el('span')->setHtml(' ' . $langTitle));
         $langs->addCheckbox(strtolower($langCode), $c);
     }
     $allLangs = array_keys($this->presenter->langManagerService->getLangs());
     $this['langs'][strtolower(reset($allLangs))]->addRule(array($this, 'atLeastOneCheckBoxChecked'), 'Alespoň jeden jazyk musí být vybrán', $this['langs']);
     $this['name']->getControlPrototype()->class[] = 'fleft';
     $this['color']->getControlPrototype()->class[] = 'color-listener';
     switch ($this->getPresenter()->getAction()) {
         case 'addLabel':
             $this->setCurrentGroup(NULL);
             $this->addSubmit('send', 'Vytvořit');
             $this->onSuccess[] = array($this, 'addformSubmited');
             break;
         case 'editLabel':
             // edit
             $labelId = $this->presenter->labelId;
             $this->setCurrentGroup(NULL);
             $this->addSubmit('send', 'Uložit');
             $this->addHidden('label_id', $labelId);
             //$this['is_global']->setDisabled();
             $defaults = $this->presenter->labelModel->getLabel($labelId);
             if ($defaults['langs'] === NULL) {
                 $defaults['langs'] = array();
             }
             $this->addSubmit('manage_extensions', 'Rozšíření...')->setValidationScope(NULL);
             $this->addSubmit('sort', 'Třídění...')->setValidationScope(NULL);
             $this->addSubmit('entityParams', 'Parametry entity...')->setValidationScope(NULL);
             $this->addSubmit('delete', 'Smazat štítek');
             $this['delete']->getControlPrototype()->class[] = 'are-you-sure';
             $this->addSubmit('createPage', 'Vytvořit stránku');
             $this->onSuccess[] = array($this, 'editFormSubmited');
             $this->setDefaults($defaults);
             break;
     }
 }
Exemple #15
0
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     /* PREPARE DATA */
     //$pageId = $this->getPresenter()->getParam('id');
     //dump($labelId);
     $st = new \BuboApp\AdminModule\Components\SelectTraverser($this->presenter);
     $cm = $this->presenter->pageManagerService->getCurrentModule();
     $moduleConfig = $this->presenter->configLoaderService->loadModulesConfig($cm);
     $linkSelectData = array();
     if (isset($moduleConfig['modules'])) {
         foreach ($moduleConfig['modules'] as $moduleName => $module) {
             $linkSelectData[$module['title']] = $st->getSelectMenu($this->presenter['structureManager']->getLanguage(), TRUE, $moduleName);
         }
     }
     $selectData = $st->getSelectMenu($this->presenter['structureManager']->getLanguage());
     //        dump($selectData);
     //        dump($linkSelectData);
     //$this->addGroup('Obraz');
     $this->addSelect('parent', "Rodič", $selectData)->setPrompt(':: Vyberte předka ::')->setRequired('Musíte vybrat předka');
     $this['parent']->getControlPrototype()->style = 'font-family:monospace;z-index:250;font-size:12px;';
     //$this->addGroup('Vzor');
     $this->addSelect('pattern', "Vzorová stránka", $linkSelectData)->setPrompt(':: Vyberte vzorovou stránku ::')->setRequired('Musíte vybrat vzorovou stránku');
     $this['pattern']->getControlPrototype()->style = 'font-family:monospace;z-index:250;font-size:12px;';
     $moduleData = array('default' => 'Výchozí modul');
     //        if (count($moduleData) > 1) {
     //
     //            $this->addSelect('pattern_module', "Modul", $moduleData)
     //                                ->setPrompt(':: Vyberte vzorový modul ::')
     //                                ->setRequired('Musíte vybrat modul');
     //
     //        } else {
     //
     //            $this->addHidden('pattern_module', $this->presenter->pageManagerService->getCurrentModule());
     //        }
     $this->addHidden('image_module', $this->presenter->pageManagerService->getCurrentModule());
     // load templates -> get only existing and with nice names (if possible)
     $_templates = $this->presenter->projectManagerService->getListOfTemplates();
     $templateConfig = $this->presenter->configLoaderService->loadLayoutConfig();
     $res = \Nette\Utils\Arrays::mergeTree($templateConfig['layouts'], $_templates);
     $templates = array_intersect_key($res, $_templates);
     $this->addSelect('layout', 'Šablona', $templates);
     //$this->addCheckbox('create_subtree', 'Vytvořit celý podstrom');
     switch ($this->getPresenter()->getAction()) {
         case 'addLink':
             //$this->setCurrentGroup(NULL);
             $this->addSubmit('send', 'Vytvořit');
             $this->onSuccess[] = array($this, 'addformSubmited');
             break;
         case 'editLink':
             // edit
             $this->addSubmit('send', 'Uložit');
             $this->addSubmit('delete', 'Smazat')->setValidationScope(NULL);
             $image = $this->presenter->getParam('id');
             $this->addHidden('image', $image);
             $defaults = $this->presenter->pageModel->getLink($image);
             $this->setDefaults($defaults);
             $this->onSuccess[] = array($this, 'editFormSubmited');
             break;
     }
 }
 public function __construct($parent, $name)
 {
     parent::__construct($parent, $name);
     // getLanguages
     $langs = $this->presenter->langManagerService->getLangs();
     $parentId = $this->presenter->getParam('parentId');
     $identifier = $this->presenter->getParam('identifier');
     $params = $this->presenter->extModel->getParams($parentId, $identifier);
     //        dump($params);
     $langForms = array();
     $labelExtensionsProperties = $this->presenter->configLoaderService->loadLabelExtentsionProperties();
     //        dump($labelExtensionsProperties['properties']['parameterValues']['values']);
     //        die();
     $units = NULL;
     if (isset($labelExtensionsProperties['properties']['parameterValues']['units'])) {
         $units = $labelExtensionsProperties['properties']['parameterValues']['units'];
     }
     //        dump($units);
     //        die();
     //        \Nette\Diagnostics\Debugger::$maxDepth = 6;
     //        dump($params);
     //        die();
     $extForms = array();
     // create extTreeNodeIdContainers
     foreach ($params as $extTreeNodeId => $langSections) {
         $extForms[$extTreeNodeId] = $this->addContainer('ext_tree_node_id_' . $extTreeNodeId);
         foreach ($langs as $langCode => $language) {
             if (isset($langSections[$langCode])) {
                 if ($units === NULL) {
                     $extForms[$extTreeNodeId]->addText($langCode, $langSections[$langCode]['param_name']);
                 } else {
                     $c = $extForms[$extTreeNodeId]->addContainer($langCode);
                     foreach ($units as $unitName => $unitLabel) {
                         $c->addText($unitName, $langSections[$langCode]['param_name']);
                     }
                 }
             }
         }
     }
     //        dump($this->components);
     //        die();
     //
     //        // language containers
     //        foreach ($langs as $langCode => $language) {
     //
     //            // !! create language section
     //            $langForms[$langCode] = $this->addContainer($langCode);
     //
     //            if (!empty($params[$langCode]['ext_tree_node_id'])) {
     //                foreach ($params[$langCode]['ext_tree_node_id'] as $extTreeNodeId => $data) {
     //                    if ($units === NULL) {
     //                        // only one unit
     //                        $formItem = $langForms[$langCode]->addText('ext_tree_node_id_'.$extTreeNodeId, $data['param_name']);
     //                    } else {
     //                        $p = $langForms[$langCode]->addContainer('ext_tree_node_id_'.$extTreeNodeId);
     //                        foreach ($units as $k => $v) {
     //                            $p->addText($k, $data['param_name']);
     //                            //$formItem = $langForms[$langCode]->
     //                        }
     //                    }
     //                }
     //            }
     //
     //
     //        }
     //$labelId = $this->presenter->getParam('labelId');
     $this->addHidden('label_id', $this->presenter->getParam('labelId'));
     $this->addHidden('tree_node_id', $this->presenter->getParam('id'));
     $this->addHidden('identifier', $this->presenter->getParam('identifier'));
     $this->addHidden('parent_id', $this->presenter->getParam('parentId'));
     $this->addHidden('ext_tree_node_id', $this->presenter->getParam('extTreeNodeId'));
     //        $extTreeNodeId = $this->presenter->getParam('extTreeNodeId');
     $this->addSubmit('send', 'Uložit');
     //dump($parentId);
     $defaults = $this->presenter->extModel->getParamValues($this->presenter->getParam('id'), $identifier);
     //
     //                dump($defaults);
     //                die();
     $this->onSuccess[] = array($this, 'editFormSubmited');
     //dump($defaults);
     if ($defaults !== NULL) {
         $this->setDefaults((array) $defaults);
     }
 }