public function testNonOptionsRequest()
 {
     $this->app['dispatcher']->addSubscriber(new CorsAcceptListener($this->app));
     $this->request->setMethod("GET");
     $response = $this->app->handle($this->request);
     $this->assertNull($response->headers->get("access-control-allow-headers"));
     $this->assertInstanceOf("Symfony\\Component\\HttpFoundation\\Response", $response);
 }
Beispiel #2
0
 static function get($data)
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $tpl = new Template($registry->get('template_path') . 'login.htm');
     return $tpl->apply(['message' => $data['message'], 'loginError' => $_SESSION['login_error'], 'site_root' => $application->siteRoot]);
 }
Beispiel #3
0
 function edit()
 {
     $registry = Registry::getInstance();
     $application = Application::getInstance();
     $locale = $registry->get('locale');
     $locales = LocaleManager::getLocales();
     $exercise = new Exercise(intval($_GET['id']));
     if ($_POST['action'] == 'save') {
         //d($_POST, 1);
         $exercise->name = trim($_POST['name']);
         $exercise->description = trim($_POST['description']);
         $exercise->controller = trim($_POST['controller']);
         $exercise->configTemplate = trim($_POST['config_template']);
         $exercise->save();
         header('Location: /cms/exercise/list');
         exit;
     } else {
         $i18n = new I18n($registry->get('i18n_path') . 'exercise.xml');
         $data = ['exercise' => $exercise];
         $renderer = new Renderer(Page::MODE_NORMAL);
         $pTitle = $i18n->get($exercise->id ? 'update_mode' : 'append_mode');
         $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', ExerciseEditView::get($data));
         $renderer->loadPage();
         $renderer->output();
     }
 }
Beispiel #4
0
 static function get($data)
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $exercise = $data['exercise'];
     $tpl = new Template($registry->get('template_path') . 'exercise_edit.htm');
     return $tpl->apply(['id' => $exercise->id, 'name' => htmlspecialchars($exercise->name), 'description' => htmlspecialchars($exercise->description), 'controller' => htmlspecialchars($exercise->controller), 'config_template' => htmlspecialchars($exercise->configTemplate), 'site_root' => $application->siteRooot]);
 }
Beispiel #5
0
 static function get($data)
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $router = $data['router'];
     $tpl = new Template($registry->get('template_path') . 'router_edit.htm');
     return $tpl->apply(['id' => $router->id, 'name' => htmlspecialchars($router->name), 'url' => htmlspecialchars($router->url), 'controller' => $router->controller, 'site_root' => $application->siteRooot]);
 }
Beispiel #6
0
 function renumber()
 {
     $application = Application::getInstance();
     $courseId = intval($application->segment[3]);
     if ($courseId) {
         Lesson::renumberAll($_POST['order']);
         //            Lesson::renumberAll($_POST['order'], NULL, NULL, '`course_id`='.$courseId);
         echo 'OK';
     } else {
         echo 'No CourseID';
     }
     exit;
 }
Beispiel #7
0
 static function get($data)
 {
     $registry = Registry::getInstance();
     $application = Application::getInstance();
     $localeId = $registry->get('locale');
     $localeData = LocaleManager::getLocaleData($localeId);
     $tpl = new Template($registry->get('template_path') . 'course.htm');
     $tpli = new template($registry->get('template_path') . 'course_item.htm');
     $listItems = '';
     foreach ($data['list'] as $item) {
         $listItems .= $tpli->apply(['id' => $item->id, 'name' => $item->l10n->get('name', $localeId), 'owner' => $data['ownerList'][$item->ownerId]->name, 'dateCreate' => date($localeData['dateFormat'], $item->dateCreate), 'dateUpdate' => $item->dateUpdate ? date($localeData['dateFormat'], $item->dateUpdate) : '', 'active' => $item->state, 'rights' => $item->rights]);
     }
     return $tpl->apply(['items' => $listItems, 'site_root' => $application->siteRoot]);
 }
Beispiel #8
0
 static function get($data)
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $tpl = new Template($registry->get('template_path') . 'exercise.htm');
     $tpli = new Template($registry->get('template_path') . 'exercise_item.htm');
     $list = $data['list'];
     $cnt = count($data['list']);
     $listItems = '';
     foreach ($list as $line) {
         $listItems .= $tpli->apply(['id' => $line->id, 'name' => $line->name, 'description' => $line->description, 'controller' => $line->controller, 'configTemplate' => $line->configTemplate]);
     }
     return $tpl->apply(['count' => $cnt, 'items' => $listItems, 'site_root' => $application->siteRoot]);
 }
