/** * 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 company_detail($company_id) { if (($company_info = _get_cache($company_id, CACHE_KEY_COMPANY_INFO)) && $company_info !== FALSE) { return $company_info; } $this->db->select('*')->from('companies')->where('id', to_int($company_id)); $company_info = $this->db->get()->row(); _set_cache($company_id, $company_info, CACHE_KEY_COMPANY_INFO); return $company_info; }
public function get_companies_list() { if (($qrows = _get_cache('', CACHE_KEY_COMPANY_DDL_LIST)) && $qrows !== FALSE) { return $qrows; } $this->db->select('id,name')->from('companies')->where('is_deleted', 0); $query = $this->db->get(); $qrows = $query->result(); _set_cache('', $qrows, CACHE_KEY_COMPANY_DDL_LIST); return $qrows; }
/** * 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; }
public function get_user_profile($user_id) { if (($data = _get_cache($user_id, CACHE_KEY_USER_PROFILE)) && $data !== FALSE) { return $data; } $this->db->select('u.id AS user_id, u.username, u.email, u.first_name, u.last_name, u.avatar, u.phone, g.id as group_id, u.postcode')->select('g.name as group_name, g.description as group_description, u.gmt_offset')->select("CONCAT(u.first_name,' ', u.last_name) AS user_full_name", FALSE)->from('users u')->join('users_groups ug', 'u.id = ug.user_id', 'INNER')->join('groups g', 'ug.group_id = g.id', 'INNER')->where('u.id', to_int($user_id))->group_by('u.id'); $query = $this->db->get(); $user_info = $query->row(); if ($user_info) { $user_info->user_id = to_int($user_info->user_id); $user_info->group_id = to_int($user_info->group_id); $user_info->gmt_offset = ci()->cfg->gmt_offset; $user_info->{'company_id'} = $this->user_company_by_user_id($user_info->user_id, $user_info->group_id); $user_info->{'client_ids'} = FALSE; if ($user_info->group_id == GROUP_CLIENT_USER) { $user_info->{'client_ids'} = $clients; } } _set_cache($user_id, $user_info, CACHE_KEY_USER_PROFILE); return $user_info; }