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


PHP Ak::file_put_contents方法代码示例

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


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

示例1: saveReport

 function saveReport()
 {
     if ($this->report == '') {
         $this->renderReport();
     }
     Ak::file_put_contents('profiler_results.txt', $this->report);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:7,代码来源:AkProfiler.php

示例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);
    }
开发者ID:joeymetal,项目名称:v1,代码行数:28,代码来源:dynamic_finder_installer.php

示例3: _createNewTestingModel

    function _createNewTestingModel($test_model_name)
    {
        static $shutdown_called;
        switch ($test_model_name) {
            case 'AkTestNestedCategory':
                $model_source = '<?php
    class AkTestNestedCategory extends AkActiveRecord 
    {
        var $act_as = "nested_set";
    } 
?>';
                break;
            default:
                $model_source = '<?php class ' . $test_model_name . ' extends AkActiveRecord { } ?>';
                break;
        }
        $file_name = AkInflector::toModelFilename($test_model_name);
        if (!Ak::file_put_contents($file_name, $model_source)) {
            die('Ooops!, in order to perform this test, you must set your app/model permissions so this can script can create and delete files into/from it');
        }
        if (!in_array($file_name, get_included_files()) && !class_exists($test_model_name)) {
            include $file_name;
        } else {
            return false;
        }
        $this->_testing_models_to_delete[] = $file_name;
        if (!isset($shutdown_called)) {
            $shutdown_called = true;
            register_shutdown_function(array(&$this, '_deleteTestingModels'));
        }
        return true;
    }
开发者ID:joeymetal,项目名称:v1,代码行数:32,代码来源:AkActsAsNestedSet.php