Beispiel #9
0
 static function get($data)
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $i18n = new I18n($registry->get('i18n_path') . 'admin.xml');
     $localeData = LocaleManager::getLocaleData($registry->get('locale'));
     $tpl = new Template($registry->get('template_path') . 'admin.htm');
     $tpli = new template($registry->get('template_path') . 'admin_item.htm');
     $listItems = '';
     foreach ($data['list'] as $item) {
         $listItems .= $tpli->apply(['id' => $item->id, 'description' => $item->description, 'email' => $item->email, 'login' => $item->login, 'name' => $item->name, 'state' => $i18n->get('state' . $item->state), 'rights' => $item->rights, 'dateCreate' => date($localeData['dateFormat'], $item->dateCreate), 'dateLogin' => $item->dateLogin ? date($localeData['dateFormat'], $item->dateLogin) : '', 'locale' => $item->locale]);
     }
     return $tpl->apply(['items' => $listItems, 'site_root' => $application->siteRoot]);
 }
Beispiel #10
0
 function __construct()
 {
     $application = Application::getInstance();
     if ($_SESSION['admin']['id']) {
         // main menu
         switch ($application->segment[1]) {
             case 'admin':
                 $controller = new AdminController();
                 break;
             case 'router':
                 $controller = new RouterController();
                 break;
             case 'redirect':
                 $controller = new RedirectController();
                 break;
             case 'setup':
                 $controller = new SetupController();
                 break;
             case 'course':
                 $controller = new CourseController();
                 break;
             case 'lesson':
                 $controller = new LessonController();
                 break;
             case 'stage':
                 $controller = new StageController();
                 break;
             case 'exercise':
                 $controller = new ExerciseController();
                 break;
             case 'logout':
                 unset($_SESSION['admin']);
                 header('Location: /cms');
                 break;
             default:
                 $registry = Registry::getInstance();
                 $i18n = new I18n($registry->get('i18n_path') . 'cms.xml');
                 $renderer = new Renderer(Page::MODE_NORMAL);
                 $pTitle = $i18n->get('title');
                 $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', '');
                 $renderer->loadPage();
                 $renderer->output();
         }
     } else {
         // authent
         $controller = new LoginController();
     }
 }
Beispiel #11
0
 static function get($data)
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $locale = $registry->get('locale');
     $locales = LocaleManager::getLocales();
     $tplso = new Template($registry->get('template_path') . 'select_option.htm');
     $admin = $data['admin'];
     $localeItems = '';
     foreach ($locales as $locale => $localeData) {
         $localeItems .= $tplso->apply(['name' => $localeData['name'], 'value' => $locale, 'selected' => $locale == $admin->locale]);
     }
     $localeData = LocaleManager::getLocaleData($registry->get('locale'));
     $tpl = new Template($registry->get('template_path') . 'admin_edit.htm');
     return $tpl->apply(['id' => $admin->id, 'description' => htmlspecialchars($admin->description), 'email' => htmlspecialchars($admin->email), 'login' => htmlspecialchars($admin->login), 'name' => htmlspecialchars($admin->name), 'rights' => $admin->rights, 'state' => $admin->state, 'localeItems' => $localeItems, 'dateCreate' => date($localeData['dateFormat'], $admin->dateCreate), 'dateLogin' => $admin->dateLogin ? date($localeData['dateFormat'] . ' H:i', $admin->dateLogin) : '', 'site_root' => $application->siteRoot]);
 }
