Example #1
0
 /**
  * run the batch to create a project in this framework
  * @tutorial bin/console create_project
  *
  * @access public
  * @param array $aOptions
  * @throws \Exception
  */
 public function create(array $aOptions = array())
 {
     /**
      * option -p [portail]
      */
     if (isset($aOptions['p'])) {
         $sPortal = $aOptions['p'];
     } else {
         $sPortal = 'Batch';
     }
     if (!preg_match('/^[a-zA-Z0-9]+$/', $sPortal)) {
         echo 'You can`t create this portail :' . $sPortal . '! The name must containt just letters and numbers.';
         throw new \Exception('You can`t create this portail :' . $sPortal . '! The name must containt just letters and numbers.');
     }
     $sActualDirectory = str_replace(DIRECTORY_SEPARATOR, '/', __DIR__);
     $sPrivatePath = str_replace('/Batch/app/Controller', DIRECTORY_SEPARATOR . $sPortal . DIRECTORY_SEPARATOR . 'app', $sActualDirectory) . DIRECTORY_SEPARATOR;
     $sPublicPath = str_replace('/Batch/app/Controller', DIRECTORY_SEPARATOR . $sPortal . DIRECTORY_SEPARATOR . 'public', $sActualDirectory) . DIRECTORY_SEPARATOR;
     if (!is_writable($sActualDirectory . '/../../../')) {
         echo 'The batch can`t create public folders for ' . $sPortal . '! Please check the rights.';
         throw new \Exception('The batch can`t create public folders for ' . $sPortal . '! Please check the rights.');
     } else {
         if (!file_exists($sPrivatePath . 'Controller')) {
             mkdir($sPublicPath . 'css', 0777, true);
             mkdir($sPublicPath . 'js', 0777, true);
             mkdir($sPublicPath . 'img', 0777, true);
         } else {
             echo 'The Project (public part) ' . $sPrivatePath . " exists\n";
         }
     }
     if (!is_writable($sActualDirectory . '/../../../')) {
         echo 'The batch can`t create private folders for ' . $sPortal . '! Please check the rights.';
         throw new \Exception('The batch can`t create private folders for ' . $sPortal . '! Please check the rights.');
     } else {
         if (!file_exists($sPrivatePath . 'Controller')) {
             mkdir($sPrivatePath . 'Controller', 0777, true);
             mkdir($sPrivatePath . 'Entity', 0777, true);
             mkdir($sPrivatePath . 'Model', 0777, true);
             mkdir($sPrivatePath . 'View', 0777, true);
             mkdir($sPrivatePath . 'conf', 0777, true);
             mkdir($sPrivatePath . 'common', 0777, true);
             $sContent = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'Controller.php');
             $sContent = str_replace('Batch', $sPortal, $sContent);
             file_put_contents($sPrivatePath . 'common' . DIRECTORY_SEPARATOR . 'Controller.php', $sContent);
             $sContent = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'Model.php');
             $sContent = str_replace('Batch', $sPortal, $sContent);
             file_put_contents($sPrivatePath . 'common' . DIRECTORY_SEPARATOR . 'Model.php', $sContent);
             $sContent = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR . 'Entity.php');
             $sContent = str_replace('Batch', $sPortal, $sContent);
             file_put_contents($sPrivatePath . 'common' . DIRECTORY_SEPARATOR . 'Entity.php', $sContent);
             $content = "<?php\n\nnamespace Venus\\src\\" . $sPortal . "\\Controller;\n\nuse \\Venus\\src\\" . $sPortal . "\\common\\Controller as Controller;\n\nclass " . $sPortal . " extends Controller {\n\n\tpublic function __construct() {\n\n\t\tparent::__construct();\n\t}\n\n\tpublic function show() {\n        ;\n\t}\n}\n";
             file_put_contents($sPrivatePath . 'Controller' . DIRECTORY_SEPARATOR . $sPortal . '.php', $content);
         } else {
             echo 'The Project (private part) ' . $sPrivatePath . " exists\n";
         }
     }
     echo 'The project ' . $sPortal . ' is created!';
     echo "\n\n";
     echo Bash::setBackground("                                                                            ", 'green');
     echo Bash::setBackground("          [OK] The bundle is created                                        ", 'green');
     echo Bash::setBackground("                                                                            ", 'green');
     echo "\n\n";
 }
Example #2
0
<?php

include "src/Bash.php";
$bash = new Bash("https://raw.githubusercontent.com/Cpt-ManlyPink/glhf-bash/master/bash");
?>
<!doctype html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>GLHF.lv Teamspeak Bash</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    </head>
    <body>
        <div class="container">
        <!--[if lt IE 8]>
            <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
                <?php 
foreach ($bash->split() as $row) {
    ?>
            <div class="row">
            <?php 
    if ($row === "") {
        ?>
                <div class="col-sm-12 space"></div>
            <?php 
    } else {
        ?>
Example #3
0
<?php

include "src/Bash.php";
include "src/Database.php";
//I don't know how to make pretty code :(
//Don't worry - me too :P
//$bash = new Bash("https://raw.githubusercontent.com/Cpt-ManlyPink/glhf-bash/master/bash.json");
$bash = new Bash("bash.json");
$db = new Database();
$entries = $bash->process();
//Checks if there have been new entries in JSON file.
$lastModified = $entries['lastModified'];
if ($db->lastSave() != $lastModified) {
    foreach ($entries['entries'] as $entry) {
        $db->saveEntrie($entry);
    }
    $db->updateLastSave($lastModified, $db->lastSave());
}
//Fetches all entries from DB
$content = $db->getEntries();
?>
<!doctype html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>GLHF.lv Teamspeak Bash</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    </head>