Skip to content

Commit

Permalink
Issue #2794 Enhancement: Grid View toggle button for Admin-UI
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Sep 22, 2017
1 parent edfcdb8 commit c7e5af6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
16 changes: 15 additions & 1 deletion e107_admin/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ class media_admin extends e_admin_dispatcher


protected $adminMenuAliases = array(
'main/edit' => 'main/list'
'main/edit' => 'main/list',
'main/grid' => 'main/list'
);

protected $menuTitle = LAN_MEDIAMANAGER;
Expand All @@ -179,6 +180,8 @@ class media_cat_ui extends e_admin_ui

// protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}";



protected $fields = array(
//'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'nolist'=>true, 'forced'=> TRUE, 'readonly'=>TRUE),
Expand Down Expand Up @@ -635,6 +638,14 @@ function media_preview($curVal, $mode, $attributes, $id=null)
switch($mode)
{
case 'read':
if($this->getController()->getAction() === 'grid')
{
$tp = e107::getParser();
$img = $this->getController()->getFieldVar('media_url');
$size = 400;
return $tp->toImage($img, array('w'=>$size,'h'=>$size, 'crop'=>1));
}

$attributes['readParms'] = 'thumb=60&thumb_urlraw=0&thumb_aw=60';
$val = $this->getController()->getListModel()->get('media_url');
break;
Expand Down Expand Up @@ -743,6 +754,9 @@ class media_admin_ui extends e_admin_ui
public $deleteConfirmScreen = true;
public $deleteConfirmMessage = IMALAN_129;

protected $grid = array('title'=>'media_name', 'image'=>'media_preview', 'body'=>'', 'class'=>'col-md-2', 'perPage'=>12, 'carousel'=>false);



protected $preftabs = array(IMALAN_78,IMALAN_89, "Youtube");

Expand Down
3 changes: 3 additions & 0 deletions e107_core/templates/admin_icons_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@
define("ADMIN_TRUE_ICON", "<i class='fa fa-check text-success'></i>");
define("ADMIN_FALSE_ICON", "<i class='fa fa-times text-danger'></i>");
define("ADMIN_WARNING_ICON", "<i class='fa fa-warning text-warning'></i>");
define("ADMIN_GRID_ICON", "<i class='fa fa-th'></i>");
define("ADMIN_LIST_ICON", "<i class='fa fa-th-list'></i>");

/*
define("ADMIN_EDIT_ICON", "<i class='fa fa-edit fa-2x fa-fw'></i>");
define("ADMIN_DELETE_ICON", "<i class='fa fa-trash fa-2x fa-fw'></i>");
Expand Down
20 changes: 17 additions & 3 deletions e107_handlers/admin_ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -6580,7 +6580,7 @@ public function getConfirmDelete($ids, $ajax = false)
*/
public function renderPagination()
{
if($this->getController()->getGrid('carousel') === true)
if($this->getController()->getAction() === 'grid' && $this->getController()->getGrid('carousel') === true)
{
return '<div class="btn-group" >
<a id="admin-ui-carousel-prev" class="btn btn-default" href="#admin-ui-carousel" data-slide="prev"><i class="fa fa-backward"></i></a>
Expand Down Expand Up @@ -6651,6 +6651,19 @@ function renderFilter($current_query = array(), $location = '', $input_options =

// $tree = $this->getTree();
// $total = $this->getTotal();
$grid = $this->getController()->getGrid();
$gridToggle = '';

if(!empty($grid))
{
$gridAction = $this->getController()->getAction() === 'grid' ? 'list' : 'grid';
$gridQuery = (array) $_GET;
$gridQuery['action'] = $gridAction;
$toggleUrl = e_REQUEST_SELF."?".http_build_query($gridQuery);
$gridIcon = ($gridAction === 'grid') ? ADMIN_GRID_ICON : ADMIN_LIST_ICON;
$gridTitle = ($gridAction === 'grid') ? LAN_UI_VIEW_GRID_LABEL : LAN_UI_VIEW_LIST_LABEL;
$gridToggle = "<a class='btn btn-default' href='".$toggleUrl."' title=\"".$gridTitle."\">".$gridIcon."</a>";
}


$text = "
Expand All @@ -6672,15 +6685,16 @@ function renderFilter($current_query = array(), $location = '', $input_options =
<div class='e-autocomplete'></div>
".implode("\n", $filter_preserve_var)."
".$this->admin_button('etrigger_filter', 'etrigger_filter', 'filter e-hide-if-js', ADMIN_FILTER_ICON, array('id' => false,'title'=>LAN_FILTER))."
".$this->renderPagination()."
<span class='indicator' style='display: none;'>
<img src='".e_IMAGE_ABS."generic/loading_16.gif' class='icon action S16' alt='".LAN_LOADING."' />
</span>
".$gridToggle."
</div>
<div id='admin-ui-list-db-language' class='span4 col-md-4 text-right' >";


// Let Admin know which language table is being saved to. (avoid default table overwrites)
$text .= $this->renderLanguageTableInfo();

Expand Down
3 changes: 3 additions & 0 deletions e107_languages/English/admin/lan_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,6 @@
define("LAN_ERROR_CONNECTION","Unable to connect for updates. Please check firewall and/or internet connection.");

define("LAN_UI_X_CANT_EQUAL_Y", "[x] cannot be the same as [y]");
define("LAN_UI_VIEW_GRID_LABEL", "Grid view");
define("LAN_UI_VIEW_LIST_LABEL", "List view");

0 comments on commit c7e5af6

Please sign in to comment.