Beispiel #12
0
 static function get($data)
 {
     $registry = Registry::getInstance();
     $application = Application::getInstance();
     $locales = LocaleManager::getLocales();
     $locale = $registry->get('locale');
     $tpl = new Template($registry->get('template_path') . 'stage_edit.htm');
     $tplTab = new Template($registry->get('template_path') . 'stage_edit_tab.htm');
     $tplTabContent = new Template($registry->get('template_path') . 'stage_edit_tab_content.htm');
     $tplMaterialItem = new Template($registry->get('template_path') . 'material_item.htm');
     $tplMaterialL10hHeaderItem = new Template($registry->get('template_path') . 'material_l10n_header_item.htm');
     $tplMaterialL10nItem = new Template($registry->get('template_path') . 'material_l10n_item.htm');
     $tplMaterialAddItem = new Template($registry->get('template_path') . 'material_add_item.htm');
     $tplMaterialAddL10nItem = new Template($registry->get('template_path') . 'material_add_l10n_item.htm');
     $tplso = new Template($registry->get('template_path') . 'select_option.htm');
     $stage = $data['stage'];
     $tabItems = '';
     $tabContentItems = '';
     $materialL10nItems = '';
     foreach ($locales as $localeId => $localeData) {
         $tabItems .= $tplTab->apply(['localeId' => $localeId, 'name' => $localeData['name']]);
         $tabContentItems .= $tplTabContent->apply(['name' => htmlspecialchars($stage->l10n->get('name', $localeId)), 'meta' => htmlspecialchars($stage->l10n->get('meta', $localeId)), 'description' => htmlspecialchars($stage->l10n->get('description', $localeId)), 'brief' => htmlspecialchars($stage->l10n->get('brief', $localeId)), 'url' => htmlspecialchars($stage->l10n->get('url', $localeId)), 'title' => htmlspecialchars($stage->l10n->get('title', $localeId)), 'localeId' => $localeId]);
         $materialL10nHeaderItems .= $tplMaterialL10hHeaderItem->apply(['locale' => $localeData['name']]);
     }
     $materialItems = '';
     foreach ($data['materials'] as $materialId => $material) {
         $materialL10nItems = '';
         foreach ($locales as $localeId => $localeData) {
             $materialL10nItems .= $tplMaterialL10nItem->apply(['localeId' => $localeId, 'materialId' => $material->id, 'mimeType' => $material->l10n->get('mimeType', $localeId)]);
         }
         $materialItems .= $tplMaterialItem->apply(['id' => $materialId, 'hash' => $material->hash, 'name' => $material->l10n->get('name', $registry->get('locale')), 'description' => $material->l10n->get('description', $registry->get('locale')), 'l10nItems' => $materialL10nItems]);
     }
     $materialAddL10nItems = '';
     foreach ($locales as $localeId => $localeData) {
         $materialAddL10nItems .= $tplMaterialAddL10nItem->apply(['materialId' => 0, 'localeId' => $localeId]);
     }
     $materialItems = $tplMaterialAddItem->apply(['l10nItems' => $materialAddL10nItems]);
     if (!$stage->id) {
         $exerciseItems = '';
         foreach ($data['exercises'] as $exerciseId => $exercise) {
             $exerciseItems .= $tplso->apply(['name' => $exercise->name, 'value' => $exerciseId, 'selected' => FALSE]);
         }
     }
     return $tpl->apply(['id' => $stage->id, 'lessonId' => $data['lessonId'], 'name' => $stage->name, 'config' => $stage->settings, 'tabItems' => $tabItems, 'tabContentItems' => $tabContentItems, 'materialL10nHeaderItems' => $materialL10nHeaderItems, 'materialItems' => $materialItems, 'exerciseName' => $data['exerciseName'], 'exerciseItems' => $exerciseItems, 'site_root' => $application->siteRoot]);
 }
Beispiel #13
0
 function getList()
 {
     $registry = Registry::getInstance();
     $application = Application::getInstance();
     $i18n = new I18n($registry->get('i18n_path') . 'setup.xml');
     $tpl = new Template($registry->get('template_path') . 'setup.htm');
     $tpli = new Template($registry->get('template_path') . 'setup_item.htm');
     $listItems = '';
     $setup = new Setup();
     foreach ($setup->getList() as $variable) {
         $listItems .= $tpli->apply(['name' => htmlspecialchars($variable->getProperty('name')), 'value' => htmlspecialchars($variable->getProperty('value')), 'desc' => $variable->getProperty('description')]);
     }
     $renderer = new Renderer(Page::MODE_NORMAL);
     $pTitle = $i18n->get('title');
     $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', $tpl->apply(['items' => $listItems, 'site_root' => $application->siteRoot]));
     $renderer->loadPage();
     $renderer->output();
 }
Beispiel #14
0
 function __construct()
 {
     $application = Application::getInstance();
     switch ($application->segment[2]) {
         case 'delete':
             $this->delete();
             break;
         case 'edit':
             $this->edit();
             break;
         case 'toggle':
             $this->toggle();
             break;
         case 'list':
         default:
             $this->getList();
             break;
     }
 }
