1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

Admin-ui: Carousel option added for use with Grid.

This commit is contained in:
Cameron 2017-04-05 12:42:42 -07:00
parent e17316eab7
commit 674fde0525
6 changed files with 173 additions and 65 deletions

View File

@ -2789,8 +2789,14 @@ class e_admin_controller_ui extends e_admin_controller
public function getPerPage()
{
if($this->getAction() === 'grid')
{
if($this->getGrid('carousel') === true)
{
return 0;
}
return $this->getGrid('perPage');
}
@ -2805,7 +2811,6 @@ class e_admin_controller_ui extends e_admin_controller
return $this->grid[$key];
}
return $this->grid;
}
@ -6526,6 +6531,21 @@ class e_admin_form_ui extends e_form
return $this->renderForm($forms, $ajax);
}
public function renderPagination()
{
if($this->getController()->getGrid('carousel') === true)
{
return '<div class="btn-group" >
<a class="btn btn-default" href="#admin-ui-carousel" data-slide="prev"><i class="fa fa-backward"></i></a>
<a id="admin-ui-carousel-index" class="btn btn-default">1</a>
<a class="btn btn-default" href="#admin-ui-carousel" data-slide="next"><i class="fa fa-forward"></i></a>
</div>';
}
}
function renderFilter($current_query = array(), $location = '', $input_options = array())
{
if(!$input_options) $input_options = array('size' => 20);
@ -6604,6 +6624,7 @@ class e_admin_form_ui extends e_form
".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->pagination(e_REQUEST_SELF.'?'.$paginate,$totalRecords,$fromPage,$perPage,array('template'=>'basic'))."
".$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>
@ -6855,20 +6876,21 @@ class e_admin_form_ui extends e_form
$text .= "<div class='input-group-btn input-append'>
".$this->admin_button('e__execute_batch', 'e__execute_batch', 'batch e-hide-if-js', LAN_GO, array('id' => false))."
</div>";
$text .= "</div></div>";
}
$text .= "</div>";
$text .= "</div></div>
";
}
$text .= "
</div>
<div id='admin-ui-list-total-records' class='span6 col-md-6 right'><span>".e107::getParser()->lanVars(LAN_UI_TOTAL_RECORDS,number_format($this->listTotal))."</span></div>
</div>
";
return $text;
}

View File

