From 1b1de9cda750fb376888c1c51bd4ddd636269dee Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 10 Apr 2017 13:29:05 -0700 Subject: [PATCH] Issue #2486 - Downloads templatea fix. Breadcrumb fix. Replacement e_url profile added. --- e107_plugins/download/download_shortcodes.php | 4 +- e107_plugins/download/e_url.php | 80 ++++++++++++++++--- .../download/handlers/download_class.php | 9 +++ .../download/templates/download_template.php | 4 +- 4 files changed, 81 insertions(+), 16 deletions(-) diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index a0fdf3f9c..8ade9d3df 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -55,11 +55,11 @@ class download_shortcodes extends e_shortcode break; case 'maincats': - $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download/index')); + $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download','index')); break; default: - $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download/index')); + $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download','index')); if(!empty($this->grandparent)) { diff --git a/e107_plugins/download/e_url.php b/e107_plugins/download/e_url.php index b00babba8..f610edd9f 100644 --- a/e107_plugins/download/e_url.php +++ b/e107_plugins/download/e_url.php @@ -24,39 +24,95 @@ class download_url // plugin-folder + '_url' public $alias = 'download'; + /** + * Support for different URL profiles (optional) + * @return array + */ + public $profiles = array( + 'default' => array('label' => 'Friendly Default', 'examples' => array('{SITEURL}download/category/3/my-category-name')), + 'non-numeric' => array('label' => 'Friendly (experimental)', 'examples' => array('{SITEURL}download/my-category/my-sub-category/my-file-name')), + ); + + function config($profile=null) { - $config = $this->profile1(); + + switch($profile) + { + case "non-numeric": + $config = $this->profile2(); + break; + + case "default": + default: + $config = $this->profile1(); + + } return $config; } - function profile1() + + + private function profile2() + { + $config = $this->profile1(); + + $config['subcategory'] = array( + 'regex' => '^{alias}/([^\/]*)/([^\/]*)/?$', + 'redirect' => '{e_PLUGIN}vstore/vstore.php?catsef=$2', + 'sef' => '{alias}/{cat_sef}/{subcat_sef}' + ); + + + $config['category'] = array( + 'regex' => '^{alias}/category/([\d]*)/(.*)$', + 'redirect' => '{e_PLUGIN}download/download.php?action=list&id=$1', + 'sef' => '{alias}/{download_category_sef}', + ); + + + return $config; + } + + + private function profile1() { $config = array(); - $config['category'] = array( +/* - 'sef' => '{alias}/category/{download_category_id}/{download_category_sef}/', + $config['subcategory'] = array( + 'regex' => '^{alias}/([^\/]*)/([^\/]*)/?$', + 'redirect' => '{e_PLUGIN}vstore/vstore.php?catsef=$2', + 'sef' => '{alias}/{cat_sef}/{subcat_sef}' + ); +*/ + + $config['category'] = array( + 'regex' => '^{alias}/category/([\d]*)/(.*)$', + 'redirect' => '{e_PLUGIN}download/download.php?action=list&id=$1', + 'sef' => '{alias}/category/{download_category_id}/{download_category_sef}/', ); $config['item'] = array( - 'sef' => '{alias}/{download_id}/{download_sef}' + 'regex' => '^{alias}/([\d]*)/(.*)$', + 'redirect' => '{e_PLUGIN}download/download.php?action=view&id=$1', + '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. + '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', + 'regex' => '{alias}/?$', + 'sef' => '{alias}', + 'redirect' => '{e_PLUGIN}download/download.php', ); diff --git a/e107_plugins/download/handlers/download_class.php b/e107_plugins/download/handlers/download_class.php index 465791ad1..92a87f929 100644 --- a/e107_plugins/download/handlers/download_class.php +++ b/e107_plugins/download/handlers/download_class.php @@ -412,6 +412,15 @@ class download } $dlrow = $sql->fetch(); + + $sc->parent = $this->getParent($dlrow['download_category_id']); + + if(!empty( $sc->parent['download_category_parent'])) + { + $sc->grandparent = $this->getParent( $sc->parent['download_category_id']); + } + + $sc->setVars($dlrow); $this->setMeta($dlrow); diff --git a/e107_plugins/download/templates/download_template.php b/e107_plugins/download/templates/download_template.php index 4bcf2fa8f..2d924b589 100644 --- a/e107_plugins/download/templates/download_template.php +++ b/e107_plugins/download/templates/download_template.php @@ -401,8 +401,8 @@ $DOWNLOAD_TEMPLATE['categories']['subchild'] = " {DOWNLOAD_CAT_SUBSUB_ICON} -
- {DOWNLOAD_CAT_SUBSUB_NEW_ICON} {DOWNLOAD_CAT_SUBSUB_NAME}
+
+ {DOWNLOAD_CAT_SUBSUB_NEW_ICON} {DOWNLOAD_CAT_SUBSUB_NAME}
{DOWNLOAD_CAT_SUBSUB_DESCRIPTION}