Beispiel #15
0
 function edit()
 {
     $router = new Router(intval($_GET['id']));
     if ($_POST['action'] == 'save') {
         $router->name = trim($_POST['name']);
         $router->url = trim($_POST['url']);
         $router->controller = trim($_POST['controller']);
         $router->save();
         header('Location: /cms/router');
         exit;
     } else {
         $application = Application::getInstance();
         $registry = Registry::getInstance();
         $i18n = new I18n($registry->get('i18n_path') . 'router.xml');
         $pTitle = $i18n->get($id ? 'update_mode' : 'append_mode');
         $renderer = new Renderer(Page::MODE_NORMAL);
         $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', RouterEditView::get(['router' => $router]));
         $renderer->loadPage();
         $renderer->output();
     }
 }
Beispiel #16
0
 static function get($data)
 {
     $registry = Registry::getInstance();
     $application = Application::getInstance();
     $locale = $registry->get('locale');
     $locales = LocaleManager::getLocales();
     $tpl = new Template($registry->get('template_path') . 'course_edit.htm');
     $tplTab = new Template($registry->get('template_path') . 'course_edit_tab.htm');
     $tplTabContent = new Template($registry->get('template_path') . 'course_edit_tab_content.htm');
     $tplLessonItem = new Template($registry->get('template_path') . 'lesson_item.htm');
     $course = $data['course'];
     $tabItems = '';
     $tabContentItems = '';
     foreach ($locales as $localeId => $localeData) {
         $tabItems .= $tplTab->apply(['localeId' => $localeId, 'name' => $localeData['name']]);
         $tabContentItems .= $tplTabContent->apply(['name' => htmlspecialchars($course->l10n->get('name', $localeId)), 'meta' => htmlspecialchars($course->l10n->get('meta', $localeId)), 'description' => htmlspecialchars($course->l10n->get('description', $localeId)), 'brief' => htmlspecialchars($course->l10n->get('brief', $localeId)), 'url' => htmlspecialchars($course->l10n->get('url', $localeId)), 'title' => htmlspecialchars($course->l10n->get('title', $localeId)), 'state' => $course->l10n->get('state', $localeId), 'localeId' => $localeId]);
     }
     $lessonItems = '';
     foreach ($data['lessons'] as $lessonId => $lesson) {
         $lessonItems .= $tplLessonItem->apply(['id' => $lessonId, 'order' => $lesson->order, 'name' => $lesson->l10n->get('name', $locale)]);
     }
     return $tpl->apply(['id' => $course->id, 'courseName' => $course->l10n->get('name', $locale), 'state' => $course->state, 'ownerName' => $data['owner']->name ? $data['owner']->name : $_SESSION['admin']['name'], 'tabItems' => $tabItems, 'tabContentItems' => $tabContentItems, 'dateCreate' => $course->dateCreate ? date($localeData['dateFormat'], $course->dateCreate) : '', 'dateUpdate' => $course->dateUpdate ? date($localeData['dateFormat'] . ' H:i', $course->dateUpdate) : '', 'lessonItems' => $lessonItems, 'site_root' => $application->siteRoot]);
 }
Beispiel #17
0
 static function get($data)
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $tpl = new Template($registry->get('template_path') . 'lesson_edit.htm');
     $tplTab = new Template($registry->get('template_path') . 'lesson_edit_tab.htm');
     $tplTabContent = new Template($registry->get('template_path') . 'lesson_edit_tab_content.htm');
     $tplStageItem = new Template($registry->get('template_path') . 'stage_item.htm');
     $locales = LocaleManager::getLocales();
     $locale = $registry->get('locale');
     $tabItems = '';
     $tabContentItems = '';
     $lesson = $data['lesson'];
     foreach ($locales as $localeId => $localeData) {
         $tabItems .= $tplTab->apply(['localeId' => $localeId, 'name' => $localeData['name']]);
         $tabContentItems .= $tplTabContent->apply(['name' => htmlspecialchars($lesson->l10n->get('name', $localeId)), 'meta' => htmlspecialchars($lesson->l10n->get('meta', $localeId)), 'description' => htmlspecialchars($lesson->l10n->get('description', $localeId)), 'brief' => htmlspecialchars($lesson->l10n->get('brief', $localeId)), 'url' => htmlspecialchars($lesson->l10n->get('url', $localeId)), 'title' => htmlspecialchars($lesson->l10n->get('title', $localeId)), 'localeId' => $localeId]);
     }
     $exercises = $data['exercises'];
     $stageItems = '';
     foreach ($data['stages'] as $stageId => $stage) {
         $stageItems .= $tplStageItem->apply(['id' => $stageId, 'order' => $stage->order, 'name' => $stage->name, 'exerciseName' => $exercises[$stage->exerciseId]->name]);
     }
     return $tpl->apply(['id' => $lesson->id, 'courseId' => $data['courseId'], 'name' => $lesson->l10n->get('name', $locale), 'tabItems' => $tabItems, 'tabContentItems' => $tabContentItems, 'stageItems' => $stageItems, 'site_root' => $application->siteRoot]);
 }
