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


PHP false::save方法代码示例

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


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

示例1: handleUpload

 /**
  * Returns array('success'=>true) or array('error'=>'error message')
  */
 public function handleUpload()
 {
     if (!$this->file) {
         return array('error' => Tools::displayError('No files were uploaded.'));
     }
     $size = $this->file->getSize();
     if ($size == 0) {
         return array('error' => Tools::displayError('File is empty'));
     }
     if ($size > $this->sizeLimit) {
         return array('error' => Tools::displayError('File is too large'));
     }
     $pathinfo = pathinfo($this->file->getName());
     $these = implode(', ', $this->allowedExtensions);
     if (!isset($pathinfo['extension'])) {
         return array('error' => sprintf(Tools::displayError('File has an invalid extension, it should be one of these: %s.'), $these));
     }
     $ext = $pathinfo['extension'];
     if ($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)) {
         return array('error' => sprintf(Tools::displayError('File has an invalid extension, it should be one of these: %s.'), $these));
     }
     return $this->file->save();
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:26,代码来源:FileUploader.php

示例2: render

 /**
  * Returns PHPTAL output - either from a render or from the cache.
  *
  * @param string|array $template The name of the template to render or
  *                                an array with the ('src') src for a template
  *                                and a ('name') name to help identify the
  *                                template in error messages.
  *
  * @return string
  */
 public function render($template)
 {
     $this->_checkLoaded();
     if ($this->_zendPageCacheContent != false) {
         return $this->_zendPageCacheContent;
     }
     if (!is_array($template)) {
         //conversion of template names from '-' split to camel-case
         $templateParts = explode('-', $template);
         $firstPart = array_shift($templateParts);
         foreach ($templateParts as &$currentPart) {
             $currentPart = ucfirst($currentPart);
         }
         $template = $firstPart . implode('', $templateParts);
         $this->_engine->setTemplate($template);
     } else {
         $this->_engine->setSource($template['src'], $template['name']);
     }
     $this->productionMode = 'production' == APPLICATION_ENV;
     $this->_engine->set('doctype', $this->doctype());
     $this->_engine->set('headTitle', $this->headTitle());
     $this->_engine->set('headScript', $this->headScript());
     $this->_engine->set('headLink', $this->headLink());
     $this->_engine->set('headMeta', $this->headMeta());
     $this->_engine->set('headStyle', $this->headStyle());
     if ($this->_purgeCacheBeforeRender) {
         $cacheFolder = $this->_engine->getPhpCodeDestination();
         if (is_dir($cacheFolder)) {
             foreach (new DirectoryIterator($cacheFolder) as $cacheItem) {
                 if (strncmp($cacheItem->getFilename(), 'tpl_', 4) != 0 || $cacheItem->isdir()) {
                     continue;
                 }
                 @unlink($cacheItem->getPathname());
             }
         }
     }
     // if a layout is being used and nothing has already overloaded the viewContent,
     // register the content as viewContent, otherwise set it to empty
     if (!isset($this->viewContent)) {
         if ($this->getHelperPath('layout') != false && $this->layout()->isEnabled()) {
             $this->_engine->set('viewContent', $this->layout()->content);
         } else {
             $this->viewContent = '';
         }
     }
     // Strip html comments and compress un-needed whitespace
     $this->_engine->addPreFilter(new PHPTAL_PreFilter_StripComments());
     if ($this->_compressWhitespace == true) {
         $this->_engine->addPreFilter(new PHPTAL_PreFilter_Compress());
     }
     try {
         $result = $this->_engine->execute();
     } catch (PHPTAL_TemplateException $e) {
         // If the exception is a root PHPTAL_TemplateException
         // rather than a subclass of this exception and xdebug is enabled,
         // it will have already been picked up by xdebug, if enabled, and
         // should be shown like any other php error.
         // Any subclass of PHPTAL_TemplateException can be handled by
         // the phptal internal exception handler as it gives a useful
         // error output
         if (get_class($e) == 'PHPTAL_TemplateException' && function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
             exit;
         }
         throw $e;
     }
     if ($this->_zendPageCache instanceof Zend_Cache_Core) {
         $this->_zendPageCache->save($result, $this->_zendPageCacheKey, array(), $this->_zendPageCacheDuration);
     }
     return $result;
 }
