function actionC() { $this->addHeader('Copying files...'); $this->setSourceDirectory('new_files'); $this->setTargetDirectory(YDPath::join($this->_target_dir, $this->target_dir)); $res = $this->copyDirectory('sub', false); $res2 = $this->copyDirectory('sub2'); $res3 = $this->copyFileByPattern('*.*'); $res4 = $this->deleteDirectory('sub3'); $res5 = $this->deleteFileByPattern('*.bmp'); $res6 = $this->createDirectory('sub4'); $res7 = $this->deleteDirectory('sub4'); $results = array_merge($res, $res2, $res3, $res4, $res5, $res6, $res7); $this->addText(YDInstaller::getReport($results)); $this->addSeparator(); $this->addNavButtons('Continue'); $this->setField('installed', true); if ($this->isValid()) { $this->goTo('D'); } $this->display(); }
function actionDefault() { YDDebugUtil::dump(YDPath::getDirectorySeparator(), 'getDirectorySeparator()'); YDDebugUtil::dump(YDPath::getPathSeparator(), 'getPathSeparator()'); YDDebugUtil::dump(YDPath::getVolumeSeparator(), 'getVolumeSeparator()'); YDDebugUtil::dump(YDPath::changeExtension(__FILE__, '.tpl'), 'changeExtension( __FILE__, ".tpl" )'); YDDebugUtil::dump(YDPath::getDirectoryName(__FILE__), 'getDirectoryName( __FILE__ )'); YDDebugUtil::dump(YDPath::getExtension(__FILE__), 'getExtension( __FILE__ )'); YDDebugUtil::dump(YDPath::getFileName(__FILE__), 'getFileName( __FILE__ )'); YDDebugUtil::dump(YDPath::getFileNameWithoutExtension(__FILE__), 'getFileNameWithoutExtension( __FILE__ )'); YDDebugUtil::dump(YDPath::getFilePath(__FILE__), 'getFilePath( __FILE__ )'); YDDebugUtil::dump(YDPath::getFilePathWithoutExtension(__FILE__), 'getFilePathWithoutExtension( __FILE__ )'); YDDebugUtil::dump(YDPath::getFullPath(__FILE__), 'getFullPath( __FILE__ )'); YDDebugUtil::dump(YDPath::getTempFileName(), 'getTempFileName()'); YDDebugUtil::dump(YDPath::getTempPath(), 'getTempPath()'); YDDebugUtil::dump(YDPath::hasExtension(__FILE__), 'hasExtension( __FILE__ )'); YDDebugUtil::dump(YDPath::hasExtension(YDPath::getFileNameWithoutExtension(__FILE__)), 'hasExtension( YDPath::getFileNameWithoutExtension( __FILE__ ) )'); YDDebugUtil::dump(YDPath::isAbsolute(__FILE__), 'isAbsolute( __FILE__ )'); YDDebugUtil::dump(YDPath::isAbsolute(YDPath::getFileName(__FILE__)), 'isAbsolute( getFileName( __FILE__ ) )'); YDDebugUtil::dump(YDPath::join(__FILE__), 'join( __FILE__ )'); YDDebugUtil::dump(YDPath::join(YDPath::getTempPath(), YDPath::getFileName(__FILE__)), 'join( getTempPath(), getFileName( __FILE__ ) )'); YDDebugUtil::dump(YDPath::join(YDPath::getTempPath(), __FILE__), 'join( getTempPath(), __FILE__ )'); }
* @addtogroup YDFramework Core */ // Check if the framework is loaded if (!defined('YD_FW_NAME')) { die('Yellow Duck Framework is not loaded.'); } // Includes include_once YD_DIR_HOME_CLS . '/YDFileSystem.php'; // The different log levels @define('YD_LOG_DEBUG', 4); @define('YD_LOG_INFO', 3); @define('YD_LOG_WARNING', 2); @define('YD_LOG_ERROR', 1); // Configure the default for this class YDConfig::set('YD_LOG_LEVEL', YD_LOG_INFO, false); YDConfig::set('YD_LOG_FILE', YDPath::join(YD_DIR_TEMP, 'YDFramework2_log.xml'), false); YDConfig::set('YD_LOG_FORMAT', 'XML', false); YDConfig::set('YD_LOG_TEXTFORMAT', "%date% | %level% | %uri% | %basefile%:%line% | %function% | %message%", false); YDConfig::set('YD_LOG_WRAPLINES', false, false); YDConfig::set('YD_LOG_MAX_LINESIZE', 100, false); /** * This class defines the logging static functions. * * @ingroup YDFramework */ class YDLog extends YDBase { /** * This adds a debug message to the logfile. * * @param $text The message to add to the logfile.
/** * This function will recursively delete a directory. It will delete the directory and the complete * contents of that directory! Be careful I would say! * * @param $directory Directory to be removed. * * @return Boolean indicating if the directory could be deleted or not. */ function deleteDirectory($directory) { $directory = YDPath::join($this->getAbsolutePath(), $directory); if (!is_dir($directory)) { return false; } return YDFSDirectory::_delete($directory); }
function tempPath($path) { return YDPath::join(YD_DIR_TEMP, 'YDF_U_' . md5($path) . '.upd'); }
/** * This function will get the name of the template. * * @internal */ function _getTemplateName($file = '') { if (file_exists($file)) { if ('.' . YDPath::getExtension($file) != YD_TPL_EXT) { trigger_error('The specified file ' . $file . ' is not a valid template file (wrong file extension)', YD_ERROR); } return realpath($file); } $this->template_dir = YDPath::getFullPath($this->template_dir); if (empty($file)) { $file = YDPath::getFileNameWithoutExtension(YD_SELF_FILE); } if (is_file(YDPath::join($this->template_dir, $file . YD_TPL_EXT))) { $tplName = $file . YD_TPL_EXT; } else { $tplName = $file; } if (!is_file(YDPath::join($this->template_dir, $tplName))) { trigger_error('Template not found: ' . $tplName, YD_ERROR); } return $tplName; }
/** * This function deletes a file or an array of files using a pattern * from the target directory. * * @param $files The file pattern or an array of file patterns * relative to the target directory. * * @returns An array with the results. */ function deleteFileByPattern($files) { if (!is_array($files)) { $files = array($files); } $res = array(); foreach ($files as $key => $pattern) { // Get the directory out of the pattern $pattern = str_replace('/', YDPath::getDirectorySeparator(), $pattern); $pattern = str_replace('\\', YDPath::getDirectorySeparator(), $pattern); $pos = strrpos($pattern, YDPath::getDirectorySeparator()); $dir = ''; if ($pos) { $dir = substr($pattern, 0, $pos + 1); $pattern = substr($pattern, $pos + 1, strlen($pattern) - $pos); } // Get the files based on the pattern $d = new YDFSDirectory(YDPath::join($this->_target_dir, $dir)); $fs = $d->getContents($pattern, '', 'YDFSFile'); // Delete the files foreach ($fs as $file) { $res = array_merge($res, $this->deleteFile(YDPath::join($dir, $file))); } } return $res; }