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


PHP waFiles::create方法代码示例

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


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

示例1: log

 public static function log($message, $file = 'error.log')
 {
     $path = waConfig::get('wa_path_log');
     if (!$path) {
         $path = dirname(dirname(dirname(__FILE__)));
     }
     $path .= '/' . $file;
     if (!file_exists($path)) {
         waFiles::create(dirname($path));
         touch($path);
         chmod($path, 0666);
     } elseif (!is_writable($path)) {
         return false;
     }
     $fd = fopen($path, 'a');
     if (!flock($fd, LOCK_EX)) {
         throw new waException('Unable to lock ' . $path);
     }
     fwrite($fd, "\n");
     fwrite($fd, date('Y-m-d H:i:s: '));
     fwrite($fd, $message);
     fflush($fd);
     flock($fd, LOCK_UN);
     fclose($fd);
     return true;
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:26,代码来源:waLog.class.php

示例2: create

 protected function create($app_id, $module, $action_type, $action_names)
 {
     $files_created = array();
     // Generate PHP controller contents
     $php_wrap = $this->getPhpWrap($app_id, $module, $action_type, $action_names);
     $php_inner = $this->getPhpInner($action_type, $action_names);
     $php = str_replace('%CLASS_CONTENT%', $php_inner, $php_wrap);
     // Save PHP controller into a file
     $action_path = wa()->getAppPath('lib/actions/' . $module . '/', $app_id);
     $action_filename = $this->getPhpFilename($app_id, $module, $action_type, $action_names);
     waFiles::create($action_path);
     file_put_contents($action_path . $action_filename, $php);
     $files_created[] = $action_path . $action_filename;
     // Save templates
     if ($action_type == 'action' || $action_type == 'actions') {
         $template_path = wa()->getAppPath('templates/actions/' . $module . '/', $app_id);
         waFiles::create($template_path);
         foreach ($action_names as $action_name) {
             $template_filename = $this->getTemplateFilename($module, $action_type, $action_name);
             file_put_contents($template_path . $template_filename, "<h1>Hello, World!</h1> <!-- !!! TODO FIXME -->\n\n<p>{$action_path}{$action_filename}</p>\n<p>{$template_path}{$template_filename}</p>");
             $files_created[] = $template_path . $template_filename;
         }
     }
     print "Successfully created the following files:\n" . join("\n", $files_created);
 }
开发者ID:niva79,项目名称:webasyst-framework,代码行数:25,代码来源:webasystCreateAction.cli.php

示例3: log

 /**
  * Write message into log file.
  *
  * @return bool
  */
 public static function log($message, $file = 'error.log')
 {
     if (!self::$path) {
         self::$path = waConfig::get('wa_path_log');
         if (!self::$path) {
             self::$path = wa()->getConfig()->getRootPath() . DIRECTORY_SEPARATOR . 'wa-log';
         }
         self::$path .= DIRECTORY_SEPARATOR;
     }
     $file = self::$path . $file;
     if (!file_exists($file)) {
         waFiles::create($file);
         touch($file);
         chmod($file, 0666);
     } elseif (!is_writable($file)) {
         return false;
     }
     $fd = fopen($file, 'a');
     if (flock($fd, LOCK_EX)) {
         fwrite($fd, PHP_EOL . date('Y-m-d H:i:s:') . PHP_EOL . $message);
         fflush($fd);
         flock($fd, LOCK_UN);
     }
     fclose($fd);
     return true;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:31,代码来源:waLog.class.php

示例4: execute

 public function execute()
 {
     $product_id = $this->get('product_id', true);
     $this->getProduct($product_id);
     $file = waRequest::file('file');
     $image = $file->waImage();
     if ($file->uploaded()) {
         $data = array('product_id' => $product_id, 'upload_datetime' => date('Y-m-d H:i:s'), 'width' => $image->width, 'height' => $image->height, 'size' => $file->size, 'original_filename' => basename($file->name), 'ext' => $file->extension, 'description' => waRequest::post('description'));
         $product_images_model = new shopProductImagesModel();
         $image_id = $data['id'] = $product_images_model->add($data);
         if (!$image_id) {
             throw new waAPIException('server_error', 500);
         }
         /**
          * @var shopConfig $config
          */
         $config = wa('shop')->getConfig();
         $image_path = shopImage::getPath($data);
         if (file_exists($image_path) && !is_writable($image_path) || !file_exists($image_path) && !waFiles::create($image_path)) {
             $product_images_model->deleteById($image_id);
             throw new waAPIException(sprintf("The insufficient file write permissions for the %s folder.", substr($image_path, strlen($config->getRootPath()))));
         }
         $file->moveTo($image_path);
         unset($image);
         shopImage::generateThumbs($data, $config->getImageSizes());
         $method = new shopProductImagesGetInfoMethod();
         $_GET['id'] = $image_id;
         $this->response = $method->getResponse(true);
     } else {
         throw new waAPIException('server_error', $file->error);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:32,代码来源:shop.product.images.add.method.php

示例5: execute

 public function execute()
 {
     ob_start();
     $app = $this->getApp();
     $app_settings_model = new waAppSettingsModel();
     $app_settings_model->set($app, 'cron_schedule', time());
     waFiles::create($this->getConfig()->getPath('log') . '/' . $app . '/');
     $log_file = "{$app}/cron.txt";
     $post_model = new blogPostModel();
     $params = array('datetime' => date("Y-m-d H:i:s"), 'status' => blogPostModel::STATUS_SCHEDULED);
     $posts_schedule = $post_model->select("id,blog_id,contact_id,status,datetime")->where('datetime <= s:datetime AND status=s:status', $params)->fetchAll();
     if ($posts_schedule) {
         foreach ($posts_schedule as $post) {
             try {
                 waLog::log("Attempt publishing post with id [{$post['id']}]", $log_file);
                 $data = array("status" => blogPostModel::STATUS_PUBLISHED);
                 waLog::log($post_model->updateItem($post['id'], $data, $post) ? "success" : "fail", $log_file);
             } catch (Exception $ex) {
                 waLog::log($ex->getMessage(), $log_file);
                 waLog::log($ex->getTraceAsString(), $log_file);
             }
         }
     }
     $action = __FUNCTION__;
     /**
      * @event cron_action
      * @param string $action
      * @return void
      */
     wa()->event('cron_action', $action);
     if ($log = ob_get_clean()) {
         waLog::log($log, $log_file);
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:34,代码来源:blogCronSchedule.cli.php

示例6: load

 public function load($locale, $locale_path, $domain, $textdomain = true)
 {
     $file = $locale_path . '/' . $locale . '/LC_MESSAGES/' . $domain . '.po';
     $cache_file = waSystem::getInstance()->getConfig()->getPath('cache') . '/apps/' . $domain . '/locale/' . $locale . '.php';
     if (isset(self::$cache[$locale][$domain])) {
     } elseif (!file_exists($file)) {
         self::$cache[$locale][$domain] = array();
     } elseif (file_exists($cache_file) && filemtime($cache_file) > filemtime($file)) {
         self::$cache[$locale][$domain] = (include $cache_file);
     } else {
         if (file_exists($file)) {
             $gettext = new waGettext($file);
             self::$cache[$locale][$domain] = $gettext->read();
         } else {
             self::$cache[$locale][$domain] = array();
         }
         waFiles::create($cache_file);
         waUtils::varExportToFile(self::$cache[$locale][$domain], $cache_file);
     }
     if (isset(self::$cache[$locale][$domain]['meta']['Plural-Forms']['plural']) && self::$cache[$locale][$domain]['meta']['Plural-Forms']['plural']) {
         self::$cache[$locale][$domain]['meta']['f'] = create_function('$n', self::$cache[$locale][$domain]['meta']['Plural-Forms']['plural']);
     }
     if ($textdomain) {
         self::$domain = $domain;
         self::$locale = $locale;
     }
     if (!self::$locale) {
         self::$locale = $locale;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:30,代码来源:waLocalePHPAdapter.class.php

示例7: save

 protected function save(waRequestFile $file)
 {
     $product_id = waRequest::post('product_id', null, waRequest::TYPE_INT);
     $product_model = new shopProductModel();
     if (!$product_model->checkRights($product_id)) {
         throw new waException(_w("Access denied"));
     }
     // check image
     if (!($image = $file->waImage())) {
         throw new waException('Incorrect image');
     }
     $image_changed = false;
     /**
      * Extend upload proccess
      * Make extra workup
      * @event image_upload
      */
     $event = wa()->event('image_upload', $image);
     if ($event) {
         foreach ($event as $plugin_id => $result) {
             if ($result) {
                 $image_changed = true;
             }
         }
     }
     if (!$this->model) {
         $this->model = new shopProductImagesModel();
     }
     $data = array('product_id' => $product_id, 'upload_datetime' => date('Y-m-d H:i:s'), 'width' => $image->width, 'height' => $image->height, 'size' => $file->size, 'original_filename' => basename($file->name), 'ext' => $file->extension);
     $image_id = $data['id'] = $this->model->add($data);
     if (!$image_id) {
         throw new waException("Database error");
     }
     /**
      * @var shopConfig $config
      */
     $config = $this->getConfig();
     $image_path = shopImage::getPath($data);
     if (file_exists($image_path) && !is_writable($image_path) || !file_exists($image_path) && !waFiles::create($image_path)) {
         $this->model->deleteById($image_id);
         throw new waException(sprintf("The insufficient file write permissions for the %s folder.", substr($image_path, strlen($config->getRootPath()))));
     }
     if ($image_changed) {
         $image->save($image_path);
         // save original
         $original_file = shopImage::getOriginalPath($data);
         if ($config->getOption('image_save_original') && $original_file) {
             $file->moveTo($original_file);
         }
     } else {
         $file->moveTo($image_path);
     }
     unset($image);
     // free variable
     shopImage::generateThumbs($data, $config->getImageSizes());
     return array('id' => $image_id, 'name' => $file->name, 'type' => $file->type, 'size' => $file->size, 'url_thumb' => shopImage::getUrl($data, $config->getImageSize('thumb')), 'url_crop' => shopImage::getUrl($data, $config->getImageSize('crop')), 'url_crop_small' => shopImage::getUrl($data, $config->getImageSize('crop_small')), 'description' => '');
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:57,代码来源:shopProductImageUpload.controller.php

示例8: set

 public function set($key, $value, $expiration = null, $group = null)
 {
     $file = waFiles::create($this->options['path'] . '/' . $key . '.php');
     $data = serialize(array('time' => time(), 'ttl' => $expiration, 'value' => $value));
     if (!file_exists($file) || is_writable($file)) {
         $r = @file_put_contents($file, $data, LOCK_EX);
         if ($r) {
             @chmod($file, 0664);
         }
         return $r;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:12,代码来源:waFileCacheAdapter.class.php

示例9: __construct

 /**
  * @param string $file CSV file path
  * @param string $delimiter
  * @param string $encoding
  * @param string $method mb or iconv encoding method (default is iconv)
  */
 public function __construct($file, $delimiter = ';', $encoding = 'utf-8', $method = 'iconv')
 {
     $this->file = ifempty($file);
     $this->delimiter = ifempty($delimiter, ';');
     if ($this->delimiter == 'tab') {
         $this->delimiter = "\t";
     }
     $this->encoding = ifempty($encoding, 'utf-8');
     $this->method = in_array($method, array('mb', 'icon'), true) ? $method : 'iconv';
     if ($this->file()) {
         waFiles::create($this->file);
     }
     $this->restore();
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:20,代码来源:shopCsvWriter.class.php

示例10: create

 protected function create($app_id, $class_name, $table)
 {
     $files_created = array();
     // Save PHP into a file
     $path = wa()->getAppPath('lib/model/', $app_id);
     if (!file_exists($path)) {
         // shop and helpdesk use `model` dir instead of `models` for some reason
         $path = wa()->getAppPath('lib/models/', $app_id);
     }
     $filename = preg_replace('~Model$~', '', $class_name) . '.model.php';
     waFiles::create($path);
     file_put_contents($path . $filename, $this->getPhp($app_id, $class_name, $table));
     $files_created[] = $path . $filename;
     print "Successfully created:\n" . join("\n", $files_created);
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:15,代码来源:webasystCreateModel.cli.php

示例11: create

 protected function create($app_id, $layout)
 {
     $files_created = array();
     // Save PHP into a file
     $layout_path = wa()->getAppPath('lib/layouts/', $app_id);
     $layout_filename = $app_id . ucfirst($layout) . '.layout.php';
     waFiles::create($layout_path);
     file_put_contents($layout_path . $layout_filename, $this->getPhp($app_id, $layout));
     $files_created[] = $layout_path . $layout_filename;
     // Save template into a file
     $template_path = wa()->getAppPath('templates/layouts/' . ucfirst($layout) . '.html', $app_id);
     waFiles::create($template_path);
     file_put_contents($template_path, $this->getHtml($app_id, $layout));
     $files_created[] = $template_path;
     print "Successfully created the following files:\n" . join("\n", $files_created);
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:16,代码来源:webasystCreateLayout.cli.php

示例12: save

 protected function save(waRequestFile $file)
 {
     if (!$this->model) {
         $this->model = new shopProductSkusModel();
     }
     $field = array('id' => waRequest::post('sku_id', null, waRequest::TYPE_INT), 'product_id' => waRequest::post('product_id', null, waRequest::TYPE_INT));
     $data = array('file_size' => $file->size, 'file_name' => $file->name);
     $this->model->updateByField($field, $data);
     $file_path = shopProduct::getPath($field['product_id'], "sku_file/{$field['id']}." . pathinfo($file->name, PATHINFO_EXTENSION));
     if (file_exists($file_path) && !is_writable($file_path) || !file_exists($file_path) && !waFiles::create($file_path)) {
         $data = array('file_size' => 0, 'file_name' => '');
         $this->model->updateByField($field, $data);
         throw new waException(sprintf("The insufficient file write permissions for the %s folder.", substr($file_path, strlen($this->getConfig()->getRootPath()))));
     }
     $file->moveTo($file_path);
     return array('name' => $file->name, 'size' => waFiles::formatSize($file->size));
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:17,代码来源:shopProductSkuEproductUpload.controller.php

示例13: getTimeZones

 /**
  * Returns the list of available time zones with localized descriptions.
  *
  * @return array
  */
 public static function getTimeZones()
 {
     $cache_file = wa()->getConfig()->getPath('cache', 'config/timezones' . wa()->getLocale());
     if (file_exists($cache_file) && filemtime($cache_file) > filemtime(dirname(__FILE__) . "/data/timezones.php")) {
         return include $cache_file;
     } else {
         $data = self::getAllTimeZones();
         $timezones = array();
         foreach ($data as $timezone_id => $info) {
             foreach ($info[1] as &$c) {
                 $c = _ws(str_replace('_', ' ', $c));
             }
             $timezones[$timezone_id] = $info[0] . ' ' . implode(', ', $info[1]);
         }
         waFiles::create($cache_file);
         waUtils::varExportToFile($timezones, $cache_file);
         return $timezones;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:24,代码来源:waDateTime.class.php

示例14: log

 /**
  * Write message into log file.
  *
  * @return bool
  */
 public static function log($message, $file = 'error.log')
 {
     self::loadPath();
     $file = self::$path . $file;
     if (!file_exists($file)) {
         waFiles::create($file);
         touch($file);
         chmod($file, 0666);
     } elseif (!is_writable($file)) {
         return false;
     }
     $fd = fopen($file, 'a');
     if (flock($fd, LOCK_EX)) {
         fwrite($fd, PHP_EOL . date('Y-m-d H:i:s:') . PHP_EOL . $message);
         fflush($fd);
         flock($fd, LOCK_UN);
     }
     fclose($fd);
     return true;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:25,代码来源:waLog.class.php

示例15: log

 public static function log($message, $file = 'error.log')
 {
     $path = waSystem::getInstance()->getConfig()->getPath('log') . '/' . $file;
     if (!file_exists($path)) {
         waFiles::create($path);
         touch($path);
         chmod($path, 0666);
     } elseif (!is_writable($path)) {
         return false;
     }
     $fd = fopen($path, 'a');
     if (!flock($fd, LOCK_EX)) {
         throw new waException('Unable to lock ' . $path);
     }
     fwrite($fd, "\n");
     fwrite($fd, date('Y-m-d H:i:s: '));
     fwrite($fd, $message);
     flock($fd, LOCK_UN);
     fclose($fd);
     return true;
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:21,代码来源:waLog.class.php


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