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


PHP waFiles::write方法代码示例

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


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

示例1: wa

<?php

$path = wa()->getDataPath('photos', true, 'contacts', false);
if (!file_exists($path . './htaccess')) {
    $path = wa()->getDataPath('photos', true, 'contacts');
    waFiles::write($path . '/thumb.php', '<?php
    $file = realpath(dirname(__FILE__)."/../../../../")."/wa-apps/contacts/lib/config/data/thumb.php";

    if (file_exists($file)) {
        include($file);
    } else {
        header("HTTP/1.0 404 Not Found");
    }
    ');
    waFiles::copy(wa()->getAppPath('lib/config/data/.htaccess', 'contacts'), $path . '/.htaccess');
}
开发者ID:Lazary,项目名称:webasyst,代码行数:16,代码来源:1409750208.php

示例2: reset

    private function reset()
    {
        /**
         * @event reset
         *
         * Notify plugins about reset all settings
         *
         * @param void
         * @return void
         */
        wa()->event('reset');
        //XXX hardcode
        $tables = array('shop_page', 'shop_page_params', 'shop_category', 'shop_category_params', 'shop_category_products', 'shop_category_routes', 'shop_product', 'shop_product_params', 'shop_product_features', 'shop_product_features_selectable', 'shop_product_images', 'shop_product_pages', 'shop_product_related', 'shop_product_reviews', 'shop_product_services', 'shop_product_skus', 'shop_product_stocks', 'shop_product_stocks_log', 'shop_search_index', 'shop_search_word', 'shop_tag', 'shop_product_tags', 'shop_set', 'shop_set_products', 'shop_stock', 'shop_feature', 'shop_feature_values_dimension', 'shop_feature_values_double', 'shop_feature_values_text', 'shop_feature_values_varchar', 'shop_feature_values_color', 'shop_feature_values_range', 'shop_type', 'shop_type_features', 'shop_type_services', 'shop_type_upselling', 'shop_service', 'shop_service_variants', 'shop_currency', 'shop_customer', 'shop_cart_items', 'shop_order', 'shop_order_items', 'shop_order_log', 'shop_order_log_params', 'shop_order_params', 'shop_affiliate_transaction', 'shop_checkout_flow', 'shop_notification', 'shop_notification_params', 'shop_coupon', 'shop_discount_by_sum', 'shop_tax', 'shop_tax_regions', 'shop_tax_zip_codes', 'shop_affiliate_transaction', 'shop_importexport');
        $model = new waModel();
        foreach ($tables as $table) {
            $exist = false;
            try {
                $model->query(sprintf("SELECT * FROM `%s` WHERE 0", $table));
                $exist = true;
                $model->query(sprintf("TRUNCATE `%s`", $table));
            } catch (waDbException $ex) {
                if ($exist) {
                    throw $ex;
                }
            }
        }
        $sqls = array();
        $sqls[] = 'UPDATE`shop_type` SET`count` = 0';
        $sqls[] = 'UPDATE`shop_set` SET`count` = 0';
        foreach ($sqls as $sql) {
            $model->query($sql);
        }
        $ccm = new waContactCategoryModel();
        $ccm->deleteByField('app_id', 'shop');
        $app_settings_model = new waAppSettingsModel();
        $currency_model = new shopCurrencyModel();
        $currency_model->insert(array('code' => 'USD', 'rate' => 1.0, 'sort' => 1), 2);
        $app_settings_model->set('shop', 'currency', 'USD');
        $app_settings_model->set('shop', 'use_product_currency', true);
        $paths = array();
        $paths[] = wa()->getDataPath('products', false, 'shop');
        $paths[] = wa()->getDataPath('products', true, 'shop');
        $paths[] = wa()->getTempPath();
        $config_path = wa()->getConfigPath('shop');
        foreach (waFiles::listdir($config_path, true) as $path) {
            if (!in_array($path, array('plugins.php', '..', '.'))) {
                $paths[] = $config_path . '/' . $path;
            }
        }
        $paths[] = wa()->getCachePath(null, 'shop');
        foreach ($paths as $path) {
            waFiles::delete($path, true);
        }
        $path = wa()->getDataPath('products', true, 'shop');
        waFiles::write($path . '/thumb.php', '<?php
$file = realpath(dirname(__FILE__)."/../../../../")."/wa-apps/shop/lib/config/data/thumb.php";

if (file_exists($file)) {
    include($file);
} else {
    header("HTTP/1.0 404 Not Found");
}
');
        waFiles::copy($this->getConfig()->getAppPath('lib/config/data/.htaccess'), $path . '/.htaccess');
        echo json_encode(array('result' => 'ok', 'redirect' => '?action=welcome'));
        exit;
    }
开发者ID:Lazary,项目名称:webasyst,代码行数:67,代码来源:shopSettingsReset.action.php

示例3: setPhpLogSetting

 public static function setPhpLogSetting($enable)
 {
     $php_log_config = self::getPhpLogConfig();
     $system_config_path = self::getSystemConfigPath();
     $system_config_contents = file_get_contents($system_config_path);
     $config_lines = self::getPhpLogSetting();
     if (is_writable($system_config_path)) {
         if ($enable) {
             if (!$config_lines) {
                 waFiles::write($system_config_path, $system_config_contents . $php_log_config);
             }
         } else {
             if ($config_lines) {
                 waFiles::write($system_config_path, str_replace($config_lines, '', $system_config_contents));
             }
         }
     } else {
         return sprintf(_w('Cannot save changes due to insufficient write permissions for file <tt>%s</tt>.'), $system_config_path);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:20,代码来源:logsHelper.class.php

示例4: createStructure

 protected function createStructure($paths)
 {
     foreach ($paths as $path => $content) {
         if (is_integer($path)) {
             $path = $content;
             $content = false;
         }
         if (preg_match('@\\.[\\w]+$@', $path)) {
             $file = $this->path . $path;
             waFiles::create(dirname($file), true);
             if (is_array($content)) {
                 waUtils::varExportToFile($content, $file);
             } elseif ($content && file_exists($content)) {
                 waFiles::copy($content, $file);
             } else {
                 waFiles::write($file, $content);
             }
         } else {
             waFiles::create($this->path . $path, true);
         }
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:22,代码来源:webasystCreateCliController.class.php

示例5: create

 protected function create($type, $id, $path, $params = array())
 {
     $template_id = 'wapattern';
     $template_path = wa()->getConfig()->getPath('plugins') . '/' . $type . '/' . $template_id . '/';
     if (!file_exists($path)) {
         try {
             $path .= '/';
             mkdir($path);
             // lib
             mkdir($path . 'lib');
             waFiles::protect($path . 'lib');
             $plugin_class = null;
             mkdir($path . 'lib/classes');
             // config
             mkdir($path . 'lib/config');
             // app description
             $plugin = array('name' => empty($params['name']) ? ucfirst($id) : $params['name'], 'description' => '', 'icon' => 'img/' . $id . '.png', 'version' => empty($params['version']) ? '1.0.0' : $params['version'], 'vendor' => empty($params['vendor']) ? '' : $params['vendor']);
             waUtils::varExportToFile($plugin, $path . 'lib/config/plugin.php');
             switch ($type) {
                 case 'payment':
                     #settings
                     if (isset($params['settings'])) {
                         waUtils::varExportToFile(array(), $path . 'lib/config/settings.php');
                     }
                     #plugin class
                     $template_class_path = $template_path . 'lib/' . $template_id . ucfirst($type) . '.class.php';
                     $class_path = $path . 'lib/' . $id . ucfirst($type) . '.class.php';
                     $template = file_get_contents($template_class_path);
                     waFiles::write($class_path, str_replace($template_id, $id, $template));
                     #plugin template
                     mkdir($path . 'templates');
                     waFiles::protect($path . 'templates');
                     waFiles::copy($template_path . 'templates/payment.html', $path . 'templates/payment.html');
                     break;
                 case 'shipping':
                     #settings
                     if (isset($params['settings'])) {
                         waUtils::varExportToFile(array(), $path . 'lib/config/settings.php');
                     }
                     #plugin class
                     $template_class_path = $template_path . 'lib/' . $template_id . ucfirst($type) . '.class.php';
                     $class_path = $path . 'lib/' . $id . ucfirst($type) . '.class.php';
                     $template = file_get_contents($template_class_path);
                     waFiles::write($class_path, str_replace($template_id, $id, $template));
                     break;
                 default:
                     throw new waException(sprintf("Plugin type \"%s\" not supported yet.\n", $type));
                     break;
             }
             print "Plugin with id \"{$id}\" created!\n";
         } catch (waException $ex) {
             print "Plugin with id \"{$id}\" was NOT created.\n";
             if (waSystemConfig::isDebug()) {
                 echo $ex;
             } else {
                 print "Error:" . $ex->getMessage() . "\n";
             }
             waFiles::delete($path);
         }
     } else {
         print "Plugin with id \"{$id}\" already exists.\n";
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:63,代码来源:webasystCreateSystemplugin.cli.php

示例6: create

    protected function create($app_id, $plugin_id, $path, $params = array())
    {
        $report = '';
        if (!file_exists($path)) {
            $plugin = array('name' => empty($params['name']) ? ucfirst($plugin_id) : $params['name'], 'icon' => 'img/' . $plugin_id . '.gif', 'version' => $version = empty($params['version']) ? '0.1' : $params['version'], 'vendor' => $vendor = empty($params['vendor']) ? '--' : $params['vendor'], 'handlers' => array());
            $path .= '/';
            mkdir($path);
            mkdir($path . 'css');
            touch($path . 'css/' . $plugin_id . '.css');
            mkdir($path . 'js');
            touch($path . 'js/' . $plugin_id . '.js');
            mkdir($path . 'img');
            // lib
            mkdir($path . 'lib');
            waFiles::protect($path . 'lib');
            $class_name = $app_id . ucfirst($plugin_id) . 'Plugin';
            wa($app_id, true);
            $extends = $app_id . 'Plugin';
            if (!class_exists($extends)) {
                $extends = 'waPlugin';
            }
            $class = <<<PHP
<?php

class {$class_name} extends {$extends}
{

}

PHP;
            waFiles::write($path . 'lib/' . $app_id . ucfirst($plugin_id) . 'Plugin.class.php', $class);
            mkdir($path . 'lib/config');
            mkdir($path . 'lib/actions');
            mkdir($path . 'lib/classes');
            if (isset($params['db'])) {
                mkdir($path . 'lib/models');
            }
            if (isset($params['frontend'])) {
                $plugin['frontend'] = true;
                $routing = array('*' => 'frontend');
                waUtils::varExportToFile($routing, $path . 'lib/config/routing.php');
                // frontend controller
                mkdir($path . 'lib/actions/frontend');
            }
            // config
            waUtils::varExportToFile($plugin, $path . 'lib/config/plugin.php');
            if (isset($params['settings'])) {
                waUtils::varExportToFile(array(), $path . 'lib/config/settings.php');
            }
            // templates
            mkdir($path . 'templates');
            waFiles::protect($path . 'templates');
            mkdir($path . 'templates/actions');
            mkdir($path . 'templates/actions/backend');
            // backend template
            if (isset($params['frontend'])) {
                // frontend template
                mkdir($path . 'templates/actions/frontend');
            }
            // locale
            if (isset($params['locale'])) {
                mkdir($path . 'locale');
                waFiles::protect($path . 'locale');
            }
            $report .= <<<REPORT
Plugin with id "{$plugin_id}" created!

Useful commands:
    #generate plugin's database description file db.php
    php wa.php generateDb {$app_id}/{$plugin_id} table1 table2 table3

    #generate plugin's locale files
    php wa-system/locale/locale.php {$app_id}/plugins/{$plugin_id}
REPORT;
        } else {
            $report .= <<<REPORT
Plugin with id "{$plugin_id}" already exists.
REPORT;
        }
        print $report . "\n";
    }
开发者ID:Lazary,项目名称:webasyst,代码行数:81,代码来源:webasystCreatePlugin.cli.php


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