Example #1
0
<?php

/**
 * Dispatch other controllers
 *
 * @author   Anton Shevchuk
 * @created  23.08.12 13:14
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([Layout::ahref('Test', ['test', 'index']), 'Dispatch']);
};
Example #2
0
<?php

/**
 * Test of test of test
 *
 * @author   Anton Shevchuk
 * @created  21.08.12 12:39
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () {
    /**
     * @var Bootstrap $this
     */
    Layout::title('Test Module');
    Layout::title('Append', Layout::POS_APPEND);
    Layout::title('Prepend', Layout::POS_PREPEND);
    Layout::breadCrumbs(['Test']);
};
Example #3
0
<?php

/**
 * Disable view, like for backbone.js
 *
 * @author   Anton Shevchuk
 * @created  22.08.12 17:14
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () {
    Layout::breadCrumbs([Layout::ahref('Test', ['test', 'index']), 'Without view']);
    return function () {
    };
};
Example #4
0
<?php

/**
 * Grid of users
 *
 * @author   Anton Shevchuk
 * @created  02.08.12 18:39
 * @return closure
 */
namespace Application;

use Application\Users;
use Bluz\Controller\Controller;
use Bluz\Proxy\Db;
use Bluz\Proxy\Layout;
/**
 * @privilege Management
 * @return \closure
 */
return function () {
    /**
     * @var Controller $this
     */
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), __('Users')]);
    $grid = new Users\Grid();
    $grid->setModule($this->module);
    $grid->setController($this->controller);
    $this->assign('roles', Db::fetchAll('SELECT * FROM acl_roles'));
    $this->assign('grid', $grid);
};
Example #5
0
<?php

/**
 * Example of forms handle
 *
 * @category Application
 *
 * @author   dark
 * @created  13.12.13 18:12
 */
namespace Application;

use Bluz\Proxy\Layout;
use Bluz\Proxy\Request;
return function ($int, $string, $array, $optional = 0) use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Form Example']);
    if (Request::isPost()) {
        ob_start();
        var_dump($int, $string, $array, $optional);
        $view->inside = ob_get_contents();
        ob_end_clean();
        $view->params = Request::getAllParams();
    }
};
Example #6
0
/**
 * Test MVC
 *
 * @author   dark
 * @created  08.07.11 13:23
 */
namespace Application;

use Bluz\Proxy\Cache;
use Bluz\Proxy\Layout;
return function ($id = null) use($bootstrap, $view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Cache Data']);
    /* @var Bootstrap $this */
    Layout::title('Check cache');
    // try to load profile of current user
    if (!$id && $this->user()) {
        $id = $this->user()->id;
    }
    if (!$id) {
        throw new \Exception('User not found', 404);
    }
    /**
     * @var Users\Row $userRow
     */
    if (!($userRow = Cache::get('user:'******'user:' . $id, $userRow, 30);
Example #7
0
<?php

/**
 * Get custom reflection data
 *
 * @category Application
 *
 * @author   dark
 * @created  17.05.13 17:05
 */
namespace Application;

use Bluz\Controller\Reflection;
use Bluz\Proxy\Layout;
return function ($id = 0, $other = "default value") use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Reflection of this controllers']);
    $reflection = new Reflection(__FILE__);
    $reflection->process();
    $view->functionData = file_get_contents(__FILE__);
    $view->reflectionData = $this->reflection(__FILE__);
    $view->id = $id;
    $view->other = $other;
};
Example #8
0
 * @category Application
 *
 * @author   Anton Shevchuk
 * @created  14.11.13 10:45
 */
namespace Application;

use Bluz\Db\Relations;
use Bluz\Proxy\Db;
use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'DB Relations']);
    /* @var Pages\Row */
    $page = Pages\Table::findRow(5);
    $user = $page->getRelation('Users');
    echo "<h2>Page Owner</h2>";
    var_dump($user);
    $pages = $user->getRelations('Pages');
    echo "<h2>User pages</h2>";
    var_dump(sizeof($pages));
    $roles = $user->getRelations('Roles');
    echo "<h2>User roles</h2>";
    var_dump($roles);
    echo "<h2>User with all relations</h2>";
    var_dump($user);
    $result = Db::fetchRelations("SELECT '__users', u.*, '__pages', p.* FROM users u LEFT JOIN pages p ON p.userId = u.id");
    echo "<h2>User - Page relation</h2>";
Example #9
0
<?php

/**
 * Example of DB usage
 *
 * @author   Anton Shevchuk
 * @created  07.09.12 18:28
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \closure $bootstrap
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Basic DB operations']);
    // all examples inside view
};
Example #10
0
<?php

/**
 * Disable view, like for backbone.js
 *
 * @author   Anton Shevchuk
 * @created  22.08.12 17:14
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Closure']);
    return function () {
        echo "<div class='jumbotron'><div class='container'>";
        echo "<h3>Closure is back</h3>";
        echo "<p class='text-warning text-primary'>Executed before render layout</p>";
        echo "</div></div>";
    };
};
Example #11
0
<?php

/**
 * Build list of routers
 *
 * @author   Anton Shevchuk
 * @created  12.06.12 12:27
 */
