/** * Compiles a template and writes it to a cache file, which is used for inclusion. * * @param string $file The full path to the template that will be compiled. * @param array $options Options for compilation include: * - `path`: Path where the compiled template should be written. * - `fallback`: Boolean indicating that if the compilation failed for some * reason (e.g. `path` is not writable), that the compiled template * should still be returned and no exception be thrown. * @return string The compiled template. */ public static function template($file, array $options = array()) { $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates'; $defaults = array('path' => $cachePath, 'fallback' => false); $options += $defaults; $stats = stat($file); $oname = basename(dirname($file)) . '_' . basename($file, '.php'); $oname .= '_' . ($stats['ino'] ?: hash('md5', $file)); $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php"; $template = "{$options['path']}/{$template}"; if (file_exists($template)) { return $template; } $compiled = static::compile(file_get_contents($file)); if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) { foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) { if ($expired !== $template) { unlink($expired); } } return $template; } if ($options['fallback']) { return $file; } throw new TemplateException("Could not write compiled template `{$template}` to cache."); }
/** * {@inheritdoc} */ public function run() { if (is_null($this->dst) || "" === $this->dst) { return Result::error($this, 'You must specify a destination file with to() method.'); } if (!$this->checkResources($this->files, 'file')) { return Result::error($this, 'Source files are missing!'); } if (file_exists($this->dst) && !is_writable($this->dst)) { return Result::error($this, 'Destination already exists and cannot be overwritten.'); } $dump = ''; foreach ($this->files as $path) { foreach (glob($path) as $file) { $dump .= file_get_contents($file) . "\n"; } } $this->printTaskInfo('Writing {destination}', ['destination' => $this->dst]); $dst = $this->dst . '.part'; $write_result = file_put_contents($dst, $dump); if (false === $write_result) { @unlink($dst); return Result::error($this, 'File write failed.'); } // Cannot be cross-volume; should always succeed. @rename($dst, $this->dst); return Result::success($this); }
public function renderContent($args, $setting) { $t = array('name' => '', 'image_folder_path' => '', 'limit' => 12, 'columns' => 4); $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $url = Tools::htmlentitiesutf8($protocol . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__); $setting = array_merge($t, $setting); $oimages = array(); if ($setting['image_folder_path']) { $path = _PS_ROOT_DIR_ . '/' . trim($setting['image_folder_path']) . '/'; $path = str_replace("//", "/", $path); if (is_dir($path)) { $images = glob($path . '*.*'); $exts = array('jpg', 'gif', 'png'); foreach ($images as $cnt => $image) { $ext = Tools::substr($image, Tools::strlen($image) - 3, Tools::strlen($image)); if (in_array(Tools::strtolower($ext), $exts)) { if ($cnt < (int) $setting['limit']) { $i = str_replace("\\", "/", '' . $setting['image_folder_path'] . "/" . basename($image)); $i = str_replace("//", "/", $i); $oimages[] = $url . $i; } } } } } $images = array(); $setting['images'] = $oimages; $output = array('type' => 'image', 'data' => $setting); return $output; }
public static function run() { foreach (glob(app_path() . '/Http/Controllers/*.php') as $filename) { $file_parts = explode('/', $filename); $file = array_pop($file_parts); $file = rtrim($file, '.php'); if ($file == 'Controller') { continue; } $controllerName = 'App\\Http\\Controllers\\' . $file; $controller = new $controllerName(); if (isset($controller->exclude) && $controller->exclude === true) { continue; } $methods = []; $reflector = new \ReflectionClass($controller); foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $rMethod) { // check whether method is explicitly defined in this class if ($rMethod->getDeclaringClass()->getName() == $reflector->getName()) { $methods[] = $rMethod->getName(); } } \Route::resource(strtolower(str_replace('Controller', '', $file)), $file, ['only' => $methods]); } }
function rglob($pattern, $files = 1, $dirs = 0, $flags = 0) { $dirname = dirname($pattern); $basename = basename($pattern); $glob = glob($pattern, $flags); $files = array(); $dirlist = array(); foreach ($glob as $path) { if (is_file($path) && !$files) { continue; } if (is_dir($path)) { $dirlist[] = $path; if (!$dirs) { continue; } } $files[] = $path; } foreach (glob("{$dirname}/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { $dirfiles = rglob($dir . '/' . $basename, $files, $dirs, $flags); $files = array_merge($files, $dirfiles); } return $files; }
public function runUnitTests($tests) { // Build any unit tests $this->make('build-tests'); // Now find all the test programs $root = $this->getProjectRoot(); $test_dir = $root . "/tests/"; $futures = array(); if (!$tests) { $paths = glob($test_dir . "*.t"); } else { $paths = array(); foreach ($tests as $path) { $tpath = preg_replace('/\\.c$/', '.t', $path); if (preg_match("/\\.c\$/", $path) && file_exists($tpath)) { $paths[] = realpath($tpath); } } } foreach ($paths as $test) { $relname = substr($test, strlen($test_dir)); $futures[$relname] = new ExecFuture($test); } $results = array(); $futures = new FutureIterator($futures); foreach ($futures->limit(4) as $test => $future) { list($err, $stdout, $stderr) = $future->resolve(); $results[] = $this->parseTestResults($test, $err, $stdout, $stderr); } return $results; }
/** * Mediboard class autoloader * * @param string $class Class to be loaded * * @return bool */ function mbAutoload($class) { $file_exists = false; $time = microtime(true); // Entry already in cache if (isset(CApp::$classPaths[$class])) { // The class is known to not be in MB if (CApp::$classPaths[$class] === false) { return false; } // Load it if we can if ($file_exists = file_exists(CApp::$classPaths[$class])) { CApp::$performance["autoloadCount"]++; return include_once CApp::$classPaths[$class]; } } // File moved ? if (!$file_exists) { unset(CApp::$classPaths[$class]); } // CSetup* class if (preg_match('/^CSetup(.+)$/', $class, $matches)) { $dirs = array("modules/{$matches['1']}/setup.php"); } else { $class_file = $class; $suffix = ".class"; // Namespaced class if (strpos($class_file, "\\") !== false) { $namespace = explode("\\", $class_file); // Mediboard class if ($namespace[0] === "Mediboard") { array_shift($namespace); $class_file = implode("/", $namespace); } else { $class_file = "vendor/" . implode("/", $namespace); $suffix = ""; } } $class_file .= $suffix; $dirs = array("classes/{$class_file}.php", "classes/*/{$class_file}.php", "mobile/*/{$class_file}.php", "modules/*/classes/{$class_file}.php", "modules/*/classes/*/{$class_file}.php", "modules/*/classes/*/*/{$class_file}.php", "install/classes/{$class_file}.php"); } $rootDir = CAppUI::conf("root_dir"); $class_path = false; foreach ($dirs as $dir) { $files = glob("{$rootDir}/{$dir}"); foreach ($files as $filename) { include_once $filename; // The class was found if (class_exists($class, false) || interface_exists($class, false)) { $class_path = $filename; break 2; } } } // Class not found, it is not in MB CApp::$classPaths[$class] = $class_path; SHM::put("class-paths", CApp::$classPaths); CApp::$performance["autoload"][$class] = (microtime(true) - $time) * 1000; return $class_path !== false; }
private function getTestsToRun() { $root = $this->getProjectRoot(); $test_dir = $root . "/tests/"; $tests = array(); foreach (glob($test_dir . "*.t") as $test) { $relname = substr($test, strlen($test_dir)); $tests[$relname] = $test; } if (!$this->getRunAllTests()) { /* run tests that sound similar to the modified paths */ printf("Finding tests based on name similarity\n"); printf("Use `arc unit --everything` to run them all\n"); $paths = array(); foreach ($this->getPaths() as $path) { $paths[] = $this->stripName($path); } foreach ($tests as $relname => $test) { $keep = false; $strip = $this->stripName($relname); foreach ($paths as $path) { $pct = 0; similar_text($path, $strip, $pct); if ($pct > 55) { $keep = true; break; } } if (!$keep) { unset($tests[$relname]); } } } return $tests; }
/** * Scans the plugins subfolder and include files * * @since 05/02/2013 * @return void */ protected function load_classes() { // load required classes foreach (glob(dirname(__FILE__) . '/inc/*.php') as $path) { require_once $path; } }
function pic_thumb($pic_id) { $this->load->helper('file'); $this->load->library('image_lib'); $base_path = "uploads/item_pics/" . $pic_id; $images = glob($base_path . "*"); if (sizeof($images) > 0) { $image_path = $images[0]; $ext = pathinfo($image_path, PATHINFO_EXTENSION); $thumb_path = $base_path . $this->image_lib->thumb_marker . '.' . $ext; if (sizeof($images) < 2) { $config['image_library'] = 'gd2'; $config['source_image'] = $image_path; $config['maintain_ratio'] = TRUE; $config['create_thumb'] = TRUE; $config['width'] = 52; $config['height'] = 32; $this->image_lib->initialize($config); $image = $this->image_lib->resize(); $thumb_path = $this->image_lib->full_dst_path; } $this->output->set_content_type(get_mime_by_extension($thumb_path)); $this->output->set_output(file_get_contents($thumb_path)); } }
function encode_send_filelist($blobdir) { $xhprofiled_files_list = array(); global $doc_root; if (file_exists("{$blobdir}/manifest.json")) { $manifest = json_decode(file_get_contents("{$blobdir}/manifest.json")); foreach ($manifest as $page => $data) { list($xhprof, $samples) = $data; if (is_array($samples)) { $samples = count($samples); } if (isset($data[2])) { $memory_prof = $data[2]; } else { $memory_prof = "MemDisabled"; } $xhprofiled_files_list[$page . " (" . $samples . ")[{$memory_prof}]"] = "{$blobdir}/{$xhprof}"; } } else { foreach (glob($blobdir . "/*") as $filename) { preg_match("/[0-9]{10}\\.(.*).xhprof\$/", $filename, $match); if (!$match) { continue; } $xhprofiled_files_list[$match[1]] = $filename; } } echo json_encode($xhprofiled_files_list); }
/** * @Route("/", methods="GET") * @Request({"folder": "string"}) */ public function indexAction($folder = '') { $images = []; $folder = trim($folder, '/'); $pttrn = '/\\.(jpg|jpeg|gif|png)$/i'; $dir = App::path(); if (!($files = glob($dir . '/' . $folder . '/*'))) { return []; } foreach ($files as $img) { // extension filter if (!preg_match($pttrn, $img)) { continue; } $data = array(); $data['filename'] = basename($img); // remove extension $data['title'] = preg_replace('/\\.[^.]+$/', '', $data['filename']); // remove leading number $data['title'] = preg_replace('/^\\d+\\s?+/', '', $data['title']); // remove trailing numbers $data['title'] = preg_replace('/\\s?+\\d+$/', '', $data['title']); // replace underscores with space and add capital $data['title'] = ucfirst(trim(str_replace(['_', '-'], ' ', $data['title']))); $data['image']['src'] = $folder . '/' . basename($img); $data['image']['alt'] = $data['title']; $images[] = $data; } return $images; }
/** * 取得今天要顯示的圖片 * @return 圖片的完整路徑 (含檔名) * FALSE: 找不到圖片 **/ function getTodayImage($orgimg) { global $chroot, $imgext; $dir = $chroot; $now = date('Ymd'); $imglst = array(); foreach (array_keys($imgext) as $ext) { foreach (glob($dir . "*.{$ext}") as $filename) { $name = basename($filename, ".{$ext}"); if (!is_numeric($name) || strlen($name) != 8) { continue; } if (strcmp($now, $name) < 0) { continue; } $imglst[$name] = $filename; } } if (count($imglst) <= 0) { setCache($orgimg); return FALSE; } else { krsort($imglst); $img = array_shift($imglst); setCache($img); return $img; } }
/** * 模板风格列表 * @param integer $siteid 站点ID,获取单个站点可使用的模板风格列表 * @param integer $disable 是否显示停用的{1:是,0:否} */ function template_list($siteid = '', $disable = 0) { $list = glob(PC_PATH . 'templates' . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); $arr = $template = array(); if ($siteid) { $site = pc_base::load_app_class('sites', 'admin'); $info = $site->get_by_id($siteid); if ($info['template']) { $template = explode(',', $info['template']); } } foreach ($list as $key => $v) { $dirname = basename($v); if ($siteid && !in_array($dirname, $template)) { continue; } if (file_exists($v . DIRECTORY_SEPARATOR . 'config.php')) { $arr[$key] = (include $v . DIRECTORY_SEPARATOR . 'config.php'); if (!$disable && isset($arr[$key]['disable']) && $arr[$key]['disable'] == 1) { unset($arr[$key]); continue; } } else { $arr[$key]['name'] = $dirname; } $arr[$key]['dirname'] = $dirname; } return $arr; }
/** * @return array */ public function getFieldTypes($extension = null) { //todo cache this if (!$this->fieldTypes) { $this->fieldTypes = []; /** @noinspection PhpUnusedLocalVariableInspection */ $app = App::getInstance(); //available for index.php files $paths = []; foreach (App::module() as $module) { if ($module->get('fieldtypes')) { $paths = array_merge($paths, glob(sprintf('%s/%s/*/index.php', $module->path, $module->get('fieldtypes')), GLOB_NOSORT) ?: []); } } foreach ($paths as $p) { $package = array_merge(['id' => '', 'path' => dirname($p), 'main' => '', 'extensions' => $this->fieldExtensions, 'class' => '\\Bixie\\Framework\\FieldType\\FieldType', 'resource' => 'bixie/framework:app/bundle', 'config' => ['hasOptions' => 0, 'readonlyOptions' => 0, 'required' => 0, 'multiple' => 0], 'dependancies' => [], 'styles' => [], 'getOptions' => '', 'prepareValue' => '', 'formatValue' => ''], include $p); $this->registerFieldType($package); } } if ($extension) { return array_filter($this->fieldTypes, function ($fieldType) use($extension) { /** @var FieldTypeBase $fieldType */ return in_array($extension, $fieldType->getExtensions()); }); } return $this->fieldTypes; }
public function index() { $dirs = glob(APP_PATH . C("APP_GROUP_PATH") . DIRECTORY_SEPARATOR . '*'); foreach ($dirs as $path) { if (is_dir($path)) { $path = basename($path); $dirs_arr[] = $path; } } //数量 $total = count($dirs_arr); //把一个数组分割为新的数组块 $dirs_arr = array_chunk($dirs_arr, 20, true); //当前分页 $page = max(intval($_GET['page']), 1); $directory = $dirs_arr[intval($page - 1)]; $pages = $this->page($total, 20); $modulesdata = M("Module")->select(); foreach ($modulesdata as $v) { $modules[$v['module']] = $v; } $this->assign("Page", $pages->show("Admin")); $this->assign("data", $directory); $this->assign("modules", $modules); $this->display(); }
private function iterateFolder($folder, $find) { $files = glob($folder); foreach ($files as $file) { if (filetype($file) == 'dir') { $this->iterateFolder($file . "/*", $find); } if ($this->isIncludedModule($file)) { $this->current_file = $file; switch (basename($file)) { case 'service.config.php': case 'services.config.php': $this->getInvokables($file); break; case 'autoload_classmap.php': case 'module.config.php': break; case 'Module.php': $this->modules_filepath[] = dirname($file); break; default: $this->searchUsed($file, $find); break; } } } }
/** * Get Global Application CMS accessibility scope. * * @access public * @static * @uses Core\Config() * * @return array */ public static function getAccessibilityScope() { $scope = glob(Core\Config()->paths('mode') . 'controllers' . DIRECTORY_SEPARATOR . '*.php'); $builtin_scope = array('CMS\\Controllers\\CMS'); $builtin_actions = array(); $accessibility_scope = array(); foreach ($builtin_scope as $resource) { $builtin_actions = array_merge($builtin_actions, get_class_methods($resource)); } $builtin_actions = array_filter($builtin_actions, function ($action) { return !in_array($action, array('create', 'show', 'edit', 'delete', 'export'), true); }); foreach ($scope as $resource) { $resource = basename(str_replace('.php', '', $resource)); if ($resource !== 'cms') { $controller_name = '\\CMS\\Controllers\\' . $resource; $controller_class = new \ReflectionClass($controller_name); if (!$controller_class->isInstantiable()) { continue; } /* Create instance only if the controller class is instantiable */ $controller_object = new $controller_name(); if ($controller_object instanceof CMS\Controllers\CMS) { $accessibility_scope[$resource] = array_diff(get_class_methods($controller_name), $builtin_actions); array_push($accessibility_scope[$resource], 'index'); foreach ($accessibility_scope[$resource] as $key => $action_with_acl) { if (in_array($action_with_acl, $controller_object->skipAclFor, true)) { unset($accessibility_scope[$resource][$key]); } } } } } return $accessibility_scope; }
public function testCheckMetadataRelationshipNames() { $dictionary = array(); $ar = new TestAbstractRelationships(); $errMsg = "Relationship key discrepancy exists with key not being in AbstractRelationships->specialCaseBaseNames."; $specialCaseBaseNames = $ar->getSpecialCaseBaseNames(); // load all files from metadata/ that could potentially have // relationships in them foreach (glob("metadata/*.php") as $filename) { include $filename; } // load all relationships into AbstractRelationships->relationships foreach ($dictionary as $key => $val) { if (isset($dictionary[$key]['relationships'])) { $relationships = $dictionary[$key]['relationships']; foreach ($relationships as $relKey => $relVal) { // if our key and relationship key are not equal // check to make sure the key is in the special list // otherwise we may have relationship naming issues down the road if ($key !== $relKey) { $this->assertContains($key, $specialCaseBaseNames, $errMsg); } } } } }
function loadAll($directory) { $directory = dirname(__FILE__) . "/../{$directory}"; foreach (glob("{$directory}/*.php") as $filename) { require_once $filename; } }
public function itemList($options = []) { $session = Yii::$app->session; $moduleId = Yii::$app->controller->module->id; if (isset($options['sub-directory'])) { $session->set($moduleId, ['path' => '/' . ltrim($options['sub-directory'], '/')]); } //$session->remove($moduleId); $dir = $this->routes->uploadDir . $session->get($moduleId)['path']; if (is_dir($dir)) { //echo $dir; $files = \yii\helpers\FileHelper::findFiles($dir, ['recursive' => false]); $files_r = []; if (!isset($options['show-directory']) || intval($options['show-directory']) === 1) { foreach (glob($dir . '/*', GLOB_ONLYDIR) as $filename) { $files_r[] = $filename; } } foreach ($files as $value) { $files_r[] = str_replace('\\', '/', $value); } } else { $message = 'Path ' . $session->get($moduleId)['path'] . ' not found!.'; $session->remove($moduleId); throw new \yii\web\HttpException(500, $message); } return $files_r; }
/** * Create main page of the site and set rights for it. * * @param int $id Site ID. */ private function createMainPage($id) { //Ищем в перечне шаблонов модуля по которому создан сайт, шаблоны отмеченные аттрибутом default //если не находим - берем default.[type].xml //а если и такого нет - берем шаблон default.[type].xml из ядра ..а что делать? $module = $this->getData()->getFieldByName('site_folder')->getRowData(0); $content = $layout = false; foreach (array('content', 'layout') as $type) { foreach (glob(implode(DIRECTORY_SEPARATOR, array(SITE_DIR, self::MODULES, $module, 'templates', $type, '*'))) as $path) { if ($xml = simplexml_load_file($path)) { $attrs = $xml->attributes(); if (isset($attrs['default'])) { ${$type} = $module . '/' . basename($path); break; } } } if (!${$type} && file_exists(implode(DIRECTORY_SEPARATOR, array(SITE_DIR, self::MODULES, $module, 'templates', $type, 'default.' . $type . '.xml')))) { ${$type} = $module . '/' . 'default.' . $type . '.xml'; } if (!${$type}) { ${$type} = 'default.' . $type . '.xml'; } //Если шаблона там не окажется //та пошло оно в жопу ...это ж не для ядерного реактора ПО } $translationTableName = 'share_sites_translation'; //Если не задан параметр конфигурации - создаем одну страницу $smapId = $this->dbh->modify(QAL::INSERT, 'share_sitemap', array('smap_content' => $content, 'smap_layout' => $layout, 'site_id' => $id, 'smap_segment' => QAL::EMPTY_STRING)); foreach ($_POST[$translationTableName] as $langID => $siteInfo) { $this->dbh->modify(QAL::INSERT, 'share_sitemap_translation', array('lang_id' => $langID, 'smap_id' => $smapId, 'smap_name' => $siteInfo['site_name'])); } //права берем ориентируясь на главную страницу дефолтного сайта $this->dbh->modify('INSERT IGNORE INTO share_access_level ' . '(smap_id, right_id, group_id) ' . 'SELECT %s, al.right_id, al.group_id ' . 'FROM `share_access_level` al ' . 'LEFT JOIN share_sitemap s ON s.smap_id = al.smap_id ' . 'WHERE s.smap_pid is NULL AND site_id= %s', $smapId, E()->getSiteManager()->getDefaultSite()->id); }
function Render() { global $currentUser; if (!$currentUser) return; if (!$currentUser->CanSubmitItems()) return; echo "\n\n"; echo "<div class='pouettbl' id='".$this->uniqueID."'>\n"; echo " <h2>".$this->title."</h2>\n"; echo " <div class='content'>\n"; $width = 15; $g = glob(POUET_CONTENT_LOCAL."avatars/*.gif"); shuffle($g); $g = array_slice($g,0,$width * $width); echo "<ul id='avatargallery'>\n"; foreach($g as $v) printf(" <li><img src='".POUET_CONTENT_URL."avatars/%s' alt='%s' title='%s'/></li>\n",basename($v),basename($v),basename($v)); echo "</ul>\n"; echo " </div>\n"; echo "</div>\n"; }
public function __construct(WpSecurityAuditLog $plugin) { parent::__construct($plugin); foreach (glob(dirname(__FILE__) . '/Sensors/*.php') as $file) { $this->AddFromFile($file); } }
public function rmdir() { $tmpDir = $this->getTmpDir(false); foreach (glob("{$tmpDir}*") as $dirname) { @rmdir($dirname); } }
/** * Create the migration * * @param string $name * @return bool */ protected function createMigration() { //Create the migration $app = app(); $migrationFiles = array($this->laravel->path . "/database/migrations/*_create_cities_table.php" => 'cities::generators.migration'); $seconds = 0; foreach ($migrationFiles as $migrationFile => $outputFile) { if (sizeof(glob($migrationFile)) == 0) { $migrationFile = str_replace('*', date('Y_m_d_His', strtotime('+' . $seconds . ' seconds')), $migrationFile); $fs = fopen($migrationFile, 'x'); if ($fs) { $output = "<?php\n\n" . $app['view']->make($outputFile)->with('table', 'cities')->render(); fwrite($fs, $output); fclose($fs); } else { return false; } $seconds++; } } //Create the seeder $seeder_file = $this->laravel->path . "/database/seeds/CitiesSeeder.php"; $output = "<?php\n\n" . $app['view']->make('cities::generators.seeder')->render(); if (!file_exists($seeder_file)) { $fs = fopen($seeder_file, 'x'); if ($fs) { fwrite($fs, $output); fclose($fs); } else { return false; } } return true; }
function saveDetectPortToCache() { foreach (glob(ST_ROOT . '/Config/Cache/*detect_port.cache.php') as $php_file) { unlink($php_file); } file_put_contents(ST_ROOT . '/Config/Cache/' . time() . '.detect_port.cache.php', "<?php\n\\Statistics\\Config::\$ProviderPort=" . var_export(\Statistics\Config::$ProviderPort, true) . ';'); }
/** * Loading classes */ public function after_setup_theme() { do_action(SCF_Config::PREFIX . 'load'); require_once plugin_dir_path(__FILE__) . 'classes/models/class.meta.php'; require_once plugin_dir_path(__FILE__) . 'classes/models/class.setting.php'; require_once plugin_dir_path(__FILE__) . 'classes/models/class.group.php'; require_once plugin_dir_path(__FILE__) . 'classes/models/class.abstract-field-base.php'; require_once plugin_dir_path(__FILE__) . 'classes/models/class.revisions.php'; require_once plugin_dir_path(__FILE__) . 'classes/models/class.ajax.php'; require_once plugin_dir_path(__FILE__) . 'classes/class.scf.php'; new Smart_Custom_Fields_Revisions(); foreach (glob(plugin_dir_path(__FILE__) . 'classes/fields/*.php') as $form_item) { include_once $form_item; $basename = basename($form_item, '.php'); $classname = preg_replace('/^class\\.field\\-(.+)$/', 'Smart_Custom_Fields_Field_$1', $basename); if (class_exists($classname)) { new $classname(); } } do_action(SCF_Config::PREFIX . 'fields-loaded'); add_action('init', array($this, 'register_post_type')); add_action('init', array($this, 'ajax_request')); add_action('admin_menu', array($this, 'admin_menu')); add_action('current_screen', array($this, 'current_screen')); }
protected function before_output() { require_once $this->qm->plugin_path('output/Headers.php'); foreach (glob($this->qm->plugin_path('output/headers/*.php')) as $file) { include_once $file; } }
public function main() { $db = ConnectionManager::getDataSource('default'); $db->query($this->migrationsTableSql); $results = $db->query("select migrations from __migrations"); $applied = array(); foreach ($results as $result) { $applied[] = $result['__migrations']['migrations']; } $migrations = glob(APP . 'Config' . DS . 'Schema' . DS . 'migrations' . DS . '*.sql'); natsort($migrations); $db->begin(); try { foreach ($migrations as $filename) { list($migration, $ignore) = explode('.', basename($filename)); if (in_array($migration, $applied)) { continue; } $this->out("Migrating to {$migration}."); $db->query(file_get_contents($filename)); $db->query("INSERT INTO `__migrations` VALUES ('{$migration}')"); } $db->commit(); $this->out('Done.'); } catch (Exception $e) { $this->out("<error>Migration failed. Rolling back.</error>"); $db->rollback(); throw $e; } }