function render_partial(&$request, $template) { trigger_before('render_partial', $this, $this); // content_for_layout() passes the $request->action as $template $ext = $this->pick_template_extension($request, $template); $view = $request->get_template_path($ext, $template); if ($template == 'get') { $template = 'index'; } if (file_exists($view)) { $action = "_" . $template; } else { $action = $template; } global $db; if (file_exists($view) && function_exists($action)) { trigger_before($request->action, $request, $db); $result = $action(array_merge($this->named_vars, $db->get_resource())); trigger_after($request->action, $request, $db); if (is_array($result)) { extract($result); } if (!$this->header_sent) { $content_type = 'Content-Type: ' . $this->pick_content_type($ext); if ($this->pick_content_charset($ext)) { $content_type .= '; charset=' . $this->pick_content_charset($ext); } header($content_type); $this->header_sent = true; } include $view; } else { // no template, check for blobcall if (in_array(type_of($ext), mime_types()) && !$this->header_sent) { $model =& $db->get_table($request->resource); if (isset($model->blob)) { $template = $model->blob; } trigger_before($request->action, $request, $db); $Member = $this->collection->MoveFirst(); render_blob($Member->{$template}, $ext); } else { if (strpos($request->uri, 'robots') === false || strpos($request->uri, 'crawl') === false) { admin_alert($request->uri . " {$view} {$action} " . $_SERVER[REMOTE_HOST]); } } } }
function preview(&$vars) { extract($vars); $model =& $db->get_table($request->resource); $Entry =& $db->model('Entry'); $p = $model->find($request->id); $e = $Entry->find($p->entry_id); $t = $Thumbnail->find_by('target_id', $e->id); if ($t) { $request->set_param('resource', 'thumbnails'); $request->set_param('id', $t->id); render_blob($t->attachment, extension_for($e->content_type)); } else { render_blob($p->attachment, extension_for($e->content_type)); } }
function preview(&$vars) { extract($vars); $p = $Post->find($request->id); $e = $p->FirstChild('entries'); $t = $Thumbnail->find_by('target_id', $e->id); if ($t) { $request->set_param('resource', 'thumbnails'); $request->set_param('id', $t->id); render_blob($t->attachment, extension_for($e->content_type)); } else { render_blob($p->attachment, extension_for($e->content_type)); } }