开发者ID:jo-m,项目名称:ecamp3,代码行数:80,代码来源:View.php

示例3: render

 /**
  * Returns PHPTAL output - either from a render or from the cache.
  *
  * @param string|array $template The name of the template to render or
  *                               an array with the ('src') src for a template
  *                               and a ('name') name to help identify the
  *                               template in error messages.
  *
  * @return string
  */
 public function render($template)
 {
     // Check we are fully configured and initialised.
     if ($this->_engine == null) {
         throw new \Zend_View_Exception('PHPTAL is not defined', $this);
     }
     // If a cache has been setup and content is available, return it
     if ($this->_zendPageCacheContent != false) {
         return $this->_zendPageCacheContent;
     }
     // Setup the script locations based on the view's script paths
     $this->_engine->setTemplateRepository($this->getScriptPaths());
     // Do this at this point rather than in the constructor because we don't
     // know what the template repositories are going to be at that point.
     $this->_engine->addSourceResolver(new PharResolver($this->getScriptPaths()));
     // Assign all the variables set here through to the PHPTAL engine.
     foreach ($this->getVars() as $key => $value) {
         $this->_engine->set($key, $value);
     }
     if (!is_array($template)) {
         $this->_engine->setTemplate($this->_convertTemplateName($template));
     } else {
         $this->_engine->setSource($template['src'], $template['name']);
     }
     // Setup a collection of standard variable available in the view
     $this->_engine->set('doctype', $this->doctype());
     $this->_engine->set('headTitle', $this->headTitle());
     $this->_engine->set('headScript', $this->headScript());
     $this->_engine->set('headLink', $this->headLink());
     $this->_engine->set('headMeta', $this->headMeta());
     $this->_engine->set('headStyle', $this->headStyle());
     $this->productionMode = 'production' == APPLICATION_ENV;
     // If perging of the tal template cache is enabled
     // find all template cache files and delete them
     if ($this->_purgeCacheBeforeRender) {
         $cacheFolder = $this->_engine->getPhpCodeDestination();
         if (is_dir($cacheFolder)) {
             foreach (new \DirectoryIterator($cacheFolder) as $cacheItem) {
                 if (strncmp($cacheItem->getFilename(), 'tpl_', 4) != 0 || $cacheItem->isdir()) {
                     continue;
                 }
                 @unlink($cacheItem->getPathname());
             }
         }
     }
     // if a layout is being used and nothing has already overloaded the viewContent,
     // register the content as viewContent, otherwise set it to empty
     if (!isset($this->viewContent)) {
         if ($this->getHelperPath('layout') != false && $this->layout()->isEnabled()) {
             $this->_engine->set('viewContent', $this->layout()->content);
         } else {
             $this->viewContent = '';
         }
     }
     if (!$this->_preFiltersRegistered) {
         // Strip html comments and compress un-needed whitespace
         $this->_engine->addPreFilter(new \PHPTAL_PreFilter_StripComments());
         if ($this->_compressWhitespace == true) {
             $this->_engine->addPreFilter(new \PHPTAL_PreFilter_Compress());
         }
         $this->_preFiltersRegistered = true;
     }
     try {
         $result = $this->_engine->execute();
     } catch (\PHPTAL_TemplateException $e) {
         // If the exception is a root PHPTAL_TemplateException
         // rather than a subclass of this exception and xdebug is enabled,
         // it will have already been picked up by xdebug, if enabled, and
         // should be shown like any other php error.
         // Any subclass of PHPTAL_TemplateException can be handled by
         // the phptal internal exception handler as it gives a useful
         // error output
         if (get_class($e) == 'PHPTAL_TemplateException' && function_exists('xdebug_is_enabled') && xdebug_is_enabled()) {
             exit;
         }
         throw $e;
     }
     // If the page needed to be rendered but was configured to
     // cache then cache the result of the render.
     if ($this->_zendPageCache instanceof \Zend_Cache_Core) {
         $this->_zendPageCache->save($result, $this->_zendPageCacheKey, array(), $this->_zendPageCacheDuration);
     }
     return $result;
 }
开发者ID:namesco,项目名称:ztal,代码行数:94,代码来源:View.php


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