Example #1
0
 }
 set_page_title(t("Page: {$pageArray['label']}"));
 // form
 \Meta\Core\Form::validateRequired('name');
 \Meta\Core\Form::validateRequired('label');
 $new_name = \Meta\Core\Form::value('name');
 // page rename action detect
 $renamed = false;
 if (is_post() && $new_name != $path) {
     $renamed = true;
     // validate page exists
     if (isset($pages[$new_name])) {
         \Meta\Core\Form::addError(t('This page already exists'));
     }
 }
 if (\Meta\Core\Form::hasValidated()) {
     if (is_demo()) {
         \Meta\Core\Flash::error(\Meta\Builder::demoMsg());
     } else {
         \Meta\Core\Flash::success(t('Page updated.'));
         // changes the new page name
         if ($renamed) {
             $pages[$new_name] = $pages[$path];
             unset($pages[$path]);
             $path = $new_name;
         }
         // atualiza array
         $page = new \Meta\Builder\Page($path, $pageArray);
         $page->label = \Meta\Core\Form::value('label');
         $page->showonmenu = \Meta\Core\Form::checked('showonmenu');
         $page->checkperms = \Meta\Core\Form::checked('checkperms');
Example #2
0
<?php

use Meta\Core\Flash;
use Meta\Core\Form;
use Meta\Core\User;
use Meta\Builder\Page;
route_add('user-login', function () {
    set_page_title('User authentication');
    Form::validateRequired('username');
    Form::validateRequired('password');
    if (Form::hasValidated()) {
        if (User::authenticate($_POST['username'], $_POST['password'])) {
            if (isset($_GET['back_to'])) {
                redirect(urldecode($_GET['back_to']));
            } else {
                redirect(PAGE_HOME);
            }
        } else {
            Flash::error(t('Invalid username or password!'));
        }
    }
    echo Page::renderLayout(array('content' => render('user-login.php')));
});
route_add('user-logout', function () {
    User::logout();
    redirect(PAGE_HOME);
});