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


PHP waFiles类代码示例

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


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

示例1: 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

示例2: 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

示例3: execute

 public function execute()
 {
     $path = null;
     $photo_rights_model = new photosPhotoRightsModel();
     $photo_id = waRequest::get('photo_id', null, waRequest::TYPE_INT);
     if ($photo_rights_model->checkRights($photo_id, true)) {
         $photo_model = new photosPhotoModel();
         if ($photo = $photo_model->getById($photo_id)) {
             if (waRequest::get('original')) {
                 $path = photosPhoto::getOriginalPhotoPath($photo);
             } else {
                 $path = photosPhoto::getPhotoPath($photo);
             }
         }
     }
     if ($path) {
         if ($attach = waRequest::get('attach') ? true : false) {
             $response = $this->getResponse();
             $response->addHeader('Expires', 'tomorrow');
             $response->addHeader('Cache-Control', ($photo['status'] == 1 ? 'public' : 'private') . ', max-age=' . 86400 * 30);
         }
         waFiles::readFile($path, $attach ? null : basename($photo['name'] . '.' . $photo['ext']), true, !$attach);
     } else {
         throw new waException(_w("Photo not found"), 404);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:26,代码来源:photosPhotoDownload.controller.php

示例4: execute

 public function execute()
 {
     $p = $path = rtrim(waRequest::post('path'), ' /');
     $file = waRequest::post('file');
     try {
         if ($file) {
             if (!is_array($file)) {
                 $file = array($file);
             }
             foreach ($file as $f) {
                 $f = $path . '/' . $f;
                 waFiles::delete(wa()->getDataPath($f, true, null, false));
             }
             $this->log('file_delete', count($file));
         } else {
             $path = wa()->getDataPath($path, true, null, false);
             if (!is_writable($path)) {
                 $this->errors = sprintf(_w("Folder could not bet deleted due to the insufficient permissions."), $p);
             } else {
                 waFiles::delete($path);
                 $this->log('file_delete', 1);
             }
         }
     } catch (Exception $e) {
         $this->errors = $e->getMessage();
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:27,代码来源:siteFilesDelete.controller.php

示例5: execute

 public function execute()
 {
     $path = $this->getConfig()->getConfigPath('data/welcome/', false);
     if (file_exists($path)) {
         $files = waFiles::listdir($path, false);
         $this->types = shopTypeModel::getTemplates();
         foreach ($files as $file) {
             if (preg_match('/^country_([a-z]{3})\\.php$/', $file, $matches)) {
                 $this->countries[$matches[1]] = $matches[1];
             }
         }
     }
     $locale_path = $path . 'locale/' . $this->getUser()->getLocale() . '.php';
     if (file_exists($locale_path)) {
         $this->translate = (include $locale_path);
         if (!is_array($this->translate)) {
             $this->translate = array();
         }
     }
     if (waRequest::post()) {
         $app_settings_model = new waAppSettingsModel();
         $app_settings_model->del('shop', 'welcome');
         $this->setup();
     } else {
         $this->overview();
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:27,代码来源:shopBackendWelcome.action.php

示例6: 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

示例7: execute

 public function execute()
 {
     $name = basename(waRequest::get('file', 'export.csv'));
     $profile = waRequest::get('profile', 0, waRequest::TYPE_INT);
     $file = wa()->getTempPath('csv/download/' . $profile . '/' . $name);
     waFiles::readFile($file, $name);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:7,代码来源:shopCsvProductdownload.controller.php

示例8: 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

示例9: removeExtras

 protected function removeExtras($app_id, $extras_id, $info)
 {
     try {
         $paths = array();
         $plugin_instance = waSystem::getInstance($app_id)->getPlugin($extras_id);
         if (!$plugin_instance) {
             return false;
         }
         $plugin_instance->uninstall();
         $this->installer->updateAppPluginsConfig($app_id, $extras_id, null);
         //wa-apps/$app_id/plugins/$slug
         $paths[] = wa()->getAppPath("{$this->extras_type}/{$extras_id}", $app_id);
         $paths[] = wa()->getTempPath(null, $app_id);
         //wa-cache/temp/$app_id/
         $paths[] = wa()->getAppCachePath(null, $app_id);
         //wa-cache/apps/$app_id/
         foreach ($paths as $path) {
             waFiles::delete($path, true);
         }
         return true;
     } catch (Exception $ex) {
         //TODO check config
         $this->installer->updateAppPluginsConfig($app_id, $extras_id, true);
         throw $ex;
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:26,代码来源:installerPluginsRemove.action.php

示例10: 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

示例11: execute

 function execute()
 {
     try {
         $message = array();
         $settings = waRequest::get('setting');
         if ($settings) {
             $model = new waAppSettingsModel();
             $changed = false;
             foreach ((array) $settings as $setting) {
                 if (in_array($setting, array('auth_form_background'))) {
                     if ($value = $model->get('webasyst', $setting)) {
                         waFiles::delete(wa()->getDataPath($value, true, 'webasyst'));
                         $message[] = _w('Image deleted');
                     }
                 } else {
                     $changed = true;
                 }
                 $model->set('webasyst', $setting, false);
             }
             if ($changed) {
                 $message[] = _w('Settings saved');
             }
         }
         $params = array('module' => 'settings', 'msg' => installerMessage::getInstance()->raiseMessage(implode(', ', $message)));
         $this->redirect($params);
     } catch (waException $ex) {
         $msg = installerMessage::getInstance()->raiseMessage($ex->getMessage(), installerMessage::R_FAIL);
         $params = array('module' => 'settings', 'msg' => $msg);
         $this->redirect($params);
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:31,代码来源:installerSettingsRemove.action.php

示例12: 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

示例13: execute

 public function execute()
 {
     $filepath = wa()->getCachePath('plugins/discountcards/export-discountcards.csv', 'shop');
     if (!file_exists($filepath)) {
         throw new waException(_ws("Page not found"), 404);
     }
     waFiles::readFile($filepath, 'export-discountcards.csv');
 }
开发者ID:klxqz,项目名称:discountcards,代码行数:8,代码来源:shopDiscountcardsPluginDownload.controller.php

示例14: delete

 public static function delete($file)
 {
     self::loadPath();
     $file = preg_replace('!\\.\\.[/\\\\]!', '', $file);
     $file = self::$path . $file;
     if (file_exists($file)) {
         waFiles::delete($file);
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:9,代码来源:waLog.class.php

示例15: 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


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