/** * @param bool $return * @return array */ public static function check($return = false) { $must_migrate = false; $return_data = array(); foreach (Core_Files::listFiles(cfg()->migration_path) as $migration_file) { if (strstr($migration_file, self::TEMPLATE_NAME)) { continue; } $migration_data = explode(DS, $migration_file); list($migration_file_name) = array_reverse($migration_data); list($migration_name, $extension) = explode('.', $migration_file_name); $migration_class_name = self::MIGRATION_PREFIX . $migration_name . self::MIGRATION_SUFIX; /* @var $migration_object Core_Migration_Abstract */ $migration_object = new $migration_class_name(); if ($migration_object->check()) { $must_migrate = true; if ($return) { $return_data[] = $migration_file_name; } else { echo 'TO RUN: ' . $migration_file_name . PHP_EOL; } } } if (!$must_migrate) { if (!$return) { echo 'DB is UP TO DATE' . PHP_EOL; } } if ($return) { return $return_data; } }
/** * */ public function indexAction() { $argv = $this->getRequest()->getServer('argv'); $test_to_run = isset($argv[3]) ? $argv[3] : Const_Tests::RUN_ALL_TESTS; $test_to_run = str_replace('_', '/', $test_to_run); foreach (Core_Files::listFiles(cfg()->tests_path) as $test) { if (!strstr($test, $test_to_run . '.php') && $test_to_run != Const_Tests::RUN_ALL_TESTS) { continue; } $class_path = str_replace(cfg()->tests_path, '', $test); $class_path_frag = explode('/', $class_path); $class_path_frag = array_map("ucfirst", $class_path_frag); $class_path_frag[count($class_path_frag) - 1] = str_replace('.php', '', $class_path_frag[count($class_path_frag) - 1]); $class = implode('_', $class_path_frag); $class_name = 'Tests_' . $class . 'File'; echo '--------------------------------------' . PHP_EOL; echo 'Running test: ' . $class_name . PHP_EOL; echo '--------------------------------------' . PHP_EOL; $phpunit = new PHPUnit_TextUI_TestRunner(); $phpunit->run($phpunit->getTest($class_name, $test), array('colors' => 'auto')); if ($test_to_run != Const_Tests::RUN_ALL_TESTS) { die; } echo PHP_EOL . PHP_EOL; } die; }
protected function getFilesTags($dir) { $files = Core_Files::listFiles($dir, true); foreach ($files as $file) { $extension = Core_Files::getExtension($file); if (in_array($extension, array('phtml', 'php'))) { $content = Core_Files::getContent($file); if (empty($content)) { continue; } preg_match_all('/__(\\(\'|\\("|\\()(.*?)(\'\\)|\\"\\)|\\)\'|\\)"|",|\',)/', $content, $matches); if ($matches[2]) { foreach ($matches[2] as $tag) { if (substr($tag, 0, 1) == '$') { continue; } $this->tags[] = array('tag' => strtolower($tag), 'location' => $file); } } } } }
/** * @param $hash_id * @param array $files * @return null|string */ public static function css($hash_id, array $files) { if (empty($files)) { return false; } $cache_name = ''; foreach ($files as &$file) { $file = cfg()->static_path . 'css' . DS . $file; $cache_name .= Core_Files::fileSize($file); } unset($file); $f_name = md5($hash_id . $cache_name) . '.css'; $f_path = cfg()->cache_path . 'css' . DS . $f_name; $f_public = cfg()->cache_address . 'css/' . $f_name; if (!is_file($f_path)) { // lets empty the directory $cache_files = Core_Files::listFiles(cfg()->cache_path . 'css' . DS); foreach ($cache_files as $cfile) { Core_Files::delete($cfile, true); } $css_content = ''; foreach ($files as $file) { $content = Core_Files::getContent($file); $css_content .= $content; } $css_content = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $css_content); // Remove space after colons $css_content = str_replace(': ', ':', $css_content); // Remove whitespace $css_content = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $css_content); // now save the file Core_Files::putContent($f_path, $css_content); } return '<link type="text/css" rel="stylesheet" href="' . $f_public . '"/>'; }