@ -4003,8 +4003,11 @@ class e_parser
// e107::getDebug()->log($file);
// e107::getDebug()->log($parm);
if(strpos($file,'e_MEDIA')!==false || strpos($file,'e_THEME')!==false || strpos($file,'e_PLUGIN')!==false || strpos($file,'{e_IMAGE}')!==false) //v2.x path.
if(strpos($file,'http')===0)
{
$path = $file;
}
elseif(strpos($file,'e_MEDIA')!==false || strpos($file,'e_THEME')!==false || strpos($file,'e_PLUGIN')!==false || strpos($file,'{e_IMAGE}')!==false) //v2.x path.
{
if(!isset($parm['w']) && !isset($parm['h']))
@ -4031,10 +4034,6 @@ class e_parser
}
}
elseif(strpos($file,'http')===0)
{
$path = $file;
}
elseif($file[0] === '{') // Legacy v1.x path. Example: {e_PLUGIN}myplugin/images/fixedimage.png
{
$path = $tp->replaceConstants($file,'abs');

View File

@ -590,9 +590,11 @@ class e_form
*/
function carousel($name="e-carousel", $array, $options = null)
{
$interval = null;
$wrap = null;
$pause = null;
$interval = null;
$wrap = null;
$pause = null;
$indicators = '';
$controls = '';
$act = varset($options['default'], 0);
@ -611,14 +613,14 @@ class e_form
$interval = 'data-pause="'.$options['pause'].'"';
}
$text ='
$start ='
<!-- Carousel -->
<div id="'.$name.'" class="carousel slide" data-ride="carousel" '.$interval.' '.$wrap.' '.$pause.'>';
if(count($array) > 1)
{
$text .= '
$indicators = '
<!-- Indicators -->
<ol class="carousel-indicators">
';
@ -627,15 +629,15 @@ class e_form
foreach($array as $key=>$tab)
{
$active = ($c == $act) ? ' class="active"' : '';
$text .= '<li data-target="#'.$name.'" data-slide-to="'.$c.'" '.$active.'></li>';
$indicators .= '<li data-target="#'.$name.'" data-slide-to="'.$c.'" '.$active.'></li>';
$c++;
}
$text .= '
$indicators .= '
</ol>';
}
$text .= '
$inner = '
<div class="carousel-inner">
';
@ -645,24 +647,24 @@ class e_form
foreach($array as $key=>$tab)
{
$active = ($c == $act) ? ' active' : '';
$text .= '<div class="item'.$active.'" id="'.$key.'">';
$text .= $tab['text'];
$inner .= '<div class="item'.$active.'" id="'.$key.'">';
$inner .= $tab['text'];
if(!empty($tab['caption']))
{
$text .= '<div class="carousel-caption">'.$tab['caption'].'</div>';
$inner .= '<div class="carousel-caption">'.$tab['caption'].'</div>';
}
$text .= '</div>';
$inner .= '</div>';
$c++;
}
$text .= '
$inner .= '
</div>';
if(count($array) > 1)
{
$text .= '
$controls = '
<a class="left carousel-control" href="#'.$name.'" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
@ -671,9 +673,20 @@ class e_form
</a>';
}
$text .= '</div><!-- End Carousel -->';
$end = '</div><!-- End Carousel -->';
return $text;
if(!empty($options['data']))
{
return array(
'start' => $start,
'indicators' => $indicators,
'inner' => $inner,
'controls' => $controls,
'end' => $end
);
}
return $start.$indicators.$inner.$controls.$end; // $text;
}
@ -5865,6 +5878,41 @@ class e_form
}
/**
* Used with 'carousel' generates slides with X number of cells/blocks per slide.
* @param $cells
* @param int $perPage
* @return array
*/
private function slides($cells, $perPage=12)
{
$tmp = '';
$s = 0;
$slides = array();
foreach($cells as $cell)
{
$tmp .= $cell;
$s++;
if($s == $perPage)
{
$slides[] = array('text'=>$tmp);
$tmp = '';
$s = 0;
}
}
if($s != $perPage)
{
$slides[] = array('text'=>$tmp);
}
return $slides;
}
/**
* Render Grid-list layout. used internally by admin UI
* @param $form_options
@ -5907,7 +5955,10 @@ class e_form
$text .= "
<form method='post' action='{$formurl}' id='{$elid}-list-form'>
<div>".$this->token()."
".vartrue($options['fieldset_pre'])."
".vartrue($options['fieldset_pre']);
$text .= "
<fieldset id='{$elid}-list'>
<legend class='{$legend_class}'>".$options['legend']."</legend>
".vartrue($options['table_pre'])."
@ -5943,14 +5994,17 @@ class e_form
$cls = !empty($options['grid']['class']) ? $options['grid']['class'] : 'col-md-2';
$pid = $options['pid'];
$perPage = $options['grid']['perPage'];
$gridFields = $options['grid'];
$gridFields['options'] = 'options';
$gridFields['checkbox'] = 'checkboxes';
unset($gridFields['class'],$gridFields['perPage']);
unset($gridFields['class'],$gridFields['perPage'], $gridFields['carousel']);
$cells = array();
foreach($tree as $model)
{
e107::setRegistry('core/adminUI/currentListModel', $model);
@ -5967,12 +6021,25 @@ class e_form
$vars[$key] = $this->renderValue($v,$data[$v],$fields[$v],$id);
}
$text .= "<div class='".$cls." admin-ui-grid'>";
$text .= $tp->simpleParse($template,$vars);
$text .= "</div>";
$cells[] = "<div class='".$cls." admin-ui-grid'>". $tp->simpleParse($template,$vars). "</div>";
}
if($options['grid']['carousel'] === true)
{
$slides = $this->slides($cells, $perPage);
$carouselData = $this->carousel('admin-ui-carousel',$slides, array('wrap'=>false, 'interval'=>false, 'data'=>true));
$text .= $carouselData['start'].$carouselData['inner'].$carouselData['end'];
}
else
{
$text .= implode("\n",$cells);
}
e107::setRegistry('core/adminUI/currentListModel', null);
$text .= "</div>

View File

@ -869,6 +869,17 @@ class themeHandler
$this->fl = e107::getFile();
$this->postObserver();
}
public function postObserver()
{
$mes = e107::getMessage();
$pref = e107::getPref();
if(!empty($_POST['upload']))
{
$unzippedTheme = $this->themeUpload();
@ -878,12 +889,12 @@ class themeHandler
{
$this->curTheme = e107::getParser()->filter($_POST['curTheme'],'file');
}
if(!empty($_POST['setUploadTheme']) && !empty($unzippedTheme))
if(!empty($_POST['setUploadTheme']) && !empty($unzippedTheme))
{
$themeArray = $this->getThemes();
$this->id = $themeArray[$unzippedTheme]['id'];
if($this->setTheme())
{
$mes->addSuccess(TPVLAN_3);
@ -892,19 +903,19 @@ class themeHandler
{
$mes->addError(TPVLAN_86);
}
}
if(!empty($_POST['installContent']))
{
$this->installContent($_POST['installContent']);
$this->installContent($_POST['installContent']);
}
$this->themeArray = (defined('E107_INSTALL')) ? $this->getThemes('xml') : $this->getThemes();
// print_a($this -> themeArray);
foreach ($_POST as $key=>$post)
{
if(strstr($key, "preview"))
@ -926,7 +937,7 @@ class themeHandler
$mes->addError(TPVLAN_3);
}
}
if(strstr($key, "selectadmin"))
{
$this->id = key($post);
@ -935,7 +946,7 @@ class themeHandler
}
}
if(isset($_POST['submit_adminstyle']))
{
$this->id = $this->curTheme;
@ -945,17 +956,17 @@ class themeHandler
}
e107::getConfig()->save(true);
}
if(isset($_POST['submit_style']))
{
$this->id = $this->curTheme;
$this->setLayouts(); // Update the layouts in case they have been manually changed.
$this->setLayouts(); // Update the layouts in case they have been manually changed.
$this->SetCustomPages($_POST['custompages']);
$this->setStyle();
e107::getConfig()->save(true);
}
if(!empty($_POST['git_pull']))
@ -963,19 +974,19 @@ class themeHandler
$return = e107::getFile()->gitPull($this->curTheme, 'theme');
$mes->addSuccess($return);
}
if(isset($_POST['installplugin']))
{
$key = key($_POST['installplugin']);
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_plugin.php");
require_once (e_HANDLER."plugin_class.php");
$eplug = new e107plugin;
$message = $eplug->install_plugin($key);
$mes->add($message, E_MESSAGE_SUCCESS);
}
if(isset($_POST['setMenuPreset']))
{
$key = key($_POST['setMenuPreset']);
@ -985,9 +996,11 @@ class themeHandler
$men->curLayout = $key;
//menu_layout is left blank when it's default.
$men->dbLayout = ($men->curLayout != $pref['sitetheme_deflayout']) ? $men->curLayout : "";
if($areas = $men->menuSetPreset())
{
$message = '';
foreach ($areas as $val)
{
$ar[$val['menu_location']][] = $val['menu_name'];
@ -996,15 +1009,14 @@ class themeHandler
{
$message .= MENLAN_14." ".$k." : ".implode(", ", $v)."<br />";
}
$mes->add(MENLAN_43." : ".$key."<br />".$message, E_MESSAGE_SUCCESS);
}
}
}
}
function getThemes($mode = FALSE)
{
@ -1605,7 +1617,7 @@ class themeHandler
</form>
";
}
$ns->tablerender(TPVLAN_26.SEP.TPVLAN_38, $mes->render().$text);
}
@ -1930,6 +1942,8 @@ class themeHandler
$info_icon = "<a class='btn btn-default btn-small btn-sm btn-inverse e-modal' data-modal-caption=\"".$theme['name']." ".$theme['version']."\" href='".e_SELF."?mode=".$_GET['mode']."&id=".$theme['path']."&action=info' title='".TPVLAN_7."'>".$tp->toGlyph('fa-info-circle',array('size'=>'2x'))."</a>";
// $preview_icon = "<a title='Preview : ".$theme['name']."' rel='external' class='e-dialog' href='".e_BASE."index.php?themepreview.".$theme['id']."'>".E_32_SEARCH."</a>";
$admin_icon = ($pref['admintheme'] != $theme['path'] ) ? "<button class='btn btn-default btn-small btn-sm btn-inverse' type='submit' name='selectadmin[".$theme['id']."]' alt=\"".TPVLAN_32."\" title=\"".TPVLAN_32."\" >".$tp->toGlyph('fa-gears',array('size'=>'2x'))."</button>" : "<button class='btn btn-small btn-default btn-sm btn-inverse' type='button'>".$tp->toGlyph('fa-check',array('size'=>'2x'))."</button>";
$price = '';
@ -2075,9 +2089,11 @@ class themeHandler
// load customn theme configuration fields.
$this->loadThemeConfig();
$text = "
<h2 class='caption'>".$theme['name']."</h2>
$text = '';
// $text .= "<h2 class='caption'>".$theme['name']."</h2>";
$text .= "
<ul class='nav nav-tabs'>
<li class='active'><a data-toggle='tab' href='#core-thememanager-configure'>".LAN_CONFIGURE."</a></li>";

View File

@ -74,7 +74,7 @@ a.core-mainpanel-link-icon:hover { text-decoration: none; filter: none; }
.e-overlay .thumbnail { margin:0; }
.admin-ui-grid img.fallback { opacity: 0.3; }
#admin-ui-carousel .carousel-inner { min-height: 65vh; }

View File

@ -720,7 +720,11 @@ $(document).ready(function()
// $(".e-spinner").spinner(); //FIXME breaks tooltips
$('.carousel').on('slid.bs.carousel', function () {
var currentIndex = $(this).find('.active').index();
var text = (currentIndex + 1);
$('#admin-ui-carousel-index').text(text);
});
//check all
$("#check-all").click(function(event){