/** * * Creates a symlink in "docroot/public" for a given class. * * @param string $class The class name. * * @return void * */ protected function _link($class) { // array of class-name parts $arr = explode('_', $class); // the last part of the class name where to put the symlink $tgt = array_pop($arr); // make the rest of the array into a subdirectory path $sub = implode('/', $arr); // where is the source (original) directory located, relatively? $k = count($arr); $src = ""; for ($i = 0; $i < $k; $i++) { $src .= "../"; } $src .= "../../include/{$sub}/{$tgt}/Public"; // need the system root $system = Solar::$system; // make sure we have a place to make the symlink $dir = "docroot/public/{$sub}"; if (!Solar_Dir::exists("{$system}/{$dir}")) { $this->_out(" Making public directory {$dir} ... "); Solar_Dir::mkdir("{$system}/{$dir}", 0755, true); $this->_outln("done."); } // make the symlink $this->_out(" Making public symlink for {$class} ... "); try { Solar_Symlink::make($src, $tgt, $dir); $this->_outln('done.'); } catch (Exception $e) { $this->_out($e->getMessage()); $this->_outln(' ... failed.'); } }
public function __construct($path = '', $fileLocking = false) { if (!$path) { require_once 'Solar/Dir.php'; $path = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR); } $this->_locking = $fileLocking; $this->_path = $path; }
/** * * Test -- Sets the base directory for the class map. * */ public function testSetBase() { $dir = Solar_Class::dir('Solar', '..'); $base = Solar_Dir::fix(realpath($dir)); $map = Solar::factory('Solar_Class_Map'); $map->setBase($base); $actual = $map->getBase(); $this->assertSame($actual, $base); }
public function __construct($path = '', $exclude = array(), $locking = false, $flushTimeLimit = 0) { if (!$path) { require_once W3TC_LIB_MINIFY_DIR . '/Solar/Dir.php'; $path = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR); } $this->_path = $path; $this->_exclude = $exclude; $this->_locking = $locking; $this->_flushTimeLimit = $flushTimeLimit; }
/** * * Writes the Solar_Mail_Message headers and content to a file. * * @return bool True on success, false on failure. * */ protected function _send() { $file = Solar_Dir::fix($this->_config['dir']) . $this->_config['prefix'] . date('Y-m-d_H-i-s') . '.' . substr(microtime(), 2, 6); $text = $this->_headersToString($this->_mail->fetchHeaders()) . $this->_mail->getCrlf() . $this->_mail->fetchContent(); $result = file_put_contents($file, $text); if ($result === false) { return false; } else { return true; } }
/** * * Setup; runs before each test method. * */ public function preTest() { if (is_null($this->_config['path'])) { $this->_config['path'] = Solar_Dir::tmp('/Solar_Cache_Testing/'); } parent::preTest(); /** * @todo remove requirement that deleteAll() actually work here */ // remove all previous entries $this->_adapter->deleteAll(); }
/** * _postConstruct * * @param $model */ protected function _postConstruct() { parent::_postConstruct(); $this->_model = $this->_config['model']; $this->web_root = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : Solar::$system . DIRECTORY_SEPARATOR . 'docroot' . DIRECTORY_SEPARATOR; $this->web_root = Solar_Dir::fix($this->web_root); $class_arr = explode('_', get_class($this)); $this->_module_name = end($class_arr); $this->_module_info = $this->_model->modules->fetchModuleInfoByName($this->_module_name); $this->_setViewPath(); $this->_setViewFile(); $this->_setView(); $this->_view->addHelperClass('Foresmo_View_Helper'); }
/** * * Makes a symbolic link to a file or directory. * * @param string $src The source path of the real file or directory. * * @param string $tgt The target path for where to put the symlink. * * @param string $dir Change to this directory before creating the * symlink, typically the target directory; this helps when making * relative symlinks. * * @return string The last line from the [[php::exec() | ]] call to * create the symlink. * */ public static function make($src, $tgt, $dir = null) { // are we on a windows system prior to NT6? $is_win = strtolower(substr(PHP_OS, 0, 3)) == 'win'; if ($is_win && php_uname('r') < 6) { throw Solar_Symlink::_exception('ERR_WINDOWS_VERSION'); } // massage the change-dir a bit $dir = trim($dir); if ($dir) { $dir = Solar_Dir::fix($dir); } // is the source a directory or a file? $path = $dir . $src; $is_dir = Solar_Dir::exists($path); $is_file = Solar_File::exists($path); if (!$is_dir && !$is_file) { // no source found throw Solar_Symlink::_exception('ERR_SOURCE_NOT_FOUND', array('src' => $src, 'tgt' => $tgt, 'dir' => $dir, 'path' => $path)); } // find any existing path to the target if ($is_dir) { $path = Solar_Dir::exists($dir . $tgt); } else { $path = Solar_File::exists($dir . $tgt); } // does the target exist already? if ($path) { throw Solar_Symlink::_exception('ERR_TARGET_EXISTS', array('src' => $src, 'tgt' => $tgt, 'dir' => $dir, 'path' => $path)); } // escape arguments for the command $src = escapeshellarg($src); $tgt = escapeshellarg($tgt); $dir = escapeshellarg($dir); if ($is_win && $is_dir) { // windows directory return Solar_Symlink::_makeWinDir($src, $tgt, $dir); } elseif ($is_win && $is_file) { // windows file return Solar_Symlink::_makeWinFile($src, $tgt, $dir); } else { // non-windows return Solar_Symlink::_make($src, $tgt, $dir); } }
public function __construct($path = '', $exclude = array(), $locking = false, $flushTimeLimit = 0, $flush_path = null) { if (!$path) { w3_require_once(W3TC_LIB_MINIFY_DIR . '/Solar/Dir.php'); $path = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR); } $this->_path = $path; $this->_exclude = $exclude; $this->_locking = $locking; $this->_flushTimeLimit = $flushTimeLimit; $this->_flush_path = is_null($flush_path) ? $path : $flush_path; if (!file_exists($this->_path . '/index.html')) { if (!is_dir($this->_path)) { w3_mkdir_from($this->_path, W3TC_CACHE_DIR); } @file_put_contents($this->_path . '/index.html', ''); } }
/** * * Write out a series of dirs and symlinks for a new Vendor source. * * @param string $vendor The Vendor name. * * @return void * */ protected function _exec($vendor = null) { // we need a vendor name, at least if (!$vendor) { throw $this->_exception('ERR_NO_VENDOR'); } $this->_outln("Removing links for vendor '{$vendor}' ..."); // build "foo-bar" and "FooBar" versions of the vendor name. $this->_inflect = Solar_Registry::get('inflect'); $this->_dashes = $this->_inflect->camelToDashes($vendor); $this->_studly = $this->_inflect->dashesToStudly($this->_dashes); // the base system dir $system = Solar::$system; // the links to remove (reverse order from make-vendor) $links = array("script/{$this->_dashes}", "include/Fixture/{$this->_studly}", "include/Mock/{$this->_studly}", "include/Test/{$this->_studly}", "include/{$this->_studly}"); // remove the links foreach ($links as $link) { $this->_out(" Removing '{$link}' ... "); $path = "{$system}/{$link}"; // fix for windows $path = str_replace('/', DIRECTORY_SEPARATOR, $path); if (Solar_File::exists($path) || Solar_Dir::exists($path)) { Solar_Symlink::remove($path); $this->_outln("done."); } else { $this->_outln("missing."); } } // done! $this->_outln("... done."); // reminders $this->_outln("Remember to remove '{$this->_studly}_App' from the " . "['Solar_Controller_Front']['classes'] element " . "in your config file."); $this->_outln("Remember to remove '{$this->_studly}_Model' from the " . "['Solar_Sql_Model_Catalog']['classes'] element " . "in your config file."); // need to write a recursive-remove method for Solar_Dir that will // delete only the symlinked files (not the real files) $this->_outln("You will need to remove the " . "'docroot/public/{$this->_studly}' directory yourself, as it " . "may contain copies of public assets (not links)."); }
/** * * Sets directory paths for reading and writing. * * @return void * */ protected function _setDirs() { // get the source class dir $class_dir = $this->_options['class_dir']; if ($class_dir) { $this->_class_dir = Solar_Dir::fix($class_dir); } // do we have a class dir? if (!$this->_class_dir) { throw $this->_exception('ERR_NO_CLASS_DIR'); } // get the source package dir (if any) $package_dir = $this->_options['package_dir']; if ($package_dir) { $this->_package_dir = Solar_Dir::fix($package_dir); } // do we have a package dir? if (!$this->_package_dir) { throw $this->_exception('ERR_NO_PACKAGE_DIR'); } // get the target docbook dir (if any) $docbook_dir = $this->_options['docbook_dir']; if ($docbook_dir) { $this->_docbook_dir = Solar_Dir::fix($docbook_dir); } // do we have a docbook dir? if (!$this->_docbook_dir) { throw $this->_exception('ERR_NO_DOCBOOK_DIR'); } }
/** * * Support method to recursively descend into cache subdirectories and * remove their contents. * * @param string $dir The directory to remove. * * @return void * */ protected function _deleteAll($dir) { // get the list of files in the directory, suppress warnings. $list = (array) @scandir($dir, null, $this->_context); // delete each file, and recurse into subdirectories foreach ($list as $item) { // ignore dot-dirs if ($item == '.' || $item == '..') { continue; } // set up the absolute path to the item $item = $dir . DIRECTORY_SEPARATOR . $item; // how to handle the item? if (is_dir($item)) { // recurse into each subdirectory ... $this->_deleteAll($item); // ... then remove it Solar_Dir::rmdir($item); } else { // remove the cache file @unlink($item, $this->_context); } } }
/** * * Finds the base directory from the include-path to the requested class. * * @param string $class The requested class file. * * @return string The base directory. * */ protected function _findBaseByClass($class) { $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; $base = Solar_File::exists($file); if ($base) { $neglen = -1 * strlen($file); $base = substr($base, 0, $neglen); return $base; } // no base yet, look for a dir (drop the .php, add a separator) $dir = substr($file, 0, -4); $base = Solar_Dir::exists($dir); if ($base) { $neglen = -1 * strlen($dir); $base = substr($base, 0, $neglen); return $base; } // still no base, we have a problem throw $this->_exception('ERR_NO_BASE_DIR', array('class' => $class)); }
try { require_once 'Solar/Dir.php'; } catch (Exception $e) { if (! $setIncludeSuccess) { echo "Minify: set_include_path() failed. You may need to set your include_path " ."outside of PHP code, e.g., in php.ini."; } else { echo $e->getMessage(); } exit(); } require 'Minify.php'; $cachePathCode = ''; if (! isset($min_cachePath)) { $detectedTmp = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR); $cachePathCode = "\$min_cachePath = " . var_export($detectedTmp, 1) . ';'; } ob_start(); ?> <!doctype html> <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--> <!--[if gt IE 8]> <html class="no-js" lang="en"> <![endif]--> <title>Workless Minify URI Builder</title> <meta name="robots" content="noindex, nofollow">
/** * * Post-construction tasks to complete object construction. * * @return void * */ protected function _postConstruct() { parent::_postConstruct(); // path to storage; include the prefix as part of the path $this->_path = Solar_Dir::fix($this->_config['path'] . '/' . $this->_prefix); // whether or not to hash $this->_hash = $this->_config['hash']; // build the context property if (is_resource($this->_config['context'])) { // assume it's a context resource $this->_context = $this->_config['context']; } elseif (is_array($this->_config['context'])) { // create from scratch $this->_context = stream_context_create($this->_config['context']); } else { // not a resource, not an array, so ignore. // have to use a resource of some sort, so create // a blank context resource. $this->_context = stream_context_create(array()); } // make sure the cache directory is there; create it if // necessary. if (!is_dir($this->_path)) { mkdir($this->_path, $this->_config['mode'], true, $this->_context); } }
/** * * Returns the OS-specific directory for temporary files. * * @param string $sub Add this subdirectory to the returned temporary * directory name. * * @return string The temporary directory path. * */ public static function tmp($sub = '') { // find the tmp dir if needed if (! Solar_Dir::$_tmp) { // use the system if we can if (function_exists('sys_get_temp_dir')) { $tmp = sys_get_temp_dir(); } else { $tmp = Solar_Dir::_tmp(); } // remove trailing separator and save Solar_Dir::$_tmp = rtrim($tmp, DIRECTORY_SEPARATOR); } // do we have a subdirectory request? $sub = trim($sub); if ($sub) { // remove leading and trailing separators, and force exactly // one trailing separator $sub = trim($sub, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; } return Solar_Dir::$_tmp . DIRECTORY_SEPARATOR . $sub; }
/** * * Replacement for rmdir() to supress warnings and throw exceptions in * their place. * * @param string $path The directory path to remove * * @return bool True on success; throws exception on failure. * * @see [[php::rmdir() | ]] * */ public static function rmdir($path) { $result = @rmdir($path); if (!$result) { $info = error_get_last(); $info['rmdir_path'] = $path; throw Solar_Dir::_exception('ERR_RMDIR_FAILED', $info); } else { return true; } }
/** * * Returns the directory for a specific class, plus an optional * subdirectory path. * * @param string|object $spec The class or object to find parents * for. * * @param string $sub Append this subdirectory. * * @return string The class directory, with optional subdirectory. * */ public static function dir($spec, $sub = null) { if (is_object($spec)) { $class = get_class($spec); } else { $class = $spec; } // convert the class to a base directory to stem from $base = str_replace('_', DIRECTORY_SEPARATOR, $class); // does the directory exist? $dir = Solar_Dir::exists($base); if (!$dir) { throw Solar::exception('Solar_Class', 'ERR_NO_DIR_FOR_CLASS', 'Directory does not exist', array('class' => $class, 'base' => $base)); } else { return Solar_Dir::fix($dir . DIRECTORY_SEPARATOR . $sub); } }
/** * * Populates the list of recognized commands. * * @return void * */ protected function _setCommandList() { $list = array(); // loop through class stack and add commands $stack = $this->_stack->get(); foreach ($stack as $class) { $dir = Solar_Dir::exists(str_replace('_', DIRECTORY_SEPARATOR, $class)); if (!$dir) { continue; } // loop through each file in the directory $files = scandir($dir); foreach ($files as $file) { // file must end in .php and start with an upper-case letter $char = $file[0]; $keep = substr($file, -4) == '.php' && ctype_alpha($char) && strtoupper($char) == $char; if (!$keep) { // doesn't look like a command class continue; } // the list-value is the base class name, plus the file name, // minus the .php extension, to give us a class name $val = $class . substr($file, 0, -4); // the list-key is the command name; convert the file name to a // command name. FooBar.php becomes "foo-bar". $key = substr($file, 0, -4); $key = preg_replace('/([a-z])([A-Z])/', '$1-$2', $key); $key = strtolower($key); // keep the command name and class name $list[$key] = $val; } } // override with explicit routings $this->_command_list = array_merge($list, $this->_routing); // sort, and done ksort($this->_command_list); }
public function testSet_byArray() { $expect = array(Solar_Dir::fix('/path/foo/'), Solar_Dir::fix('/path/bar/'), Solar_Dir::fix('/path/baz/')); $stack = Solar::factory('Solar_Path_Stack'); $stack->set($expect); $this->assertSame($stack->get(), $expect); }
/** * * Main action: parse the classes and write documentation. * * @param string $class Start parsing with this class and recursively * descend. * * @return void * */ protected function _exec($class = null) { $begin = time(); if (!$class) { $class = 'Solar'; } // get the source dir $this->_source = $this->_options['source']; if (!$this->_source) { // get the directory where this class is stored $this->_source = Solar_Dir::name(__FILE__, 2); } // start parsing $this->_outln("Parsing source files from '{$this->_source}' ... "); $ref = Solar::factory('Solar_Docs_Apiref'); $ref->addFiles($this->_source, $class); // are we only linting the sources? if ($this->_options['lint']) { $this->_outln('Done.'); return; } // get the target API dir $class_dir = $this->_options['class_dir']; if ($class_dir) { $this->_class_dir = Solar_Dir::fix($class_dir); } // do we have a class dir? if (!$this->_class_dir) { throw $this->_exception('ERR_NO_CLASS_DIR'); } // get the target package dir (if any) $package_dir = $this->_options['package_dir']; if ($package_dir) { $this->_package_dir = Solar_Dir::fix($package_dir); } // do we have a package dir? if (!$this->_package_dir) { throw $this->_exception('ERR_NO_PACKAGE_DIR'); } // import the class data $this->api = $ref->api; ksort($this->api); // import the package data $this->packages = $ref->packages; ksort($this->packages); // write out the package pages $this->_outln(); $this->writePackages(); // write out the class pages $this->_outln(); $this->writeClasses(); // done! $this->_outln(); $time = time() - $begin; $this->_outln("Docs completed in {$time} seconds."); }
/** * * Sets the base directory target. * * @return void * */ protected function _setTarget() { $target = Solar::$system . "/include"; $this->_target = Solar_Dir::fix($target); }
/** * * Main action: parse the classes and write documentation. * * @param string $class Start parsing with this class and recursively * descend. * * @return void * */ protected function _exec($class = null) { $begin = time(); if (!$class) { $class = 'Solar'; } // get the source dir $this->_source = $this->_options['source']; if (!$this->_source) { // get the directory where this class is stored $this->_source = Solar_Dir::name(__FILE__, 2); } // start parsing $this->_outln("Parsing source files from '{$this->_source}' ... "); $ref = Solar::factory('Solar_Docs_Apiref'); $ref->addFiles($this->_source, $class); // are we only linting the sources? if ($this->_options['lint']) { $this->_outln('Done.'); return; } // get the target API dir $class_dir = $this->_options['class_dir']; if ($class_dir) { $this->_class_dir = Solar_Dir::fix($class_dir); } // do we have a class dir? if (!$this->_class_dir) { throw $this->_exception('ERR_NO_CLASS_DIR'); } // get the target package dir (if any) $package_dir = $this->_options['package_dir']; if ($package_dir) { $this->_package_dir = Solar_Dir::fix($package_dir); } // do we have a package dir? if (!$this->_package_dir) { throw $this->_exception('ERR_NO_PACKAGE_DIR'); } // get the docbook dir $docbook_dir = $this->_options['docbook_dir']; if ($docbook_dir) { $this->_docbook_dir = Solar_Dir::fix($docbook_dir); } // import the class data $this->api = $ref->api; ksort($this->api); // import the package data $this->packages = $ref->packages; ksort($this->packages); // write out the package pages $this->_outln(); $this->writePackages(); // write out the class pages $this->_outln(); $this->writeClasses(); // time note $time = time() - $begin; $this->_outln("Wiki docs written in {$time} seconds."); // convert to docbook? if ($this->_docbook_dir) { $this->_outln(); $cli = Solar::factory('Solar_Cli_MakeDocbook'); $argv = array("--class-dir={$this->_class_dir}", "--package-dir={$this->_package_dir}", "--docbook-dir={$this->_docbook_dir}", $class); $cli->exec($argv); $this->_outln(); $time = time() - $begin; $this->_outln("All docs written and converted in {$time} seconds."); } }
function flush_minify_caches() { // flush minify caches on save try { $minpath = realpath(dirname(APPPATH)) . '/assets/min/'; require_once $minpath . 'lib/Solar/Dir.php'; $tmppath = rtrim(Solar_Dir::tmp(), DIRECTORY_SEPARATOR); $files = glob(rtrim($tmppath, '/') . '/minify_*'); foreach ($files as $file) { if (is_writable($file)) { unlink($file); } } } catch (Exception $e) { log_message('error', $e->getMessage()); } }
/** * * Loads the translation array for a given class. * * @param string $class The class name to load translations for. * * @return void * */ protected function _load($class) { // build the file name. note that we use the fixdir() // method, which automatically replaces '/' with the // correct directory separator. $base = str_replace('_', '/', $class); $file = Solar_Dir::fix($base . '/Locale/') . $this->_code . '.php'; // can we find the file? $target = Solar_File::exists($file); if ($target) { // put the locale values into the shared locale array $this->trans[$class] = (array) Solar_File::load($target); } else { // could not find file. // fail silently, as it's often the case that the // translation file simply doesn't exist. $this->trans[$class] = array(); } }
/** * * Returns the OS-specific directory for temporary files, with a file * name appended. * * @param string $file The file name to append to the temporary directory * path. * * @return string The temp directory and file name. * */ public static function tmp($file) { // convert slashes to OS-specific separators, // then remove leading and trailing separators $file = str_replace('/', DIRECTORY_SEPARATOR, $file); $file = trim($file, DIRECTORY_SEPARATOR); // return the tmp dir plus file name return Solar_Dir::tmp() . $file; }
/** * _setLayoutTemplates * Override Solar_Controller_Page _setLayoutTemplates * to add theme layout path to layout stack * */ protected function _setLayoutTemplates() { // get the parents of the current class, including self $stack = array_reverse(Solar_Class::parents($this, true)); // remove Solar_Base array_pop($stack); // convert underscores to slashes, and add /Layout foreach ($stack as $key => $val) { $stack[$key] = str_replace('_', '/', $val) . '/Layout'; } // add theme layout path if ($this->_controller == 'admin') { $theme_name = $this->blog_admin_theme; $theme_layout_path = Solar::$system . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $theme_name . DIRECTORY_SEPARATOR . 'layouts'; $default_layout_path = Solar::$system . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'layouts'; } else { $theme_name = $this->blog_theme; $theme_layout_path = Solar::$system . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'main' . DIRECTORY_SEPARATOR . $theme_name . DIRECTORY_SEPARATOR . 'layouts'; $default_layout_path = Solar::$system . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'main' . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'layouts'; } if (Solar_Dir::exists($default_layout_path)) { array_unshift($stack, $default_layout_path); } if (Solar_Dir::exists($theme_layout_path) && $theme_layout_path != $default_layout_path) { array_unshift($stack, $theme_layout_path); } // done, add the stack $this->_view_object->setTemplatePath($stack); }
public function testFindReal() { // use the testing directory to look for __construct.phpt files $dir = $this->_support_path; $path = array("{$dir}/a", "{$dir}/b", "{$dir}/c"); $stack = Solar::factory('Solar_Path_Stack'); $stack->add($path[0]); $stack->add($path[1]); $stack->add($path[2]); // should find it at Solar_Base $actual = $stack->findReal('target1'); $expect = Solar_Dir::fix($path[0]) . 'target1'; $this->assertSame($expect, $actual); // should find it at Solar_Debug_Timer $actual = $stack->findReal('target2'); $expect = Solar_Dir::fix($path[1]) . 'target2'; $this->assertSame($expect, $actual); // should find it at Solar_Debug_Var $actual = $stack->findReal('target3'); $expect = Solar_Dir::fix($path[2]) . 'target3'; $this->assertSame($expect, $actual); // should not find it at all $actual = $stack->findReal('no_such_file'); $this->assertFalse($actual); }
/** * * Sets the base directory target. * * @return void * */ protected function _setTarget() { $target = $this->_options['target']; if (!$target) { // use the solar system "include" directory. // that should automatically point to the right vendor for us. $target = Solar::$system . "/include"; } $this->_target = Solar_Dir::fix($target); }
/** * * Writes the model "Locale/en_US.php" file. * * @param string $class The model class name. * * @return void * */ protected function _writeLocaleFile($class) { $dir = Solar_Dir::fix($this->_target . str_replace('_', '/', $class) . '/Locale'); // does the locale file already exist? $file = $dir . DIRECTORY_SEPARATOR . 'en_US.php'; if (file_exists($file)) { $this->_outln('Locale file for en_US already exists.'); return; } // does it exist? if (!$this->_table_cols) { $this->_outln('Not creating locale file; no table_cols available.'); return; } // create a label value & descr placeholder for each column $list = array_keys($this->_table_cols); $label = array(); $descr = array(); foreach ($list as $col) { $key = strtoupper("LABEL_{$col}"); $label[$key] = ucwords(str_replace('_', ' ', $col)); $key = strtoupper("DESCR_{$col}"); $descr[$key] = ''; } // write the en_US file $this->_out('Saving locale file for en_US ... '); $data = array_merge($label, $descr); $text = var_export($data, true); file_put_contents($file, "<?php return {$text};"); $this->_outln('done.'); }