From 50ff6736a352333a3f91c1274d9020584f85760a Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 20 Nov 2017 10:16:37 -0800 Subject: [PATCH] Custom Menus 'grid' view added. Admin theme stylesheets relabeled as "Skins" --- e107_admin/cpage.php | 27 +++++-- e107_handlers/form_handler.php | 8 ++- e107_handlers/theme_handler.php | 4 +- e107_languages/English/admin/lan_theme.php | 1 + e107_plugins/gallery/admin_gallery.php | 82 ++++++++++++++++++---- e107_themes/bootstrap3/theme.xml | 2 +- 6 files changed, 104 insertions(+), 20 deletions(-) diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index 2ef3d7644..5fb8d9ed7 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -84,6 +84,7 @@ class page_admin extends e_admin_dispatcher 'overview/edit' => 'overview/list', 'page/edit' => 'page/list', 'menu/edit' => 'menu/create', + 'menu/grid' => 'menu/list', 'cat/edit' => 'cat/list' ); @@ -552,7 +553,13 @@ class page_admin_ui extends e_admin_ui protected $url = array('route'=>'page/view/index', 'vars' => array('id' => 'page_id', 'name' => 'page_sef', 'other' => 'page_sef', 'chapter' => 'chapter_sef', 'book' => 'book_sef'), 'name' => 'page_title', 'description' => ''); // 'link' only needed if profile not provided. protected $tabs = array(CUSLAN_59,CUSLAN_60,CUSLAN_61,CUSLAN_62); protected $featurebox = array('name'=>'page_title', 'description'=>'page_text', 'image' => 'menu_image', 'visibility' => 'page_class', 'url' => true); - + + + protected $grid = array('title'=>'menu_title', 'image'=>'menu_image', 'body'=>'', 'class'=>'col-md-2', 'perPage'=>12, 'carousel'=>false); + + + + /* * 'fb_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'inline'=>true, 'width' => 'auto', 'thclass' => 'left'), 'fb_text' => array('title'=> FBLAN_08, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1','writeParms'=>'template=admin'), @@ -633,7 +640,15 @@ class page_admin_ui extends e_admin_ui function init() { - if($this->getMode() === 'overview') + $mode = $this->getMode(); + + + if($mode !== 'menu') + { + $this->grid = array(); + } + + if($mode === 'overview') { $this->listQry = "SELECT SQL_CALC_FOUND_ROWS p.*,u.user_id,u.user_name FROM #page AS p LEFT JOIN #user AS u ON p.page_author = u.user_id "; // without any Order or Limit. $this->fieldpref = array("page_id", "page_title", 'page_chapter', 'page_template', "menu_title", 'menu_image', 'menu_template' ); @@ -684,11 +699,11 @@ class page_admin_ui extends e_admin_ui } // USED IN Menu LIST/INLINE-EDIT MODE ONLY. - if($this->getMode() === 'menu' && ($this->getAction() == 'list' || $this->getAction() == 'inline')) + if($this->getMode() === 'menu' && ($this->getAction() == 'list' || $this->getAction() == 'inline' || $this->getAction() == 'grid')) { $this->listQry = "SELECT SQL_CALC_FOUND_ROWS p.*,u.user_id,u.user_name FROM #page AS p LEFT JOIN #user AS u ON p.page_author = u.user_id WHERE (p.menu_name != '' OR p.menu_image != '' OR p.menu_icon !='') "; // without any Order or Limit. - + // $this->gridQry = $this->listQry; $this->listOrder = 'p.page_order asc'; // 'p.page_id desc'; $this->batchDelete = false; @@ -724,7 +739,11 @@ class page_admin_ui extends e_admin_ui $this->fields['menu_name']['inline'] = true; } + if($this->getAction() == 'grid') + { + $this->fields['menu_image']['readParms'] = 'thumb=400x400'; + } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 775c50abc..165f65687 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -4741,8 +4741,12 @@ class e_form $value = $tmp[0]; unset($tmp); } - - + + if(empty($parms['thumb_aw']) && !empty($parms['thumb']) && strpos($parms['thumb'],'x')!==false) + { + list($parms['thumb_aw'],$parms['thumb_ah']) = explode('x',$parms['thumb']); + } + $vparm = array('thumb'=>'tag','w'=> vartrue($parms['thumb_aw'],'80')); if($video = e107::getParser()->toVideo($value,$vparm)) diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index c2bb15344..4fecb4b6a 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -2354,8 +2354,10 @@ class themeHandler if(array_key_exists("multipleStylesheets", $theme) && $mode && !empty($theme['css'])) { + $pLabel = (self::RENDER_ADMINPREFS === $mode) ? TPVLAN_95 : TPVLAN_22; + $text .= " - ".TPVLAN_22.": + ".$pLabel.": diff --git a/e107_languages/English/admin/lan_theme.php b/e107_languages/English/admin/lan_theme.php index ac782e3ef..248ef4ffe 100644 --- a/e107_languages/English/admin/lan_theme.php +++ b/e107_languages/English/admin/lan_theme.php @@ -129,4 +129,5 @@ define("TPVLAN_92", "New Theme Folder"); define("TPVLAN_93", "Selection"); define("TPVLAN_94", "Site theme changed to [x]."); +define("TPVLAN_95", "Skin"); diff --git a/e107_plugins/gallery/admin_gallery.php b/e107_plugins/gallery/admin_gallery.php index e09741bdb..eb37abb11 100644 --- a/e107_plugins/gallery/admin_gallery.php +++ b/e107_plugins/gallery/admin_gallery.php @@ -83,7 +83,9 @@ class plugin_gallery_admin extends e_admin_dispatcher * @var array */ protected $adminMenu = array( - 'main/prefs' => array('caption' => LAN_PREFS, 'perm' => 'P') + 'main/prefs' => array('caption' => LAN_PREFS, 'perm' => 'P'), + 'main/list' => array('caption' => LAN_CATEGORIES, 'perm' => 'P'), + 'main/create' => array('caption' => LAN_CREATE, 'perm' => 'P'), ); /** @@ -98,6 +100,7 @@ class plugin_gallery_admin extends e_admin_dispatcher */ function init() { + if(E107_DEBUG_LEVEL > 0) { $this->adminMenu['main/list'] = array( @@ -214,6 +217,7 @@ class gallery_cat_admin_ui extends e_admin_ui 'width' => 'auto', 'thclass' => 'left', 'readonly' => false, + 'inline' => true, ), 'media_cat_sef' => array( 'title' => LAN_SEFURL, @@ -538,6 +542,8 @@ class gallery_cat_admin_ui extends e_admin_ui ), ); + private $ownerCount; + /** * Initial function. */ @@ -571,24 +577,76 @@ class gallery_cat_admin_ui extends e_admin_ui $message = $tp->lanVars(LAN_GALLERY_ADMIN_01, array($x, $y), true); $mes->addInfo($message); + + $this->setGalleryCount(); } - /** - * User defined pre-create logic, return false to prevent DB query execution. - * - * @param $new_data - * Posted data. - * @param $old_data - * - * @return boolean - */ + + + function setGalleryCount() + { + + $sql = e107::getDb(); + + if($sql->gen("SELECT media_cat_owner, MAX(CAST(SUBSTRING_INDEX(media_cat_category, '_', -1 ) AS UNSIGNED)) as maxnum, count(media_cat_id) as number FROM `#core_media_cat` GROUP BY media_cat_owner")) + { + while($row = $sql->fetch()) + { + $this->ownerCount[$row['media_cat_owner']] = $row['number']; + $own = $row['media_cat_owner']; + // if(!in_array($own,$this->restricted)) + { +// $this->fields['media_cat_owner']['writeParms'][$own] = $own; + + if($row['maxnum'] > 0) + { + $this->ownerCount[$row['media_cat_owner']] = $row['maxnum']; // $maxnum; + } + } + } + } + + e107::getMessage()->addDebug("Max value for category names: ".print_a($this->ownerCount,true)); + + + + + } + + public function beforeCreate($new_data, $old_data) { - $replace = array("_", " ", "'", '"', "."); // FIXME Improve. - $new_data['media_cat_category'] = strtolower(str_replace($replace, "", $new_data['media_cat_title'])); + $new_data = $this->setCategory($new_data); + return $new_data; } + + public function beforeUpdate($new_data, $old_data, $id) + { + // $new_data = $this->setCategory($new_data); + + return $new_data; + } + + private function setCategory($new_data) + { + $type = 'image_'; + + $increment = ($this->ownerCount['gallery'] +1); + + $new_data['media_cat_owner'] = 'gallery'; + $new_data['media_cat_category'] = 'gallery_'.$type.$increment; + + if(empty($new_data['media_cat_sef'])) + { + $new_data['media_cat_sef'] = eHelper::title2sef($new_data['media_cat_title']); + } + + return $new_data; + } + + function galleryPage() { $mes = e107::getMessage(); diff --git a/e107_themes/bootstrap3/theme.xml b/e107_themes/bootstrap3/theme.xml index 60cb72992..804b884d2 100644 --- a/e107_themes/bootstrap3/theme.xml +++ b/e107_themes/bootstrap3/theme.xml @@ -24,7 +24,7 @@ - +