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


PHP Jaws_Utils::file_put_contents方法代码示例

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


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

示例1: saveFile

 /**
  * Saves data into the file
  *
  * @access  public
  * @param   string  $cache_file
  * @param   string  $data
  * @return  mixed   True on success and PEAR error on failure
  */
 function saveFile($cache_file, $data)
 {
     if (!Jaws_Utils::file_put_contents($cache_file, serialize($data))) {
         return PEAR::raiseError("Fail to save stream with file_put_contents('{$cache_file}',...).");
     }
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:15,代码来源:Google.php

示例2: set

 /**
  * Store cache of given component/section
  *
  * @access  public
  */
 function set($component, $section, $params, &$data, $lifetime = 0)
 {
     if (!is_null($params)) {
         $params = is_array($params) ? implode('_', $params) : $params;
     } else {
         $params = '';
     }
     $file = $this->_path . $component . '.' . $section . (empty($params) ? '' : '.' . $params);
     return (bool) Jaws_Utils::file_put_contents($file, $data);
 }
开发者ID:juniortux,项目名称:jaws,代码行数:15,代码来源:File.php

示例3: SetLangData


//.........这里部分代码省略.........
                 $orig_file = JAWS_PATH . "upgrade/Resources/translates.ini";
             } else {
                 $orig_file = JAWS_PATH . "languages/{$langTo}/Upgrade.ini";
             }
             $data_file = JAWS_DATA . "languages/{$langTo}/Upgrade.ini";
             break;
         default:
             if ($langTo == 'en') {
                 $orig_file = JAWS_PATH . "include/Jaws/Resources/translates.ini";
             } else {
                 $orig_file = JAWS_PATH . "languages/{$langTo}/Global.ini";
             }
             $data_file = JAWS_DATA . "languages/{$langTo}/Global.ini";
     }
     $update_default_lang = $this->gadget->registry->fetch('update_default_lang') == 'true';
     $strings = array();
     if (file_exists($orig_file)) {
         $strings = parse_ini_file($orig_file, false, INI_SCANNER_RAW);
     }
     // user translation
     $tpl = $this->gadget->template->loadAdmin('FileTemplate.html');
     $tpl->SetBlock('template');
     $tpl->SetVariable('project', $module_name);
     $tpl->SetVariable('language', strtoupper($langTo));
     // orig translation
     $tpl2 = $this->gadget->template->loadAdmin('FileTemplate.html');
     $tpl2->SetBlock('template');
     $tpl2->SetVariable('project', $module_name);
     $tpl2->SetVariable('language', strtoupper($langTo));
     // Meta
     foreach ($data['meta'] as $k => $v) {
         // user translation
         $tpl->SetBlock('template/meta');
         $tpl->SetVariable('key', $k);
         $tpl->SetVariable('value', $v);
         $tpl->ParseBlock('template/meta');
         // orig translation
         $tpl2->SetBlock('template/meta');
         $tpl2->SetVariable('key', $k);
         $tpl2->SetVariable('value', $v);
         $tpl2->ParseBlock('template/meta');
     }
     // Strings
     $change_detected = false;
     foreach ($data['strings'] as $k => $v) {
         if ($v == '') {
             continue;
         } elseif ($v === $this->_EMPTY_STRING) {
             $v = '';
         }
         $v = preg_replace("\$\r\n|\n\$", '\\n', $v);
         $changed = !isset($strings[$k]) || $strings[$k] !== $v;
         if ($changed) {
             $change_detected = true;
             $tpl->SetBlock('template/string');
             $tpl->SetVariable('key', $k);
             $tpl->SetVariable('value', $v);
             $tpl->ParseBlock('template/string');
         }
         // orig translation
         $tpl2->SetBlock('template/string');
         $tpl2->SetVariable('key', $k);
         $tpl2->SetVariable('value', $v);
         $tpl2->ParseBlock('template/string');
     }
     $tpl->ParseBlock('template');
     $tpl2->ParseBlock('template');
     // update original translation
     if ($update_default_lang) {
         // update default language translation,
         // so we can delete customized language's file
         if (Jaws_Utils::file_put_contents($orig_file, $tpl2->Get())) {
             $change_detected = false;
         }
     }
     // Writable
     if (file_exists($data_file)) {
         $writeable = Jaws_Utils::is_writable($data_file);
     } else {
         Jaws_Utils::mkdir(dirname($data_file), 3);
         $writeable = Jaws_Utils::is_writable(dirname($data_file));
     }
     if (!$writeable) {
         $GLOBALS['app']->Session->PushLastResponse(_t('LANGUAGES_NOT_PERMISSION'), RESPONSE_ERROR);
         return false;
     }
     if ($change_detected) {
         if (Jaws_Utils::file_put_contents($data_file, $tpl->Get())) {
             $GLOBALS['app']->Session->PushLastResponse(_t('LANGUAGES_UPDATED', $module), RESPONSE_NOTICE);
             return true;
         } else {
             $GLOBALS['app']->Session->PushLastResponse(_t('LANGUAGES_NOT_UPDATED', $module), RESPONSE_ERROR);
             return false;
         }
     } else {
         Jaws_Utils::Delete($data_file);
         $GLOBALS['app']->Session->PushLastResponse(_t('LANGUAGES_UPDATED', $module), RESPONSE_NOTICE);
         return true;
     }
 }
