本文整理汇总了PHP中Ak::file_get_contents方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::file_get_contents方法的具体用法?PHP Ak::file_get_contents怎么用?PHP Ak::file_get_contents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::file_get_contents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runCommand
function runCommand($command)
{
$commands = $this->getOptionsFromCommand($command);
$generator_name = isset($commands['generator']) ? $commands['generator'] : array_shift($commands);
if (empty($generator_name)) {
echo "\n " . Ak::t("You must supply a valid generator as the first command.\n\n Available generator are:");
echo "\n\n " . join("\n ", $this->_getAvailableGenerators()) . "\n\n";
AK_CONSOLE_MODE ? null : exit;
return;
}
if (count(array_diff($commands, array('help', '-help', 'usage', '-usage', 'h', '-h', 'USAGE', '-USAGE'))) != count($commands) || count($commands) == 0) {
$usage = method_exists($this, 'banner') ? $this->banner() : @Ak::file_get_contents(AK_SCRIPT_DIR . DS . 'generators' . DS . $generator_name . DS . 'USAGE');
echo empty($usage) ? "\n" . Ak::t('Could not locate usage file for this generator') : "\n" . $usage . "\n";
return;
}
if (file_exists(AK_SCRIPT_DIR . DS . 'generators' . DS . $generator_name . DS . $generator_name . '_generator.php')) {
include_once AK_SCRIPT_DIR . DS . 'generators' . DS . $generator_name . DS . $generator_name . '_generator.php';
$generator_class_name = AkInflector::camelize($generator_name . '_generator');
$generator = new $generator_class_name();
$generator->type = $generator_name;
$generator->_identifyUnnamedCommands($commands);
$generator->_assignVars($commands);
$generator->cast();
$generator->_generate();
} else {
echo "\n" . Ak::t('Could not find %generator_name generator', array('%generator_name' => $generator_name)) . "\n";
}
}
示例2: up_1
function up_1()
{
$new_code = '
private function __call ($method, $args)
{
if(substr($method,0,4) == \'find\'){
$finder = substr(AkInflector::underscore($method), 5);
list($type, $columns) = explode(\'by_\', $finder);
$callback = strstr($type,\'create\') ? \'findOrCreateBy\' : (strstr($type,\'first\') || !strstr($type,\'all\') ? \'findFirstBy\' : \'findAllBy\');
$columns = strstr($columns, \'_and_\') ? explode(\'_and_\', $columns) : array($columns);
array_unshift($args, join(\' AND \', $columns));
return Ak::call_user_func_array(array(&$this,$callback), $args);
}
$backtrace = debug_backtrace();
trigger_error(\'Call to undefined method \'.__CLASS__.\'::\'.$method.\'() in <b>\'.$backtrace[1][\'file\'].\'</b> on line <b>\'.$backtrace[1][\'line\'].\'</b> reported \', E_USER_ERROR);
}
';
$original_class = Ak::file_get_contents(AK_APP_DIR.DS.'shared_model.php');
if(strstr($original_class, '__call')){
trigger_error('You seem to have a __call method on your shared model. This plugin can\'t be installed as it will conflict with your existing code.', E_USER_ERROR);
}
$modified_class = preg_replace('/ActiveRecord[ \n\t]*extends[ \n\t]*AkActiveRecord[ \n\t]*[ \n\t]*{/i', "ActiveRecord extends AkActiveRecord \n{\n\n$new_code", $original_class);
Ak::file_put_contents(AK_APP_DIR.DS.'shared_model.php', $modified_class);
}
示例3: convert
public function convert()
{
$word = new COM('word.application') or die('Unable to instantiate Word');
$word->Visible = false;
$word->Documents->Open($this->source_file);
$word->Documents[1]->SaveAs($this->destination_file, $this->_file_type_codes[$this->convert_to]);
$word->Quit();
$word = null;
$result = Ak::file_get_contents($this->destination_file);
$this->delete_source_file ? Ak::file_delete($this->source_file) : null;
$this->keep_destination_file ? null : Ak::file_delete($this->destination_file);
return $result;
}
示例4: convert
public function convert()
{
$excel = new COM('excel.application') or die('Unable to instantiate Excel');
$excel->Visible = false;
$excel->WorkBooks->Open($this->source_file);
$excel->WorkBooks[1]->SaveAs($this->destination_file, $this->_file_type_codes[$this->convert_to]);
$excel->Quit();
unset($excel);
$result = Ak::file_get_contents($this->destination_file);
$this->delete_source_file ? @Ak::file_delete($this->source_file) : null;
$this->keep_destination_file ? null : Ak::file_delete($this->destination_file);
return $result;
}
示例5: generate
function generate()
{
if (empty($this->clone_setup_done)) {
$this->_setupCloner();
}
foreach ($this->files_to_clone as $origin => $destination) {
if (file_exists($origin)) {
$origin_code = Ak::file_get_contents($origin);
$destination_code = str_replace(array_keys($this->clone_replacements), array_values($this->clone_replacements), $origin_code);
$this->save($destination, $destination_code);
}
}
}
示例6: raiseError
function raiseError($code = null)
{
$code = empty($code) ? @$this->_options['code'] : $code;
if (AK_DEBUG) {
// We can't halt execution while testing and the error message is too large for trigger_error
if (AK_ENVIRONMENT == 'testing') {
trigger_error(join("\n", $this->getErrors()), E_USER_WARNING);
} else {
echo '<h1>' . Ak::t('Template %template_file security error', array('%template_file' => @$this->_options['file_path'])) . ':</h1>' . "<ul><li>" . join("</li>\n<li>", $this->getErrors()) . "</li></ul><hr />\n" . '<h2>' . Ak::t('Showing template source from %file:', array('%file' => $this->_options['file_path'])) . '</h2>' . (isset($this->_options['file_path']) ? '<pre>' . htmlentities(Ak::file_get_contents($this->_options['file_path'])) . '</pre><hr />' : '') . '<h2>' . Ak::t('Showing compiled template source:') . '</h2>' . highlight_string($code, true);
die;
}
} else {
trigger_error(Ak::t('Template compilation error'), E_USER_ERROR);
}
}
示例7: Test_file_get_contents
function Test_file_get_contents()
{
$file_name = AK_CACHE_DIR . DS . 'test_file_1.txt';
$content = 'This is the NEW content for file 1';
$this->assertFalse(!Ak::file_get_contents($file_name) === $content);
$file_name = AK_CACHE_DIR . DS . 'test_file_2.txt';
$content = "\n\rThis is the content of file 2\n";
$this->assertFalse(!Ak::file_get_contents($file_name) === $content);
$file_name = 'cache' . DS . 'test_file_3.txt';
$content = "\rThis is the content of file 3\r\n";
$this->assertFalse(!Ak::file_get_contents($file_name) === $content);
$file_name = 'cache/test_file_4.txt';
$content = "\rThis is the content of file 4\r\n";
$this->assertFalse(!Ak::file_get_contents($file_name) === $content);
}
示例8: install
function install()
{
$source = dirname(__FILE__) . DS . 'phpunit_test.php';
$target = AK_BASE_DIR . DS . 'script' . DS . 'phpunit_testsuite.php';
if (copy($source, $target)) {
echo "Copied script to your ./script folder.\n\r";
$source_file_mode = fileperms($source);
$target_file_mode = fileperms($target);
if ($source_file_mode != $target_file_mode) {
chmod($destination_file, $source_file_mode);
}
}
echo "Be sure to read the README.\n\r";
echo "We're now on version: " . Ak::file_get_contents(dirname(dirname(__FILE__)) . DS . 'VERSION');
}
示例9: raiseError
function raiseError($code = null)
{
$code = empty($code) ? @$this->_options['code'] : $code;
if(AK_DEBUG){
echo
'<h1>'.Ak::t('Template %template_file security error', array('%template_file'=>@$this->_options['file_path'])).':</h1>'.
"<ul><li>".join("</li>\n<li>",$this->getErrors())."</li></ul><hr />\n".
'<h2>'.Ak::t('Showing template source from %file:',array('%file'=>$this->_options['file_path'])).'</h2>'.
(isset($this->_options['file_path']) ? '<pre>'.htmlentities(Ak::file_get_contents($this->_options['file_path'])).'</pre><hr />':'').
'<h2>'.Ak::t('Showing compiled template source:').'</h2>'.highlight_string($code,true);
die();
}else{
trigger_error(Ak::t('Template compilation error'),E_USER_ERROR);
}
}
示例10: convert
function convert()
{
$xdoc2txt_bin = AK_VENDOR_DIR . DS . 'hyperestraier' . DS . 'xdoc2txt.exe';
if (AK_OS != 'WINDOWS') {
trigger_error(Ak::t('Xdoc2Text is a windows only application. Please use wvWare instead'), E_USER_WARNING);
return false;
}
if (!file_exists($xdoc2txt_bin)) {
trigger_error(Ak::t('Could not find xdoc2txt.exe on %path. Please download it from http://www31.ocn.ne.jp/~h_ishida/xdoc2txt.html', array('%path' => $xdoc2txt_bin)), E_USER_WARNING);
return false;
}
exec('@"' . $xdoc2txt_bin . '" -f "' . $this->source_file . '" "' . $this->destination_file . '"');
$result = Ak::file_get_contents($this->destination_file);
$this->delete_source_file ? @Ak::file_delete($this->source_file) : null;
$this->keep_destination_file ? null : Ak::file_delete($this->destination_file);
return $result;
}
示例11: _loadDbDesignerDbSchema
function _loadDbDesignerDbSchema()
{
if($path = $this->_getDbDesignerFilePath()){
$this->db_designer_schema = Ak::convert('DBDesigner','AkelosDatabaseDesign', Ak::file_get_contents($path));
return !empty($this->db_designer_schema);
}
return false;
}
示例12: relativizeStylesheetPaths
function relativizeStylesheetPaths()
{
$asset_path = $this->_getAssetBasePath();
if($this->hasUrlSuffix() || !empty($asset_path)){
$url_suffix = trim($this->getUrlSuffix(),'/');
if(!empty($asset_path)){
$url_suffix = trim($url_suffix.'/'.$asset_path,'/');
}
foreach ($this->stylesheets as $stylesheet) {
$filename = AK_PUBLIC_DIR.DS.'stylesheets'.DS.$stylesheet.'.css';
$relativized_css = preg_replace("/url\((\'|\")?\/images/","url($1/$url_suffix/images", @Ak::file_get_contents($filename));
empty($relativized_css) ? null : @Ak::file_put_contents($filename, $relativized_css);
}
}
}
示例13: testFtpSettings
function testFtpSettings()
{
if (!$this->canUseFtpFileHandling()) {
return false;
}
$ftp_path = 'ftp://' . $this->getFtpUser() . ':' . $this->getFtpPassword() . '@' . $this->getFtpHost() . $this->getFtpPath();
@define('AK_UPLOAD_FILES_USING_FTP', true);
@define('AK_READ_FILES_USING_FTP', false);
@define('AK_DELETE_FILES_USING_FTP', true);
@define('AK_FTP_PATH', $ftp_path);
@define('AK_FTP_AUTO_DISCONNECT', true);
if (@Ak::file_put_contents(AK_CONFIG_DIR . DS . 'test_file.txt', 'hello from ftp')) {
$text = @Ak::file_get_contents(AK_CONFIG_DIR . DS . 'test_file.txt');
@Ak::file_delete(AK_CONFIG_DIR . DS . 'test_file.txt');
}
$this->ftp_enabled = isset($text) && $text == 'hello from ftp';
return $this->ftp_enabled;
}
示例14: Test_of_binary_data_on_database
function Test_of_binary_data_on_database()
{
$long_string = Ak::file_get_contents(AK_LIB_DIR . DS . 'AkActiveRecord.php');
$_tmp_file = fopen(AK_LIB_DIR . DS . 'AkActiveRecord.php', "rb");
$binary_data = fread($_tmp_file, fileSize(AK_LIB_DIR . DS . 'AkActiveRecord.php'));
$i = 1;
$details = array('varchar_field' => "{$i} string ", 'longtext_field' => $long_string, 'text_field' => "{$i} text", 'logblob_field' => $binary_data, 'date_field' => "2005/05/{$i}", 'datetime_field' => "2005/05/{$i}", 'tinyint_field' => $i, 'integer_field' => $i, 'smallint_field' => $i, 'bigint_field' => $i, 'double_field' => "{$i}.{$i}", 'numeric_field' => $i, 'bytea_field' => $binary_data, 'timestamp_field' => "2005/05/{$i} {$i}:{$i}:{$i}", 'boolean_field' => !($i % 2), 'int2_field' => "{$i}", 'int4_field' => $i, 'int8_field' => $i, 'foat_field' => "{$i}.{$i}", 'varchar4000_field' => "{$i} text", 'clob_field' => "{$i} text", 'nvarchar2000_field' => "{$i} text", 'blob_field' => $binary_data, 'nvarchar_field' => "{$i}", 'decimal1_field' => "{$i}", 'decimal3_field' => $i, 'decimal5_field' => $i, 'decimal10_field' => "{$i}", 'decimal20_field' => $i, 'decimal_field' => $i);
$AkTestField = new AkTestField($details);
$this->assertEqual($long_string, $binary_data);
$this->assertTrue($AkTestField->save());
$AkTestField = new AkTestField($AkTestField->getId());
$this->assertEqual($AkTestField->longtext_field, $long_string);
$this->assertEqual($AkTestField->bytea_field, $binary_data);
$this->assertEqual($AkTestField->blob_field, $binary_data);
$this->assertEqual($AkTestField->logblob_field, $binary_data);
//Now we add some more records for next tests
foreach (range(2, 10) as $i) {
$details = array('varchar_field' => "{$i} string", 'text_field' => "{$i} text", 'date_field' => "2005/05/{$i}", 'datetime_field' => "2005/05/{$i}", 'tinyint_field' => $i, 'integer_field' => $i, 'smallint_field' => $i, 'bigint_field' => $i, 'double_field' => "{$i}.{$i}", 'numeric_field' => $i, 'timestamp_field' => "2005/05/{$i} {$i}:{$i}:{$i}", 'boolean_field' => !($i % 2), 'int2_field' => "{$i}", 'int4_field' => $i, 'int8_field' => $i, 'foat_field' => "{$i}.{$i}", 'varchar4000_field' => "{$i} text", 'clob_field' => "{$i} text", 'nvarchar2000_field' => "{$i} text", 'nvarchar_field' => "{$i}", 'decimal1_field' => "{$i}", 'decimal3_field' => $i, 'decimal5_field' => $i, 'decimal10_field' => "{$i}", 'decimal20_field' => $i, 'decimal_field' => $i);
$AkTestField = new AkTestField($details);
$this->assertTrue($AkTestField->save());
}
}
示例15: getPlugins
/**
* Gets a list of available plugins.
*
* Goes through each trusted plugin server and retrieves the name of the
* folders (plugins) on the repository path.
*
* @param boolean $force_update If it is not set to true, it will only check remote sources once per hour
* @return array Returns an array containing "plugin_name" => "repository URL"
* @access public
*/
function getPlugins($force_update = false)
{
if($force_update || !is_file($this->_getRepositoriesCahePath()) || filemtime($this->_getRepositoriesCahePath()) > 3600){
if(!$this->_updateRemotePluginsList()){
return array();
}
}
return array_map('trim', Ak::convert('yaml', 'array', Ak::file_get_contents($this->_getRepositoriesCahePath())));
}