本文整理汇总了PHP中Filesystem::move方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::move方法的具体用法?PHP Filesystem::move怎么用?PHP Filesystem::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::move方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveTask
//.........这里部分代码省略.........
}
foreach ($fields as $field) {
if (!in_array($field->name, $found) && $field->required) {
$found[] = $field->name;
$this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $field->label));
}
}
}
// Code cleaner for xhtml transitional compliance
if ($row->type != 7) {
$row->introtext = str_replace('<br>', '<br />', $row->introtext);
$row->fulltxt = str_replace('<br>', '<br />', $row->fulltxt);
}
// Check content
if (!$row->check()) {
throw new Exception($row->getError(), 500);
}
// Store content
if (!$row->store()) {
throw new Exception($row->getError(), 500);
}
// Checkin resource
$row->checkin();
// Rename the temporary upload directory if it exist
$tmpid = Request::getInt('tmpid', 0, 'post');
if ($tmpid != Html::niceidformat($row->id)) {
// Build the full paths
$path = Html::dateToPath($row->created);
$dir_id = Html::niceidformat($row->id);
$tmppath = Utilities::buildUploadPath($path . DS . $tmpid);
$newpath = Utilities::buildUploadPath($path . DS . $dir_id);
// Attempt to rename the temp directory
if (\Filesystem::exists($tmppath)) {
$result = \Filesystem::move($tmppath, $newpath);
if ($result !== true) {
$this->setError($result);
}
}
$row->path = str_replace($tmpid, Html::niceidformat($row->id), $row->path);
$row->store();
}
// Incoming tags
$tags = Request::getVar('tags', '', 'post');
// Save the tags
$rt = new Tags($row->id);
$rt->setTags($tags, User::get('id'), 1, 1);
// Incoming authors
if ($row->type != 7) {
$authorsOldstr = Request::getVar('old_authors', '', 'post');
$authorsNewstr = Request::getVar('new_authors', '', 'post');
if (!$authorsNewstr) {
$authorsNewstr = $authorsOldstr;
}
include_once dirname(dirname(__DIR__)) . DS . 'tables' . DS . 'contributor.php';
$authorsNew = explode(',', $authorsNewstr);
$authorsOld = explode(',', $authorsOldstr);
// We have either a new ordering or new authors or both
if ($authorsNewstr) {
for ($i = 0, $n = count($authorsNew); $i < $n; $i++) {
$rc = new Contributor($this->database);
$rc->subtable = 'resources';
$rc->subid = $row->id;
if (is_numeric($authorsNew[$i])) {
$rc->authorid = $authorsNew[$i];
} else {
$rc->authorid = $rc->getUserId($authorsNew[$i]);
示例2: fixTemplateName
/**
* Method to rename the template in the XML files and rename the language files
*
* @return boolean true if successful, false otherwise
* @since 2.5
*/
protected function fixTemplateName()
{
// Rename Language files
// Get list of language files
$result = true;
$files = Filesystem::files($this->getState('to_path'), '.ini', true, true);
$newName = strtolower($this->getState('new_name'));
$oldName = $this->getTemplate()->element;
foreach ($files as $file) {
$newFile = str_replace($oldName, $newName, $file);
$result = Filesystem::move($file, $newFile) && $result;
}
// Edit XML file
$xmlFile = $this->getState('to_path') . '/templateDetails.xml';
if (Filesystem::exists($xmlFile)) {
$contents = Filesystem::read($xmlFile);
$pattern[] = '#<name>\\s*' . $oldName . '\\s*</name>#i';
$replace[] = '<name>' . $newName . '</name>';
$pattern[] = '#<language(.*)' . $oldName . '(.*)</language>#';
$replace[] = '<language${1}' . $newName . '${2}</language>';
$contents = preg_replace($pattern, $replace, $contents);
$result = Filesystem::write($xmlFile, $contents) && $result;
}
return $result;
}
示例3: uploadTask
/**
* Uploads a file to a given directory and returns an attachment string
* that is appended to report/comment bodies
*
* @param string $listdir Directory to upload files to
* @return string A string that gets appended to messages
*/
public function uploadTask($listdir, $comment_id = 0)
{
if (!$listdir) {
$this->setError(Lang::txt('COM_SUPPORT_ERROR_MISSING_UPLOAD_DIRECTORY'));
return '';
}
// Construct our file path
$path = PATH_APP . DS . trim($this->config->get('webpath', '/site/tickets'), DS) . DS . $listdir;
$row = new Tables\Attachment($this->database);
// Rename temp directories
if ($tmp = Request::getInt('tmp_dir')) {
$tmpPath = PATH_APP . DS . trim($this->config->get('webpath', '/site/tickets'), DS) . DS . $tmp;
if (is_dir($tmpPath)) {
if (!\Filesystem::move($tmpPath, $path)) {
$this->setError(Lang::txt('COM_SUPPORT_ERROR_UNABLE_TO_MOVE_UPLOAD_PATH'));
throw new Exception(Lang::txt('COM_SUPPORT_ERROR_UNABLE_TO_MOVE_UPLOAD_PATH'), 500);
return '';
}
$row->updateTicketId($tmp, $listdir);
}
}
// Incoming file
$file = Request::getVar('upload', '', 'files', 'array');
if (!isset($file['name']) || !$file['name']) {
//$this->setError(Lang::txt('SUPPORT_NO_FILE'));
return '';
}
// Incoming
$description = Request::getVar('description', '');
// Build the path if it doesn't exist
if (!is_dir($path)) {
if (!Filesystem::makeDirectory($path)) {
$this->setError(Lang::txt('COM_SUPPORT_ERROR_UNABLE_TO_CREATE_UPLOAD_PATH'));
return '';
}
}
// Make the filename safe
$file['name'] = Filesystem::clean($file['name']);
$file['name'] = str_replace(' ', '_', $file['name']);
$ext = strtolower(Filesystem::extension($file['name']));
//make sure that file is acceptable type
if (!in_array($ext, explode(',', $this->config->get('file_ext')))) {
$this->setError(Lang::txt('COM_SUPPORT_ERROR_INCORRECT_FILE_TYPE'));
return Lang::txt('COM_SUPPORT_ERROR_INCORRECT_FILE_TYPE');
}
$filename = Filesystem::name($file['name']);
while (file_exists($path . DS . $filename . '.' . $ext)) {
$filename .= rand(10, 99);
}
$finalfile = $path . DS . $filename . '.' . $ext;
// Perform the upload
if (!Filesystem::upload($file['tmp_name'], $finalfile)) {
$this->setError(Lang::txt('COM_SUPPORT_ERROR_UPLOADING'));
return '';
} else {
// Scan for viruses
if (!\Filesystem::isSafe($finalfile)) {
if (\Filesystem::delete($finalfile)) {
$this->setError(Lang::txt('COM_SUPPORT_ERROR_FAILED_VIRUS_SCAN'));
return Lang::txt('COM_SUPPORT_ERROR_FAILED_VIRUS_SCAN');
}
}
// File was uploaded
// Create database entry
$description = htmlspecialchars($description);
$row->bind(array('id' => 0, 'ticket' => $listdir, 'comment_id' => $comment_id, 'filename' => $filename . '.' . $ext, 'description' => $description));
if (!$row->check()) {
$this->setError($row->getError());
}
if (!$row->store()) {
$this->setError($row->getError());
}
if (!$row->id) {
$row->getID();
}
return '{attachment#' . $row->id . '}';
}
}
示例4: saveTask
/**
* Save a wiki page
*
* @return void
*/
public function saveTask()
{
// Check for request forgeries
Request::checkToken();
// Check if they are logged in
if (User::isGuest()) {
$url = Request::getVar('REQUEST_URI', '', 'server');
App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url)));
return;
}
// Incoming revision
$rev = Request::getVar('revision', array(), 'post', 'none', 2);
//$rev['pageid'] = (isset($rev['pageid'])) ? intval($rev['pageid']) : 0;
$this->revision = $this->page->revision('current');
$this->revision->set('version', $this->revision->get('version') + 1);
if (!$this->revision->bind($rev)) {
$this->setError($this->revision->getError());
$this->editTask();
return;
}
$this->revision->set('id', 0);
// Incoming page
$page = Request::getVar('page', array(), 'post', 'none', 2);
$this->page = new Article(intval($rev['pageid']));
if (!$this->page->bind($page)) {
$this->setError($this->page->getError());
$this->editTask();
return;
}
$this->page->set('pagename', trim(Request::getVar('pagename', '', 'post')));
$this->page->set('scope', trim(Request::getVar('scope', '', 'post')));
// Get parameters
$params = new \Hubzero\Config\Registry($this->page->get('params', ''));
$params->merge(Request::getVar('params', array(), 'post'));
$this->page->set('params', $params->toString());
// Get the previous version to compare against
if (!$rev['pageid']) {
// New page - save it to the database
$this->page->set('created_by', User::get('id'));
$old = new Revision(0);
} else {
// Get the revision before changes
$old = $this->page->revision('current');
}
// Was the preview button pushed?
$this->preview = trim(Request::getVar('preview', ''));
if ($this->preview) {
// Set the component task
if (!$rev['pageid']) {
Request::setVar('task', 'new');
$this->_task = 'new';
} else {
Request::setVar('task', 'edit');
$this->_task = 'edit';
}
// Push on through to the edit form
$this->editTask();
return;
}
// Check content
// First, make sure the pagetext isn't empty
if ($this->revision->get('pagetext') == '') {
$this->setError(Lang::txt('COM_WIKI_ERROR_MISSING_PAGETEXT'));
$this->editTask();
return;
}
// Store new content
if (!$this->page->store(true)) {
$this->setError($this->page->getError());
$this->editTask();
return;
}
// Get allowed authors
if (!$this->page->updateAuthors(Request::getVar('authors', '', 'post'))) {
$this->setError($this->page->getError());
$this->editTask();
return;
}
// Get the upload path
$wpa = new Tables\Attachment($this->database);
$path = $wpa->filespace();
// Rename the temporary upload directory if it exist
$lid = Request::getInt('lid', 0, 'post');
if ($lid != $this->page->get('id')) {
if (is_dir($path . DS . $lid)) {
if (!\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id'))) {
$this->setError(\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id')));
}
$wpa->setPageID($lid, $this->page->get('id'));
}
}
$this->revision->set('pageid', $this->page->get('id'));
$this->revision->set('pagename', $this->page->get('pagename'));
$this->revision->set('scope', $this->page->get('scope'));
$this->revision->set('group_cn', $this->page->get('group_cn'));
//.........这里部分代码省略.........
示例5: process
//.........这里部分代码省略.........
$resizedImageSource .= 'x' . (string) $cropratio;
}
$resizedImageSource .= '-' . $image;
$resizedImage = $resizedImageSource;
//md5($resizedImageSource);
$resized = $docRoot . $resizedImage;
// We don't want to run out of memory
ini_set('memory_limit', $this->_MEMORY_TO_ALLOCATE);
// Set up a blank canvas for our resized image (destination)
$dst = imagecreatetruecolor($tnWidth, $tnHeight);
// Set up the appropriate image handling functions based on the original image's mime type
switch ($size['mime']) {
case 'image/gif':
// We will be converting GIFs to PNGs to avoid transparency issues when resizing GIFs
// This is maybe not the ideal solution, but IE6 can suck it
$creationFunction = 'ImageCreateFromGif';
$outputFunction = 'ImagePng';
$mime = 'image/png';
// We need to convert GIFs to PNGs
$doSharpen = FALSE;
$quality = round(10 - $quality / 10);
// We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'image/x-png':
case 'image/png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - $quality / 10);
// PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = TRUE;
break;
}
// Read in the original image
$src = $creationFunction($docRoot . $image);
if (in_array($size['mime'], array('image/gif', 'image/png'))) {
if (!$color) {
// If this is a GIF or a PNG, we need to set up transparency
imagealphablending($dst, false);
imagesavealpha($dst, true);
} else {
// Fill the background with the specified color for matting purposes
if ($color[0] == '#') {
$color = substr($color, 1);
}
$background = FALSE;
if (strlen($color) == 6) {
$background = imagecolorallocate($dst, hexdec($color[0] . $color[1]), hexdec($color[2] . $color[3]), hexdec($color[4] . $color[5]));
} else {
if (strlen($color) == 3) {
$background = imagecolorallocate($dst, hexdec($color[0] . $color[0]), hexdec($color[1] . $color[1]), hexdec($color[2] . $color[2]));
}
}
if ($background) {
imagefill($dst, 0, 0, $background);
}
}
}
// Resample the original image into the resized canvas we set up earlier
ImageCopyResampled($dst, $src, 0, 0, $offsetX, $offsetY, $tnWidth, $tnHeight, $width, $height);
if ($doSharpen) {
// Sharpen the image based on two things:
// (1) the difference between the original size and the final size
// (2) the final size
$sharpness = $this->findSharp($width, $tnWidth);
$sharpenMatrix = array(array(-1, -2, -1), array(-2, $sharpness + 12, -2), array(-1, -2, -1));
$divisor = $sharpness;
$offset = 0;
if (function_exists('imageconvolution')) {
imageconvolution($dst, $sharpenMatrix, $divisor, $offset);
}
}
// Write the resized image to the cache
$outputFunction($dst, $resized, $quality);
// Yes - remove it
$overwrite = $this->overwrite;
if ($overwrite) {
$outputName = $this->outputName;
if ($outputName) {
$image = $outputName;
}
if (file_exists($resized)) {
if (file_exists($docRoot . $image)) {
if (!\Filesystem::delete($docRoot . $image)) {
$this->setError(Lang::txt('UNABLE_TO_DELETE_FILE'));
return false;
}
}
if (!\Filesystem::move($resized, $docRoot . $image)) {
$this->setError(Lang::txt('UNABLE_TO_DELETE_FILE'));
return false;
}
}
}
return true;
}
示例6: step_compose_process
//.........这里部分代码省略.........
}
}
$fulltxt = $row->get('fulltxt');
$nbtag = Request::getVar('nbtag', array(), 'post');
$found = array();
foreach ($nbtag as $tagname => $tagcontent) {
$f = '';
$fulltxt .= "\n" . '<nb:' . $tagname . '>';
if (is_array($tagcontent)) {
$c = count($tagcontent);
$num = 0;
foreach ($tagcontent as $key => $val) {
if (trim($val)) {
$num++;
}
$fulltxt .= '<' . $key . '>' . trim($val) . '</' . $key . '>';
}
if ($c == $num) {
$f = 'found';
}
} else {
$f = trim($tagcontent);
if ($f) {
$fulltxt .= trim($tagcontent);
}
}
$fulltxt .= '</nb:' . $tagname . '>' . "\n";
if (!$f && isset($fields[$tagname]) && $fields[$tagname]->required) {
$this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $fields[$tagname]->label));
}
$found[] = $tagname;
}
$row->set('fulltxt', $fulltxt);
foreach ($fields as $field) {
if (!in_array($field->name, $found) && $field->required) {
$found[] = $field->name;
$this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $field->label));
}
}
$row->set('title', preg_replace('/\\s+/', ' ', $row->get('title')));
$row->set('title', $this->_txtClean($row->get('title')));
// Strip any scripting there may be
if (trim($row->get('fulltxt'))) {
$row->set('fulltxt', \Components\Resources\Helpers\Html::stripStyles($row->get('fulltxt')));
$row->set('fulltxt', $this->_txtClean($row->get('fulltxt')));
$row->set('footertext', $this->_txtClean($row->get('footertext')));
}
// Fall back to step if any errors found
if ($this->getError()) {
$this->step--;
$this->view->step = $this->step;
$this->view->setLayout('compose');
return $this->step_compose($row);
}
// reset id
if ($isNew) {
$row->set('id', 0);
}
// Store new content
if (!$row->save()) {
$this->setError(Lang::txt('Error: Failed to store changes.'));
$this->step--;
$this->view->step = $this->step;
$this->view->setLayout('compose');
return $this->step_compose($row);
}
// build path to temp upload folder and future permanent folder
$session = App::get('session');
$created = Date::format('Y-m-d 00:00:00');
$oldPath = $row->basepath() . Html::build_path($created, $session->get('resources_temp_id'), '');
$newPath = $row->filespace();
// if we have a temp dir, move it to permanent location
if (is_dir($oldPath)) {
\Filesystem::move($oldPath, $newPath);
$old = DS . $session->get('resources_temp_id') . DS;
$new = DS . $row->id . DS;
// update all images in abstract
$row->set('introtext', str_replace($old, $new, $row->get('introtext')));
$row->set('fulltxt', str_replace($old, $new, $row->get('fulltxt')));
$row->save();
// clear temp id
$session->clear('resources_temp_id');
}
// Is it a new resource?
if ($isNew) {
// Automatically attach this user as the first author
Request::setVar('pid', $row->get('id'));
Request::setVar('id', $row->get('id'));
Request::setVar('authid', User::get('id'));
include_once __DIR__ . DS . 'authors.php';
$authors = new Authors();
$authors->saveTask(0);
}
// Log activity
$recipients = array(['resource', $row->get('id')], ['user', $row->get('created_by')]);
foreach ($row->authors()->where('authorid', '>', 0)->rows() as $author) {
$recipients[] = ['user', $author->get('authorid')];
}
Event::trigger('system.logActivity', ['activity' => ['action' => $isNew ? 'updated' : 'created', 'scope' => 'resource', 'scope_id' => $row->get('id'), 'description' => Lang::txt('COM_RESOURCES_ACTIVITY_ENTRY_' . (!$isNew ? 'UPDATED' : 'CREATED'), '<a href="' . Route::url('index.php?option=com_resources&id=' . $row->get('id')) . '">' . $row->get('title') . '</a>'), 'details' => array('title' => $row->get('title'), 'url' => Route::url('index.php?option=com_resources&id=' . $row->get('id')))], 'recipients' => $recipients]);
}
示例7: step_compose_process
//.........这里部分代码省略.........
$row->fulltxt .= "\n" . '<nb:' . $tagname . '>';
if (is_array($tagcontent)) {
$c = count($tagcontent);
$num = 0;
foreach ($tagcontent as $key => $val) {
if (trim($val)) {
$num++;
}
$row->fulltxt .= '<' . $key . '>' . trim($val) . '</' . $key . '>';
}
if ($c == $num) {
$f = 'found';
}
} else {
$f = trim($tagcontent);
if ($f) {
$row->fulltxt .= trim($tagcontent);
//(isset($fields[$tagname]) && $fields[$tagname]->type == 'textarea') ? $this->_txtAutoP(trim($tagcontent), 1) : trim($tagcontent);
}
}
$row->fulltxt .= '</nb:' . $tagname . '>' . "\n";
if (!$f && isset($fields[$tagname]) && $fields[$tagname]->required) {
$this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $fields[$tagname]->label));
}
$found[] = $tagname;
}
foreach ($fields as $field) {
if (!in_array($field->name, $found) && $field->required) {
$found[] = $field->name;
$this->setError(Lang::txt('COM_CONTRIBUTE_REQUIRED_FIELD_CHECK', $field->label));
}
}
$row->title = preg_replace('/\\s+/', ' ', $row->title);
$row->title = $this->_txtClean($row->title);
// Strip any scripting there may be
if (trim($row->fulltxt)) {
$row->fulltxt = \Components\Resources\Helpers\Html::stripStyles($row->fulltxt);
$row->fulltxt = $this->_txtClean($row->fulltxt);
//$row->fulltxt = $this->_txtAutoP($row->fulltxt, 1);
$row->footertext = $this->_txtClean($row->footertext);
}
// Check content
if (!$row->check()) {
$this->setError($row->getError());
}
// Fall back to step if any errors found
if ($this->getError()) {
$this->step--;
$this->view->step = $this->step;
$this->view->setLayout('compose');
$this->step_compose($row);
return;
}
// reset id
if ($isNew) {
$row->id = null;
}
// Store new content
if (!$row->store()) {
$this->setError(Lang::txt('Error: Failed to store changes.'));
$this->step--;
$this->view->step = $this->step;
$this->view->setLayout('compose');
$this->step_compose($row);
return;
}
// build path to temp upload folder and future permanent folder
$session = App::get('session');
$created = Date::format('Y-m-d 00:00:00');
$oldPath = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/resources'), DS) . Html::build_path($created, $session->get('resources_temp_id'), '');
$newPath = PATH_APP . DS . trim($this->config->get('uploadpath', '/site/resources'), DS) . Html::build_path($row->created, $row->id, '');
// if we have a temp dir, move it to permanent location
if (is_dir($oldPath)) {
\Filesystem::move($oldPath, $newPath);
$old = DS . $session->get('resources_temp_id') . DS;
$new = DS . $row->id . DS;
// update all images in abstract
$row->introtext = str_replace($old, $new, $row->introtext);
$row->fulltxt = str_replace($old, $new, $row->fulltxt);
$row->store();
// clear temp id
$session->clear('resources_temp_id');
}
// Checkin the resource
$row->checkin();
// Is it a new resource?
if ($isNew) {
// Get the resource ID
if (!$row->id) {
$row->id = $row->insertid();
}
// Automatically attach this user as the first author
Request::setVar('pid', $row->id);
Request::setVar('id', $row->id);
Request::setVar('authid', User::get('id'));
include_once __DIR__ . DS . 'authors.php';
$authors = new Authors();
$authors->saveTask(0);
}
}
示例8: doWork
/**
* This method allows you to do any additional work beyond unpacking
* the files that is required. This could include work such as downloading
* and unpacking an archive.
*
* The following are some of the methods available to you in this file:
* $this->curlFile($url, $destFolder)
* $this->move($src, $dest)
* $this->unzip($file, $destFolder)
*/
public function doWork()
{
$fs = new Filesystem();
// Ensure tmp working dir exists
$tmp = $this->mRootPath . "\\tmp";
$this->log("Creating temporary build directory: " . $tmp);
$fs->mkdir($tmp);
if ($this->p->get('source') != '' && $fs->exists($this->p->get('source'))) {
// Use WordPress codebase from source parameter
$this->log("Copying WordPress from " . $this->p->get('source'));
$fs->copy($this->p->get('source'), $this->mAppRoot);
} else {
// Download and unpack WordPress
$this->log('Downloading WordPress');
$file = $this->curlFile(WP_URL, $tmp);
$this->log('Extracting WordPress');
$this->unzip($file, $tmp);
$this->log('Moving WordPress files to ' . $this->mAppRoot);
$fs->move("{$tmp}\\wordpress", $this->mAppRoot);
}
// Download and unpack DB abstraction layer
$this->log('Downloading Database Abstraction Layer');
$file = $this->curlFile(DB_ABSTRACTION_URL, $tmp);
$this->log('Extracting Database Abstraction Layer');
$this->unzip($file, $tmp);
$this->log('Moving Database Abstraction Layer files to ' . $this->mAppRoot . "\\wp-content\\mu-plugins");
$fs->copy("{$tmp}\\wordpress-database-abstraction\\wp-db-abstraction\\db.php", $this->mAppRoot . "\\wp-content\\db.php");
$fs->move("{$tmp}\\wordpress-database-abstraction", $this->mAppRoot . "\\wp-content\\mu-plugins");
// Download and unpack Azure Storage Plugin
$this->log('Downloading Azure Storage Plugin');
$file = $this->curlFile(WAZ_STORAGE_URL, $tmp);
$this->log('Extracting Azure Storage Plugin');
$this->unzip($file, $tmp);
$this->log('Moving Azure Storage Plugin files to ' . $this->mAppRoot . "\\wp-content\\plugins");
$fs->move("{$tmp}\\windows-azure-storage", $this->mAppRoot . "\\wp-content\\plugins\\windows-azure-storage");
if ($this->p->get('WP_ALLOW_MULTISITE') && $this->p->get('WP_ALLOW_MULTISITE') != 'false') {
$fs->mkdir($this->mAppRoot . "\\wp-content\\blogs.dir");
unlink("{$this->mAppRoot}.config");
if ($this->p->get('SUBDOMAIN_INSTALL')) {
copy($this->mAppRoot . "\\resources\\Web-network-subdomains.config", $this->mAppRoot . "\\Web.config");
} else {
copy($this->mAppRoot . "\\resources\\Web-network-subfolders.config", $this->mAppRoot . "\\Web.config");
}
}
// Remove tmp build folder
$fs->rm($tmp);
$fs->rm($this->mRootPath . "/Params.class.php");
$fs->rm($this->mRootPath . "/FileSystem.class.php");
$this->updateWpConfig();
echo "\n\nCongratulations! You now have a brand new Windows Azure WordPress project at " . $this->mRootPath . "\n";
}
示例9: saveTask
/**
* Save a wiki page
*
* @return void
*/
public function saveTask()
{
// Check for request forgeries
Request::checkToken();
// Check if they are logged in
if (User::isGuest()) {
$url = Request::getVar('REQUEST_URI', '', 'server');
App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url), false));
}
// Incoming revision
$revision = $this->page->version;
$revision->set('version', $revision->get('version') + 1);
$revision->set(Request::getVar('revision', array(), 'post', 'none', 2));
$revision->set('id', 0);
// Incoming page
$page = Request::getVar('page', array(), 'post', 'none', 2);
if (!isset($page['protected']) || !$page['protected']) {
$page['protected'] = 0;
}
$this->page = Page::oneOrNew(intval($revision->get('page_id')));
$this->page->set($page);
$this->page->set('pagename', trim(Request::getVar('pagename', '', 'post')));
// Get parameters
$params = new \Hubzero\Config\Registry($this->page->get('params', ''));
$params->merge(Request::getVar('params', array(), 'post'));
$this->page->set('params', $params->toString());
// Get the previous version to compare against
if (!$revision->get('page_id')) {
// New page - save it to the database
$this->page->set('created_by', User::get('id'));
$old = Version::blank();
} else {
// Get the revision before changes
$old = $this->page->version;
}
// Was the preview button pushed?
$this->preview = trim(Request::getVar('preview', ''));
if ($this->preview) {
// Set the component task
if (!$page['id']) {
Request::setVar('task', 'new');
$this->_task = 'new';
} else {
Request::setVar('task', 'edit');
$this->_task = 'edit';
}
// Push on through to the edit form
return $this->editTask($revision);
}
// Check content
// First, make sure the pagetext isn't empty
if ($revision->get('pagetext') == '') {
$this->setError(Lang::txt('COM_WIKI_ERROR_MISSING_PAGETEXT'));
return $this->editTask($revision);
}
// Store new content
if (!$this->page->save()) {
$this->setError($this->page->getError());
return $this->editTask($revision);
}
// Get allowed authors
if (!Author::setForPage(Request::getVar('authors', '', 'post'), $this->page->get('id'))) {
$this->setError(Lang::txt('COM_WIKI_ERROR_SAVING_AUTHORS'));
return $this->editTask($revision);
}
// Get the upload path
$path = Attachment::blank()->filespace();
// Rename the temporary upload directory if it exist
$lid = Request::getInt('lid', 0, 'post');
if ($lid != $this->page->get('id')) {
if (is_dir($path . DS . $lid)) {
if (!\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id'))) {
$this->setError(\Filesystem::move($path . DS . $lid, $path . DS . $this->page->get('id')));
}
}
foreach (Attachment::all()->whereEquals('page_id', $lid)->rows() as $attachment) {
$attachment->set('page_id', $this->page->get('id'));
if (!$attachment->save()) {
$this->setError($attachment->getError());
}
}
}
$revision->set('page_id', $this->page->get('id'));
$revision->set('version', $revision->get('version') + 1);
if ($this->page->param('mode', 'wiki') == 'knol') {
// Set revisions to NOT approved
$revision->set('approved', 0);
// If an author or the original page creator, set to approved
if ($this->page->get('created_by') == User::get('id') || $this->page->isAuthor(User::get('id'))) {
$revision->set('approved', 1);
}
} else {
// Wiki mode, approve revision
$revision->set('approved', 1);
}
//.........这里部分代码省略.........