function isCached()
 {
     if (!$this->refreshCacheDir()) {
         Debug::out('pageRender::isCached() : Impossible de rafraichir le dossier de cache. Mauvaise utilisation ?');
         return false;
     }
     $page = 'page' . Config::getTemplateExt();
     return $this->is_cached($page, $this->cacheId);
 }
 public function updateModelBaseFile($objName, $structure)
 {
     $dependency = new Dependency();
     $dependencies = $dependency->getDependencies($objName);
     $this->_createComponents($objName, $structure, $dependencies);
     $this->_createModelBaseFileStr($objName, $structure);
     $modelBaseFileName = NamingConvention::camelCaseToSnakeCase($objName) . '_base.php';
     $modelBasePath = ROOT . '/app/model/base/' . $modelBaseFileName;
     Debug::out('update: ' . $modelBasePath);
     file_put_contents($modelBasePath, $this->_modelBaseFileStr);
 }
Esempio n. 3
0
 function dump($var, $varName = '')
 {
     ob_start();
     var_dump($var);
     $out = ob_get_contents();
     ob_end_clean();
     if ($varName != '') {
         $out = $varName . ' : ' . $out;
     }
     Debug::out($out);
 }
Esempio n. 4
0
 static function checkLoggedIn($html, $login)
 {
     $matches = array('@log\\s?(out|off)@i', '@sign\\s?(out|off)@i', '@Last Month|Last Week@i', '@[^a-z]My [a-z]@i', '@[ >]Scoop Interactive[< ]@i');
     foreach ($matches as $match) {
         if (preg_match($match, $html)) {
             return true;
         }
     }
     Debug::out('||ERROR||: Could not login');
     Debug::out($login);
     return false;
 }
Esempio n. 5
0
 public static function build()
 {
     self::$enabled = $GLOBALS['config']['DEBUG']['enabled'];
     self::$out = $GLOBALS['config']['DEBUG']['out'];
     self::$outfile = $GLOBALS['config']['DEBUG']['outfile'];
     self::$verbosity = $GLOBALS['config']['DEBUG']['verbosity'];
     if (self::$enabled && !is_writable(self::$outfile) && (self::$out === "file" || self::$out === "both")) {
         self::$out = "stdout";
         self::write("Debug outfile is not writable. Switching back to stdout", 0);
     }
     if (self::$enabled === true) {
         self::write(date('Ymd-Gis - ') . "Debug mode enabled. Use in development env. only!", 0);
     }
 }
 public function createModelControllerFile($objName, $app)
 {
     $app = ucfirst($app);
     if ($app == '') {
         $app = 'Public';
     }
     $objName .= 's';
     $controllerTmpl = file_get_contents(ROOT . '/library/core/console/tmpl/obj_controller.tmpl');
     $controllerTmpl = str_replace('{CLASS_NAME}', $objName, $controllerTmpl);
     $controllerTmpl = str_replace('{APP}', $app, $controllerTmpl);
     $controllerName = NamingConvention::camelCaseToSnakeCase($objName) . '_' . lcfirst($app) . '.php';
     $controllerPath = ROOT . '/app/controller/' . lcfirst($app) . '/' . $controllerName;
     Debug::out('create: ' . $controllerPath);
     file_put_contents($controllerPath, $controllerTmpl);
 }
Esempio n. 7
0
 public static function getInstance()
 {
     if (!self::$PDOINSTANCE) {
         try {
             self::$PDOINSTANCE = new PDO('mysql:host=' . self::$HOST . ';dbname=' . self::$BASE . ';charset=' . self::$CHAR . ';', self::$USER, self::$PASS);
             //self::$PDOINSTANCE->exec("SET NAMES 'utf8';");
         } catch (PDOException $e) {
             //Debug::out($e);
             Debug::out('PDO connection error: ' . $e->getMessage());
             Debug::out('Or maybe you have to set: export PATH=/Applications/MAMP/bin/php/phpX.X.X/bin/:$PATH');
             die;
             //Debug::log($dbh->errorInfo());
         }
     }
     return self::$PDOINSTANCE;
 }
