protected function _prepareTpl() { $config = new \Jelix\JCommunity\Config(); $this->_tpl->assign('canRegister', $config->isRegistrationEnabled()); $this->_tpl->assign('canResetPassword', $config->isResetPasswordEnabled()); if (jAuth::isConnected()) { $this->_tpl->assign('login', jAuth::getUserSession()->login); } else { $conf = jAuth::loadConfig(); $this->_tpl->assign('persistance_ok', jAuth::isPersistant()); $form = jForms::get("jcommunity~login"); if (!$form) { $form = jForms::create("jcommunity~login"); } $this->_tpl->assign('form', $form); $this->_tpl->assign('url_return', ''); if ($conf['enable_after_login_override']) { $req = jApp::coord()->request; if ($req->getParam('auth_url_return')) { $this->_tpl->assign('url_return', $req->getParam('auth_url_return')); } else { if ($this->param('as_main_content')) { if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] && $_SERVER['HTTP_REFERER'] != jUrl::getCurrentUrl(false, true)) { $this->_tpl->assign('url_return', $_SERVER['HTTP_REFERER']); } } else { if ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD') { $this->_tpl->assign('url_return', jUrl::getCurrentUrl(false, true)); } } } } } }
/** * prepare a form in order to edit an existing record, and redirect to the editupdate action */ function preupdate() { $id = $this->param('id'); $rep = $this->getResponse('redirect'); if ($id === null) { $rep->action = 'master_admin~default:index'; return $rep; } $rep->params['id'] = $id; $form = jForms::create($this->form, $id); try { $rec = $form->initFromDao($this->dao, null, $this->dbProfile); foreach ($rec->getPrimaryKeyNames() as $pkn) { $c = $form->getControl($pkn); if ($c !== null) { $c->setReadOnly(true); } } } catch (Exception $e) { $rep->action = 'default:view'; return $rep; } jEvent::notify('jauthdbAdminPrepareUpdate', array('form' => $form)); $form->setReadOnly('login'); $form->deactivate('password'); $form->deactivate('password_confirm'); $rep->action = 'user:editupdate'; return $rep; }
/** * Main page */ public function index() { $submit = $this->param('validate'); if ($submit == jLocale::get('hfnucontact~contact.form.saveBt')) { $form = jForms::fill('hfnucontact~admincontact'); $rep = $this->getResponse('redirect'); if (!$form->check()) { $rep->action = 'hfnucontact~admin:index'; return $rep; } $HfnucontactConfig = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php')); $HfnucontactConfig->setValue('email_contact', $this->param('contact'), 'hfnucontact'); $HfnucontactConfig->save(); jMessage::add(jLocale::get('hfnucontact~contact.admin.form.email.saved'), 'ok'); jForms::destroy('hfnucontact~admincontact'); $rep->action = 'hfnucontact~admin:index'; return $rep; } else { $form = jForms::create('hfnucontact~admincontact'); } $form->setData('contact', jApp::config()->hfnucontact['email_contact']); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('hfnucontact~admincontact')); $rep->body->assign('selectedMenuItem', 'contact'); return $rep; }
function images() { $vidsService = new OnDiskVideosService(); $albumId = $this->param('albumId'); $rep = $this->getResponse('html'); $tpl = new Jtpl(); $picasaService = new jPicasa(); $thumbnailSize = 400; foreach ($picasaService->images($albumId, $thumbnailSize) as $image) { $paint = new Painting($image); $paintings[] = $paint; //break; } $tpl->assign('albumId', $albumId); $tpl->assign('images', $paintings); if ($this->param('commented')) { $tpl->assign('commented', true); } else { $tpl->assign('commented', false); } $form = jForms::create('coment'); $form->setData('albumId', $albumId); $tpl->assign('form', $form); $vidFile = $vidsService->getVideo($picasaService->getAlbumById($albumId)->name); $tpl->assign('video', $vidFile); $rep->body->assign('MAIN', $tpl->fetch('images_html')); return $rep; }
protected function _prepareTpl() { $form = jForms::get('password'); if ($form == null) { $form = jForms::create('password'); } $this->_tpl->assign('form', $form); }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $id_forum = $this->param('id_forum'); if (!$id_forum) { return; } $form = jForms::create('havefnubb~jumpto', $id_forum); $this->_tpl->assign('form', $form); }
protected function _prepareTpl() { $form = jForms::get('registration'); if ($form == null) { $form = jForms::create('registration'); } jForms::destroy('confirmation'); jEvent::notify('jcommunity_registration_init_form', array('form' => $form, 'tpl' => $this->_tpl)); $this->_tpl->assign('form', $form); }
/** * form to ask to reindex */ function index() { $rep = $this->getResponse('html'); $form = jForms::create('hfnusearch~indexing'); $tpl = new jTpl(); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('hfnusearch~admin.index')); $rep->body->assign('selectedMenuItem', 'searchengine'); return $rep; }
function testStart() { global $gJCoord; $_SESSION['JFORMS'] = array(); $form = jForms::create('product'); $this->savedParams = $gJCoord->request->params; $labels = array(array('key' => 1, 'keyalias' => 'aa', 'lang' => 'fr', 'label' => 'aa-fr'), array('key' => 2, 'keyalias' => 'bb', 'lang' => 'fr', 'label' => 'bb-fr'), array('key' => 3, 'keyalias' => 'cc', 'lang' => 'fr', 'label' => 'cc-fr'), array('key' => 4, 'keyalias' => 'dd', 'lang' => 'en', 'label' => 'dd-en'), array('key' => 5, 'keyalias' => 'ee', 'lang' => 'en', 'label' => 'ee-en')); $this->insertRecordsIntoTable('labels1_test', array('key', 'keyalias', 'lang', 'label'), $labels, true); $labels = array(array('key' => 1, 'keyalias' => 'aa', 'lang' => 'fr', 'label' => 'aa-fr'), array('key' => 2, 'keyalias' => 'bb', 'lang' => 'fr', 'label' => 'bb-fr'), array('key' => 3, 'keyalias' => 'cc', 'lang' => 'fr', 'label' => 'cc-fr'), array('key' => 1, 'keyalias' => 'dd', 'lang' => 'en', 'label' => 'dd-en'), array('key' => 2, 'keyalias' => 'ee', 'lang' => 'en', 'label' => 'ee-en')); $this->insertRecordsIntoTable('labels_test', array('key', 'keyalias', 'lang', 'label'), $labels, true); }
protected function _prepareTpl() { $id = $this->param('id'); $form = jForms::create('events'); $form->initFromDao('events', $id); $this->_tpl->assign('id', $id); $this->_tpl->assign('form', $form); $this->_tpl->assign('record', jDao::get('events')->get($id)); $this->_tpl->assign('editAction', 'events~events:preupdate'); $this->_tpl->assign('deleteAction', 'events~events:delete'); $this->_tpl->assign('listAction', 'events~events:index'); }
function editPage() { $form = jForms::create("pages"); $form->setData('name', $this->param('page')); $pageSrv = new PagesService(); $text = $pageSrv->getPage($this->param('page')); $form->setData('text', $text); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('editPage')); return $rep; }
function index() { $form = jForms::create('hfnuadmin~bans'); $dao = jDao::get('havefnubb~bans'); $bans = $dao->findAll(); $tpl = new jTpl(); $tpl->assign('form', $form); $tpl->assign('bans', $bans); $rep = $this->getResponse('html'); $rep->body->assign('MAIN', $tpl->fetch('hfnuadmin~bans_edit')); $rep->body->assign('selectedMenuItem', 'ban'); return $rep; }
/** * */ function index() { $rep = $this->getResponse('html'); $form = jForms::get('config'); if (!$form) { $form = jForms::create('config'); $activeusers = jClasses::create('activeusers~connectedusers'); $form->setData('timeout_visit', $activeusers->getVisitTimeout()); } $tpl = new jTpl(); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('config')); return $rep; }
function config() { $resp = $this->getResponse('html'); $form = jForms::get('hfnuadmin~config'); if (!$form) { $form = jForms::create('hfnuadmin~config'); $this->initform($form); } $tpl = new jTpl(); $tpl->assign('form', $form); $forumUrl = '<a href="' . jUrl::get('hfnuadmin~forum:index') . '" >' . jLocale::get('config.anonymous_post_authorized.rights.management.by.forum') . '</a>'; $tpl->assign('forumUrl', $forumUrl); $resp->body->assign('MAIN', $tpl->fetch('config')); $resp->body->assign('selectedMenuItem', 'config'); return $resp; }
function index() { $tpl = new jTpl(); $form = jForms::create('hfnuadmin~ranks'); $dao = jDao::get('havefnubb~ranks'); $ranks = $dao->findAll(); //initializing of the Token $token = jClasses::getService("havefnubb~hfnutoken"); $token->setHfnuToken(); $tpl->assign('hfnutoken', $token->getHfnuToken()); $tpl->assign('form', $form); $tpl->assign('ranks', $ranks); $rep = $this->getResponse('html'); $rep->body->assign('MAIN', $tpl->fetch('hfnuadmin~ranks_index')); $rep->body->assign('selectedMenuItem', 'ranks'); return $rep; }
function index() { $rep = $this->getResponse('html'); $tpl = new jTpl(); $form = jForms::create('search'); $tpl->assign('formulaire', $form); $vidsServ = new OnDiskVideosService(); $tpl->assign('video', $vidsServ->randomVideo()); $picasaSrv = new jPicasa(); $paintings = array(); foreach ($picasaSrv->lastImages() as $img) { $paintings[$img->name] = new Painting($img); } $tpl->assign('images', $paintings); $rep->body->assign('MAIN', $tpl->fetch('photogallery_index')); return $rep; }
/** * The user want to change his password */ function changepwd() { $login = $this->param('user'); if ($login == '' || !jAuth::isConnected() || jAuth::getUserSession()->login != $login) { $rep = $this->getResponse('redirect'); $rep->action = 'jcommunity~account:show'; $rep->params = array('user' => $user); return $rep; } $form = jForms::create('havefnubb~pwd', $login); $form->initFromDao('havefnubb~pwd'); $rep = $this->getResponse('html'); $tpl = new jTpl(); $tpl->assign('login', $login); $tpl->assign('form', $form); $rep->body->assign('selectedMenuItem', 'members'); $rep->body->assign('MAIN', $tpl->fetch('member_changepwd')); return $rep; }
function prepareEdit() { $user = $this->param('user'); $rep = $this->getResponse('redirect'); $rep->action = 'jcommunity~account:show'; $rep->params = array('user' => $user); if (!jAuth::isConnected() || jAuth::getUserSession()->login != $user) { return $rep; } $form = jForms::create('account', $this->param('user')); jEvent::notify('jcommunity_init_edit_form_account', array('login' => $user, 'form' => $form)); try { $form->initFromDao('user'); } catch (Exception $e) { return $rep; } jEvent::notify('jcommunity_prepare_edit_account', array('login' => $user, 'form' => $form)); $rep->action = 'jcommunity~account:edit'; return $rep; }
function show() { // recupère les données du formulaire $form = jForms::get('sample'); if ($form == null) { $form = jForms::create('sample'); $form->deactivate('unwanted'); } $rep = $this->getResponse('html'); $rep->title = 'Form editing'; $tpl = new jTpl(); $tpl->assign('form', $form); $tpl->assign('builder', $this->param('builder', 'html')); if ($this->param('full')) { $rep->body->assign('MAIN', $tpl->fetch('sampleformfull')); } else { $rep->body->assign('MAIN', $tpl->fetch('sampleform')); } $rep->body->assign('page_title', 'forms'); return $rep; }
function answer() { $resp = $this->precreate(); $this->_markAsRead(); if ($id = $this->param("id")) { // verify i'm the dest of the message i will answer $mail = jDao::get($this->dao)->get($id); if ($mail->id_for != jAuth::getUserSession()->id) { return $resp; } $form = jForms::get($this->form); if ($form == null) { $form = jForms::create($this->form); } $form->deactivate("id_for", true); $form->setData("answer_to", $mail->id_from); $resp->params['id'] = $id; $form->setData("title", "Re : " . jDao::get($this->dao)->get($id)->title); } return $resp; }
/** * */ public function edit() { $rep = $this->getResponse('html'); $id = $this->param('id', 0); $pref = jPrefManager::getPref($id); if (!$pref) { $rep = $this->getResponse('redirect'); $rep->action = 'jpref_admin~prefs:index'; return $rep; } if (!$pref->isWritable()) { $rep = $this->getResponse('redirect'); $rep->action = 'jpref_admin~prefs:index'; jMessage::add(jLocale::get('jacl2~errors.action.right.needed'), 'error'); return $rep; } $form = jForms::create('jpref_admin~pref', $id); $ctrls = array('integer', 'string', 'boolean', 'decimal'); foreach ($ctrls as $c) { $form->deactivate($c); } $form->deactivate($pref->type, false); $label = !empty($pref->locale) ? jLocale::get($pref->locale) : $pref->id; $control = $form->getControl($pref->type); $control->label = $label; if ($pref->type != 'boolean') { $control->help = jLocale::get('jpref_admin~admin.help.' . $pref->type); } if (!empty($pref->value)) { $form->setData($pref->type, $pref->value); } $tpl = new jTpl(); $tpl->assign('form', $form); $tpl->assign('title', jLocale::get('jpref_admin~admin.pref.edit', array($label))); $tpl->assign('id', $id); $tpl->assign('field', $pref->type); $rep->body->assign('MAIN', $tpl->fetch('pref_edit')); $rep->body->assign('selectedMenuItem', 'pref'); return $rep; }
/** * Create the form to resquest an account. * * @return Redirect to the form display action. */ function createAccount() { $rep = $this->getResponse('redirect'); $rep->action = 'view~default:index'; // Get lizmap services $services = lizmap::getServices(); // Redirect if not active if (!$services->allowUserAccountRequests) { return $rep; } // Redirect if already a logged user if (jAuth::isConnected()) { jMessage::add(jLocale::get("view~user.already.logged")); return $rep; } // Create the form $form = jForms::create('view~lizmap_user'); // redirect to the form display action $rep = $this->getResponse("redirect"); $rep->action = "view~user:editAccount"; return $rep; }
/** * function to manage data before assigning to the template of its zone */ protected function _prepareTpl() { $thread_id = (int) $this->param('thread_id'); $id_post = (int) $this->param('id_post'); $id_forum = (int) $this->param('id_forum'); $isConnected = (bool) $this->param('connected'); if ($id_post < 1) { return; } if ($id_forum < 1) { return; } $daoUser = jDao::get('havefnubb~member'); if (jAuth::isConnected()) { $user = $daoUser->getByLogin(jAuth::getUserSession()->login); } else { $user = new StdClass(); $user->id = 0; } $post = jClasses::getService('havefnubb~hfnuposts')->getPost($id_post); $subject = ''; if ($post->subject != '') { $subject = $post->subject; } if (jAuth::isConnected()) { $form = jForms::create('havefnubb~posts', $thread_id); } else { $form = jForms::create('havefnubb~posts_anonym', $thread_id); } $form->setData('id_forum', $id_forum); $form->setData('id_user', $user->id); $form->setData('id_post', $id_post); $form->setData('thread_id', $thread_id); $form->setData('subject', $subject); $this->_tpl->assign('form', $form); $this->_tpl->assign('id_post', $id_post); $this->_tpl->assign('thread_id', $thread_id); }
protected function _prepareTpl() { if (jAuth::isConnected()) { $this->_tpl->assign('login', jAuth::getUserSession()->login); } else { $conf = jApp::coord()->getPlugin('auth')->config; $this->_tpl->assign('persistance_ok', $conf['persistant_enable']); $form = jForms::get("jcommunity~login"); if (!$form) { $form = jForms::create("jcommunity~login"); } $this->_tpl->assign('form', $form); if ($conf['enable_after_login_override']) { $req = jApp::coord()->request; if ($req->getParam('auth_url_return')) { $this->_tpl->assign('url_return', $req->getParam('auth_url_return')); } else { if ($this->param('as_main_content')) { if ($_SERVER['HTTP_REFERER']) { $this->_tpl->assign('url_return', $_SERVER['HTTP_REFERER']); } else { $this->_tpl->assign('url_return', ''); } } else { //(empty($_SERVER['HTTPS'])?'http':'https').'://'.$_SERVER["HTTP_HOST"]. $url = $req->urlScript . $req->urlPathInfo; if (!empty($_SERVER['QUERY_STRING'])) { $url .= '?' . $_SERVER['QUERY_STRING']; } $this->_tpl->assign('url_return', $url); } } } else { $this->_tpl->assign('url_return', ''); } } }
/** * displays a record */ function view() { $spk = $this->param($this->spkName); $dpk = $this->param($this->dpkName); $page = $this->param($this->offsetParameterName); if ($dpk === null) { $rep = $this->getResponse('redirect'); $rep->action = $this->_getAction('index'); $rep->params[$this->spkName] = $spk; return $rep; } $rep = $this->_getResponse(); $id = $this->_getPk($spk, $dpk); // we're using a form to display a record, to have the portunity to have // labels with each values. We need also him to load easily values of some // of controls with initControlFromDao (to use in _view method). $form = jForms::create($this->form, $id); $form->initFromDao($this->dao, $id, $this->dbProfile); $tpl = new jTpl(); $tpl->assign('dpk', $dpk); $tpl->assign('dpkName', $this->dpkName); $tpl->assign('spkName', $this->spkName); $tpl->assign('spk', $spk); $tpl->assign('form', $form); $tpl->assign('page', $page); $tpl->assign('offsetParameterName', $this->offsetParameterName); $tpl->assign('editAction', $this->_getAction('preupdate')); $tpl->assign('deleteAction', $this->_getAction('delete')); $tpl->assign('listAction', $this->_getAction('index')); $this->_view($form, $rep, $tpl); $rep->body->assign($this->templateAssign, $tpl->fetch($this->viewTemplate)); return $rep; }
/** * Modification of a repository. * @return Redirect to the form display action. */ public function modifySection() { // initialise data $repository = $this->param('repository'); // Get the corresponding repository $lrep = lizmap::getRepository($repository); // Redirect if no repository with this key if (!$lrep || $lrep->getKey() != $repository) { $rep = $this->getResponse('redirect'); $rep->action = 'admin~config:index'; return $rep; } // Create and fill the form $form = jForms::create('admin~config_section'); $form->setData('new', "0"); $form->setData('repository', (string) $lrep->getKey()); $form->setReadOnly('repository', true); // Create and fill form controls relatives to repository data lizmap::constructRepositoryForm($lrep, $form); // Create and fill the form control relative to rights for each group for this repository $form = $this->populateRepositoryRightsFormControl($form, $lrep->getKey(), 'db'); // redirect to the form display action $rep = $this->getResponse("redirect"); $rep->params['repository'] = $repository; $rep->action = "admin~config:editSection"; return $rep; }
/** * create the form. You can redefine this method to modify dynamically the form * Typically, you call jForms::create and then you can call addControl or whatever. * Don't do a jForms::get or jForms::fill in this method ! * called in methods: index, precreate, create, preupdate, view * @return jFormsBase the form * @since 1.1 */ protected function _createForm($formId = null) { return jForms::create($this->form, $formId); }
public function getDefaultBottomDockable() { jClasses::inc('view~lizmapMapDockItem'); $dockable = array(); $configOptions = $this->getOptions(); $bp = jApp::config()->urlengine['basePath']; if ($this->hasAttributeLayers()) { $form = jForms::create('view~attribute_layers_option'); $assign = array('form' => $form); $tpl = new jTpl(); $dockable[] = new lizmapMapDockItem('attributeLayers', jLocale::get('view~map.attributeLayers.navbar.title'), array('view~map_attributeLayers', $assign), 1, '', $bp . 'js/attributeTable.js'); } return $dockable; }
/** * form to enter the confirmation key * to activate the new password */ function confirmform() { $repError = $this->_check(); if ($repError) { return $repError; } $rep = $this->_getjCommunityResponse(); $form = jForms::get('confirmation'); if ($form == null) { $form = jForms::create('confirmation'); } $tpl = new jTpl(); $tpl->assign('form', $form); $rep->body->assign('MAIN', $tpl->fetch('password_confirmation')); return $rep; }
/** * Send a thread to a friend */ public function send_to_friend() { if (!array_key_exists('SENDTOFRIEND', $_SESSION)) { $rep = $this->getResponse('redirect'); $rep->action = 'jelix~error:404'; return $rep; } $url = $_SESSION['SENDTOFRIEND']['send_to_friend_url']; $message = jLocale::get('contact.a.page.to.read.message') . "\n\n" . 'http://' . $_SERVER['SERVER_NAME'] . '/' . $url; $subject = jLocale::get('contact.a.page.to.read.subject', 'http://' . $_SERVER['SERVER_NAME'] . '/' . $url); $form = jForms::create('hfnucontact~send_to_friend'); $form->setData('message', $message); $form->setData('subject', $subject); $rep = $this->getResponse('html'); $rep->title = jLocale::get('contact.send.an.email.to.a.friend'); $tpl = new jTpl(); $tpl->assign('form', $form); $tpl->assign('action', 'hfnucontact~default:send_a_message_to_friend'); $rep->body->assign('MAIN', $tpl->fetch('hfnucontact~send_to_friend')); return $rep; }