本文整理汇总了PHP中VQMod::path方法的典型用法代码示例。如果您正苦于以下问题:PHP VQMod::path方法的具体用法?PHP VQMod::path怎么用?PHP VQMod::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VQMod
的用法示例。
在下文中一共展示了VQMod::path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _parseMods
/**
* VQModObject::_parseMods()
*
* @param DOMNode $node <modification> node to be parsed
* @return null
* @description Parses modifications in preparation for the applyMod method to work
*/
private function _parseMods(DOMNode $node)
{
$files = $node->getElementsByTagName('file');
$replaces = VQMod::$_replaces;
foreach ($files as $file) {
$path = $file->getAttribute('path') ? $file->getAttribute('path') : '';
$filesToMod = explode(',', $file->getAttribute('name'));
foreach ($filesToMod as $filename) {
$fileToMod = $path . $filename;
if (!empty($replaces)) {
foreach ($replaces as $r) {
if (count($r) == 2) {
$fileToMod = preg_replace($r[0], $r[1], $fileToMod);
}
}
}
$error = $file->hasAttribute('error') ? $file->getAttribute('error') : 'log';
$fullPath = VQMod::path($fileToMod);
if (!$fullPath || !file_exists($fullPath)) {
if (strpos($fileToMod, '*') !== false) {
$fullPath = VQMod::getCwd() . $fileToMod;
} else {
if ($error == 'log' || $error == 'abort') {
$skip = $error == 'log' ? ' (SKIPPED)' : ' (ABORTING MOD)';
VQMod::$log->write('VQModObject::parseMods - Could not resolve path for [' . $fileToMod . ']' . $skip, $this);
}
if ($error == 'log' || $error == 'skip') {
continue;
} elseif ($error == 'abort') {
return false;
}
}
}
$operations = $file->getElementsByTagName('operation');
foreach ($operations as $opIndex => $operation) {
$error = $operation->hasAttribute('error') ? $operation->getAttribute('error') : 'abort';
$ignoreif = $operation->getElementsByTagName('ignoreif')->item(0);
if ($ignoreif) {
$ignoreif = new VQSearchNode($ignoreif);
} else {
$ignoreif = false;
}
$this->mods[$fullPath][] = array('search' => new VQSearchNode($operation->getElementsByTagName('search')->item(0)), 'add' => new VQAddNode($operation->getElementsByTagName('add')->item(0)), 'ignoreif' => $ignoreif, 'error' => $error, 'fileToMod' => $fileToMod, 'opIndex' => $opIndex);
}
}
}
}
示例2: __destruct
/**
* VQModLog::__destruct()
*
* @return null
* @description Logs any messages to the log file just before object is destroyed
*/
public function __destruct()
{
if (empty($this->_logs) || VQMod::$logging == false) {
return;
}
$logPath = VQMod::path(VQMod::$logFolder . date('w_D') . '.log', true);
$txt = array();
$txt[] = str_repeat('-', 10) . ' Date: ' . date('Y-m-d H:i:s') . ' ~ IP : ' . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'N/A') . ' ' . str_repeat('-', 10);
$txt[] = 'REQUEST URI : ' . $_SERVER['REQUEST_URI'];
foreach ($this->_logs as $count => $log) {
if ($log['obj']) {
$vars = get_object_vars($log['obj']);
$txt[] = 'MOD DETAILS:';
foreach ($vars as $k => $v) {
if (is_string($v)) {
$txt[] = ' ' . str_pad($k, 10, ' ', STR_PAD_RIGHT) . ': ' . $v;
}
}
}
foreach ($log['log'] as $msg) {
$txt[] = $msg;
}
if ($count > count($this->_logs) - 1) {
$txt[] = '';
}
}
$txt[] = $this->_sep;
$txt[] = str_repeat(PHP_EOL, 2);
$append = true;
if (!file_exists($logPath)) {
$append = false;
} else {
$content = file_get_contents($logPath);
if (!empty($content) && strpos($content, ' Date: ' . date('Y-m-d ')) === false) {
$append = false;
}
}
$result = file_put_contents($logPath, implode(PHP_EOL, $txt), $append ? FILE_APPEND | LOCK_EX : LOCK_EX);
if (!$result) {
die('VQModLog::__destruct - LOG FILE "' . $logPath . '" COULD NOT BE WRITTEN');
}
}