当前位置: 首页>>代码示例>>PHP>>正文


PHP File::write方法代码示例

本文整理汇总了PHP中File::write方法的典型用法代码示例。如果您正苦于以下问题:PHP File::write方法的具体用法?PHP File::write怎么用?PHP File::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File的用法示例。


在下文中一共展示了File::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * {@inheritdoc}
  */
 public function handle(\Input $input)
 {
     if ($input->post('FORM_SUBMIT') == 'tl_composer_migrate_undo') {
         /** @var RootPackage $rootPackage */
         $rootPackage = $this->composer->getPackage();
         $requires = $rootPackage->getRequires();
         foreach (array_keys($requires) as $package) {
             if ($package != 'contao-community-alliance/composer') {
                 unset($requires[$package]);
             }
         }
         $rootPackage->setRequires($requires);
         $lockPathname = preg_replace('#\\.json$#', '.lock', $this->configPathname);
         /** @var DownloadManager $downloadManager */
         $downloadManager = $this->composer->getDownloadManager();
         $downloadManager->setOutputProgress(false);
         $installer = Installer::create($this->io, $this->composer);
         if (file_exists(TL_ROOT . '/' . $lockPathname)) {
             $installer->setUpdate(true);
         }
         if ($installer->run()) {
             $_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
         } else {
             $_SESSION['COMPOSER_OUTPUT'] .= $this->io->getOutput();
             $this->redirect('contao/main.php?do=composer&migrate=undo');
         }
         // load config
         $json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
         $config = $json->read();
         // remove migration status
         unset($config['extra']['contao']['migrated']);
         // write config
         $json->write($config);
         // disable composer client and enable repository client
         $inactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']);
         $inactiveModules[] = '!composer';
         foreach (array('rep_base', 'rep_client', 'repository') as $module) {
             $pos = array_search($module, $inactiveModules);
             if ($pos !== false) {
                 unset($inactiveModules[$pos]);
             }
         }
         if (version_compare(VERSION, '3', '>=')) {
             $skipFile = new \File('system/modules/!composer/.skip');
             $skipFile->write('Remove this file to enable the module');
             $skipFile->close();
         }
         if (file_exists(TL_ROOT . '/system/modules/repository/.skip')) {
             $skipFile = new \File('system/modules/repository/.skip');
             $skipFile->delete();
         }
         $this->Config->update("\$GLOBALS['TL_CONFIG']['inactiveModules']", serialize($inactiveModules));
         $this->redirect('contao/main.php?do=repository_manager');
     }
     $template = new \BackendTemplate('be_composer_client_migrate_undo');
     $template->composer = $this->composer;
     $template->output = $_SESSION['COMPOSER_OUTPUT'];
     unset($_SESSION['COMPOSER_OUTPUT']);
     return $template->parse();
 }
开发者ID:designs2,项目名称:composer-client,代码行数:63,代码来源:UndoMigrationController.php

示例2: main

 function main()
 {
     if (empty($this->args)) {
         return $this->err('Usage: ./cake fixturize <table>');
     }
     if ($this->args[0] == '?') {
         return $this->out('Usage: ./cake fixturize <table> [-force] [-reindex]');
     }
     $options = array('force' => false, 'reindex' => false);
     foreach ($this->params as $key => $val) {
         foreach ($options as $name => $option) {
             if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
                 $options[$name] = true;
             }
         }
     }
     foreach ($this->args as $table) {
         $name = Inflector::classify($table);
         $Model = new AppModel(array('name' => $name, 'table' => $table));
         $file = sprintf('%stests/fixtures/%s_fixture.php', APP, Inflector::underscore($name));
         $File = new File($file);
         if ($File->exists() && !$options['force']) {
             $this->err(sprintf('File %s already exists, use --force option.', $file));
             continue;
         }
         $records = $Model->find('all');
         $out = array();
         $out[] = '<?php';
         $out[] = '';
         $out[] = sprintf('class %sFixture extends CakeTestFixture {', $name);
         $out[] = sprintf('	var $name = \'%s\';', $name);
         $out[] = '	var $records = array(';
         $File->write(join("\n", $out));
         foreach ($records as $record) {
             $out = array();
             $out[] = '		array(';
             if ($options['reindex']) {
                 foreach (array('old_id', 'vendor_id') as $field) {
                     if ($Model->hasField($field)) {
                         $record[$name][$field] = $record[$name]['id'];
                         break;
                     }
                 }
                 $record[$name]['id'] = String::uuid();
             }
             foreach ($record[$name] as $field => $val) {
                 $out[] = sprintf('			\'%s\' => \'%s\',', addcslashes($field, "'"), addcslashes($val, "'"));
             }
             $out[] = '		),';
             $File->write(join("\n", $out));
         }
         $out = array();
         $out[] = '	);';
         $out[] = '}';
         $out[] = '';
         $out[] = '?>';
         $File->write(join("\n", $out));
         $this->out(sprintf('-> Create %sFixture with %d records (%d bytes) in "%s"', $name, count($records), $File->size(), $file));
     }
 }
