From 2977c7b9c38632e9d022c4c31c345d197ed5e27a Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 9 Apr 2017 18:03:25 -0700 Subject: [PATCH] Download plugin SEF-URLs currently a hybrid of old and new. More work needed. --- e107_plugins/download/download_shortcodes.php | 48 ++++++++++--------- e107_plugins/download/e_url.php | 37 ++++++++------ 2 files changed, 48 insertions(+), 37 deletions(-) diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index dae6f6076..a0fdf3f9c 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -48,9 +48,9 @@ class download_shortcodes extends e_shortcode switch ($this->qry['action']) { case 'mirror': - $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download/index')); - $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => e107::url('download/list/category', array('id'=>$this->var['download_category_id'],'name'=>$this->var['download_category_sef']))); // e_SELF."?action=list&id=".$this->var['download_category_id']); - $breadcrumb[] = array('text' => $this->var['download_name'], 'url' => e107::url('download/view/item', array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef']))); // e_SELF."?action=view&id=".$this->var['download_id']); + $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download', 'index')); + $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => e107::url('download', 'category', $this->var)); // e_SELF."?action=list&id=".$this->var['download_category_id']); + $breadcrumb[] = array('text' => $this->var['download_name'], 'url' => e107::url('download', 'item', $this->var)); // e_SELF."?action=view&id=".$this->var['download_id']); $breadcrumb[] = array('text' => LAN_dl_67, 'url' => null); break; @@ -63,19 +63,19 @@ class download_shortcodes extends e_shortcode if(!empty($this->grandparent)) { - $breadcrumb[] = array('text' => $this->grandparent['download_category_name'], 'url' => ($this->grandparent['download_category_id']) ? e107::url('download/list/category', array('id'=>$this->grandparent['download_category_id'],'name'=>$this->grandparent['download_category_sef'])) : null); + $breadcrumb[] = array('text' => $this->grandparent['download_category_name'], 'url' => ($this->grandparent['download_category_id']) ? e107::url('download', 'category', $this->grandparent) : null); // 'download/list/category', array('id'=>$this->grandparent['download_category_id'],'name'=>$this->grandparent['download_category_sef'])) : null); } if(!empty($this->parent)) { - $breadcrumb[] = array('text' => $this->parent['download_category_name'], 'url' => ($this->parent['download_category_id']) ? e107::url('download/list/category', array('id'=>$this->parent['download_category_id'],'name'=>$this->parent['download_category_sef'])) : null); + $breadcrumb[] = array('text' => $this->parent['download_category_name'], 'url' => ($this->parent['download_category_id']) ? e107::url('download', 'category', $this->parent) : null); // e107::url('download/list/category', array('id'=>$this->parent['download_category_id'],'name'=>$this->parent['download_category_sef'])) : null); } - $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => ($this->var['download_category_id']) ? e107::url('download/list/category', array('id'=>$this->var['download_category_id'],'name'=>$this->var['download_category_sef'])) : null); + $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null); // e107::url('download/list/category', array('id'=>$this->var['download_category_id'],'name'=>$this->var['download_category_sef'])) : null); $breadcrumb[] = array('text' => $this->var['download_name'], 'url' => null); break; } - + return $frm->breadcrumb($breadcrumb); } @@ -111,7 +111,7 @@ class download_shortcodes extends e_shortcode if ($this->dlsubrow['d_count']) { - $url = e107::url('download/list/category',array('id'=>$this->dlsubrow['download_category_id'], 'name'=> vartrue($this->dlsubrow['download_category_sef'],'--sef-not-set--'))); + $url = e107::url('download', 'category', $this->dlsubrow); return "".$tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE').""; // return "".$tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE').""; @@ -167,7 +167,7 @@ class download_shortcodes extends e_shortcode $tp = e107::getParser(); if ($this->dlsubsubrow['d_count']) { - $url = e107::url('download/list/category', array('id'=>$this->dlsubsubrow['download_category_id'], 'name'=> vartrue($this->dlsubsubrow['download_category_sef'],'--sef-not-set--'))); + $url = e107::url('download', 'category', $this->dlsubsubrow); // /list/category', array('id'=>$this->dlsubsubrow['download_category_id'], 'name'=> vartrue($this->dlsubsubrow['download_category_sef'],'--sef-not-set--'))); // e_PLUGIN_ABS."download/download.php?action=list&id=".$this->dlsubsubrow['download_category_id'] return "".$tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE').""; } @@ -292,7 +292,7 @@ class download_shortcodes extends e_shortcode return $text; } - $url = e107::url('download/view/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); + $url = e107::url('download', 'item', $this->var); return "".$tp->toHTML($this->var['download_name'],TRUE,'LINKTEXT').""; // return "".$tp->toHTML($this->var['download_name'],TRUE,'LINKTEXT').""; @@ -352,7 +352,7 @@ class download_shortcodes extends e_shortcode if ($parm == "link" && $this->var['download_thumb']) { - $url = e107::url('download/view/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); + $url = e107::url('download', 'item', $this->var); return "".$img.""; // return "".$img.""; } @@ -403,7 +403,7 @@ class download_shortcodes extends e_shortcode function sc_download_request_url($parm=null) { - return e107::url('download/request/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); + return e107::url('download', 'get', $this->var); // /request/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); } @@ -417,7 +417,7 @@ class download_shortcodes extends e_shortcode { if ($parm == "link") { - $url = e107::url('download/view/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); + $url = e107::url('download', 'item', $this->var); return "".$img.""; // return "".$img.""; } @@ -440,7 +440,7 @@ class download_shortcodes extends e_shortcode if($parm == "link" && $this->var['download_image']) { - $url = e107::url('download/view/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); + $url = e107::url('download', 'item', $this->var); return "".$img.""; // return "".$img.""; @@ -510,7 +510,7 @@ class download_shortcodes extends e_shortcode { $tp = e107::getParser(); - $viewUrl = e107::url('download/view/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); + $viewUrl = e107::url('download', 'item', $this->var); $requestUrl = $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true,$this); // $this->sc_download_request_url(); $link['view'] = "".$this->var['download_name'].""; @@ -605,6 +605,7 @@ class download_shortcodes extends e_shortcode { $tp = e107::getParser(); + $url = e107::url('download', 'get', $this->var); if($this->var['download_thumb']) { @@ -614,11 +615,12 @@ class download_shortcodes extends e_shortcode ); $image = $tp->toImage($this->var['download_thumb'], $opts); - return ($this->var['download_image'] ? "" . $image . "" : $image); + + return ($this->var['download_image'] ? "" . $image . "" : $image); } elseif($this->var['download_image']) { - return "" . LAN_dl_40 . ""; + return "" . LAN_dl_40 . ""; } else { @@ -902,8 +904,8 @@ class download_shortcodes extends e_shortcode { $dlrowrow = $sql->fetch(); - $url = e107::url('download/view/item',array('id'=>$dlrowrow['download_id'], 'name'=>$dlrowrow['download_sef'])); - + $url = e107::url('download', 'item', $dlrowrow); + $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('chevron-left') : '<<'; return "".$icon." ".LAN_PREVIOUS."\n"; @@ -929,7 +931,7 @@ class download_shortcodes extends e_shortcode { $dlrowrow = $sql->fetch(); extract($dlrowrow); - $url = e107::url('download/view/item', array('id'=>$dlrowrow['download_id'], 'name'=>$dlrowrow['download_sef'])); + $url = $url = e107::url('download', 'item', $dlrowrow); $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('chevron-right') : '>>'; @@ -948,7 +950,7 @@ class download_shortcodes extends e_shortcode */ function sc_download_back_to_list($parm) { - $url = e107::url('download/list/category', array('id'=>$this->var['download_category_id'],'name'=>$this->var['download_category_sef'])); + $url = e107::url('download', 'category', $this->var); // e_PLUGIN_ABS."download/download.php?action=list&id=".$this->var['download_category'] $title = "Back to [x]"; @@ -961,11 +963,11 @@ class download_shortcodes extends e_shortcode { if(!empty($this->parent)) { - $link = e107::url('download/list/category', array('id'=>$this->parent['download_category_id'],'name'=>$this->parent['download_category_sef'])); + $link = e107::url('download', 'category', $this->parent); } else { - $link = ($this->var['download_category_id']) ? e107::url('download/list/category', array('id'=>$this->var['download_category_id'],'name'=>$this->var['download_category_sef'])) : null; + $link = ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null; } return "".LAN_dl_9.""; diff --git a/e107_plugins/download/e_url.php b/e107_plugins/download/e_url.php index 2f07a6e95..b00babba8 100644 --- a/e107_plugins/download/e_url.php +++ b/e107_plugins/download/e_url.php @@ -24,33 +24,42 @@ class download_url // plugin-folder + '_url' public $alias = 'download'; - function config() + function config($profile=null) + { + $config = $this->profile1(); + + return $config; + } + + + function profile1() { $config = array(); - $config['index'] = array( - // 'regex' => '^download/?$', // matched against url, and if true, redirected to 'redirect' below. - 'alias' => 'download', - 'sef' => '{alias}', // used by e107::url(); to create a url from the db table. - 'redirect' => '{e_PLUGIN}download/download.php', // file-path of what to load when the regex returns true. - - ); - $config['category'] = array( - + 'sef' => '{alias}/category/{download_category_id}/{download_category_sef}/', ); $config['item'] = array( - - + 'sef' => '{alias}/{download_id}/{download_sef}' ); $config['get'] = array( - - + 'regex' => '^{alias}/get/([\d]*)/(.*)$', + 'sef' => '{alias}/get/{download_id}/{download_sef}', + 'redirect' => '{e_PLUGIN}download/request.php?id=$1', // file-path of what to load when the regex returns true. ); + + $config['index'] = array( + // 'regex' => '^download/?$', + 'alias' => 'download', + 'sef' => '{alias}', + 'redirect' => '{e_PLUGIN}download/download.php', + ); + + return $config; }