Added Move, started to add delete
This commit is contained in:
@@ -13,6 +13,96 @@ class Controller_Photo extends Controller_TemplateDefault {
|
||||
public function action_index() {
|
||||
}
|
||||
|
||||
public function action_delete() {
|
||||
$output = '';
|
||||
|
||||
// Update the current posted photos.
|
||||
if ($this->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 .= '<table class="table table-striped table-condensed table-hover">';
|
||||
|
||||
foreach (array(
|
||||
'ID'=>array('key'=>'id','value'=>HTML::anchor('/photo/details/%VALUE%','%VALUE%')),
|
||||
'Thumbnail'=>array('key'=>'id','value'=>HTML::anchor('/photo/view/%VALUE%',HTML::image('photo/thumbnail/%VALUE%'))),
|
||||
'Signature'=>array('key'=>'signature'),
|
||||
'Date Taken'=>array('key'=>'date_taken()'),
|
||||
'File Modified'=>array('key'=>'date_file("m",TRUE)'),
|
||||
'File Created'=>array('key'=>'date_file("c",TRUE)'),
|
||||
'Filename'=>array('key'=>'file_path(TRUE,FALSE)'),
|
||||
'Proposed Name'=>array('key'=>'path()'),
|
||||
'Width'=>array('key'=>'width'),
|
||||
'Height'=>array('key'=>'height'),
|
||||
'Orientation'=>array('key'=>'orientation'),
|
||||
'Orientate'=>array('key'=>'rotation()'),
|
||||
'Make'=>array('key'=>'make'),
|
||||
'Model'=>array('key'=>'model'),
|
||||
) as $k=>$v)
|
||||
$output .= $this->table_duplicate_details($dp,$po,$v['key'],$k,Arr::get($v,'value','%VALUE%'));
|
||||
|
||||
foreach (array(
|
||||
'Delete'=>array('key'=>'id','value'=>'remove'),
|
||||
) as $k=>$v)
|
||||
$output .= $this->table_duplicate_checkbox($dp,$po,$v['key'],$k,Arr::get($v,'value','%VALUE%'));
|
||||
|
||||
$output .= '</table>';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$output .= '<div class="row">';
|
||||
$output .= '<div class="col-md-offset-2">';
|
||||
$output .= '<button type="submit" class="btn btn-primary">Save changes</button>';
|
||||
$output .= '<button type="button" class="btn">Cancel</button>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= Form::close();
|
||||
|
||||
Block::factory()
|
||||
->title('Delete Photo:'.$po->id)
|
||||
->title_icon('icon-delete')
|
||||
->body($output);
|
||||
}
|
||||
|
||||
public function action_details() {
|
||||
$po = ORM::factory('Photo',$this->request->param('id'));
|
||||
if (! $po->loaded())
|
||||
@@ -32,7 +122,7 @@ class Controller_Photo extends Controller_TemplateDefault {
|
||||
$po = ORM::factory('Photo',$pid);
|
||||
|
||||
$po->duplicate = Arr::get($this->request->post('duplicate'),$pid);
|
||||
$po->delete = Arr::get($this->request->post('delete'),$pid);
|
||||
$po->remove = Arr::get($this->request->post('remove'),$pid);
|
||||
$po->flag = Arr::get($this->request->post('flag'),$pid);
|
||||
|
||||
$po->save();
|
||||
@@ -40,20 +130,21 @@ class Controller_Photo extends Controller_TemplateDefault {
|
||||
|
||||
$p = ORM::factory('Photo');
|
||||
|
||||
// Review a specific photo, or the next one marked duplicate
|
||||
if ($x=$this->request->param('id'))
|
||||
$p->where('id','=',$x);
|
||||
|
||||
else
|
||||
$p->where('duplicate','=',TRUE)
|
||||
->where_open()
|
||||
->where('delete','!=',TRUE)
|
||||
->or_where('delete','is',NULL)
|
||||
->where('remove','!=',TRUE)
|
||||
->or_where('remove','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->duplicate_find()->find_all();
|
||||
$dp = $po->list_duplicate()->find_all();
|
||||
|
||||
// Check that there are still duplicates
|
||||
if ($dp->count() == 0) {
|
||||
@@ -73,20 +164,24 @@ class Controller_Photo extends Controller_TemplateDefault {
|
||||
'Thumbnail'=>array('key'=>'id','value'=>HTML::anchor('/photo/view/%VALUE%',HTML::image('photo/thumbnail/%VALUE%'))),
|
||||
'Signature'=>array('key'=>'signature'),
|
||||
'Date Taken'=>array('key'=>'date_taken()'),
|
||||
'Filename'=>array('key'=>'filename'),
|
||||
'Proposed Name'=>array('key'=>'path()'),
|
||||
'File Modified'=>array('key'=>'date_file("m",TRUE)'),
|
||||
'File Created'=>array('key'=>'date_file("c",TRUE)'),
|
||||
'Filename'=>array('key'=>'file_path(TRUE,FALSE)'),
|
||||
'Proposed Name'=>array('key'=>'file_path(TRUE,TRUE)'),
|
||||
'Width'=>array('key'=>'width'),
|
||||
'Height'=>array('key'=>'height'),
|
||||
'Orientation'=>array('key'=>'orientation'),
|
||||
'Orientate'=>array('key'=>'rotation()'),
|
||||
'Make'=>array('key'=>'make'),
|
||||
'Model'=>array('key'=>'model'),
|
||||
'Exif Diff'=>array('key'=>"propertydiff({$po->id})"),
|
||||
) as $k=>$v)
|
||||
$output .= $this->table_duplicate_details($dp,$po,$v['key'],$k,Arr::get($v,'value','%VALUE%'));
|
||||
|
||||
foreach (array(
|
||||
'Flag'=>array('key'=>'id','value'=>'flag'),
|
||||
'Duplicate'=>array('key'=>'id','value'=>'duplicate'),
|
||||
'Delete'=>array('key'=>'id','value'=>'delete'),
|
||||
'Delete'=>array('key'=>'id','value'=>'remove'),
|
||||
) as $k=>$v)
|
||||
$output .= $this->table_duplicate_checkbox($dp,$po,$v['key'],$k,Arr::get($v,'value','%VALUE%'));
|
||||
|
||||
@@ -96,7 +191,7 @@ class Controller_Photo extends Controller_TemplateDefault {
|
||||
}
|
||||
|
||||
$output .= '<div class="row">';
|
||||
$output .= '<div class="offset2">';
|
||||
$output .= '<div class="col-md-offset-2">';
|
||||
$output .= '<button type="submit" class="btn btn-primary">Save changes</button>';
|
||||
$output .= '<button type="button" class="btn">Cancel</button>';
|
||||
$output .= '</div>';
|
||||
@@ -157,24 +252,29 @@ class Controller_Photo extends Controller_TemplateDefault {
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function evaluate(Model $o,$param) {
|
||||
$result = NULL;
|
||||
|
||||
if (preg_match('/\(/',$param) OR preg_match('/-\>/',$param))
|
||||
eval("\$result = \$o->$param;");
|
||||
else
|
||||
$result = $o->display($param);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function table_duplicate_details(Database_MySQL_Result $dp,Model_Photo $po,$param,$title='',$content='') {
|
||||
$output = '<tr>';
|
||||
|
||||
if (preg_match('/\(/',$param) OR preg_match('/-\>/',$param))
|
||||
eval("\$d = \$po->$param;");
|
||||
else
|
||||
$d = $po->display($param);
|
||||
$v = $this->evaluate($po,$param);
|
||||
|
||||
$output .= sprintf('<th>%s</th>',$title);
|
||||
$output .= sprintf('<td>%s</td>',$content ? str_replace('%VALUE%',$d,$content) : $d);
|
||||
$output .= sprintf('<td>%s</td>',$content ? str_replace('%VALUE%',$v,$content) : $v);
|
||||
|
||||
foreach ($dp as $dpo) {
|
||||
if (preg_match('/\(/',$param) OR preg_match('/-\>/',$param))
|
||||
eval("\$d = \$dpo->$param;");
|
||||
else
|
||||
$d = $dpo->display($param);
|
||||
$d = $this->evaluate($dpo,$param);
|
||||
|
||||
$output .= sprintf('<td>%s</td>',$content ? str_replace('%VALUE%',$d,$content) : $d);
|
||||
$output .= sprintf('<td class="%s">%s</td>',($d==$v ? 'success' : 'warning'),$content ? str_replace('%VALUE%',$d,$content) : $d);
|
||||
}
|
||||
|
||||
$output .= '</tr>';
|
||||
|
Reference in New Issue
Block a user