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


PHP File::pwd方法代码示例

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


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

示例1: write

 /**
  * Write a file from an array
  *
  * @param array $data A PhpBaker style array
  * @return boolean
  */
 public function write($data = array())
 {
     $data = Set::merge($this->data, $data);
     $data['class'] = Set::merge(array('doc' => "/**\n * " . $this->class . "\n * \n */", 'class' => '', 'uses' => ''), $data['class']);
     $code = '<?php' . "\n";
     if (!empty($data['class']['uses'])) {
         $uses = array_unique($data['class']['uses']);
         $code .= implode("\n", $uses) . "\n\n";
     }
     $code .= $data['class']['doc'] . "\n";
     $code .= $data['class']['class'] . " {\n";
     foreach ($data['properties'] as $prop => $arr) {
         $type = is_array($arr['value']) ? 'array' : 'string';
         $arr = Set::merge(array('doc' => "/**\n * {$prop}\n * \n * @var {$type}\n */", 'value' => '', 'access' => 'public'), $arr);
         $code .= $arr['doc'] . "\n";
         if (is_array($arr['value'])) {
             $val = $this->arrayToCode($arr['value'], 2);
         } else {
             $val = "'" . $arr['value'] . "'";
         }
         $code .= "\t" . $arr['access'] . " \${$prop} = {$val};\n\n";
     }
     foreach ($data['methods'] as $meth => $arr) {
         $arr = Set::merge(array('doc' => "/**\n * {$meth}\n * \n */", 'value' => "\tpublic function {$meth}() {\n\t\t\n\t}"), $arr);
         $code .= $arr['doc'] . "\n";
         $code .= $arr['value'] . "\n";
     }
     $code .= '}';
     file_put_contents($this->_File->pwd(), $code);
     return true;
 }
开发者ID:shama,项目名称:oven,代码行数:37,代码来源:PhpBaker.php