开发者ID:stripthis,项目名称:donate,代码行数:60,代码来源:fixturize.php

示例3: write

 /**
  * Write the contents into the file
  *
  * @param   string  $fileName  The full path to the file
  * @param   string  $contents  The contents to write to the file
  *
  * @return  boolean  True on success
  */
 public function write($fileName, $contents)
 {
     $ret = $this->fileAdapter->write($fileName, $contents);
     if (!$ret && is_object($this->abstractionAdapter)) {
         return $this->abstractionAdapter->write($fileName, $contents);
     }
     return $ret;
 }
开发者ID:edrdesigner,项目名称:awf,代码行数:16,代码来源:Hybrid.php

示例4: set

 /**
  * @see CacheSource::set()
  */
 public function set($cacheResource, $value)
 {
     // write cache
     $targetFile = new File($cacheResource['file']);
     $targetFile->write("<?php exit; /* cache: " . $cacheResource['cache'] . " (generated at " . gmdate('r') . ") DO NOT EDIT THIS FILE */ ?>\n");
     $targetFile->write(serialize($value));
     $targetFile->close();
     // add value
     $this->cache[$cacheResource['cache']] = $value;
     $this->loaded[$cacheResource['file']] = true;
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:14,代码来源:DiskCacheSource.class.php

示例5: write_css_cache

/**
 * Write CSS cache
 *
 * @param unknown_type $path
 * @param unknown_type $content
 * @return unknown
 */
function write_css_cache($path, $content) {
	if (!is_dir(dirname($path))) {
		mkdir(dirname($path));
	}
	$cache = new File($path);
	return $cache->write($content);
}
开发者ID:ralmeida,项目名称:FoundFree.org,代码行数:14,代码来源:css.php

示例6: updateInactiveModules

 /**
  * Update the inactive modules
  * @param mixed
  * @return mixed
  */
 public function updateInactiveModules($varValue)
 {
     $arrModules = deserialize($varValue);
     if (!is_array($arrModules)) {
         $arrModules = array();
     }
     foreach (scan(TL_ROOT . '/system/modules') as $strModule) {
         if (strncmp($strModule, '.', 1) === 0) {
             continue;
         }
         // Add the .skip file to disable the module
         if (in_array($strModule, $arrModules)) {
             if (!file_exists(TL_ROOT . '/system/modules/' . $strModule . '/.skip')) {
                 $objFile = new File('system/modules/' . $strModule . '/.skip');
                 $objFile->write('As long as this file exists, the module will be ignored.');
                 $objFile->close();
             }
         } else {
             if (file_exists(TL_ROOT . '/system/modules/' . $strModule . '/.skip')) {
                 $objFile = new File('system/modules/' . $strModule . '/.skip');
                 $objFile->delete();
             }
         }
     }
     return $varValue;
 }
开发者ID:rikaix,项目名称:core,代码行数:31,代码来源:tl_settings.php

示例7: admin_index

 /**
  * [ADMIN] サイトマップXML生成実行ページ
  */
 public function admin_index()
 {
     $path = WWW_ROOT . Configure::read('Sitemapxml.filename');
     if ($this->request->data) {
         $sitemap = $this->requestAction('/admin/sitemapxml/sitemapxml/create', array('return', $this->request->data));
         ClassRegistry::removeObject('View');
         $File = new File($path);
         $File->write($sitemap);
         $File->close();
         $this->setMessage('サイトマップの生成が完了しました。');
         chmod($path, 0666);
     }
     $dirWritable = true;
     $fileWritable = true;
     if (file_exists($path)) {
         if (!is_writable($path)) {
             $fileWritable = false;
         }
     } else {
         if (!is_writable(dirname($path))) {
             $dirWritable = false;
         }
     }
     $this->set('path', $path);
     $this->set('fileWritable', $fileWritable);
     $this->set('dirWritable', $dirWritable);
     $this->pageTitle = 'サイトマップXML作成';
     $this->render('index');
 }
开发者ID:kaburk,项目名称:basercms-sitemapxml,代码行数:32,代码来源:SitemapxmlController.php

示例8: testDeletingFileMarksBackedPagesAsBroken

 public function testDeletingFileMarksBackedPagesAsBroken()
 {
     // Test entry
     $file = new File();
     $file->Filename = 'test-file.pdf';
     $file->write();
     $obj = $this->objFromFixture('Page', 'content');
     $obj->Content = sprintf('<p><a href="[file_link,id=%d]">Working Link</a></p>', $file->ID);
     $obj->write();
     $this->assertTrue($obj->doPublish());
     // Confirm that it isn't marked as broken to begin with
     $obj->flushCache();
     $obj = DataObject::get_by_id("SiteTree", $obj->ID);
     $this->assertEquals(0, $obj->HasBrokenFile);
     $liveObj = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = {$obj->ID}");
     $this->assertEquals(0, $liveObj->HasBrokenFile);
     // Delete the file
     $file->delete();
     // Confirm that it is marked as broken in both stage and live
     $obj->flushCache();
     $obj = DataObject::get_by_id("SiteTree", $obj->ID);
     $this->assertEquals(1, $obj->HasBrokenFile);
     $liveObj = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = {$obj->ID}");
     $this->assertEquals(1, $liveObj->HasBrokenFile);
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:25,代码来源:SiteTreeBrokenLinksTest.php

示例9: run

 /**
  * Run
  *
  * Runs the application.
  *
  * @param array $args
  * @return true
  * @throws Exception
  */
 public function run(array $args)
 {
     if (!isset($args[1]) || !isset($args[2])) {
         throw new Exception("Invalid input.");
     }
     $command = $args[1];
     $param = $args[2];
     if (count($args) > 4) {
         throw new Exception("Expected 2-3 params, received: " . count($args));
     }
     switch ($command) {
         case 'year':
             $param = (int) $param;
             $out = $this->commandYear($param);
             break;
         case 'matches':
             $out = $this->commandMatches($param);
             break;
         case 'rankings':
             $out = $this->commandRankings($param);
             break;
         default:
             throw new Exception("Unknown command: " . $command);
             break;
     }
     echo $out . PHP_EOL;
     if (isset($args[3])) {
         echo "Saving to " . $args[3] . PHP_EOL;
         if (!File::write($args[3], $out)) {
             throw new Exception("File failed to write.");
         }
     }
     return true;
 }
开发者ID:cougarTech2228,项目名称:Alliance-Scraper,代码行数:43,代码来源:App.php

示例10: disableOldClientHook

 public function disableOldClientHook()
 {
     // disable the repo client
     $reset = false;
     $activeModules = $this->Config->getActiveModules();
     $inactiveModules = deserialize($GLOBALS['TL_CONFIG']['inactiveModules']);
     if (in_array('rep_base', $activeModules)) {
         $inactiveModules[] = 'rep_base';
         $reset = true;
     }
     if (in_array('rep_client', $activeModules)) {
         $inactiveModules[] = 'rep_client';
         $reset = true;
     }
     if (in_array('repository', $activeModules)) {
         $inactiveModules[] = 'repository';
         $skipFile = new \File('system/modules/repository/.skip');
         $skipFile->write('Remove this file to enable the module');
         $skipFile->close();
         $reset = true;
     }
     if ($reset) {
         $this->Config->update("\$GLOBALS['TL_CONFIG']['inactiveModules']", serialize($inactiveModules));
         $this->reload();
     }
     unset($GLOBALS['TL_HOOK']['loadLanguageFiles']['composer']);
 }
开发者ID:tim-bec,项目名称:composer-client,代码行数:27,代码来源:Client.php

示例11: testCreateWithFilenameWithSubfolder

 function testCreateWithFilenameWithSubfolder()
 {
     // Note: We can't use fixtures/setUp() for this, as we want to create the db record manually.
     // Creating the folder is necessary to avoid having "Filename" overwritten by setName()/setRelativePath(),
     // because the parent folders don't exist in the database
     $folder = Folder::findOrMake('/FileTest/');
     $testfilePath = 'assets/FileTest/CreateWithFilenameHasCorrectPath.txt';
     // Important: No leading slash
     $fh = fopen(BASE_PATH . '/' . $testfilePath, "w");
     fwrite($fh, str_repeat('x', 1000000));
     fclose($fh);
     $file = new File();
     $file->Filename = $testfilePath;
     // TODO This should be auto-detected
     $file->ParentID = $folder->ID;
     $file->write();
     $this->assertEquals('CreateWithFilenameHasCorrectPath.txt', $file->Name, '"Name" property is automatically set from "Filename"');
     $this->assertEquals($testfilePath, $file->Filename, '"Filename" property remains unchanged');
     // TODO This should be auto-detected, see File->updateFilesystem()
     // $this->assertType('Folder', $file->Parent(), 'Parent folder is created in database');
     // $this->assertFileExists($file->Parent()->getFullPath(), 'Parent folder is created on filesystem');
     // $this->assertEquals('FileTest', $file->Parent()->Name);
     // $this->assertType('Folder', $file->Parent()->Parent(), 'Grandparent folder is created in database');
     // $this->assertFileExists($file->Parent()->Parent()->getFullPath(), 'Grandparent folder is created on filesystem');
     // $this->assertEquals('assets', $file->Parent()->Parent()->Name);
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:26,代码来源:FileTest.php

示例12: database

 /**
  * Step 1: database
  *
  * @return void
  */
 public function database()
 {
     $this->pageTitle = __('Step 1: Database', true);
     if (!empty($this->data)) {
         // test database connection
         if (mysql_connect($this->data['Install']['host'], $this->data['Install']['login'], $this->data['Install']['password']) && mysql_select_db($this->data['Install']['database'])) {
             // rename database.php.install
             rename(APP . 'config' . DS . 'database.php.install', APP . 'config' . DS . 'database.php');
             // open database.php file
             App::import('Core', 'File');
             $file = new File(APP . 'config' . DS . 'database.php', true);
             $content = $file->read();
             // write database.php file
             if (!class_exists('String')) {
                 App::import('Core', 'String');
             }
             $this->data['Install']['prefix'] = '';
             //disabled
             $content = String::insert($content, $this->data['Install'], array('before' => '{default_', 'after' => '}'));
             if ($file->write($content)) {
                 $this->redirect(array('action' => 'data'));
             } else {
                 $this->Session->setFlash(__('Could not write database.php file.', true));
             }
         } else {
             $this->Session->setFlash(__('Could not connect to database.', true));
         }
     }
 }
开发者ID:hiromi2424,项目名称:candycane_clone,代码行数:34,代码来源:install_controller.php

示例13: database

 /**
  * Step 1: database
  *
  * @return void
  */
 function database()
 {
     $this->pageTitle = __('Step 1: Database', true);
     if (!empty($this->data)) {
         // test database connection
         if (mysql_connect($this->data['Install']['host'], $this->data['Install']['login'], $this->data['Install']['password']) && mysql_select_db($this->data['Install']['database'])) {
             // rename database.php.install
             rename(APP . 'config' . DS . 'database.php.install', APP . 'config' . DS . 'database.php');
             // open database.php file
             App::import('Core', 'File');
             $file = new File(APP . 'config' . DS . 'database.php', true);
             $content = $file->read();
             // write database.php file
             $content = str_replace('{default_host}', $this->data['Install']['host'], $content);
             $content = str_replace('{default_login}', $this->data['Install']['login'], $content);
             $content = str_replace('{default_password}', $this->data['Install']['password'], $content);
             $content = str_replace('{default_database}', $this->data['Install']['database'], $content);
             if ($file->write($content)) {
                 $this->redirect(array('action' => 'data'));
             } else {
                 $this->Session->setFlash(__('Could not write database.php file.', true));
             }
         } else {
             $this->Session->setFlash(__('Could not connect to database.', true));
         }
     }
 }
开发者ID:andruu,项目名称:croogo,代码行数:32,代码来源:install_controller.php

示例14: mount

 /**
  * @param array $arr
  * @param $type
  * @throws \Exception
  */
 public function mount(array $arr, $type)
 {
     foreach ($arr as $k => $v) {
         if (array_key_exists($k, $this->format[$type])) {
             $v = $this->parseAlphanum($v);
             if (isset($this->format[$type][$k]['default'])) {
                 $v = $this->getDefault($v, $this->format[$type][$k]['default']);
             }
             if (isset($this->format[$type][$k]['date_format'])) {
                 $v = $this->dateFormat($v, $this->format[$type][$k], $k);
             }
             $v = $this->picture->encode($v, $this->format[$type][$k]['picture']);
             $this->file->write($v, $this->format[$type][$k]['pos'][0]);
         }
     }
 }
开发者ID:pvitoroliveira,项目名称:cnab,代码行数:21,代码来源:Generate.php

示例15: find

 function find($conditions = null, $fields = array(), $order = null, $recursive = null)
 {
     if ($conditions != 'range') {
         return parent::find($conditions, $fields, $order, $recursive);
     }
     $file = Set::extract($fields, 'file');
     if (empty($file)) {
         $file = ROOT . DS . APP_DIR . DS . 'plugins/mobileip/config/mobile_ips.yml';
     }
     if (!file_exists($file)) {
         return false;
     }
     $cacheDir = $this->getCacheDir();
     $folder = new Folder($cacheDir);
     $folder->create($cacheDir, 0777);
     $cacheFile = $this->getCacheFile();
     if (file_exists($cacheFile) && $this->_getLastModified($file) <= filemtime($cacheFile)) {
         return include $cacheFile;
     }
     $mobile_ips =& Spyc::YAMLLoad($file);
     if (!is_array($mobile_ips)) {
         return false;
     }
     $data = $this->_get_ranges($mobile_ips);
     $file = new File($cacheFile, true);
     $file->write($data);
     $file->close();
     return include $cacheFile;
 }
开发者ID:kaz29,项目名称:mobileip,代码行数:29,代码来源:mobile_ip.php


注:本文中的File::write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。