Skip to content

Commit

Permalink
Delete confirm screen for media manager
Browse files Browse the repository at this point in the history
  • Loading branch information
myovchev committed Oct 31, 2012
1 parent a533274 commit 909735d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
2 changes: 2 additions & 0 deletions e107_admin/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ class media_admin_ui extends e_admin_ui
protected $batchDelete = true;
// protected $defaultOrder = 'desc';
protected $listOrder = 'm.media_id desc'; // show newest images first.
public $deleteConfirmScreen = true;
public $deleteConfirmMessage = 'You are about to delete %d records and <strong>ALL CORRESPONDING FILES</strong>! Please confirm to continue!';

//TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields
/*
Expand Down
55 changes: 39 additions & 16 deletions e107_handlers/admin_ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -3044,8 +3044,8 @@ protected function parseAliases()
{
if($this->_alias_parsed) return $this; // already parsed!!!


/* OUTDATED.
$this->joinAlias(); // generate Table Aliases from listQry

if($this->getJoinData())
{
foreach ($this->getJoinData() as $table => $att)
Expand All @@ -3069,11 +3069,7 @@ protected function parseAliases()
$this->setJoinData($table, $att);
}
}
*/


$this->joinAlias(); // generate Table Aliases from listQry


// check for table & field aliases
$fields = array(); // preserve order
foreach ($this->fields as $field => $att)
Expand All @@ -3084,14 +3080,14 @@ protected function parseAliases()
$tmp = explode('.', $field, 2);
$table = $this->getTableFromAlias($tmp[0]);
$att['table'] = $table;
$att['alias'] = $field;
$att['alias'] = $tmp[0];
$att['field'] = $tmp[1];
$att['__tableField'] = $field;
$att['__tableFrom'] = "`#".$table."`.".$tmp[1]." AS ".$field;
$att['__tablePath'] = $att['alias'].'.';
$att['__tableFrom'] = "`#".$table."`.".$tmp[1];//." AS ".$att['alias'];
$field = $att['alias'] ? $tmp[1] : $tmp[0];

$fields[$field] = $att;

unset($tmp);
}
else
Expand All @@ -3105,7 +3101,8 @@ protected function parseAliases()
$att['table'] = $table;
$att['alias'] = $newField;
$att['__tableField'] = $newField;
$att['__tableFrom'] = "`#".$table."`.".$field." AS ".$newField;
// $att['__tablePath'] = $newField; ????!!!!!
$att['__tableFrom'] = "`#".$table."`.".$field;//." AS ".$newField;
}
elseif(isset($this->joinAlias[$this->table]) && $field !='checkboxes' && $field !='options')
{
Expand Down Expand Up @@ -3186,6 +3183,23 @@ protected function joinAlias()
}

}
elseif($this->tableJoin)
{
foreach ($this->tableJoin as $tbl => $data)
{
$matches = explode('.', $tbl, 2);
$this->joinAlias[$matches[1]] = $matches[0]; // array. eg $this->joinAlias['core_media'] = 'm';
//'user_name'=>'u.user_name'
if(isset($data['fields']) && $data['fields'] !== '*')
{
$tmp = explode(',', $data['fields']);
foreach ($tmp as $field)
{
$this->joinField[$field] = $matches[0].'.'.$field;
}
}
}
}

}

Expand Down Expand Up @@ -3247,9 +3261,9 @@ protected function _modifyListQry($raw = false, $isfilter = false, $forceFrom =
}

// select FROM... for main table
if($var['alias'] && vartrue($var['__tableFrom']))
if($var['alias'] && vartrue($var['__tableField']))
{
$tableSFieldsArr[] = $var['__tableFrom'];
$tableSFieldsArr[] = $var['__tableField'];
}

// filter for WHERE and FROM clauses
Expand Down Expand Up @@ -3566,6 +3580,12 @@ class e_admin_ui extends e_admin_controller_ui
* @var boolean
*/
public $deleteConfirmScreen = false;

/**
* Confirm screen custom message
* @var string
*/
public $deleteConfirmMessage = null;

/**
* Constructor
Expand Down Expand Up @@ -4430,8 +4450,11 @@ public function getConfirmDelete($ids, $ajax = false)
$forms = array();
$id_array = explode(',', $ids);
$delcount = count($id_array);

e107::getMessage()->addWarning(sprintf(LAN_UI_DELETE_WARNING, $delcount));

if(!empty($controller->deleteConfirmMessage))
e107::getMessage()->addWarning(sprintf($controller->deleteConfirmMessage, $delcount));
else
e107::getMessage()->addWarning(sprintf(LAN_UI_DELETE_WARNING, $delcount));

$fieldsets['confirm'] = array(
'fieldset_pre' => '', // markup to be added before opening fieldset element
Expand Down

0 comments on commit 909735d

Please sign in to comment.