protected function _generateContent($code) { $url = $this->getVersionUrl(); $type = $this->has('type') ? $this->get('type') : 'echo'; if ($this->has('gzip_static_dir')) { $zlevel = $this->has('gzip_level') ? $this->get('gzip_level') : 3; $file_source = lmbFs::normalizePath($this->get('gzip_static_dir'), lmbFs::UNIX) . '/' . str_replace('/', '-', lmbFs::normalizePath($this->getFileUrl(), lmbFs::UNIX)); lmbFs::cp($this->getFilePath(), $this->getRootDir() . '/' . $file_source); $file_gz = $file_source . '.gz'; lmbFs::safeWrite($this->getRootDir() . '/' . $file_gz, gzencode(file_get_contents($this->getFilePath()), $zlevel, FORCE_DEFLATE)); $url = $this->addVersion($file_source); } switch ($type) { case 'echo': if ($this->has('to_var')) { $code->writePhp($this->get('to_var') . ' = \'' . addslashes($url) . '\';'); } else { $code->writeHTML(htmlspecialchars($url, 3)); } break; case 'js': $code->writeHTML('<script type="text/javascript" src="' . htmlspecialchars($url, 3) . '" ></script>'); break; case 'css': $code->writeHTML('<link rel="stylesheet" type="text/css" href="' . htmlspecialchars($url, 3) . '" />'); break; default: throw new lmbMacroException('Unknown type ' . $type); } }
function create($argv) { $input = new lmbCliInput(); $input->setMinimumArguments(1); if (!$input->read($argv, false)) { $this->help($argv); return 1; } $dst_dir = $input->getArgument(0); if (file_exists($dst_dir)) { echo "Directory or file '{$dst_dir}' already exists\n"; return 1; } echo "Copying skeleton Limb3 WEB_APP application to '{$dst_dir}'...\n"; lmbFs::cp(dirname(__FILE__) . '/../skel', $dst_dir, '~^\\.svn~'); echo "Generating code from templates...\n"; $this->_resolveTemplate("{$dst_dir}/setup.override.php.tpl", array('%LIMB_PARENT_DIR%' => realpath(dirname(__FILE__) . '/../../../'))); echo "done!"; }
/** * @desc Create folders in /www/shared for all packages */ function task_project_shares() { lmb_require('limb/fs/src/lmbFs.class.php'); foreach (glob(taskman_prop('PROJECT_DIR') . "/lib/limb/*/shared") as $pkg_shared) { $pkg = basename(dirname($pkg_shared)); $shared_dir = taskman_prop('PROJECT_DIR') . '/www/shared/'; if (!is_dir($shared_dir)) { mkdir($shared_dir, 0755, true); } $destination = $shared_dir . $pkg; if (is_link($destination)) { unlink($destination); } else { lmbFs::rm($destination); } try { if (function_exists('symlink')) { symlink($pkg_shared, $destination); taskman_msg("Created symlink for {$pkg} ({$destination})...\n"); } else { throw new Exception(); } } catch (Exception $e) { lmbFs::cp($pkg_shared, $destination); taskman_msg("Copied share for {$pkg} ({$destination})...\n"); } } }
function testCpFileIntoNonExistingDir() { $this->_createFileSystem(); $this->assertFalse(file_exists(LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy')); $res = lmbFs::cp(LIMB_VAR_DIR . '/tmp/test1_1', LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy'); $this->assertTrue(file_exists(LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy')); $this->_removeFileSystem(); }
protected function _copyFolders() { lmbFs::mkdir($this->getProjectDir() . '/folders'); $folders = $this->folders; foreach ($folders as $key => $value) { lmbFs::mkdir($this->getProjectDir() . '/folders/' . $key); lmbFs::cp($value, $this->getProjectDir() . '/folders/' . $key); } }
static function mergeInto($index1, $index2) { $index_name = basename($index2); $index_dir = dirname($index2); $old_dir = $index_dir . '-old-' . mt_rand(); $merged_dir = lmbFs::getTmpDir() . '/merged-' . mt_rand(); $merged = $merged_dir . '/' . $index_name; self::merge($index1, $index2, $merged); lmbFs::mv($index_dir, $old_dir); lmbFs::mv($merged_dir, $index_dir); lmbFs::rm($old_dir); lmbFs::cp(dirname($index1) . '/' . self::$stamp, $index_dir); lmbFs::rm(dirname($index1)); }