/**
  * @access public
  */
 public function showForm($withOptions = true)
 {
     MT::addTemplate(dirname(__FILE__) . "/show_form.phtml", 'gallery');
     $id_node = $_GET['id_modul'];
     $form = new NForm('saveGalleryForm');
     $form->getElementPrototype()->id = "formGallery";
     $form->addGroup('Nastavenie galérie');
     $form->addText('name', 'Názov');
     $form->addText('th_width', 'Šírka náhľadov');
     $form->addText('th_height', 'Výška náhľadov');
     $form->addText('width', 'Šírka obrázka');
     $form->addText('height', 'Výška obrázka');
     $form->addSelect('open_in_window', 'Otvárať do nového okna', array(1 => 'áno', 0 => 'nie'));
     $form->addSelect('type', 'Typ zobrazenia galérie', (array) NEnvironment::getConfig('gallery')->type);
     $form->addSubmit('saveGallery', 'Ulož');
     $form->onSubmit[] = array($this, 'save');
     $form->fireEvents();
     $defaults = self::get($id_node);
     if ($defaults != NULL) {
         $form->setDefaults($defaults);
     }
     $f = new FilesNode(self::MODULE_NAME, $_GET['id_modul']);
     MT::addVar('gallery', 'showMultiupload', $f->render());
     MT::addVar('gallery', 'galleryOptionsForm', $form);
     MT::addVar('gallery', 'withOptions', $withOptions);
     MT::addVar('gallery', 'gallery', self::get($_GET['id_modul']));
     MT::addVar('gallery', 'list', self::getAllFiles(self::MODULE_NAME, $_GET['id_modul']));
 }
Exemplo n.º 2
0
 function showLogin()
 {
     $user = NEnvironment::getUser();
     if (!isset($this->session['time'])) {
         $this->session['time'] = date('d.m.Y H:i:s');
     }
     //pouzit iba jeden CSS
     MT::addCss('/require_modules/authentication/css/auth.css');
     MT::addScripts('/jscripts/mootools/mootools1.2b2.js', 'mootools');
     MT::addScripts('/jscripts/mootools/mootools_DWrequest.js', 'mootools_adds');
     $form = new NForm('LoginForm');
     $form->getElementPrototype()->id = 'LoginForm';
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = 'div';
     $renderer->wrappers['pair']['container'] = 'div';
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $form->addGroup();
     $form->addText('login', 'Prihlasovacie meno')->addRule(NForm::FILLED, 'Prihlasovacie meno musí byť vyplnené.')->addRule(NForm::MAX_LENGTH, 'Maximálny počet znakov je %s', 20);
     $form->addPassword('password', 'Heslo')->addRule(NForm::FILLED, 'Prihlasovacie meno musí byť vyplnené.')->addRule(NForm::MAX_LENGTH, 'Maximálny počet znakov je %s', 30);
     $form->addSubmit('submit_login', 'Log In');
     $form->addProtection('Sedenie vypršalo. Proším obnovte prihlasovací formulár a zadajte údaje znovu.', 1800);
     $form['login']->getControlPrototype()->class = 'text';
     $form['login']->getLabelPrototype()->id = 'loginLabel';
     $form['password']->getControlPrototype()->class = 'text';
     $form['password']->getLabelPrototype()->id = 'passwordLabel';
     $form['submit_login']->getControlPrototype()->class = 'btnLogin';
     if ($form->isSubmitted()) {
         if ($form->isValid()) {
             $values = $form->getValues();
             try {
                 if (self::getCountOfUnautorizedAccess() > 10) {
                     throw new NAuthenticationException('Prihlásenie bolo zablokované na 10 minút.');
                 }
                 Log::addGlobalLog(1);
                 $user->setExpiration('+ 2 days', FALSE);
                 //	        	$user->setAuthenticationHandler( new Login() );
                 $user->login($values['login'], $values['password']);
                 $form->setValues(array(), TRUE);
                 header('Location: ' . $_SERVER['REQUEST_URI']);
                 exit;
             } catch (NAuthenticationException $e) {
                 $form->addError($e->getMessage());
             }
         }
     }
     MT::addTemplate(dirname(__FILE__) . '/login.phtml', 'authentication');
     MT::addVar('authentication', 'error_msg', $this->error_msg);
     MT::addVar('authentication', 'loginForm', $form);
     echo MT::renderHeader();
     echo MT::renderContentHolder();
     exit;
 }