本文整理汇总了PHP中Zend_Cache_Backend::getTmpDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Cache_Backend::getTmpDir方法的具体用法?PHP Zend_Cache_Backend::getTmpDir怎么用?PHP Zend_Cache_Backend::getTmpDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Cache_Backend
的用法示例。
在下文中一共展示了Zend_Cache_Backend::getTmpDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTmpDir
/**
* Returns a valid tmp folder depending on the OS used.
*
* @return string
*/
public function getTmpDir()
{
// We use a Zend method here, for it already checks the OS.
require_once 'Zend/Cache/Backend.php';
$temp = new Zend_Cache_Backend();
return $temp->getTmpDir();
}
示例2: _getHeaderHtml
protected function _getHeaderHtml($element)
{
$headerHtml = parent::_getHeaderHtml($element);
if ($this->getGroup() && @current($this->getGroup()->data_model) !== false) {
// Set up cache, using the Magento cache doesn't make sense as it won't cache if cache is disabled
try {
$cacheBackend = new Zend_Cache_Backend();
$cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 43200), array('cache_dir' => $cacheBackend->getTmpDir()));
} catch (Exception $e) {
return $headerHtml;
}
// Get data model
$dataModelName = @current($this->getGroup()->data_model);
$cacheKey = 'info_' . @current(explode("/", $dataModelName));
if (@current($this->getGroup()->module_name) !== false) {
$moduleVersion = (string) @Mage::getConfig()->getNode()->modules->{current($this->getGroup()->module_name)}->version;
if (!empty($moduleVersion)) {
$cacheKey .= '_' . str_replace('.', '_', $moduleVersion);
}
}
// Is the response cached?
$cachedHtml = $cache->load($cacheKey);
#$cachedHtml = false; // Test: disable cache
if ($cachedHtml !== false && $cachedHtml !== '') {
$storeHtml = $cachedHtml;
} else {
try {
$dataModel = Mage::getSingleton($dataModelName);
$dataModel->afterLoad();
// Fetch info whether updates for the module are available
$url = 'ht' . 'tp://w' . 'ww.' . 'xte' . 'nto.' . 'co' . 'm/li' . 'cense/info/';
$version = Mage::getVersion();
$extensionVersion = $dataModel->getValue();
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$storeHtml = file_get_contents($url . '?version=' . $version . '&d=' . $extensionVersion);
} else {
$client = new Zend_Http_Client($url, array('timeout' => 10));
$client->setParameterGet('version', $version);
$client->setParameterGet('d', $extensionVersion);
$response = $client->request('GET');
// Post version
/*$client = new Zend_Http_Client($url, array('timeout' => 10));
$client->setParameterPost('version', $version);
$client->setParameterPost('d', $extensionVersion);
$response = $client->request('POST');*/
$storeHtml = $response->getBody();
}
$cache->save($storeHtml, $cacheKey);
} catch (Exception $e) {
return '------------------------------------------------<div style="display:none">Exception: ' . $e->getMessage() . '</div>' . $headerHtml;
}
}
if (preg_match('/There has been an error processing your request/', $storeHtml)) {
return $headerHtml;
}
$headerHtml = str_replace('</div><table cellspacing="0" class="form-list">', $storeHtml . '</div><table cellspacing="0" class="form-list">', $headerHtml);
// below 1.6
$headerHtml = str_replace('</span><table cellspacing="0" class="form-list">', $storeHtml . '</span><table cellspacing="0" class="form-list">', $headerHtml);
// after 1.7
}
return $headerHtml;
}
示例3: getTmpDir
/**
* Determine system TMP directory and detect if we have read access
*
* inspired from \Zend_File_Transfer_Adapter_Abstract
*
* @return string
* @throws \Zend_Cache_Exception if unable to determine directory
*/
public function getTmpDir()
{
return $this->_backend->getTmpDir();
}