request->post())
foreach ($this->request->post('process') as $pid) {
if (! Arr::get($this->request->post('remove'),$pid,FALSE))
continue;
$po = ORM::factory('Photo',$pid);
// If the photo is not marked as remove, or flagged, dont do it.
if (! $po->loaded() OR $po->flag OR ! $po->remove)
continue;
if (! is_writable(dirname($po->file_path())))
$output .= sprintf('Dont have write permissions on %s',dirname($po->file_path()));
$output .= sprintf('Removing %s (%s)',$po->id,$po->file_path());
}
$p = ORM::factory('Photo');
// Review a specific photo, or the next one marked remove
if ($x=$this->request->param('id'))
$p->where('id','=',$x);
else
$p->where('remove','=',TRUE)
->where_open()
->where('flag','!=',TRUE)
->or_where('flag','is',NULL)
->where_close();
$output .= Form::open(sprintf('%s/%s',strtolower($this->request->controller()),$this->request->action()));
foreach ($p->find_all() as $po) {
$dp = $po->list_duplicate()->find_all();
$output .= Form::hidden('process[]',$po->id);
foreach ($dp as $dpo)
$output .= Form::hidden('process[]',$dpo->id);
$output .= '
';
$output .= Form::close();
Block::factory()
->title('Duplicate Photo:'.$po->id)
->title_icon('icon-edit')
->body($output);
}
public function action_thumbnail() {
// Get the file path from the request
$po = ORM::factory('Photo',$this->request->param('id'));
return $this->image($po->thumbnail(),$po->date_taken,$po->type(TRUE));
}
public function action_view() {
$po = ORM::factory('Photo',$this->request->param('id'));
return $this->image($po->image(),$po->date_taken,$po->type(TRUE));
}
private function image($content,$modified,$type) {
// Send the file content as the response
if ($content)
$this->response->body($content);
// Return a 404 status
else
$this->response->status(404);
// Generate and check the ETag for this file
if (Kohana::$environment < Kohana::TESTING OR Kohana::$config->load('debug')->etag)
$this->check_cache(sha1($this->response->body()));
// Set the proper headers to allow caching
$this->response->headers('Content-Type',$type);
$this->response->headers('Content-Length',(string)$this->response->content_length());
$this->response->headers('Last-Modified',date('r',$modified));
$this->auto_render = FALSE;
}
private function table_duplicate_checkbox(Database_MySQL_Result $dp,Model_Photo $po,$param,$title,$condition) {
$output = '