开发者ID:juniortux,项目名称:jaws,代码行数:101,代码来源:Languages.php

示例4: GetSitemapXML

 /**
  * Get Sitemap XML content
  *
  * @access  public
  * @return  XML   content of sitemap
  */
 function GetSitemapXML()
 {
     $xml_file = JAWS_DATA . 'sitemap/sitemap.xml';
     if (file_exists($xml_file)) {
         if (false === ($data = @file_get_contents($xml_file))) {
             return false;
         }
         return $data;
     }
     $tpl = $this->gadget->template->load('SitemapXML.html');
     $tpl->SetBlock('xml');
     $date = Jaws_Date::getInstance();
     $gadgets = $this->GetAvailableSitemapGadgets();
     foreach ($gadgets as $gadget) {
         $gadget_xml_file = JAWS_DATA . 'sitemap/' . strtolower($gadget['name']) . '/sitemap.xml';
         if (file_exists($gadget_xml_file)) {
             $tpl->SetBlock('xml/item');
             $tpl->SetVariable('loc', $this->gadget->urlMap('SitemapXML', array('gname' => strtolower($gadget['name'])), true));
             $tpl->SetVariable('lastmod', $date->ToISO(filemtime($gadget_xml_file)));
             $tpl->ParseBlock('xml/item');
         }
     }
     $tpl->ParseBlock('xml');
     $xmlContent = $tpl->Get();
     if (!Jaws_Utils::file_put_contents($xml_file, $xmlContent)) {
         return false;
     }
     return $xmlContent;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:35,代码来源:Sitemap.php

示例5: SyncSitemapData

 /**
  * Sync sitemap data files
  *
  * @access  public
  * @param   string  $gadget  Gadget name
  * @return  mixed   Array of Tag info or Jaws_Error on failure
  */
 function SyncSitemapData($gadget)
 {
     $objGadget = Jaws_Gadget::getInstance($gadget);
     if (Jaws_Error::IsError($objGadget)) {
         return '';
     }
     $objHook = $objGadget->hook->load('Sitemap');
     if (Jaws_Error::IsError($objHook)) {
         return '';
     }
     $result[$gadget] = array();
     $gResult = $objHook->Execute(1);
     if (Jaws_Error::IsError($gResult) || empty($gResult)) {
         return '';
     }
     // Check gadget directory in sitemap
     $gadget_dir = JAWS_DATA . 'sitemap/' . strtolower($gadget);
     if (!Jaws_Utils::mkdir($gadget_dir, 1)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_DIR', $gadget_dir));
     }
     $cache_file = $gadget_dir . '/sitemap.bin';
     if (!Jaws_Utils::file_put_contents($cache_file, serialize($gResult))) {
         return false;
     }
     return true;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:33,代码来源:Sitemap.php

示例6: saveFile

 /**
  * Saves data into the file
  *
  * @access  public
  * @param   string  $cache_file    Filename
  * @return  mixed   True on success or error on failure
  */
 function saveFile($cache_file)
 {
     if (!isset($this->feed)) {
         return false;
     }
     $serialized = serialize($this->ex_array_map('base64_encode', $this->feed));
     if (Jaws_Utils::file_put_contents($cache_file, $serialized)) {
         return true;
     } else {
         return $this->raiseError("Fail to save stream with file_put_contents('{$cache_file}',...).");
     }
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:19,代码来源:XML_Feed.php


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