/**
 * @namespace
 */
namespace Application;

use Bluz\Common\Nil;
use Bluz\Proxy\Cache;
use Bluz\Proxy\Layout;
use Bluz\Proxy\Messages;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), $view->ahref('Cache', ['cache', 'index']), __('Statistics')]);
    if (!Cache::getInstance() instanceof Nil) {
        $view->adapter = Cache::getInstance()->getAdapter();
    } else {
        Messages::addNotice("Cache is disabled");
        $this->redirectTo('cache', 'index');
    }
};
Example #12
0
namespace Application;

use Application\Media;
use Bluz\Controller;
use Bluz\Proxy\Config;
use Bluz\Proxy\Layout;
use Bluz\Proxy\Session;
use Bluz\Request\AbstractRequest;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Session::start();
    $this->useLayout('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), $view->ahref('Media', ['media', 'grid']), __('Upload')]);
    if (!$this->user()) {
        throw new Exception('User not found');
    }
    $userId = $this->user()->id;
    $crud = Media\Crud::getInstance();
    // get path from config
    $path = Config::getModuleData('media', 'upload_path');
    if (empty($path)) {
        throw new Exception('Upload path is not configured');
    }
    $crud->setUploadDir($path . '/' . $userId . '/media');
    $crudController = new Controller\Crud();
    $crudController->setCrud($crud);
    $result = $crudController();
    // FIXME: workaround
Example #13
0
<?php

/**
 * Example of backbone usage
 *
 * @category Application
 *
 * @author   dark
 * @created  13.08.13 17:16
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Backbone']);
};
Example #14
0
<?php

/**
 * Default dashboard module/controller
 *
 * @author   Anton Shevchuk
 * @created  06.07.11 18:39
 * @return   \Closure
 */
/**
 * @namespace
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () {
    /**
     * @var Bootstrap $this
     */
    Layout::breadCrumbs([__('Dashboard')]);
    Layout::setTemplate('dashboard.phtml');
};
Example #15
0
<?php

/**
 * Demo of View helpers
 *
 * @category Application
 *
 * @author   dark
 * @created  14.05.13 16:12
 */
namespace Application;

use Bluz\Proxy\Layout;
use Bluz\Proxy\Request;
return function ($sex = false, $car = 'none', $remember = false) use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'View Form Helpers']);
    /**
     * @var Bootstrap $this
     */
    $view->sex = $sex;
    $view->car = $car;
    $view->remember = $remember;
    if (Request::isPost()) {
        $view->params = Request::getAllParams();
    }
};
Example #16
0
<?php

/**
 * Default module/controllers
 *
 * @author   Anton Shevchuk
 * @created  06.07.11 18:39
 * @return closure
 */
namespace Application;

use Bluz\Proxy\Layout;
use Bluz\Proxy\Session;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Session']);
    Layout::title("Test/Index");
    Session::set('test', Session::get('test') ?: 'Session time: ' . date("H:i:s"));
    $view->title = Layout::title();
    $view->session = Session::get('test');
    //    if ($identity = $app->user()) {
    //        var_dump($acl->isAllowed('index/index', $identity['sid']));
    //        var_dump($acl->isAllowed('index/test', $identity['sid']));
    //        var_dump($acl->isAllowed('index/error', $identity['sid']));
    //    } else {
    //        Auth::authenticate('admin', '123456');
    //    }
};
Example #17
0
<?php

/**
 * Bootstrap example
 *
 * @author   Anton Shevchuk
 * @created  12.06.12 13:08
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($bootstrap, $view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Bootstrap']);
    $view->result = $bootstrap(2);
};
Example #18
0
<?php

/**
 * Grid of pages
 *
 * @author   Anton Shevchuk
 * @created  27.08.12 10:08
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view, $module, $controller) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), __('Pages')]);
    $grid = new Pages\Grid();
    $grid->setModule($module);
    $grid->setController($controller);
    $view->grid = $grid;
};
Example #19
0
<?php

/**
 * PHP Info Wrapper
 *
 * @author   Anton Shevchuk
 * @created  22.08.12 17:14
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::title('PHP Info');
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), $view->ahref('System', ['system', 'index']), __('PHP Info')]);
};
Example #20
0
 */
/**
 * @namespace
 */
namespace Application;