Beispiel #18
0
<?php

require __DIR__ . '/../config/config.php';
\common\Application::getInstance()->route();
Beispiel #19
0
<?php

require __DIR__ . '/../Common/AutoLoader.php';
use Common\Config;
use Common\AutoLoader;
use Common\Application;
$loader = new AutoLoader(__DIR__);
$loader->register();
$config = new Config(__DIR__ . '/../app/Config/config.ini');
$app = new Application($config);
$app->run();
Beispiel #20
0
 function renumber()
 {
     $application = Application::getInstance();
     $lessonId = intval($application->segment[3]);
     if ($lessonId) {
         Stage::renumberAll($_POST['order']);
         echo 'OK';
     } else {
         echo 'No LessonID';
     }
     exit;
 }
Beispiel #21
0
Application::run(function (BLW\Type\Command\IInput $Input, BLW\Type\Command\IOutput $Output, BLW\Type\Command\ICommand $Command) {
    $Print = function ($Message) use(&$Output, &$Command) {
        $Output->write("{$Message}\r\n");
        $Command->Config['Logger']->debug($Message);
    };
    $Empty = function ($Dir) use(&$Empty) {
        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Dir), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
            if ($path->isDir() && $path->getBasename() != '.' && $path->getBasename() != '..') {
                $Empty($path->getPathname());
            } elseif ($path->isFile()) {
                unlink($path->getPathname());
            }
        }
        usleep(100000);
        rmdir($Dir);
    };
    $Copy = function ($Src, $Dest) use(&$Copy) {
        $Src = rtrim($Src, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        $Dest = rtrim($Dest, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Src, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
            if ($path->isDir()) {
                continue;
            } elseif ($path->isFile()) {
                if (!is_dir($Dir = str_replace($Src, $Dest, $path->getPath()))) {
                    mkdir($Dir);
                }
                copy($path->getPathname(), str_replace($Src, $Dest, $path->getPathname()));
            }
        }
    };
    // #####################
    // RUN COMPOSER
    // #####################
    $Print('Running Composer...');
    $ShellInput = new Input(new Handle(fopen('data:text/plain,', 'r')));
    $Composer = new ShellCommand('composer dumpautoload -o', new Config(array('Timeout' => 60, 'CWD' => dirname(__DIR__), 'Environment' => null, 'Extras' => array())), $Command->getMediator(), $Command->getMediatorID());
    // Check results
    if ($code = $Composer->run($ShellInput, $Output)) {
        return $code;
    }
    $Output->write("\r\n");
    // #####################
    // COMPILE APPLICATION
    // #####################
    $Print('Compiling application...');
    @unlink(BLW_DIR . 'build' . DIRECTORY_SEPARATOR . 'BLW.phar');
    @unlink(BLW_DIR . 'build' . DIRECTORY_SEPARATOR . 'BLW.tar.gz');
    $Output->write("-Collecting files\r\n");
    $Output->write('[--------------------------------------------------]');
    // Create PHAR
    $Compiler = new Compiler(new GenericFile(BLW_DIR . 'build'), new GenericFile(BLW_DIR), new GenericFile(BLW_DIR . 'temp'), $Command->getMediator());
    // Collect files
    $Compiler->addDir(new GenericFile(BLW_DIR . 'src'), 'php*', 'js', 'css');
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/composer')), 'php');
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/autoload.php')));
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/jeremeamia/SuperClosure/src')), 'php');
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/jeremeamia/SuperClosure/LICENSE.md')));
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/monolog/monolog/src/Monolog')), 'php');
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/monolog/monolog/LICENSE')));
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/mrclay/minify/min/lib')), 'php');
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/mrclay/minify/LICENSE.txt')));
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/nikic/php-parser/lib')), 'php');
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/nikic/php-parser/LICENSE')));
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/nikic/php-parser/lib')), 'php');
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/nikic/php-parser/LICENSE')));
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/psr/log/Psr')), 'php');
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/psr/log/LICENSE')));
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/symfony')), 'php');
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/symfony/yaml/Symfony/Component/Yaml/LICENSE')));
    $Compiler->addFile(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE')));
    // Thank you zend. Yours is truly the best library
    $Compiler->addDir(new GenericFile(BLW_DIR . str_replace('/', DIRECTORY_SEPARATOR, 'vendor/zendframework')), 'php');
    $Output->overwrite('[=-------------------------------------------------]');
    // Compile files
    $Compiler->onAdvance(function ($Event) use(&$Output) {
        static $Total = 0;
        static $Percent = 1;
        // Add count
        $Total += $Event->Steps;
        // Check count
        if ($Total > 100) {
            // Reset
            $Total = $Total % 100;
            // Advance
            $Percent++;
            $Output->overwrite(substr_replace('[--------------------------------------------------]', str_repeat('=', $Percent), 1, $Percent));
        }
    });
    $Output->overwrite('-Packaging files');
    $Output->write("\r\n[=-------------------------------------------------]");
    $Compiler->compile('BLW');
    unset($Compiler);
    $Output->overwrite('-Creating archive');
    $Output->write("\r\n[========================================----------]");
    // Copy assets
    $TempBuild = BLW_DIR . 'temp' . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR;
    @mkdir($TempBuild);
    copy(BLW_DIR . 'build/BLW.phar', $TempBuild . 'BLW.phar');
    copy(BLW_DIR . 'LICENSE.md', $TempBuild . 'LICENSE.md');
    $Output->overwrite("[=========================================---------]");
    // Create Archive
    $Archiver = new Archiver(new GenericFile(BLW_DIR . 'build'), new GenericFile($TempBuild), new GenericFile(BLW_DIR . 'temp'), $Command->getMediator());
    $Archiver->addDir(new GenericFile($TempBuild), '*');
    $Archiver->onAdvance(function ($Event) use(&$Output) {
        static $Total = 0;
        static $Percent = 0;
        // Add count
        $Total += $Event->Steps;
        // Check count
        if ($Total > 100) {
            // Reset
            $Total = $Total % 100;
            // Advance
            $Percent++;
            $Output->overwrite(substr_replace('[=========================================---------]', str_repeat('=', $Percent), 41, $Percent));
        }
    });
    $Archiver->compile('BLW');
    unset($Archiver);
    // Cleanup
    $Empty($TempBuild);
    $Output->overwrite("[==================================================]\r\n");
    // Done
    $Print('Finished compiling.');
    return 0;
});
Beispiel #22
0
Application::configure();
Application::run(function (BLW\Type\Command\IInput $Input, BLW\Type\Command\IOutput $Output, BLW\Type\Command\ICommand $Command) {
    $Print = function ($Message) use(&$Output, &$Command) {
        $Output->write("{$Message}\r\n");
        $Command->Config['Logger']->debug($Message);
    };
    // #####################
    // TEST LIBRARY
    // #####################
    $Print('Testing BLW Library...');
    // Run framework tests
    $ShellInput = new Input(new Handle(fopen('data:text/plain,', 'r')));
    $ShellInput->Options[] = new Option('testsuite', 'Types');
    $ShellInput->Options[] = new Option('coverage-php', 'temp/coverage-types.serialized');
    $PHPUnit = new ShellCommand('phpunit', new Config(array('Timeout' => 60, 'CWD' => dirname(__DIR__), 'Environment' => null, 'Extras' => array())), $Command->getMediator(), $Command->getMediatorID());
    // Check results
    if ($code = $PHPUnit->run($ShellInput, $Output)) {
        return $code;
    }
    // Run library tests
    $ShellInput = new Input(new Handle(fopen('data:text/plain,', 'r')));
    $ShellInput->Options[] = new Option('testsuite', 'Models');
    $ShellInput->Options[] = new Option('coverage-php', 'temp/coverage-models.serialized');
    $PHPUnit->run($ShellInput, $Output);
    // Merge coverage files
    // ...
    $Print('Finished testing.');
    // Done
    return 0;
});
// @codeCoverageIgnoreStart