示例2: read

 /**
  * Reads a MagicDb from various formats
  *
  * @var $magicDb mixed Can be an array containing the db, a magic db as a string, or a filename pointing to a magic db in .db or magic.db.php format
  * @return boolean Returns false if reading / validation failed or true on success.
  * @access private
  */
 public function read($magicDb = null)
 {
     if (!is_string($magicDb) && !is_array($magicDb)) {
         return false;
     }
     if (is_array($magicDb) || strpos($magicDb, '# FILE_ID DB') === 0) {
         $data = $magicDb;
     } else {
         $File = new File($magicDb);
         if (!$File->exists()) {
             return false;
         }
         if ($File->ext() == 'php') {
             include $File->pwd();
             $data = $magicDb;
         } else {
             // @TODO: Needs test coverage
             $data = $File->read();
         }
     }
     $magicDb = $this->toArray($data);
     if (!$this->validates($magicDb)) {
         return false;
     }
     return !!($this->db = $magicDb);
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:33,代码来源:magic_db.php

示例3: _createRenderedView

 /**
  * Create the rendered view cache file
  *
  * @param string $file The view file path
  *
  * @return string The file path
  */
 protected function _createRenderedView($file)
 {
     $content = $this->_renderHaml($file);
     $tmpFile = new File($this->_cacheFileName(), true);
     $tmpFile->write($content);
     $tmpFile->close();
     return $tmpFile->pwd();
 }
开发者ID:tiutalk,项目名称:haml,代码行数:15,代码来源:HamlView.php

示例4:

	/**
	 * Get absolute file for a given key
	 *
	 * @param string $key The key
	 * @return mixed Absolute cache file for the given key or false if erroneous
	 * @access private
	 */
	function _setKey($key) {
		$this->_File->Folder->cd($this->settings['path']);
		if ($key !== $this->_File->name) {
			$this->_File->name = $key;
			$this->_File->path = null;
		}
		if (!$this->_File->Folder->inPath($this->_File->pwd(), true)) {
			return false;
		}
	}
开发者ID:ralmeida,项目名称:FoundFree.org,代码行数:17,代码来源:file.php

示例5: File

 function upload_file()
 {
     $file = $this->getNextParam(null, 'file');
     $container = $this->getNextParam(null, 'container');
     if (empty($file) || empty($container)) {
         $this->errorAndExit('File and Container required');
     }
     $File = new File($file);
     $file_path = $File->pwd();
     CloudFiles::upload($file_path, $container, $this->params['type']);
     $this->out($File->name . " uploaded to {$container}");
 }
开发者ID:rnavarro,项目名称:CakePHP-CloudFiles-Plugin,代码行数:12,代码来源:CloudFilesShell.php

示例6: testCommit

 function testCommit()
 {
     $Svn = new Svn($this->__repos[1]);
     $File = new File($Svn->working . '/branches/demo_1.0.x.x/index.php', true);
     $File->write("this is a new php file with plain text");
     $result = $Svn->run('add', array(dirname($File->pwd())));
     //var_dump($result);
     $result = $Svn->run('commit', array($Svn->working, '--message "Adding index.php"'));
     //var_dump($result);
     $result = $Svn->info('/branches/demo_1.0.x.x/index.php');
     //var_dump($result);
 }
开发者ID:Theaxiom,项目名称:chaw-source,代码行数:12,代码来源:svn.test.php

示例7: createLayoutFile

 private function createLayoutFile($name, $layout_type, $override = false)
 {
     $layout_file = new File('' . $this->layout_folder . '' . $name . '.ctp');
     $template_file = new File($this->layout_files['' . $layout_type . '']);
     if ($this->layoutFileExists($name) && $override == true) {
         $layout_file->delete();
     }
     $this->hr();
     $this->out(__d('cake_console', '<yellow>Creating layout file `' . $layout_file->pwd() . '`:</yellow>'));
     if ($layout_file->create()) {
         $content = $template_file->read();
         if ($layout_file->write($content)) {
             $this->out(__d('cake_console', '<green>SUCCESS!</green>'));
         } else {
             $this->out(__d('cake_console', 'Could not write contents to `' . $layout_file->pwd() . '`'));
         }
     } else {
         $this->error(__d('cake_console', 'Could not create file!'));
     }
 }
开发者ID:volareinc,项目名称:BootstrapCake,代码行数:20,代码来源:LayoutShell.php

示例8: File

    /**
     * Create or update the installed.php file with version details
     *
     * @return void
     */
    function _writeInstalled($schema = SCHEMA_VERSION)
    {
        $file = new File(CONFIGS . 'installed.php', true);
        $date = date('r');
        $version = ZULURU_MAJOR . '.' . ZULURU_MINOR . '.' . ZULURU_REVISION;
        $installed = <<<CONFIG
<?php
\$config['installed'] = array(
\t'date' => '{$date}',
\t'ip' => '{$_SERVER['REMOTE_ADDR']}',
\t'version' => '{$version}',
\t'schema_version' => {$schema},
);
?>
CONFIG;
        if (!$file->write($installed)) {
            $this->set('config_file', $file->pwd());
            $this->set('config_contents', $installed);
            return false;
        }
        return true;
    }
开发者ID:roboshed,项目名称:Zuluru,代码行数:27,代码来源:install_controller.php

示例9: metadata

 /**
  * Retrieve (cached) metadata of a file
  *
  * @param Model $Model
  * @param string $file An absolute path to a file
  * @param integer $level level of amount of info to add, `0` disable, `1` for basic, `2` for detailed info
  * @return mixed Array with results or false if file is not readable
  */
 function metadata(&$Model, $file, $level = 1)
 {
     if ($level < 1) {
         return array();
     }
     extract($this->settings[$Model->alias]);
     $File = new File($file);
     if (!$File->readable()) {
         return false;
     }
     $checksum = $File->md5(true);
     if (isset($this->__cached[$Model->alias][$checksum])) {
         $data = $this->__cached[$Model->alias][$checksum];
     }
     if ($level > 0 && !isset($data[1])) {
         $data[1] = array('size' => $File->size(), 'mime_type' => MimeType::guessType($File->pwd()), 'checksum' => $checksum);
     }
     if ($level > 1 && !isset($data[2])) {
         $Media = Media::factory($File->pwd());
         if ($Media->name === 'Audio') {
             $data[2] = array('artist' => $Media->artist(), 'album' => $Media->album(), 'title' => $Media->title(), 'track' => $Media->track(), 'year' => $Media->year(), 'length' => $Media->duration(), 'quality' => $Media->quality(), 'sampling_rate' => $Media->samplingRate(), 'bit_rate' => $Media->bitRate());
         } elseif ($Media->name === 'Image') {
             $data[2] = array('width' => $Media->width(), 'height' => $Media->height(), 'ratio' => $Media->ratio(), 'quality' => $Media->quality(), 'megapixel' => $Media->megapixel());
         } elseif ($Media->name === 'Text') {
             $data[2] = array('characters' => $Media->characters(), 'syllables' => $Media->syllables(), 'sentences' => $Media->sentences(), 'words' => $Media->words(), 'flesch_score' => $Media->fleschScore(), 'lexical_density' => $Media->lexicalDensity());
         } elseif ($Media->name === 'Video') {
             $data[2] = array('title' => $Media->title(), 'year' => $Media->year(), 'length' => $Media->duration(), 'width' => $Media->width(), 'height' => $Media->height(), 'ratio' => $Media->ratio(), 'quality' => $Media->quality(), 'bit_rate' => $Media->bitRate());
         } else {
             $data[2] = array();
         }
     }
     for ($i = $level, $result = array(); $i > 0; $i--) {
         $result = array_merge($result, $data[$i]);
     }
     $this->__cached[$Model->alias][$checksum] = $data;
     return Set::filter($result);
 }
开发者ID:redlion09,项目名称:ems-1,代码行数:45,代码来源:meta.php

示例10: protect

 /**
  * Protects the transfer directory
  *
  * @access public
  * @return void
  */
 function protect()
 {
     if (MEDIA_TRANSFER_URL === false) {
         $this->out('The content of the transfer directory is not served.');
         return true;
     }
     $file = MEDIA_TRANSFER . '.htaccess';
     if (is_file($file)) {
         $this->err($this->shortPath($file) . ' is already present.');
         return true;
     }
     $this->out('Your transfer directory is missing a htaccess file to block requests.');
     if ($this->in('Do you want to create it now?', 'y,n', 'n') == 'n') {
         return false;
     }
     $File = new File($file);
     $File->append("Order deny,allow\n");
     $File->append("Deny from all\n");
     $File->close();
     $this->out($this->shortPath($File->pwd()) . ' created.');
     $this->out();
     return true;
 }
开发者ID:youkidearitai,项目名称:CakePHP-Media-Plugin,代码行数:29,代码来源:media.php

示例11: admin_edit

 /**
  * admin_edit method
  *
  * @param mixed $id
  * @access public
  * @return void
  */
 public function admin_edit($id)
 {
     if ($this->data) {
         $file = new File(TMP . rand());
         $file->write('<?php $this->data["MiEmail"]["data"] = ' . $this->data['MiEmail']['data'] . ';');
         include $file->pwd();
         $file->delete();
         if ($this->MiEmail->save($this->data)) {
             return $this->_back();
         }
     }
     parent::admin_edit($id);
     $this->data['MiEmail']['data'] = var_export($this->data['MiEmail']['data'], true);
 }
开发者ID:razzman,项目名称:mi_email,代码行数:21,代码来源:MiEmailController.php

示例12: htmlTidy

 /**
  * htmlTidy method
  *
  * Disabled for windows
  *
  * @param mixed $Model
  * @param string $string ''
  * @param array $params array()
  * @return string
  * @access public
  */
 function htmlTidy(&$Model, $string = '', $params = array())
 {
     if (DS === '\\') {
         return true;
     }
     extract(am($this->settings[$Model->alias]['methods']['htmlTidy'], $params));
     $string = $prefix . $string . $suffix;
     $File = new File(TMP . 'tidy' . DS . rand() . '.html', true);
     $File->write($string);
     $path = $File->pwd();
     $errors = $path . '.err';
     $args = implode($args, ' ');
     $this->_exec("tidy {$args} -f {$errors} {$path}", $out);
     $result = $File->read();
     $File->delete();
     if ($result && $bodyOnly) {
         preg_match("@<body[^>]*>(.*)</body>@s", $result, $matches);
         if ($matches) {
             $result = trim($matches[1]);
         }
     }
     if (file_exists($errors)) {
         $Error = new File($errors);
         $errors = $Error->read();
         $Error->delete();
     } else {
         $errors = false;
     }
     if ($return === 'result') {
         return $result;
     } elseif ($return === 'errors') {
         return $errors;
     }
     return $string === $result;
 }
开发者ID:hiromi2424,项目名称:mi,代码行数:46,代码来源:auto_format.php

示例13: testNoPartialPathBeingSetForNonExistentPath

 /**
  * Tests that no path is being set for passed file paths that
  * do not exist.
  *
  * @return void
  * @covers ::pwd
  */
 public function testNoPartialPathBeingSetForNonExistentPath()
 {
     $tmpFile = new File('/non/existent/file');
     $this->assertNull($tmpFile->pwd());
     $this->assertNull($tmpFile->path);
 }
开发者ID:angel-mendoza,项目名称:proyecto-pasantia,代码行数:13,代码来源:FileTest.php

示例14: tidyErrors

 /**
  * Run the html string through tidy, and return the (raw) errors. pass back a reference to the
  * normalized string so that the error messages can be linked to the line that caused them.
  *
  * @param string $in ''
  * @param string $out ''
  * @return string
  * @access public
  */
 public function tidyErrors($in = '', &$out = '')
 {
     $out = preg_replace('@>\\s*<@s', ">\n<", $in);
     // direct access? windows etc
     if (function_exists('tidy_parse_string')) {
         $tidy = tidy_parse_string($out, array(), 'UTF8');
         $tidy->cleanRepair();
         $errors = $tidy->errorBuffer . "\n";
         return $errors;
     }
     // cli
     $File = new File(rtrim(TMP, DS) . DS . rand() . '.html', true);
     $File->write($out);
     $path = $File->pwd();
     $errors = $path . '.err';
     $this->_exec("tidy -eq -utf8 -f {$errors} {$path}");
     $File->delete();
     if (!file_exists($errors)) {
         return '';
     }
     $Error = new File($errors);
     $errors = $Error->read();
     $Error->delete();
     return $errors;
 }
开发者ID:cc2i,项目名称:calibrephp,代码行数:34,代码来源:TidyHelper.php

示例15: importAnnotationsAndDocuments

 function importAnnotationsAndDocuments()
 {
     $this->Round = $this->Project->Round;
     $this->Document = $this->Project->Document;
     $this->UsersRound = $this->Project->User->UsersRound;
     $this->AnnotatedDocument = $this->Round->AnnotatedDocument;
     $this->Type = $this->Project->Type;
     $this->Annotation = $this->Type->Annotation;
     $maxAnnotation = $this->Annotation->find('first', array('recursive' => -1, 'fields' => 'id', 'order' => 'id DESC'));
     if (isset($maxAnnotation['Annotation']['id'])) {
         $maxAnnotation = $maxAnnotation['Annotation']['id'];
     } else {
         $maxAnnotation = 0;
     }
     $maxType = $this->Project->Type->find('first', array('recursive' => -1, 'fields' => 'id', 'order' => 'id DESC'));
     if (isset($maxType['Type']['id'])) {
         $maxType = $maxType['Type']['id'];
     } else {
         $maxType = 0;
     }
     if ($this->request->is('post') || $this->request->is('put')) {
         $maxAnnotation++;
         App::uses('Folder', 'Utility');
         App::uses('File', 'Utility');
         App::uses('CakeTime', 'Utility');
         $scriptTimeLimit = Configure::read('scriptTimeLimit');
         set_time_limit($scriptTimeLimit);
         $users = $this->request->data['User']['User'];
         //App::import('Vendor', 'htmLawed', array('file' => 'htmLawed' . DS . 'htmLawed.php'));
         $zipFile = new File($this->request->data['Project']['File']['tmp_name'], false, 0777);
         $projectName = ucwords(pathinfo($this->request->data['Project']['File']['name'], PATHINFO_FILENAME));
         if ($zipFile->exists() && !empty($users)) {
             $filesAllowed = Configure::read('filesAllowed');
             $zip = new ZipArchive();
             if (!$zip->open($zipFile->pwd(), ZipArchive::CREATE)) {
                 $zipFile->remove();
                 throw new Exception("Failed to open Zip archive\n");
             }
             $path = Configure::read('uploadFolder');
             $path = $path . uniqid();
             //creamos la carpeta de descarga para el usuario si no existe
             $extractFolder = new Folder($path, true, 0700);
             $zip->extractTo($extractFolder->pwd());
             $zip->close();
             $zipFile->delete();
             // I am deleting this file
             $rounds = array();
             $db = $this->Project->getDataSource();
             $db->query("ALTER TABLE annotations AUTO_INCREMENT = {$maxAnnotation}");
             $db->execute("LOCK TABLES " . $this->Annotation->table . " " . $this->Type->table . " WRITE");
             $db->begin();
             $db->useNestedTransactions = false;
             $this->Project->create();
             if ($this->Project->save(array('Project' => array("title" => $projectName, "description" => ""), "User" => array('User' => $users)))) {
                 //creamos round de anotacion automatica
                 $this->Round->create();
                 if (!$this->Round->save(array('Round' => array("title" => "Round for job " . date("Y/m/d"), "project_id" => $this->Project->id, "description" => "-", 'ends_in_date' => date("Y-m-d", strtotime("+30 day")), 'trim_helper' => true, 'whole_word_helper' => true, 'punctuation_helper' => true, 'start_document' => 0, 'end_document' => 0, 'is_visible' => 0)))) {
                     $extractFolder->delete();
                     $db->rollback();
                     $db->execute("UNLOCK TABLES");
                     throw new Exception("Round work can not be saved");
                 }
                 array_push($rounds, $this->Round->id);
                 foreach ($users as $user) {
                     foreach ($rounds as $round) {
                         $this->UsersRound->create();
                         if (!$this->UsersRound->save(array('state' => 0, 'round_id' => $round, 'user_id' => $user))) {
                             $extractFolder->delete();
                             $db->rollback();
                             $db->execute("UNLOCK TABLES");
                             throw new Exception("This UsersRound can not be save:" . $fileName);
                         }
                     }
                 }
                 $typesText = new File($extractFolder->pwd() . DS . 'types.txt', false, 0644);
                 if (!$typesText->exists()) {
                     $extractFolder->delete();
                     $db->rollback();
                     $db->execute("UNLOCK TABLES");
                     throw new Exception("types.txt not exist in zip file");
                 }
                 $count = new File($extractFolder->pwd() . DS . 'count.txt', false, 0644);
                 if (!$count->exists()) {
                     $extractFolder->delete();
                     $db->rollback();
                     $db->execute("UNLOCK TABLES");
                     throw new Exception("count.txt not exist in zip filer");
                 }
                 $typesText = $typesText->read();
                 $count = $count->read();
                 $count = intval($count) + 1;
                 //buscamos la anotacion final con dicho Id si ya existe no se puede crear el proyecto
                 $existLastId = $this->Annotation->find('count', array('recursive' => -1, 'conditions' => array('id' => $count)));
                 $existInitialId = $this->Annotation->find('count', array('recursive' => -1, 'conditions' => array('id' => $count - ($count - $maxAnnotation))));
                 if ($existInitialId > 0) {
                     $extractFolder->delete();
                     $db->rollback();
                     $db->execute("UNLOCK TABLES");
                     throw new Exception("the first id already exist in Marky");
                 }
//.........这里部分代码省略.........
开发者ID:sing-group,项目名称:Markyt,代码行数:101,代码来源:ProjectsController.php


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