示例4: createTemplate

 function createTemplate($file_name, $content = 'Dummy')
 {
     $file_name = str_replace('/', DS, $file_name);
     $file_name = AK_VIEWS_DIR . DS . $file_name;
     $this->assertTrue((bool) Ak::file_put_contents($file_name, $content));
     $this->created_files[] = $file_name;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:7,代码来源:TemplatePicking_TestCase.php

示例5: generate

    function generate()
    {
        $this->_preloadPaths();

        $this->class_name = AkInflector::camelize($this->class_name);

        $files = array(
        'model'=>AkInflector::toModelFilename($this->class_name),
        'unit_test'=>AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_model_name.'.php',
        'model_fixture.tpl'=>AK_TEST_DIR.DS.'fixtures'.DS.$this->model_path,
        'installer_fixture.tpl'=>AK_TEST_DIR.DS.'fixtures'.DS.$this->installer_path
        );

        $this->_template_vars = (array)$this;

        foreach ($files as $template=>$file_path){
            $this->save($file_path, $this->render($template));
        }

        $installer_path = AK_APP_DIR.DS.'installers'.DS.$this->underscored_model_name.'_installer.php';
        if(!file_exists($installer_path)){
            $this->save($installer_path, $this->render('installer'));
        }

        $unit_test_runner = AK_TEST_DIR.DS.'unit.php';
        if(!file_exists($unit_test_runner)){
            Ak::file_put_contents($unit_test_runner, file_get_contents(AK_FRAMEWORK_DIR.DS.'test'.DS.'app.php'));
        }

    }
开发者ID:joeymetal,项目名称:v1,代码行数:30,代码来源:model_generator.php

示例6: test_should_fill_the_table_with_yaml_data

    public function test_should_fill_the_table_with_yaml_data()
    {
        $unit_tester = new AkUnitTest();
        $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name'));
        $TheModel =& $unit_tester->TheModel;
        $TheModel->create(array('name'=>'eins'));
        $TheModel->create(array('name'=>'zwei'));
        $TheModel->create(array('name'=>'drei'));
        $TheModel->create(array('name'=>'vier'));
        $this->assertEqual($TheModel->count(),4);

        $this->assertTrue($AllRecords = $TheModel->find());
        $yaml = $TheModel->toYaml($AllRecords);
        $this->assertFalse(file_exists(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml'));
        Ak::file_put_contents(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml',$yaml);

        $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name'));
        $this->assertFalse($TheModel->find());
        $this->assertEqual($TheModel->count(),0);

        $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name'),array('populate'=>true));
        $this->assertEqual($TheModel->count(),4);
        unlink(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml');

    }
开发者ID:joeymetal,项目名称:v1,代码行数:25,代码来源:AkUnitTest.php

示例7: Test_file_put_contents

 public function Test_file_put_contents()
 {
     $file_name = AK_TMP_DIR.DS.'test_file_1.txt';
     $content = 'This is the content of file 1';
     $this->assertFalse(!Ak::file_put_contents($file_name, $content));
     
     $file_name = '/cache'.DS.'test_file_1.txt';
     $content = 'This is the NEW content for file 1';
     $this->assertFalse(!Ak::file_put_contents($file_name, $content));
     
     $file_name = AK_TMP_DIR.DS.'test_file_2.txt';
     $content = "\n\rThis is the content of file 2\n";
     $this->assertFalse(!Ak::file_put_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_put_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_put_contents($file_name, $content));
     
     $file_name = 'ak_test_folder/test_file.txt';
     $content = "\rThis is the content of the test file";
     $this->assertFalse(!Ak::file_put_contents($file_name, $content));
     
     $file_name = 'ak_test_folder/new_folder/test_file.txt';
     $content = "\rThis is the content of the test file";
     $this->assertFalse(!Ak::file_put_contents($file_name, $content));
     
 }
开发者ID:joeymetal,项目名称:v1,代码行数:31,代码来源:_Ak_file_functions.php

示例8: test_get_extra_resources

 public function test_get_extra_resources()
 {
     $this->photo_path = AK_TEST_DIR . DS . 'fixtures' . DS . 'public' . DS . 'images' . DS . 'cristobal.jpg';
     $this->watermark = AK_TEST_DIR . DS . 'fixtures' . DS . 'public' . DS . 'images' . DS . 'watermark.png';
     if (!is_file($this->photo_path)) {
         Ak::file_put_contents($this->photo_path, Ak::url_get_contents('http://www.akelos.org/testing_resources/images/cristobal.jpg'));
         Ak::file_put_contents($this->watermark, Ak::url_get_contents('http://www.akelos.org/testing_resources/images/watermark.png'));
     }
     $this->_run_extra_tests = is_file($this->photo_path);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:10,代码来源:AkImage.php

示例9: _createNewTestingModel

    function _createNewTestingModel($test_model_name)
    {

        static $shutdown_called;
        switch ($test_model_name) {

            case 'AkTestPerson':
            $model_source =
            '<?php
    class AkTestPerson extends AkActiveRecord 
    { 
        function validate()
        {
            $this->validatesPresenceOf("first_name");            
        }
        
        function validateOnCreate()
        {
            $this->validatesAcceptanceOf("tos");
        }
        
        function validateOnUpdate()
        {
            $this->validatesPresenceOf("email");
        }
    
    } 
?>';
            break;

            default:
            $model_source = '<?php class '.$test_model_name.' extends AkActiveRecord { } ?>';
            break;
        }

        $file_name = AkInflector::toModelFilename($test_model_name);

        if(!Ak::file_put_contents($file_name,$model_source)){
            die('Ooops!, in order to perform this test, you must set your app/model permissions so this can script can create and delete files into/from it');
        }
        if(!in_array($file_name, get_included_files()) && !class_exists($test_model_name)){
            include($file_name);
        }else {
            return false;
        }
        $this->_testing_models_to_delete[] = $file_name;
        if(!isset($shutdown_called)){
            $shutdown_called = true;
            register_shutdown_function(array(&$this,'_deleteTestingModels'));
        }
        return true;
    }
开发者ID:joeymetal,项目名称:v1,代码行数:52,代码来源:AkValidation.php

示例10: _getMenuOptionsForControllersInModule

 function _getMenuOptionsForControllersInModule($type = 'admin')
 {
     $controllers = (Ak::dir(AK_CONTROLLERS_DIR.DS.$this->_controller->getModuleName(), array('dirs'=>false)));
     sort($controllers);
     $menu_options = array();
     foreach ($controllers as $controller){
         $controller_name = substr($controller,0,-15);
         $menu_options[AkInflector::titleize($controller_name)] = array('id'=>$controller_name, 'url'=> array('controller'=>$controller_name));
     }
     $options_file = $this->_getMenuOptionsFile($type);
     if(!file_exists($options_file)){
         Ak::file_put_contents(AK_CONFIG_DIR.DS.$options_file, Ak::convert('array', 'yaml', array('default'=>$menu_options)));
     }
     return $menu_options;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:15,代码来源:admin_helper.php

示例11: init

 public function init()
 {
     $this->ext = empty($this->ext) ? 'xls' : strtolower(trim($this->ext, '.'));
     $this->tmp_name = Ak::randomString();
     if (empty($this->source_file)) {
         $this->source_file = AK_TMP_DIR . DS . $this->tmp_name . '.' . $this->ext;
         Ak::file_put_contents($this->source_file, $this->source);
         $this->delete_source_file = true;
         $this->keep_destination_file = empty($this->keep_destination_file) ? empty($this->destination_file) ? false : true : $this->keep_destination_file;
     } else {
         $this->delete_source_file = false;
         $this->keep_destination_file = true;
     }
     $this->convert_to = !empty($this->convert_to) && empty($this->_file_type_codes[$this->convert_to]) ? 'csv' : (empty($this->convert_to) ? 'csv' : $this->convert_to);
     $this->destination_file_name = empty($this->destination_file_name) ? $this->tmp_name . '.' . $this->convert_to : $this->destination_file_name . (strstr($this->destination_file_name, '.') ? '' : '.' . $this->convert_to);
     $this->destination_file = empty($this->destination_file) ? AK_TMP_DIR . DS . $this->destination_file_name : $this->destination_file;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:17,代码来源:AkMsExcelToMany.php

示例12: init

 function init()
 {
     $this->ext = empty($this->ext) ? 'doc' : strtolower(trim($this->ext, '.'));
     $this->tmp_name = Ak::randomString();
     if (empty($this->source_file)) {
         $this->source_file = AK_CACHE_DIR . DS . $this->tmp_name . '.' . $this->ext;
         Ak::file_put_contents($this->source_file, $this->source);
         $this->delete_source_file = true;
         $this->keep_destination_file = empty($this->keep_destination_file) ? empty($this->destination_file) ? false : true : $this->keep_destination_file;
     } else {
         $this->delete_source_file = false;
         $this->keep_destination_file = true;
     }
     $this->convert_to = 'txt';
     $this->destination_file_name = empty($this->destination_file_name) ? $this->tmp_name . '.' . $this->convert_to : $this->destination_file_name . (strstr($this->destination_file_name, '.') ? '' : '.' . $this->convert_to);
     $this->destination_file = empty($this->destination_file) ? AK_CACHE_DIR . DS . $this->destination_file_name : $this->destination_file;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:17,代码来源:AkXdocToText.php

示例13: init

 function init()
 {
     if (empty($this->handler)) {
         require_once AK_VENDOR_DIR . DS . 'Excel' . DS . 'reader.php';
         $this->handler = new Spreadsheet_Excel_Reader();
         $this->handler->setRowColOffset(empty($this->first_column) ? 0 : $this->first_column);
     }
     $this->tmp_name = Ak::randomString();
     if (empty($this->source_file)) {
         $this->source_file = AK_CACHE_DIR . DS . $this->tmp_name . '.xls';
         Ak::file_put_contents($this->source_file, $this->source);
         $this->delete_source_file = true;
         $this->keep_destination_file = empty($this->keep_destination_file) ? empty($this->destination_file) ? false : true : $this->keep_destination_file;
     } else {
         $this->delete_source_file = false;
         $this->keep_destination_file = true;
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:18,代码来源:AkExcelToArray.php

示例14: uncompress

 function uncompress($compressed_data, $format = 'gzip')
 {
     $key = Ak::randomString(15);
     $compressed_file = AK_TMP_DIR . DS . 's' . $key;
     $uncompressed_file = AK_TMP_DIR . DS . 'd' . $key;
     if (Ak::file_put_contents($compressed_file, $compressed_data, array('base_path' => AK_TMP_DIR))) {
         $compressed = gzopen($compressed_file, "r");
         $uncompressed = fopen($uncompressed_file, "w");
         while (!gzeof($compressed)) {
             $string = gzread($compressed, 4096);
             fwrite($uncompressed, $string, strlen($string));
         }
         gzclose($compressed);
         fclose($uncompressed);
     } else {
         trigger_error(Ak::t('Could not write to temporary directory for generating uncompressing file using Ak::uncompress(). Please provide write access to %dirname', array('%dirname' => AK_TMP_DIR)), E_USER_ERROR);
     }
     $result = Ak::file_get_contents($uncompressed_file, array('base_path' => AK_TMP_DIR));
     return $result;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:20,代码来源:Ak.php

示例15: 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);
         }
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:15,代码来源:framework_setup.php


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