use Application\Categories;
use Bluz\Proxy\Layout;
use Bluz\Proxy\Messages;
return function ($id = null) use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::setTemplate('dashboard.phtml');
    Layout::headStyle($view->baseUrl('css/categories.css'));
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'grid']), __('Categories')]);
    $categoriesTable = Categories\Table::getInstance();
    $rootTree = $categoriesTable->getAllRootCategory();
    if (count($rootTree) == 0) {
        Messages::addNotice('There are no categories');
        return $view;
    }
    $view->rootTree = $rootTree;
    if (!$id) {
        $id = $rootTree[0]->id;
    }
    $view->branch = $id;
    $view->tree = $categoriesTable->buildTree($id);
    return $view;
};
Example #21
0
 * Created by PhpStorm.
 * User: gunko
 * Date: 9/14/15
 * Time: 11:04 AM
 */
namespace Application;

use Bluz\Proxy\Layout;
use Bluz\Proxy\Request;
use Bluz\Proxy\Response;
return function () use($view, $module, $controller) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), __('Musician')]);
    $countCol = Request::getParam('countCol');
    if ($countCol != null) {
        Response::setCookie("countCol", $countCol, time() + 3600, '/');
    } else {
        $countCol = Request::getCookie('countCol', 4);
    }
    $grid = new Musician\Grid();
    $lnCol = (int) (12 / $countCol);
    $view->countCol = $countCol;
    $view->col = $lnCol;
    $grid->setModule($module);
    $grid->setController($controller);
    $view->grid = $grid;
};
Example #22
0
<?php

/**
 * Example of grid
 *
 * @author   Anton Shevchuk
 * @created  27.08.12 10:08
 */
namespace Application;

use Application\Test;
use Bluz\Proxy\Layout;
return function ($alias) use($view, $module, $controller) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Grid with Select']);
    $grid = new Test\SelectGrid();
    $grid->setModule($module);
    $grid->setController($controller);
    $grid->setParams(['alias' => $alias]);
    $view->grid = $grid;
    return 'grid-sql.phtml';
};
Example #23
0
<?php

/**
 * Debug bookmarklet
 *
 * @author   Anton Shevchuk
 * @created  22.08.12 17:14
 */
namespace Application;

use Bluz\Controller\Controller;
use Bluz\Proxy\Layout;
/**
 * @privilege Info
 *
 * @return array
 */
return function () {
    /**
     * @var Controller $this
     */
    Layout::title('Bookmarklets');
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), Layout::ahref('System', ['system', 'index']), __('Bookmarklets')]);
    $key = getenv('BLUZ_DEBUG_KEY') ?: 'BLUZ_DEBUG';
    return ['key' => $key];
};
Example #24
0
<?php

/**
 * Route examples
 *
 * @author   Anton Shevchuk
 * @created  12.06.12 13:08
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Routers Examples']);
};
Example #25
0
<?php

/**
 * Example of DB Query builder usage
 *
 * @author   Anton Shevchuk
 * @created  07.06.13 18:28
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \closure $bootstrap
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'DB Query Builders']);
    // all examples inside view
};
Example #26
0
/**
 * Build list of custom routers
 *
 * @author   Anton Shevchuk
 * @created  12.06.12 12:27
 */
namespace Application;

use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::title('Routers Map');
    Layout::setTemplate('dashboard.phtml');
    Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), $view->ahref('System', ['system', 'index']), __('Routers Map')]);
    $routers = array();
    foreach (new \GlobIterator(PATH_APPLICATION . '/modules/*/controllers/*.php') as $file) {
        $module = pathinfo(dirname(dirname($file->getPathname())), PATHINFO_FILENAME);
        $controller = pathinfo($file->getPathname(), PATHINFO_FILENAME);
        $reflection = $this->reflection($file->getPathname());
        if ($route = $reflection->getRoute()) {
            if (!isset($routers[$module])) {
                $routers[$module] = array();
            }
            $routers[$module][$controller] = ['route' => $route, 'params' => $reflection->getParams()];
        }
    }
    $view->routers = $routers;
};
Example #27
0
 *
 * @author   Anton Shevchuk
 * @created  16.03.12 15:21
 * @return closure
 */
namespace Application;

use Bluz\EventManager\Event;
use Bluz\Proxy\EventManager;
use Bluz\Proxy\Layout;
return function () use($view) {
    /**
     * @var Bootstrap $this
     * @var \Bluz\View\View $view
     */
    Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Events']);
    EventManager::attach('testevent', function (Event $event) {
        return $event->getTarget() * 2;
    });
    EventManager::attach('testevent', function (Event $event) {
        return $event->getTarget() * 2;
    });
    EventManager::attach('testspace:event', function (Event $event) {
        return $event->getTarget() + 4;
    });
    EventManager::attach('testspace:event', function (Event $event) {
        return $event->getTarget() + 2;
    });
    EventManager::attach('testspace:event2', function (Event $event) {
        $event->setTarget($event->getTarget() + 5);
        return false;