Esempio n. 8
0
function load_file($relativPath, $showError = true)
{
    $absolutePath = ROOT . $relativPath;
    if (file_exists($absolutePath)) {
        require_once $absolutePath;
        return false;
    } else {
        if ($showError) {
            if (class_exists('Debug')) {
                Debug::out('Warning: load_file() could not find "' . $absolutePath . '"<br> in ' . debug_backtrace()[0]['file'] . ' on line ' . debug_backtrace()[0]['line']);
            } else {
                echo 'Warning: load_file() could not find "' . $absolutePath . '" in ' . debug_backtrace()[0]['file'] . ' on line ' . debug_backtrace()[0]['line'];
            }
        }
    }
    return true;
}
 public function action($argv)
 {
     $command = $argv[1];
     if ($command == 'migrate' || $command == '-m') {
         $migration = new Migration();
         $migration->up();
     } elseif ($command == 'rollback' || $command == '-r') {
         $migration = new Migration();
         $migration->rollback();
     } elseif ($command == 'status' || $command == '-s') {
         $migration = new Migration();
         $migration->printStatus();
     } elseif ($command === 'help' || $command == '-h') {
         Debug::out('Command: -h (help)');
         Debug::out('migrate or -m');
         Debug::out('rollback or -r');
         Debug::out('status or -s');
     } else {
         Debug::out('Command unknown. Try -h for help.');
     }
 }
 public function updateRepositoryBaseFile($objName, $structure)
 {
     foreach ($structure as $name => $definitions) {
         $strRepoAttributes[$name] = $this->_createStrRepoAttribute($name, $definitions);
     }
     $last = count($strRepoAttributes);
     foreach ($strRepoAttributes as $strRepoAttribute) {
         $strRepoAttributeResult .= $strRepoAttribute;
         if (++$count != $last) {
             $strRepoAttributeResult .= ",\n";
         }
     }
     $repoBaseFileName = NamingConvention::camelCaseToSnakeCase($objName) . '_base_repo.php';
     $repoBasePath = ROOT . '/app/repository/base/' . $repoBaseFileName;
     $repoBaseTmpl = file_get_contents(ROOT . '/library/core/console/tmpl/obj_repo_base.tmpl');
     $classNameSnakeCase = NamingConvention::camelCaseToSnakeCase($objName);
     $repoBaseTmpl = str_replace('{CLASS_NAME_SNAKE_CASE}', $classNameSnakeCase, $repoBaseTmpl);
     $repoBaseTmpl = str_replace('{CLASS_NAME}', $objName, $repoBaseTmpl);
     $repoBaseTmpl = str_replace('{OBJ_NAME}', $objName, $repoBaseTmpl);
     $repoBaseTmpl = str_replace('{ATTRIBUTES}', $strRepoAttributeResult, $repoBaseTmpl);
     Debug::out('update: ' . $repoBasePath);
     file_put_contents($repoBasePath, $repoBaseTmpl);
 }
Esempio n. 11
0
 public function getSchema()
 {
     $sql = 'SHOW full columns FROM ' . $this->getTableName();
     $dbh = Database::getInstance();
     $dbResult = $dbh->query($sql, PDO::FETCH_ASSOC);
     if (!$dbResult) {
         Debug::out($dbh->errorInfo());
     }
     foreach ($dbResult as $row) {
         foreach ($row as $key => $value) {
             $schemaRow[strtolower($key)] = $value;
         }
         $schema[] = $schemaRow;
     }
     Debug::out($schema);
 }
Esempio n. 12
0
 private function _checkQueryNamingConvention($query)
 {
     if ($query['app'] && !NamingConvention::isSnakeCase($query['app'])) {
         Debug::out('Dispatcher NamingConventionError: app=' . $query['app'] . ' has to be snake_case.');
         die;
     }
     if ($query['module'] && !NamingConvention::isSnakeCase($query['module'])) {
         Debug::out('Dispatcher NamingConventionError: module=' . $query['module'] . ' has to be snake_case.');
         die;
     }
     if ($query['action'] && !NamingConvention::isSnakeCase($query['action'])) {
         Debug::out('Dispatcher NamingConventionError: action=' . $query['action'] . ' has to be snake_case.');
         die;
     }
 }
Esempio n. 13
0
 static function checkConfig()
 {
     Control::req('scripts/crons/config');
     $run = self::getRun(new Time());
     Debug::out('Config check completed');
 }
Esempio n. 14
0
 function end_out()
 {
     $end = $this->end();
     Debug::out($end);
 }
Esempio n. 15
0
 static function lowerCase($str, $minLen = 0, $maxLen = 0, $upCase = 0, $dreg = 0)
 {
     if (!$str || !mb_check_encoding($str, 'UTF-8')) {
         Debug::out('The input string can not be empty and it must be encoded in UTF-8.');
         return '';
     }
     $md5 = md5($str);
     $str = is_array($dreg) ? preg_replace('/' . implode('|', $dreg) . '/', '', $str) : $str;
     $str = preg_replace('/^[^0-9A-Za-z]|[^0-9A-Za-z-]*|[^0-9A-Za-z]$/x', '', strtolower(self::rawConvByUtf8($str, $upCase)));
     $len = strlen($str);
     return $minLen && $len < $minLen ? $str . substr($md5, 0, $minLen - $len) : ($maxLen && $len > $maxLen ? substr($str, 0, $maxLen) : $str);
 }