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


PHP tools::file_put_contents方法代码示例

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


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

示例1: onMove

 public function onMove($typeProgress, $module, $name, $copy = FALSE)
 {
     $imgs = $this->getConfig('img');
     foreach ($imgs as $img) {
         $oldPath = $img['name'];
         $imagePath = substr(strstr($oldPath, '/files/'), 7);
         $newPath = $module . '/files/' . $imagePath;
         if ($oldPath !== $newPath) {
             if (stream_resolve_include_path($newPath) !== FALSE) {
                 /* check if an image with this path already exists in profile */
                 $fileInfo = pathinfo($imagePath);
                 $extension = strtolower($fileInfo['extension']);
                 $filename = $fileInfo['filename'];
                 /* allow to not overload filename with name_0_3_2_0 ... */
                 $generatedPart = strrchr($filename, '_');
                 if ($generatedPart !== FALSE && is_numeric(substr($generatedPart, 1))) {
                     $filename = substr($fileInfo['filename'], 0, -strlen($generatedPart));
                 }
                 $nbn = 0;
                 while (stream_resolve_include_path($newPath)) {
                     $imagePath = $filename . '_' . $nbn . '.' . $extension;
                     $newPath = $module . '/files/' . $imagePath;
                     $nbn++;
                 }
             }
             $this->setConfig('imgPath', $newPath);
             \tools::file_put_contents(PROFILE_PATH . $newPath, file_get_contents($oldPath, FILE_USE_INCLUDE_PATH));
         }
     }
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:30,代码来源:block.php

示例2: setContent

 public function setContent($html)
 {
     if (\app::getClass('user')->VerifyConnexion() && $_SESSION['permissions'] & 128) {
         /* perm 128 = configure blocks */
         return \tools::file_put_contents(PROFILE_PATH . $this->getConfig('viewPath'), \tools::sanitize($html));
     }
     return FALSE;
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:8,代码来源:block.php

示例3: savePictureAction

 /**
  * Get, decode base 64 & file put content
  * @param string $file
  * @param string $code
  * @return string 
  */
 protected function savePictureAction($file, $code)
 {
     return \tools::file_put_contents($file, base64_decode($code));
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:10,代码来源:module.php

示例4: display

 /**
  * Returns HTML view, manages cache of a block...
  * @return string
  */
 public function display()
 {
     $html = '';
     $balise = 'div';
     $maxAge = 0;
     $headerTitle = $CSSclasses = $attributes = '';
     $ajaxLoad = FALSE;
     foreach ($this->configs as $name => $config) {
         switch ($name) {
             case 'devices':
                 if (is_array($config) && !in_array(DEVICE, $config)) {
                     return '';
                 }
                 break;
             case 'allowedModules':
                 if (is_array($config) && !in_array(MODULE, $config)) {
                     return '';
                 }
                 break;
             case 'allowedRoles':
                 if (is_array($config) && !in_array($_SESSION['id_role'], $config)) {
                     return '';
                 }
                 break;
             case 'tag':
                 $balise = $config;
                 break;
             case 'maxAge':
                 $maxAge = (int) $config;
                 break;
             case 'headerTitle':
                 if ($config) {
                     $headerTitle = '<h2 class="parsiTitle">' . t($config) . '</h2>';
                 }
                 break;
             case 'cssClasses':
                 $CSSclasses .= ' ' . $config;
                 break;
             case 'attributes':
                 $attributes .= ' ' . $config;
                 break;
             case 'ajaxReload':
                 if ((int) $config > 0 && \app::$request->isAjax() === FALSE) {
                     \app::$response->head .= '<script>$(document).ready(function(){setInterval("loadBlock(\'' . $this->id . '\')", ' . $config . '000);});</script>';
                 }
                 break;
             case 'ajaxLoad':
                 if ($config == 1 && \app::$request->isAjax() === FALSE) {
                     $ajaxLoad = TRUE;
                     \app::$response->head .= '<script>$(document).ready(function(){loadBlock("' . $this->id . '")});</script>';
                 }
                 break;
             case 'CSSFiles':
                 foreach ($config as $file => $pos) {
                     \app::$response->addCSSFile(strstr($file, '//') ? $file : $file, $pos);
                 }
                 break;
             case 'JSFiles':
                 foreach ($config as $file => $pos) {
                     \app::$response->addJSFile(strstr($file, '//') ? $file : $file, $pos);
                 }
                 break;
             default:
                 break;
         }
     }
     $cacheFile = 'var/cache/' . PROFILE_PATH . $this->moduleName . '/blocks/' . $this->blockName . '/' . MODULE . '_' . $this->id . '.cache';
     if ($maxAge > 0 && is_file($cacheFile) && filemtime($cacheFile) + $maxAge > time()) {
         ob_start();
         include $cacheFile;
         $html .= ob_get_clean();
     } else {
         $html .= '<' . $balise . ' id="' . $this->id . '" is="' . $this->moduleName . '-' . $this->blockName . '" class="parsiblock ' . $this->moduleName . '_' . $this->blockName . $CSSclasses . '"' . $attributes . '>' . $headerTitle;
         if ($ajaxLoad === FALSE) {
             /* Catch all exceptions or error in order to keep tha page structure in creation mode */
             try {
                 $view = $this->getView();
                 $html .= $view;
             } catch (\Exception $e) {
                 if ($_SESSION['permissions'] > 0) {
                     /* Display Error or exception just for the dev */
                     ob_clean();
                     $html .= '<div class="PHPError"><div class="titleError"><strong>Block </strong>#' . $this->getId() . ' </div>';
                     $html .= '<div class="error"> <strong>' . t('Error') . ' ' . t('in line') . ' </strong>' . $e->getLine() . ' : </strong>' . $e->getMessage() . '</div>';
                     $html .= '<div class="file"><strong>File : </strong>' . $e->getFile() . '</div></div>';
                 }
                 unset($GLOBALS['lastError']);
                 /* to avoid to display error at the end of page load*/
             }
         }
         $html .= '</' . $balise . '>';
         if ($maxAge > 0) {
             tools::file_put_contents($cacheFile, $html);
         }
     }
     return $html;
//.........这里部分代码省略.........
开发者ID:saitinet,项目名称:parsimony,代码行数:101,代码来源:block.php

示例5: save

 /**
  * Put contents in file
  * @return bool
  */
 public function save()
 {
     return tools::file_put_contents($this->file, $this->content);
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:8,代码来源:config.php

示例6: serialize

 /**
  * Serialize an object in a file
  * @param string $filename
  * @param object $obj
  * @return bool
  */
 public static function serialize($filename, $obj)
 {
     $objCopy = clone $obj;
     /* to let used object awake => don't call _sleep on $obj */
     $serial = serialize($objCopy);
     /* we save serialized objects with aliases names to allow to overreide classes and reduce file size */
     foreach (\app::$aliasClasses as $alias => $className) {
         $serial = str_replace('O:' . strlen($className) . ':"' . $className . '"', 'O:' . strlen($alias) . ':"' . $alias . '"', $serial);
     }
     return \tools::file_put_contents($filename . '.obj', $serial);
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:17,代码来源:tools.php

示例7: save

 /**
  * Save file
  * @param string $selector
  * @return bool
  */
 public function save()
 {
     $output = '';
     $media = 'first';
     $oldMedia = 'first';
     foreach ($this->selectors as $selector) {
         $media = isset($selector['media']) ? $selector['media'] : '';
         if ($oldMedia != $media) {
             if (!empty($output)) {
                 if (!empty($oldMedia)) {
                     $output .= PHP_EOL . '}';
                 }
                 if (!empty($media)) {
                     $output .= (isset($selector['bmedia']) ? $selector['bmedia'] : '') . $media . '{';
                 }
             }
             $oldMedia = $media;
         }
         if (!empty($selector['p'])) {
             $output .= $selector['b'] . $selector['s'] . ' {' . $selector['p'] . '}';
         }
     }
     if (substr($media, 0, 1) == '@') {
         $output .= PHP_EOL . '}';
     }
     return \tools::file_put_contents($this->path, $output);
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:32,代码来源:css.php

示例8: determineLocale

 /**
  * Detetermine Locale from current HTTP request
  */
 protected function determineLocale()
 {
     if (isset($_COOKIE['locale']) && isset(self::$locales[$_COOKIE['locale']])) {
         $this->locale = $_COOKIE['locale'];
     } else {
         $this->locale = app::$config['localization']['default_language'];
     }
     setlocale(LC_ALL, $this->locale);
     date_default_timezone_set(app::$config['localization']['timezone']);
     $pathCache = 'var/cache/' . $this->locale . '-lang';
     $lang = '';
     if (is_file($pathCache . '.php')) {
         include $pathCache . '.php';
     } else {
         foreach (app::$activeModules as $moduleName => $type) {
             if (is_file('modules/' . $moduleName . '/locale/' . $this->locale . '.php')) {
                 include 'modules/' . $moduleName . '/locale/' . $this->locale . '.php';
             }
         }
         $config = new \config($pathCache . '.php', TRUE);
         $config->setVariable('lang');
         $config->saveConfig($lang);
         \tools::file_put_contents($pathCache . '.js', substr($config->getContent(), 5, false));
     }
     app::$lang = $lang;
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:29,代码来源:request.php


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