public function initialize($context, $moduleName, $actionName, $viewName)
 {
     parent::initialize($context, $moduleName, $actionName, $viewName);
     $format = $context->getRequest()->getRequestFormat();
     // make sure directory is set
     if (!$this->directory) {
         $this->setDirectory($this->context->getConfiguration()->getTemplateDir($this->moduleName, str_replace('.' . $format, '', $this->template)));
     }
     if ($format || $format != 'html') {
         $this->checkFallback($format);
     }
     return true;
 }
/**
 * Evaluates and returns a partial.
 * The syntax is similar to the one of include_partial
 *
 * <b>Example:</b>
 * <code>
 *  echo get_partial('mypartial', array('myvar' => 12345));
 * </code>
 *
 * @param  string partial name
 * @param  array variables to be made accessible to the partial
 * @return string result of the partial execution
 * @see    include_partial
 */
function get_partial($templateName, $vars = array())
{
    $context = sfContext::getInstance();
    // partial is in another module?
    if (false !== ($sep = strpos($templateName, '/'))) {
        $moduleName = substr($templateName, 0, $sep);
        $templateName = substr($templateName, $sep + 1);
    } else {
        $moduleName = $context->getActionStack()->getLastEntry()->getModuleName();
    }
    $actionName = '_' . $templateName;
    if ($cacheManager = $context->getViewCacheManager()) {
        if ($retval = _get_cache($cacheManager, $moduleName, $actionName, $vars)) {
            return $retval;
        }
    }
    $view = new sfPartialView();
    $view->initialize($context, $moduleName, $actionName, '');
    $retval = $view->render($vars);
    if ($cacheManager && (!sfConfig::get('sf_lazy_cache_key') || $cacheManager->isActionCacheable($moduleName, $actionName))) {
        $uri = _get_cache_uri($moduleName, $actionName, $vars);
        $retval = _set_cache($cacheManager, $uri, $retval);
    }
    return $retval;
}
 public function initialize($context, $moduleName, $actionName, $viewName)
 {
     parent::initialize($context, $moduleName, $actionName, sfSmartphoneViewToolKit::getViewNameFromUA($this, $context, $moduleName, $actionName, $viewName));
 }
Exemple #4
0
/**
 * Evaluates and returns a partial.
 * The syntax is similar to the one of include_partial
 *
 * <b>Example:</b>
 * <code>
 *  echo get_partial('mypartial', array('myvar' => 12345));
 * </code>
 *
 * @param  string partial name
 * @param  array variables to be made accessible to the partial
 * @return string result of the partial execution
 * @see    include_partial
 */
function get_partial($templateName, $vars = array())
{
    $context = sfContext::getInstance();
    // partial is in another module?
    if (false !== ($sep = strpos($templateName, '/'))) {
        $moduleName = substr($templateName, 0, $sep);
        $templateName = substr($templateName, $sep + 1);
    } else {
        $moduleName = $context->getActionStack()->getLastEntry()->getModuleName();
    }
    $actionName = '_' . $templateName;
    if ($cacheManager = $context->getViewCacheManager()) {
        $cacheManager->registerConfiguration($moduleName);
        $uri = '@sf_cache_partial?module=' . $moduleName . '&action=' . $actionName . '&sf_cache_key=' . (isset($vars['sf_cache_key']) ? $vars['sf_cache_key'] : md5(serialize($vars)));
        if ($retval = _get_cache($cacheManager, $uri)) {
            return $retval;
        }
    }
    $view = new sfPartialView();
    $view->initialize($context, $moduleName, $actionName, '');
    $retval = $view->render($vars);
    if ($cacheManager) {
        $retval = _set_cache($cacheManager, $uri, $retval);
    }
    return $retval;
}