diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 77e177b0f..2aba8bf6b 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -10,7 +10,7 @@ * */ -if(!defined('e107_INIT')) +if (!defined('e107_INIT')) { exit(); } @@ -97,19 +97,19 @@ class e_parse 'link_replace' => true, // Parse shortcodes - TRUE enables parsing - 'parse_sc' => false, + 'parse_sc' => false, // remove HTML tags. - 'no_tags' => false, + 'no_tags' => false, // Restore entity form of quotes and such to single characters - TRUE disables - 'value' => false, + 'value' => false, // Line break compression - TRUE removes newline characters - 'nobreak' => false, + 'nobreak' => false, // Retain newlines - wraps to \n instead of
if TRUE (for non-HTML email text etc) - 'retain_nl' => false + 'retain_nl' => false ); // Super modifiers override default option values @@ -178,10 +178,10 @@ class e_parse array( 'nobreak' => true, 'retain_nl' => true, 'link_click' => false, 'emotes' => false, 'hook' => false, 'no_tags' => true ), - 'NODEFAULT' => - array ('context' => false, 'fromadmin' => false, 'emotes' => false, 'defs' => false, 'constants' => false, 'hook' => false, - 'scripts' => false, 'link_click' => false, 'link_replace' => false, 'parse_sc' => false, 'no_tags' => false, 'value' => false, - 'nobreak' => false, 'retain_nl' => false + 'NODEFAULT' => + array('context' => false, 'fromadmin' => false, 'emotes' => false, 'defs' => false, 'constants' => false, 'hook' => false, + 'scripts' => false, 'link_click' => false, 'link_replace' => false, 'parse_sc' => false, 'no_tags' => false, 'value' => false, + 'nobreak' => false, 'retain_nl' => false ) ); @@ -251,11 +251,11 @@ class e_parse private $bootstrap; private $fontawesome; - private $removedList = array(); - private $nodesToDelete = array(); - private $nodesToConvert = array(); + private $removedList = array(); + private $nodesToDelete = array(); + private $nodesToConvert = array(); private $nodesToDisableSC = array(); - private $pathList = array(); + private $pathList = array(); private $allowedAttributes = array(); @@ -265,7 +265,7 @@ class e_parse private $replaceAttrValues = array(); private $allowedTags = array(); - private $scriptTags = array(); + private $scriptTags = array(); private $scriptAttributes = array(); @@ -290,7 +290,7 @@ class e_parse public function getModifierList($type = '') { - if($type === 'super') + if ($type === 'super') { return $this->e_SuperMods; } @@ -310,13 +310,14 @@ class e_parse public function setMultibyte($bool) { - if($bool === false) + if ($bool === false) { $this->multibyte = false; + return null; } - if(extension_loaded('mbstring')) + if (extension_loaded('mbstring')) { $this->multibyte = true; mb_internal_encoding('UTF-8'); @@ -333,14 +334,14 @@ class e_parse */ public function ustrlen($str) { - if($this->multibyte) + if ($this->multibyte) { return mb_strlen($str); } return strlen($str); - // return strlen(utf8_decode($str)); + // return strlen(utf8_decode($str)); } @@ -353,7 +354,7 @@ class e_parse */ public function ustrtolower($str) { - if($this->multibyte) + if ($this->multibyte) { return mb_strtolower($str); } @@ -372,7 +373,7 @@ class e_parse public function ustrtoupper($str) { - if($this->multibyte) + if ($this->multibyte) { return mb_strtoupper($str); } @@ -389,16 +390,16 @@ class e_parse * Returns the numeric position (offset in amount of UTF-8 characters) * of the first occurrence of needle in the haystack string. * - * @param string $haystack The UTF-8 encoded string being searched in. - * @param integer $needle The UTF-8 encoded string being searched for. - * @param integer $offset [optional] The optional offset parameter allows you to specify which character in haystack to start searching. - * The position returned is still relative to the beginning of haystack. + * @param string $haystack The UTF-8 encoded string being searched in. + * @param integer $needle The UTF-8 encoded string being searched for. + * @param integer $offset [optional] The optional offset parameter allows you to specify which character in haystack to start searching. + * The position returned is still relative to the beginning of haystack. * @return integer|boolean Returns the position as an integer. If needle is not found, the function will return boolean FALSE. */ public function ustrpos($haystack, $needle, $offset = 0) { - if($this->multibyte) + if ($this->multibyte) { return mb_strpos($haystack, $needle, $offset); } @@ -413,15 +414,15 @@ class e_parse * Returns the numeric position (offset in amount of UTF-8 characters) * of the last occurrence of needle in the haystack string. * - * @param string $haystack The UTF-8 encoded string being searched in. - * @param integer $needle The UTF-8 encoded string being searched for. - * @param integer $offset [optional] - The optional offset parameter allows you to specify which character in haystack to start searching. - * The position returned is still relative to the beginning of haystack. + * @param string $haystack The UTF-8 encoded string being searched in. + * @param integer $needle The UTF-8 encoded string being searched for. + * @param integer $offset [optional] - The optional offset parameter allows you to specify which character in haystack to start searching. + * The position returned is still relative to the beginning of haystack. * @return integer|boolean Returns the position as an integer. If needle is not found, the function will return boolean FALSE. */ public function ustrrpos($haystack, $needle, $offset = 0) { - if($this->multibyte) + if ($this->multibyte) { return mb_strrpos($haystack, $needle, $offset); } @@ -434,15 +435,15 @@ class e_parse * Returns all of haystack starting from and including the first occurrence of needle to the end. * Unicode (UTF-8) analogue of standard @link http://php.net/stristr stristr PHP function. * - * @param string $haystack The UTF-8 encoded string to search in. - * @param mixed $needle If needle is not a string, it is converted to an integer and applied as the ordinal value of a character. - * @param bool $before_needle [optional] (PHP 5.3+) If TRUE, returns the part of the haystack before the first occurrence of the needle (excluding needle). + * @param string $haystack The UTF-8 encoded string to search in. + * @param mixed $needle If needle is not a string, it is converted to an integer and applied as the ordinal value of a character. + * @param bool $before_needle [optional] (PHP 5.3+) If TRUE, returns the part of the haystack before the first occurrence of the needle (excluding needle). * @return string Returns the matched substring. If needle is not found, returns FALSE. */ public function ustristr($haystack, $needle, $before_needle = false) { - if($this->multibyte) + if ($this->multibyte) { return mb_stristr($haystack, $needle, $before_needle); } @@ -458,17 +459,17 @@ class e_parse * NOTE: May be subtle differences in return values dependent on which routine is used. * Native substr() routine can return FALSE. mb_substr() and utf8_substr() just return an empty string. * - * @param string $str The UTF-8 encoded string. - * @param integer $start Start of portion to be returned. Position is counted in amount of UTF-8 characters from the beginning of str. - * First character's position is 0. Second character position is 1, and so on. + * @param string $str The UTF-8 encoded string. + * @param integer $start Start of portion to be returned. Position is counted in amount of UTF-8 characters from the beginning of str. + * First character's position is 0. Second character position is 1, and so on. * @param integer $length [optional] If length is given, the string returned will contain at most length characters beginning from start - * (depending on the length of string). If length is omitted, the rest of string from start will be returned. + * (depending on the length of string). If length is omitted, the rest of string from start will be returned. * @return string The extracted UTF-8 encoded part of input string. */ public function usubstr($str, $start, $length = null) { - if($this->multibyte) + if ($this->multibyte) { return ($length === null) ? mb_substr($str, $start) : mb_substr($str, $start, $length); } @@ -480,14 +481,14 @@ class e_parse /** * Converts the supplied text (presumed to be from user input) to a format suitable for storing in a database table. * - * @param mixed $data - * @param boolean $nostrip [optional] Assumes all data is GPC ($_GET, $_POST, $_COOKIE) unless indicate otherwise by setting this var to TRUE. - * If magic quotes is enabled on the server and you do not tell toDB() that the data is non GPC then slashes will be stripped when they should not be. - * @param boolean $no_encode [optional] This parameter should nearly always be FALSE. It is used by the save_prefs() function to preserve HTML content within prefs even when - * the save_prefs() function has been called by a non admin user / user without html posting permissions. - * @param boolean|string $mod [optional] model = admin-ui usage. The 'no_html' and 'no_php' modifiers blanket prevent HTML and PHP posting regardless of posting permissions. (used in logging) - * The 'pReFs' value is for internal use only, when saving prefs, to prevent sanitisation of HTML. - * @param mixed $parm [optional] + * @param mixed $data + * @param boolean $nostrip [optional] Assumes all data is GPC ($_GET, $_POST, $_COOKIE) unless indicate otherwise by setting this var to TRUE. + * If magic quotes is enabled on the server and you do not tell toDB() that the data is non GPC then slashes will be stripped when they should not be. + * @param boolean $no_encode [optional] This parameter should nearly always be FALSE. It is used by the save_prefs() function to preserve HTML content within prefs even when + * the save_prefs() function has been called by a non admin user / user without html posting permissions. + * @param boolean|string $mod [optional] model = admin-ui usage. The 'no_html' and 'no_php' modifiers blanket prevent HTML and PHP posting regardless of posting permissions. (used in logging) + * The 'pReFs' value is for internal use only, when saving prefs, to prevent sanitisation of HTML. + * @param mixed $parm [optional] * @return mixed * @todo complete the documentation of this essential method */ @@ -496,16 +497,16 @@ class e_parse $variableType = gettype($data); - if(($variableType !== 'string' && $variableType !== 'array') || $data === '0') + if (($variableType !== 'string' && $variableType !== 'array') || $data === '0') { return $data; } - if($variableType === 'array') + if ($variableType === 'array') { $ret = array(); - foreach($data as $key => $var) + foreach ($data as $key => $var) { //Fix - sanitize keys as well $key = str_replace(['"', "'"], ['"', '''], $key); @@ -516,20 +517,20 @@ class e_parse } - if(MAGIC_QUOTES_GPC === true && $nostrip === false) + if (MAGIC_QUOTES_GPC === true && $nostrip === false) { $data = stripslashes($data); } $core_pref = e107::getConfig(); - if($mod !== 'pReFs') //XXX We're not saving prefs. + if ($mod !== 'pReFs') //XXX We're not saving prefs. { $data = $this->preFilter($data); // used by bb_xxx.php toDB() functions. bb_code.php toDB() allows us to properly bypass HTML cleaning below. $data = $this->cleanHtml($data); // clean it regardless of if it is text or html. (html could have missing closing tags) - if(($this->isHtml($data)) && strpos($mod, 'no_html') === false) + if (($this->isHtml($data)) && strpos($mod, 'no_html') === false) { $this->isHtml = true; // $data = $this->cleanHtml($data); // sanitize all html. (moved above to include everything) @@ -546,7 +547,7 @@ class e_parse } - if(!check_class($core_pref->get('post_html', e_UC_MAINADMIN))) + if (!check_class($core_pref->get('post_html', e_UC_MAINADMIN))) { $data = strip_tags($data); // remove tags from cleaned html. $data = str_replace(array('[html]', '[/html]'), '', $data); @@ -556,17 +557,17 @@ class e_parse } - if(check_class($core_pref->get('post_html'))) /*$core_pref->is('post_html') && XXX preformecd by cleanHtml() */ + if (check_class($core_pref->get('post_html'))) /*$core_pref->is('post_html') && XXX preformecd by cleanHtml() */ { $no_encode = true; } - if($parm !== null && is_numeric($parm) && !check_class($core_pref->get('post_html'), '', $parm)) + if ($parm !== null && is_numeric($parm) && !check_class($core_pref->get('post_html'), '', $parm)) { $no_encode = false; } - if($no_encode === true && strpos($mod, 'no_html') === false) + if ($no_encode === true && strpos($mod, 'no_html') === false) { $search = array('$', '"', "'", '\\', 'get('php_bbcode'))) + if ((strpos($mod, 'no_php') !== false) || !check_class($core_pref->get('php_bbcode'))) { $ret = preg_replace("#\[(php)#i", "[\\1", $ret); } // Don't allow hooks to mess with prefs. - if($mod !== 'model') + if ($mod !== 'model') { return $ret; } @@ -602,7 +603,7 @@ class e_parse * e_parse hook */ $eParseList = $core_pref->get('e_parse_list'); - if(!empty($eParseList)) + if (!empty($eParseList)) { $opts = array( @@ -612,10 +613,10 @@ class e_parse 'field' => $parm['field'] ); - foreach($eParseList as $plugin) + foreach ($eParseList as $plugin) { $hookObj = e107::getAddon($plugin, 'e_parse'); - if($tmp = e107::callMethod($hookObj, 'toDB', $ret, $opts)) + if ($tmp = e107::callMethod($hookObj, 'toDB', $ret, $opts)) { $ret = $tmp; } @@ -632,6 +633,7 @@ class e_parse /** * Check for umatched 'dangerous' HTML tags * (these can destroy page layout where users are able to post HTML) + * * @param string $data * @param string $tagList - if empty, uses default list of input tags. Otherwise a CSV list of tags to check (any type) * @@ -672,7 +674,7 @@ class e_parse public function preFilter($data) { - if(!$this->isBBcode($data)) + if (!$this->isBBcode($data)) { return $data; } @@ -684,6 +686,7 @@ class e_parse /** * Takes a multi-dimensional array and converts the keys to a list of routing paths. * paths are the key and value are the top most key. + * * @param array $array * @return array */ @@ -692,24 +695,24 @@ class e_parse $res = $this->_processRoute($array); $tmp = explode("_#_", $res); $ret = []; - foreach($tmp as $v) + foreach ($tmp as $v) { - list($k) = explode('/',$v); + list($k) = explode('/', $v); $ret[$v] = $k; } return $ret; } - private function _processRoute($array, $prefix='') + private function _processRoute($array, $prefix = '') { $text = []; - if(is_array($array)) + if (is_array($array)) { - foreach($array as $key=>$val) + foreach ($array as $key => $val) { - if($tag = $this->_processRoute($val, $key.'/')) + if ($tag = $this->_processRoute($val, $key . '/')) { $add = $tag; } @@ -718,27 +721,25 @@ class e_parse $add = $key; } - $text[] = $prefix.$add; + $text[] = $prefix . $add; } } - return implode('_#_',$text); + return implode('_#_', $text); } - - public function toForm($text) { - if(empty($text)) // fix - handle proper 0, Space etc values. + if (empty($text)) // fix - handle proper 0, Space etc values. { return $text; } - if(is_string($text) && strpos($text, '[html]') === 0) + if (is_string($text) && strpos($text, '[html]') === 0) { // $text = $this->toHTML($text,true); $search = array('"', ''', '\', '&',); // '&' must be last. @@ -758,7 +759,7 @@ class e_parse $replace = array('$', '"', '<', '>', '%2B'); $text = str_replace($search, $replace, $text); - if(is_string($text) && e107::wysiwyg() !== true) + if (is_string($text) && e107::wysiwyg() !== true) { // fix for utf-8 issue with html_entity_decode(); ??? $text = urldecode($text); @@ -775,10 +776,10 @@ class e_parse public function post_toForm($text) { - if(is_array($text)) + if (is_array($text)) { $arr = array(); - foreach($text as $key => $value) + foreach ($text as $key => $value) { $key = $this->post_toForm($key); $arr[$key] = $this->post_toForm($value); @@ -789,7 +790,7 @@ class e_parse $text = (string) $text; - if(MAGIC_QUOTES_GPC == true) + if (MAGIC_QUOTES_GPC == true) { $text = stripslashes($text); } @@ -807,16 +808,16 @@ class e_parse } /** - * @param $text - template to parse. - * @param boolean $parseSCFiles - parse core 'single' shortcodes - * @param object|array $extraCodes - shortcode class containing sc_xxxxx methods or an array of key/value pairs or legacy shortcode content (eg. content within .sc) - * @param object $eVars - XXX more info needed. + * @param $text - template to parse. + * @param boolean $parseSCFiles - parse core 'single' shortcodes + * @param object|array $extraCodes - shortcode class containing sc_xxxxx methods or an array of key/value pairs or legacy shortcode content (eg. content within .sc) + * @param object $eVars - XXX more info needed. * @return string */ public function parseTemplate($text, $parseSCFiles = true, $extraCodes = null, $eVars = null) { - if(!is_bool($parseSCFiles)) + if (!is_bool($parseSCFiles)) { trigger_error('$parseSCFiles in parseTemplate() was given incorrect data'); } @@ -826,10 +827,10 @@ class e_parse /** * @experimental - * @param string $text - * @param bool $parseSCFiles + * @param string $text + * @param bool $parseSCFiles * @param object|array $extraCodes - * @param object $eVars + * @param object $eVars * @return string */ public function parseSchemaTemplate($text, $parseSCFiles = true, $extraCodes = null, $eVars = null) @@ -839,6 +840,7 @@ class e_parse $text = e107::getScParser()->parseCodes($text, $parseSCFiles, $extraCodes, $eVars); $text = str_replace(''; - $homeIcon = ($this->_fontawesome) ? e107::getParser()->toGlyph('fa-home.glyph') : $fallbackIcon; + $homeIcon = ($this->_fontawesome) ? $this->tp->toGlyph('fa-home.glyph') : $fallbackIcon; } @@ -3812,7 +3810,7 @@ var_dump($select_options);*/ 'target' => '_blank', 'title' => LAN_EDIT, 'href' => $url, - ]) . ">" . e107::getParser()->toGlyph('fa-edit') . ''; + ]) . ">" . $this->tp->toGlyph('fa-edit') . ''; } return ''; @@ -4037,22 +4035,7 @@ var_dump($select_options);*/ */ private function attributes($attributes) { - $stringifiedAttributes = []; - - foreach ($attributes as $key => $value) - { - - if ($value === true && (strpos($key,'data-') !== 0)) - { - $value = $key; - } - if (!empty($value) || is_numeric($value) || $key === "value" || strpos($key,'data-') === 0) - { - $stringifiedAttributes[] = $key . "='" . htmlspecialchars((string) $value, ENT_QUOTES) . "'"; - } - } - - return count($stringifiedAttributes) > 0 ? " ".implode(" ", $stringifiedAttributes) : ""; + return $this->tp->toAttributes($attributes, true); } public function get_attributes($options, $name = '', $value = '') @@ -4454,7 +4437,6 @@ var_dump($select_options);*/ public function thead($fieldarray, $columnPref = array(), $querypattern = '', $requeststr = '') { - $tp = e107::getParser(); $text = ''; $querypattern = strip_tags($querypattern); @@ -4631,7 +4613,7 @@ var_dump($select_options);*/ - $tp = e107::getParser(); + $tp = $this->tp; $types = explode(',',$parm['types']); $list = array(); @@ -4857,7 +4839,7 @@ var_dump($select_options);*/ } } - $source = e107::getParser()->toJSON($jsonArray, true); + $source = $this->tp->toJSON($jsonArray, true); $mode = preg_replace('/[\W]/', '', vartrue($_GET['mode'])); @@ -4946,7 +4928,7 @@ var_dump($select_options);*/ } elseif (!empty($model)) // old way. { - $tp = e107::getParser(); + $tp = $this->tp; $data = $model->getData(); @@ -4994,7 +4976,7 @@ var_dump($select_options);*/ private function renderOptions($parms, $id, $attributes) { - $tp = e107::getParser(); + $tp = $this->tp; $cls = false; $editIconDefault = deftrue('ADMIN_EDIT_ICON', $tp->toGlyph('fa-edit')); @@ -5134,7 +5116,7 @@ var_dump($select_options);*/ } // @see custom fields in cpage which accept json params. - if(!empty($attributes['writeParms']) && $tmpOpt = e107::getParser()->isJSON($attributes['writeParms'])) + if(!empty($attributes['writeParms']) && $tmpOpt = $this->tp->isJSON($attributes['writeParms'])) { $attributes['writeParms'] = $tmpOpt; unset($tmpOpt); @@ -5158,7 +5140,7 @@ var_dump($select_options);*/ $this->renderValueTrigger($field, $value, $parms, $id); - $tp = e107::getParser(); + $tp = $this->tp; switch($field) // special fields { case 'options': @@ -5602,7 +5584,7 @@ var_dump($select_options);*/ } else { - $url = e107::getParser()->replaceConstants($value, 'full'); + $url = $this->tp->replaceConstants($value, 'full'); } $name = basename($value); $value = ''.$name.''; @@ -5640,7 +5622,7 @@ var_dump($select_options);*/ $vparm = array('thumb'=>'tag','w'=> vartrue($parms['thumb_aw'],'80')); - if($video = e107::getParser()->toVideo($value,$vparm)) + if($video = $tp->toVideo($value,$vparm)) { return $video; } @@ -5653,7 +5635,7 @@ var_dump($select_options);*/ $icon = '{e_IMAGE}filemanager/zip_32.png'; $src = $tp->replaceConstants(vartrue($parms['pre']).$icon, 'abs'); // return $value; - return e107::getParser()->toGlyph('fa-file','size=2x'); + return $tp->toGlyph('fa-file','size=2x'); // return ''.$value.''; } @@ -6275,7 +6257,7 @@ var_dump($select_options);*/ $value = html_entity_decode($value, ENT_QUOTES); } - $tp = e107::getParser(); + $tp = $this->tp; $ret = ''; $parms = vartrue($attributes['writeParms'], array()); @@ -6498,7 +6480,7 @@ var_dump($select_options);*/ if(!empty($parms['maxlength']) && empty($parms['post'])) { - $charMsg = e107::getParser()->lanVars(defset('LAN_X_CHARS_REMAINING', '[x] chars remaining'), "" . $parms['maxlength'] . ""); + $charMsg = $tp->lanVars(defset('LAN_X_CHARS_REMAINING', '[x] chars remaining'), "" . $parms['maxlength'] . ""); $parms['post'] = "attributes([ 'id' => $this->name2id($key) . "-char-count", 'class' => 'text-muted', @@ -6928,7 +6910,7 @@ var_dump($select_options);*/ case 'upload': //TODO - from method // TODO uploadfile SC is now processing uploads as well (add it to admin UI), write/readParms have to be added (see uploadfile.php parms) $disbut = varset($parms['disable_button'], '0'); - $ret = $tp->parseTemplate('{UPLOADFILE=' .(vartrue($parms['path']) ? e107::getParser()->replaceConstants($parms['path']) : e_UPLOAD)."|nowarn&trigger=etrigger_uploadfiles&disable_button={$disbut}}"); + $ret = $tp->parseTemplate('{UPLOADFILE=' .(vartrue($parms['path']) ? $tp->replaceConstants($parms['path']) : e_UPLOAD)."|nowarn&trigger=etrigger_uploadfiles&disable_button={$disbut}}"); break; case 'hidden': @@ -7014,7 +6996,7 @@ var_dump($select_options);*/ foreach($parms['optArray'] as $key=>$val) { - $thumbnail = e107::getParser()->toImage($val['thumbnail'], $parms); + $thumbnail = $this->tp->toImage($val['thumbnail'], $parms); $active = ($key === $value) ? ' active' : ''; $text .= "
@@ -7055,7 +7037,7 @@ var_dump($select_options);*/ foreach($parms['optArray'] as $key=>$val) { - $thumbnail = e107::getParser()->toImage($val,$parms); + $thumbnail = $this->tp->toImage($val,$parms); $text .= "
attributes([ @@ -7122,7 +7104,7 @@ var_dump($select_options);*/ */ public function renderListForm($form_options, $tree_models, $nocontainer = false) { - $tp = e107::getParser(); + $tp = $this->tp; $text = ''; $formPre = ''; $formPost = ''; @@ -7294,7 +7276,7 @@ var_dump($select_options);*/ */ public function renderGridForm($form_options, $tree_models, $nocontainer = false) { - $tp = e107::getParser(); + $tp = $this->tp; $text = ''; @@ -7516,7 +7498,7 @@ var_dump($select_options);*/ } $query = isset($form['query']) ? $form['query'] : e_QUERY ; - $url = (isset($form['url']) ? e107::getParser()->replaceConstants($form['url'], 'abs') : e_SELF).($query ? '?'.$query : ''); + $url = (isset($form['url']) ? $this->tp->replaceConstants($form['url'], 'abs') : e_SELF).($query ? '?'.$query : ''); $curTab = (string) varset($_GET['tab'], '0'); $text .= " @@ -7902,7 +7884,7 @@ var_dump($select_options);*/ foreach ($forms as $fid => $form) { $query = isset($form['query']) ? $form['query'] : e_QUERY ; - $url = (isset($form['url']) ? e107::getParser()->replaceConstants($form['url'], 'abs') : e_SELF).($query ? '?'.$query : ''); + $url = (isset($form['url']) ? $this->tp->replaceConstants($form['url'], 'abs') : e_SELF).($query ? '?'.$query : ''); $text .= ' ' .vartrue($form['form_pre'])." diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index 83c84d2b6..e19994c8e 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -14,10 +14,14 @@ * $Author$ */ -if (!defined('e107_INIT')) { exit; } +if (!defined('e107_INIT')) +{ + exit; +} e107::plugLan('download', 'front', true); + /** * download_shortcodes */ @@ -28,66 +32,99 @@ class download_shortcodes extends e_shortcode public $dlsubsubrow; public $mirror; - public $parent; - public $grandparent; + public $parent; + public $grandparent; private $pref; - - /** - * download_shortcodes constructor - */ - function __construct() + + /** + * download_shortcodes constructor + */ + public function __construct() { + parent::__construct(); $this->pref = e107::getPref(); } + /** + * Get the download agreement text as an HTML-stripped JSON string + * + * Configured in Admin-UI at `/e107_plugins/download/admin_download.php?mode=main&action=settings` + * + * @return string|null JSON string with the contents of the "agree_text" pref reformatted without HTML + * {@see null} if the "agree_flag" pref is not truthy or if the formatted "agree_text" is empty. + */ + private function getAgreeTextAsHtmlAttributeJsonString() + { + if (!isset($this->pref['agree_flag']) || !$this->pref['agree_flag']) return null; + + $rawAgreeText = isset($this->pref['agree_text']) ? $this->pref['agree_text'] : ""; + $tp = e107::getParser(); + $agreeText = $tp->toJSON($tp->toText($rawAgreeText), true); + + if (!$agreeText) return null; + + return $agreeText; + } + + /** + * Wrap the formatted download agreement text into an HTML JavaScript event that calls `confirm()` + * + * @return string + */ + private function getAgreeTextAsHtmlEventAttribute() + { + $maybeJson = $this->getAgreeTextAsHtmlAttributeJsonString(); + + return empty($maybeJson) ? "" : "return confirm($maybeJson);"; + } public function breadcrumb() { - $breadcrumb = array(); + $breadcrumb = array(); $action = varset($this->qry['action']); switch ($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', '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; + $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; case 'maincats': - $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download','index')); - break; + $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)) + if (!empty($this->grandparent)) { - $breadcrumb[] = array('text' => $this->grandparent['download_category_name'], 'url' => ($this->grandparent['download_category_id']) ? e107::url('download', 'category', $this->grandparent) : null); + $breadcrumb[] = array('text' => $this->grandparent['download_category_name'], 'url' => ($this->grandparent['download_category_id']) ? e107::url('download', 'category', $this->grandparent) : null); } - if(!empty($this->parent)) + if (!empty($this->parent)) { - $breadcrumb[] = array('text' => $this->parent['download_category_name'], 'url' => ($this->parent['download_category_id']) ? e107::url('download', 'category', $this->parent) : null); + $breadcrumb[] = array('text' => $this->parent['download_category_name'], 'url' => ($this->parent['download_category_id']) ? e107::url('download', 'category', $this->parent) : null); } - if(isset($this->var['download_category_name'])) + if (isset($this->var['download_category_name'])) { - $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null); + $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null); } - $breadcrumb[] = array('text' => varset($this->var['download_name']), 'url' => null); - break; + $breadcrumb[] = array('text' => varset($this->var['download_name']), 'url' => null); + break; } e107::breadcrumb($breadcrumb); } - - function sc_download_breadcrumb($parm='') + + function sc_download_breadcrumb($parm = '') { $tp = e107::getParser(); $frm = e107::getForm(); @@ -95,39 +132,41 @@ class download_shortcodes extends e_shortcode $breadcrumb = e107::breadcrumb(); return $frm->breadcrumb($breadcrumb); - - } - - - // Category ************************************************************************************ - public function sc_download_cat_main_name() - { - $tp = e107::getParser(); - if(!empty($this->var['d_count'])) + } + + + // Category ************************************************************************************ + public function sc_download_cat_main_name() + { + $tp = e107::getParser(); + + if (!empty($this->var['d_count'])) { $url = e107::url('download', 'category', $this->var); - return "".$tp->toHTML($this->var['download_category_name'], FALSE, 'TITLE').""; + + return "" . $tp->toHTML($this->var['download_category_name'], false, 'TITLE') . ""; } - return $tp->toHTML($this->var['download_category_name'], FALSE, 'TITLE'); - } - - public function sc_download_cat_main_description() - { - $tp = e107::getParser(); - return $tp->toHTML($this->var['download_category_description'], TRUE, 'DESCRIPTION'); - } - - public function sc_download_cat_main_icon() - { - // Pass count as 1 to force non-empty icon - return $this->_sc_cat_icons($this->var['download_category_icon'], 1, $this->var['download_category_name']); - } + return $tp->toHTML($this->var['download_category_name'], false, 'TITLE'); + } + + public function sc_download_cat_main_description() + { + $tp = e107::getParser(); + + return $tp->toHTML($this->var['download_category_description'], true, 'DESCRIPTION'); + } + + public function sc_download_cat_main_icon() + { + // Pass count as 1 to force non-empty icon + return $this->_sc_cat_icons($this->var['download_category_icon'], 1, $this->var['download_category_name']); + } public function sc_download_cat_main_count() { - if(!empty($this->var['d_count'])) + if (!empty($this->var['d_count'])) { return intval($this->var['d_count']); } @@ -135,7 +174,7 @@ class download_shortcodes extends e_shortcode public function sc_download_cat_main_size() { - if(!empty($this->var['d_count'])) + if (!empty($this->var['d_count'])) { return eHelper::parseMemorySize($this->var['d_size']); } @@ -144,369 +183,373 @@ class download_shortcodes extends e_shortcode public function sc_download_cat_main_downloaded() { - if(!empty($this->var['d_count'])) + if (!empty($this->var['d_count'])) { return intval($this->var['d_requests']); } } - + // Sub-Category ******************************************************************************** - function sc_download_cat_sub_name($parm = '') - { - $tp = e107::getParser(); + function sc_download_cat_sub_name($parm = '') + { + $tp = e107::getParser(); $class = 'category-name'; $class .= isset($this->dlsubrow['d_last']) && $this->isNewDownload($this->dlsubrow['d_last']) ? ' new' : ''; - if($parm == 'raw') - { - return $tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE'); - } - + if ($parm == 'raw') + { + return $tp->toHTML($this->dlsubrow['download_category_name'], false, 'TITLE'); + } + if (!empty($this->dlsubrow['d_count'])) - { + { $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').""; - } - elseif(isset($this->dlsubrow['download_category_name'])) - { - return $tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE'); - } + + return "" . $tp->toHTML($this->dlsubrow['download_category_name'], false, 'TITLE') . ""; + // return "".$tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE').""; + } + elseif (isset($this->dlsubrow['download_category_name'])) + { + return $tp->toHTML($this->dlsubrow['download_category_name'], false, 'TITLE'); + } } - function sc_download_cat_sub_description() - { - if(empty($this->dlsubrow['download_category_description'])) - { + function sc_download_cat_sub_description() + { + if (empty($this->dlsubrow['download_category_description'])) + { return null; - } + } - return e107::getParser()->toHTML($this->dlsubrow['download_category_description'], TRUE, 'DESCRIPTION'); - } + return e107::getParser()->toHTML($this->dlsubrow['download_category_description'], true, 'DESCRIPTION'); + } - function sc_download_cat_sub_icon() - { - if(empty($this->dlsubrow['download_category_icon'])) - { - return null; - } + function sc_download_cat_sub_icon() + { + if (empty($this->dlsubrow['download_category_icon'])) + { + return null; + } - return $this->_sc_cat_icons($this->dlsubrow['download_category_icon'], $this->dlsubrow['d_count'], $this->dlsubrow['download_category_name']); - } + return $this->_sc_cat_icons($this->dlsubrow['download_category_icon'], $this->dlsubrow['d_count'], $this->dlsubrow['download_category_name']); + } - function sc_download_cat_sub_new_icon() - { - return (isset($this->dlsubrow['d_last_subs']) && $this->isNewDownload($this->dlsubrow['d_last_subs'])) ? $this->renderNewIcon() : ""; - } - - function sc_download_cat_sub_count() - { - return varset($this->dlsubrow['d_count'],'0'); - } + function sc_download_cat_sub_new_icon() + { + return (isset($this->dlsubrow['d_last_subs']) && $this->isNewDownload($this->dlsubrow['d_last_subs'])) ? $this->renderNewIcon() : ""; + } - function sc_download_cat_sub_size() - { - if(empty($this->dlsubrow['d_size'])) - { - return null; - } + function sc_download_cat_sub_count() + { + return varset($this->dlsubrow['d_count'], '0'); + } + + function sc_download_cat_sub_size() + { + if (empty($this->dlsubrow['d_size'])) + { + return null; + } + + return eHelper::parseMemorySize($this->dlsubrow['d_size']); + } + + function sc_download_cat_sub_downloaded() + { + if (!isset($this->dlsubrow['d_requests'])) + { + return 0; + } + + return intval($this->dlsubrow['d_requests']); + } - return eHelper::parseMemorySize($this->dlsubrow['d_size']); - } - - function sc_download_cat_sub_downloaded() - { - if(!isset($this->dlsubrow['d_requests'])) - { - return 0; - } - return intval($this->dlsubrow['d_requests']); - } - - // Sub-Sub-Category **************************************************************************** - - - function sc_download_cat_subsub_name($parm = '') - { - $tp = e107::getParser(); + + + function sc_download_cat_subsub_name($parm = '') + { + $tp = e107::getParser(); // isNewDownload $class = 'category-name'; $class .= isset($this->dlsubsubrow['d_last']) && $this->isNewDownload($this->dlsubsubrow['d_last']) ? ' new' : ''; - - if($parm == 'raw') - { - return $tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE'); - } - if (!empty($this->dlsubsubrow['d_count'])) - { - $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--'))); + if ($parm == 'raw') + { + return $tp->toHTML($this->dlsubsubrow['download_category_name'], false, 'TITLE'); + } + + if (!empty($this->dlsubsubrow['d_count'])) + { + $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').""; - } - elseif(!empty($this->dlsubsubrow['download_category_name'])) - { - return $tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE'); - } - } - - function sc_download_cat_subsub_description() - { - if(empty($this->dlsubsubrow['download_category_description'])) - { - return null; - } + return "" . $tp->toHTML($this->dlsubsubrow['download_category_name'], false, 'TITLE') . ""; + } + elseif (!empty($this->dlsubsubrow['download_category_name'])) + { + return $tp->toHTML($this->dlsubsubrow['download_category_name'], false, 'TITLE'); + } + } - return e107::getParser()->toHTML($this->dlsubsubrow['download_category_description'], TRUE, 'DESCRIPTION'); - } - - function sc_download_cat_subsub_icon() - { - if(empty($this->dlsubsubrow['download_category_icon'])) - { - return null; - } + function sc_download_cat_subsub_description() + { + if (empty($this->dlsubsubrow['download_category_description'])) + { + return null; + } - return $this->_sc_cat_icons($this->dlsubsubrow['download_category_icon'], $this->dlsubsubrow['d_count'], $this->dlsubsubrow['download_category_name']); - } - - function sc_download_cat_subsub_new_icon() - { - return (isset($this->dlsubsubrow['d_last']) && $this->isNewDownload($this->dlsubsubrow['d_last'])) ? $this->renderNewIcon() : ""; - } + return e107::getParser()->toHTML($this->dlsubsubrow['download_category_description'], true, 'DESCRIPTION'); + } - function sc_download_cat_subsub_count() - { - return varset($this->dlsubsubrow['d_count'], '0'); - } - - function sc_download_cat_subsub_size() - { - if(empty($this->dlsubsubrow['d_size'])) - { - return 0; - } + function sc_download_cat_subsub_icon() + { + if (empty($this->dlsubsubrow['download_category_icon'])) + { + return null; + } - return eHelper::parseMemorySize($this->dlsubsubrow['d_size']); - } - - function sc_download_cat_subsub_downloaded() - { - if(empty($this->dlsubsubrow['d_requests'])) - { - return 0; - } + return $this->_sc_cat_icons($this->dlsubsubrow['download_category_icon'], $this->dlsubsubrow['d_count'], $this->dlsubsubrow['download_category_name']); + } - return (int) $this->dlsubsubrow['d_requests']; - } + function sc_download_cat_subsub_new_icon() + { + return (isset($this->dlsubsubrow['d_last']) && $this->isNewDownload($this->dlsubsubrow['d_last'])) ? $this->renderNewIcon() : ""; + } + + function sc_download_cat_subsub_count() + { + return varset($this->dlsubsubrow['d_count'], '0'); + } + + function sc_download_cat_subsub_size() + { + if (empty($this->dlsubsubrow['d_size'])) + { + return 0; + } + + return eHelper::parseMemorySize($this->dlsubsubrow['d_size']); + } + + function sc_download_cat_subsub_downloaded() + { + if (empty($this->dlsubsubrow['d_requests'])) + { + return 0; + } + + return (int) $this->dlsubsubrow['d_requests']; + } // List **************************************************************************************** - - function sc_download_list_caption($parm='') + + function sc_download_list_caption($parm = '') { - + $qry = $this->qry; - + $qry['sort'] = (isset($qry['sort']) && $qry['sort'] == 'asc') ? 'desc' : 'asc'; // reverse. - switch ($parm) + switch ($parm) { case 'name': $qry['order'] = 'name'; $text = LAN_NAME; - break; + break; case 'datestamp': $qry['order'] = 'datestamp'; $text = LAN_DATE; - break; - + break; + case 'author': $qry['order'] = 'author'; $text = LAN_AUTHOR; - break; - + break; + case 'filesize': $qry['order'] = 'filesize'; $text = LAN_SIZE; - break; + break; case 'requested': $qry['order'] = 'requested'; $text = LAN_dl_29; - break; + break; case 'rating': $text = LAN_RATING; - break; - + break; + case 'link': $text = LAN_dl_8; - break; - + break; + default: $text = "Missing LAN Column"; // debug. - break; + break; } - return "".$text."" ; - } - - - - function sc_download_list_name($parm='') - { - $tp = e107::getParser(); - - if ($parm == "nolink") - { - return $tp->toHTML($this->var['download_name'],TRUE,'LINKTEXT'); - } - - if ($parm == "request") - { - $agreetext = $tp->toAttribute($tp->toJSON($tp->toText($this->pref['agree_text'],FALSE,'DESCRIPTION'), 'str')); - - if ($this->var['download_mirror_type']) - { - $text = ($this->pref['agree_flag'] ? "" : ""); - } - else - { - $text = ($this->pref['agree_flag'] ? "" : ""); - } - - $text .= $tp->toHTML($this->var['download_name'], FALSE, 'TITLE').""; - - return $text; - } - - $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').""; - } - - function sc_download_list_author() - { - return $this->var['download_author']; - } - - function sc_download_list_requested() - { - return $this->var['download_requested']; - } - - function sc_download_list_newicon() - { - return $this->isNewDownload($this->var['download_datestamp']) ? $this->renderNewIcon() : ""; - } - - function sc_download_list_recenticon() - { - // convert "recent_download_days" to seconds - return ($this->var['download_datestamp'] > time()-(varset($this->pref['recent_download_days'],0) * 86400) ? $this->renderNewIcon() : ''); - } - - function sc_download_list_filesize() - { - return eHelper::parseMemorySize($this->var['download_filesize']); - } - - function sc_download_list_datestamp() - { - - $tp = e107::getParser(); - return $tp->toDate($this->var['download_datestamp'], "short"); - } - - function sc_download_list_thumb($parm='') - { - $tp = e107::getParser(); - - $img = ""; - - if(!empty($this->var['download_thumb'])) - { - $opts = array( - 'legacy' => "{e_FILE}downloadthumbs/", - 'class' => 'download-image img-responsive img-fluid', - 'alt' => $this->var['download_name'] - ); - - $img = $tp->toImage($this->var['download_thumb'], $opts); - } + return "" . $text . ""; + } - if ($parm == "link" && $this->var['download_thumb']) - { - $url = e107::url('download', 'item', $this->var); - return "".$img.""; - // return "".$img.""; - } - else - { - return $img; - } - } - - function sc_download_list_id() - { - return $this->var['download_id']; - } - - function sc_download_list_rating() - { - return e107::getForm()->rate("download", $this->var['download_id']); - } - - function sc_download_list_link($parm='') - { + function sc_download_list_name($parm = '') + { + $tp = e107::getParser(); + + if ($parm == "nolink") + { + return $tp->toHTML($this->var['download_name'], true, 'LINKTEXT'); + } + + if ($parm == "request") + { + $agreeTextJs = $this->getAgreeTextAsHtmlEventAttribute(); + + if ($this->var['download_mirror_type']) + { + $href = e_PLUGIN_ABS . "download/download.php?mirror." . $this->var['download_id']; + } + else + { + $href = e_PLUGIN_ABS . "download/request.php?" . $this->var['download_id']; + } + + $text = "toAttributes([ + "href" => $href, + "onclick" => $agreeTextJs, + "title" => defined("LAN_DOWNLOAD") ? LAN_DOWNLOAD : null, + ]) . ">"; + + $text .= $tp->toHTML($this->var['download_name'], false, 'TITLE') . ""; + + return $text; + } + + $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').""; + } + + function sc_download_list_author() + { + return $this->var['download_author']; + } + + function sc_download_list_requested() + { + return $this->var['download_requested']; + } + + function sc_download_list_newicon() + { + return $this->isNewDownload($this->var['download_datestamp']) ? $this->renderNewIcon() : ""; + } + + function sc_download_list_recenticon() + { + // convert "recent_download_days" to seconds + return ($this->var['download_datestamp'] > time() - (varset($this->pref['recent_download_days'], 0) * 86400) ? $this->renderNewIcon() : ''); + } + + function sc_download_list_filesize() + { + return eHelper::parseMemorySize($this->var['download_filesize']); + } + + function sc_download_list_datestamp() + { + + $tp = e107::getParser(); + + return $tp->toDate($this->var['download_datestamp'], "short"); + } + + function sc_download_list_thumb($parm = '') + { + $tp = e107::getParser(); + + $img = ""; + + if (!empty($this->var['download_thumb'])) + { + $opts = array( + 'legacy' => "{e_FILE}downloadthumbs/", + 'class' => 'download-image img-responsive img-fluid', + 'alt' => $this->var['download_name'] + ); + + $img = $tp->toImage($this->var['download_thumb'], $opts); + } + + + if ($parm == "link" && $this->var['download_thumb']) + { + $url = e107::url('download', 'item', $this->var); + + return "" . $img . ""; + // return "".$img.""; + } + else + { + return $img; + } + } + + function sc_download_list_id() + { + return $this->var['download_id']; + } + + function sc_download_list_rating() + { + return e107::getForm()->rate("download", $this->var['download_id']); + } + + function sc_download_list_link($parm = '') + { $tp = e107::getParser(); $img = ''; - $agreetext = !empty($this->pref['agree_text']) ? $tp->toAttribute($tp->toJSON($tp->toText($this->pref['agree_text'],FALSE,'DESCRIPTION'), 'str')) : ''; - - if(defined('IMAGE_DOWNLOAD')) + if (defined('IMAGE_DOWNLOAD')) { - $img = "".LAN_DOWNLOAD.""; + $img = "" . LAN_DOWNLOAD . ""; } - if(deftrue('BOOTSTRAP')) + if (deftrue('BOOTSTRAP')) { - $img = e107::getParser()->toGlyph('fa-download',false); - // $img = ''; + $img = e107::getParser()->toGlyph('fa-download', false); + // $img = ''; } - - if ($this->var['download_mirror_type']) - { - return "{$img}"; - } - else - { - $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true, $this); // $this->sc_download_request_url(); - return (!empty($this->pref['agree_flag']) ? "{$img}" : "{$img}"); - - // return ($this->pref['agree_flag'] ? "{$img}" : "{$img}"); - } - } + + return "toAttributes([ + "class" => "e-tip", + "title" => defined("LAN_DOWNLOAD") ? LAN_DOWNLOAD : null, + "href" => $this->var['download_mirror_type'] ? + e_PLUGIN_ABS . "download/download.php?mirror." . $this->var['download_id'] : + $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}", true, $this), + "onclick" => $this->getAgreeTextAsHtmlEventAttribute(), + ]) . ">$img"; + } - function sc_download_request_url($parm=null) - { - return e107::url('download', 'get', $this->var); // /request/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); + function sc_download_request_url($parm = null) + { + return e107::url('download', 'get', $this->var); // /request/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); - } + } - function sc_download_filename($parm=null) + function sc_download_filename($parm = null) { return basename($this->var['download_url']); @@ -516,17 +559,17 @@ class download_shortcodes extends e_shortcode { $img = ''; - if(defined('IMAGE_DOWNLOAD')) + if (defined('IMAGE_DOWNLOAD')) { $img = "" . LAN_DOWNLOAD . ""; } - if(deftrue('BOOTSTRAP')) + if (deftrue('BOOTSTRAP')) { $img = e107::getParser()->toGlyph('fa-download', false); } - if($parm == "link") + if ($parm == "link") { $url = e107::url('download', 'item', $this->var); @@ -540,306 +583,292 @@ class download_shortcodes extends e_shortcode return; } - - function sc_download_list_imagefull($parm='') - { - + + function sc_download_list_imagefull($parm = '') + { + $img = ""; - if(!empty($this->var['download_image'])) - { - $img = $this->sc_download_view_imagefull(); - } + if (!empty($this->var['download_image'])) + { + $img = $this->sc_download_view_imagefull(); + } - if($parm == "link" && $this->var['download_image']) + if ($parm == "link" && $this->var['download_image']) { $url = e107::url('download', 'item', $this->var); - return "".$img.""; - - // return "".$img.""; + + return "" . $img . ""; + + // return "".$img.""; } else { return $img; } } - - - function sc_download_list_nextprev() - { - global $nextprev_parms; - return e107::getParser()->parseTemplate("{NEXTPREV={$nextprev_parms}}"); - } - function sc_download_list_total_amount() - { - global $dltdownloads; - return intval($dltdownloads)." ".LAN_dl_16; - } - - function sc_download_list_total_files() - { - global $dlft; - return intval($dlft)." ".strtolower(LAN_FILES); - } - - - - + + function sc_download_list_nextprev() + { + global $nextprev_parms; + + return e107::getParser()->parseTemplate("{NEXTPREV={$nextprev_parms}}"); + } + + function sc_download_list_total_amount() + { + global $dltdownloads; + + return intval($dltdownloads) . " " . LAN_dl_16; + } + + function sc_download_list_total_files() + { + global $dlft; + + return intval($dlft) . " " . strtolower(LAN_FILES); + } + + // View **************************************************************************************** - - - function sc_download_view_id() - { - return $this->var['download_id']; - } - - function sc_download_admin_edit() - { - $icon = (deftrue('BOOTSTRAP')) ? e107::getParser()->toGlyph('fa-edit') : "*"; - - $url = e_PLUGIN_ABS."download/admin_download.php?action=edit&id=".$this->var['download_id']; - - return (ADMIN && getperms('6')) ? "".$icon."" : ""; - } - - function sc_download_category() - { - return $this->var['download_category_name']; - } - - function sc_download_category_description($parm=null) - { - $text = e107::getParser()->toHTML($this->var['download_category_description'], true, 'DESCRIPTION'); - if($parm) - { - return substr($text, 0, $parm); - } - else - { - return $text; - } - } - function sc_download_view_name($parm='') - { + function sc_download_view_id() + { + return $this->var['download_id']; + } + + function sc_download_admin_edit() + { + $icon = (deftrue('BOOTSTRAP')) ? e107::getParser()->toGlyph('fa-edit') : "*"; + + $url = e_PLUGIN_ABS . "download/admin_download.php?action=edit&id=" . $this->var['download_id']; + + return (ADMIN && getperms('6')) ? "" . $icon . "" : ""; + } + + function sc_download_category() + { + return $this->var['download_category_name']; + } + + function sc_download_category_description($parm = null) + { + + $text = e107::getParser()->toHTML($this->var['download_category_description'], true, 'DESCRIPTION'); + + if ($parm) + { + return substr($text, 0, $parm); + } + else + { + return $text; + } + } + + function sc_download_view_name($parm = '') + { $tp = e107::getParser(); - $viewUrl = e107::url('download', 'item', $this->var); - $requestUrl = $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true,$this); // $this->sc_download_request_url(); + $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'].""; - $link['request'] = "".$this->var['download_name'].""; + $link['view'] = "" . $this->var['download_name'] . ""; + $link['request'] = "" . $this->var['download_name'] . ""; // $link['view'] = "".$this->var['download_name'].""; // $link['request'] = "".$this->var['download_name'].""; - - + + if ($parm) { - return $tp->toHTML($link[$parm],true, 'TITLE'); + return $tp->toHTML($link[$parm], true, 'TITLE'); } - + return $this->var['download_name']; - } + } - function sc_download_view_name_linked() - { + function sc_download_view_name_linked() + { - $tp = e107::getParser(); + $tp = e107::getParser(); - $url = $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true,$this); //$this->sc_download_request_url(); - - if (!empty($this->pref['agree_flag'])) - { - return "toAttribute($tp->toJSON($tp->toHTML($this->pref['agree_text'],FALSE,'DESCRIPTION'))).");\" title='".LAN_dl_46."'>".$this->var['download_name'].""; - // return "toJS($tp->toHTML($this->pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name'].""; - } - else - { - return "".$this->var['download_name'].""; - - // return "".$dl['download_name'].""; - } - } - - function sc_download_view_author() - { - return !empty($this->var['download_author']) ? $this->var['download_author'] : ""; - } - - function sc_download_view_authoremail() - { - return !empty($this->var['download_author_email']) ? e107::getParser()->toHTML($this->var['download_author_email'], TRUE, 'LINKTEXT') : ""; - } - - function sc_download_view_authorwebsite() - { - return !empty($this->var['download_author_website']) ? e107::getParser()->toHTML($this->var['download_author_website'], TRUE,'LINKTEXT') : ""; - } - - function sc_download_view_description($parm='') - { - $maxlen = ($parm ? intval($parm) : 0); - $text = ($this->var['download_description'] ? e107::getParser()->toHTML($this->var['download_description'], TRUE, 'DESCRIPTION') : ""); - - if ($maxlen) - { - return substr($text, 0, $maxlen); - } - else - { - return $text; - } - - return $text; - } + $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}", true, $this); //$this->sc_download_request_url(); - function sc_download_view_date($parm='') - { - return ($this->var['download_datestamp']) ? e107::getParser()->toDate($this->var['download_datestamp'], $parm) : ""; - } - - /** - * @deprecated DOWNLOAD_VIEW_DATE should be used instead. - */ - function sc_download_view_date_short() - { - trigger_error('{DOWNLOAD_VIEW_DATE_SHORT} is deprecated. Use {DOWNLOAD_VIEW_DATE} instead.', E_USER_DEPRECATED); // NO LAN + return "toAttributes([ + "href" => $url, + "onclick" => $this->getAgreeTextAsHtmlEventAttribute(), + "title" => defined('LAN_dl_46') ? LAN_dl_46 : null, + ]) . ">{$this->var['download_name']}"; + } + + function sc_download_view_author() + { + return !empty($this->var['download_author']) ? $this->var['download_author'] : ""; + } + + function sc_download_view_authoremail() + { + return !empty($this->var['download_author_email']) ? e107::getParser()->toHTML($this->var['download_author_email'], true, 'LINKTEXT') : ""; + } + + function sc_download_view_authorwebsite() + { + return !empty($this->var['download_author_website']) ? e107::getParser()->toHTML($this->var['download_author_website'], true, 'LINKTEXT') : ""; + } + + function sc_download_view_description($parm = '') + { + $maxlen = ($parm ? intval($parm) : 0); + $text = ($this->var['download_description'] ? e107::getParser()->toHTML($this->var['download_description'], true, 'DESCRIPTION') : ""); + + if ($maxlen) + { + return substr($text, 0, $maxlen); + } + else + { + return $text; + } + + return $text; + } + + function sc_download_view_date($parm = '') + { + return ($this->var['download_datestamp']) ? e107::getParser()->toDate($this->var['download_datestamp'], $parm) : ""; + } + + /** + * @deprecated DOWNLOAD_VIEW_DATE should be used instead. + */ + function sc_download_view_date_short() + { + trigger_error('{DOWNLOAD_VIEW_DATE_SHORT} is deprecated. Use {DOWNLOAD_VIEW_DATE} instead.', E_USER_DEPRECATED); // NO LAN return $this->sc_download_view_date('short'); - } - - /** - * @deprecated DOWNLOAD_VIEW_DATE should be used instead. - */ - function sc_download_view_date_long() - { - trigger_error('{DOWNLOAD_VIEW_DATE_LONG} is deprecated. Use {DOWNLOAD_VIEW_DATE} instead.', E_USER_DEPRECATED); // NO LAN + } - return $this->sc_download_view_date('long'); - } + /** + * @deprecated DOWNLOAD_VIEW_DATE should be used instead. + */ + function sc_download_view_date_long() + { + trigger_error('{DOWNLOAD_VIEW_DATE_LONG} is deprecated. Use {DOWNLOAD_VIEW_DATE} instead.', E_USER_DEPRECATED); // NO LAN - function sc_download_view_image() - { - $tp = e107::getParser(); + return $this->sc_download_view_date('long'); + } + + function sc_download_view_image() + { + $tp = e107::getParser(); $url = e107::url('download', 'image', $this->var); - //$url = e_PLUGIN_ABS . "download/request.php?download." . $this->var['download_id']; + //$url = e_PLUGIN_ABS . "download/request.php?download." . $this->var['download_id']; - if($this->var['download_thumb']) - { - $opts = array( - 'legacy' => "{e_FILE}downloadthumbs/", - 'class' => 'download-image dl_image img-responsive img-fluid' - ); - $image = $tp->toImage($this->var['download_thumb'], $opts); + if ($this->var['download_thumb']) + { + $opts = array( + 'legacy' => "{e_FILE}downloadthumbs/", + 'class' => 'download-image dl_image img-responsive img-fluid' + ); + $image = $tp->toImage($this->var['download_thumb'], $opts); - return ($this->var['download_image'] ? "" . $image . "" : $image); - } - elseif($this->var['download_image']) - { - $opts = array( - //'legacy' => "{e_FILE}downloadthumbs/", - 'class' => 'download-image dl_image img-responsive img-fluid', - 'w' => 200 - ); - $image = $tp->toImage($this->var['download_image'], $opts); + return ($this->var['download_image'] ? "" . $image . "" : $image); + } + elseif ($this->var['download_image']) + { + $opts = array( + //'legacy' => "{e_FILE}downloadthumbs/", + 'class' => 'download-image dl_image img-responsive img-fluid', + 'w' => 200 + ); + $image = $tp->toImage($this->var['download_image'], $opts); - return "" . $image . ""; - //return "" . LAN_dl_40 . ""; - } - else - { - return LAN_dl_75; - } - } + return "" . $image . ""; + //return "" . LAN_dl_40 . ""; + } + else + { + return LAN_dl_75; + } + } - /** - * {DOWNLOAD_VIEW_LINK: class=thumbnail} - */ - function sc_download_view_imagefull($parm=array()) - { - - if(!empty($this->var['download_image'])) - { - - $opts = array( - 'legacy' => "{e_FILE}downloadimages/", - 'class' => 'download-image dl_image download-view-image img-responsive img-fluid '.vartrue($parm['class']), - 'alt' => basename($this->var['download_image']) - ); - - return e107::getParser()->toImage($this->var['download_image'], $opts); - } - - } - - /** - * {DOWNLOAD_VIEW_LINK: size=2x} - */ - function sc_download_view_link($parm=null) + /** + * {DOWNLOAD_VIEW_LINK: class=thumbnail} + */ + function sc_download_view_imagefull($parm = array()) { - $tp = e107::getParser(); + + if (!empty($this->var['download_image'])) + { + + $opts = array( + 'legacy' => "{e_FILE}downloadimages/", + 'class' => 'download-image dl_image download-view-image img-responsive img-fluid ' . vartrue($parm['class']), + 'alt' => basename($this->var['download_image']) + ); + + return e107::getParser()->toImage($this->var['download_image'], $opts); + } + + } + + /** + * {DOWNLOAD_VIEW_LINK: size=2x} + */ + function sc_download_view_link($parm = null) + { + $tp = e107::getParser(); $click = ""; $img = ''; - if(defined('IMAGE_DOWNLOAD')) + if (defined('IMAGE_DOWNLOAD')) { - $img = "".LAN_DOWNLOAD.""; + $img = "" . LAN_DOWNLOAD . ""; } - if(deftrue('BOOTSTRAP')) + if (deftrue('BOOTSTRAP')) { - $img = e107::getParser()->toGlyph('fa-download',$parm); // ''; - } - - if(!empty($this->pref['agree_flag'])) - { - $click = " onclick='return confirm(".$tp->toAttribute($tp->toJSON($tp->toHTML($this->pref['agree_text'],true,'emotes, no_tags'))).")'"; + $img = e107::getParser()->toGlyph('fa-download', $parm); // ''; } - - $url = $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true,$this); //$this->sc_download_request_url(); - - if(varset($parm['type']) == 'href') + + $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}", true, $this); //$this->sc_download_request_url(); + + if (varset($parm['type']) == 'href') { - return $url; + return $url; } - - $dnld_link = ""; - - if ($this->var['download_mirror']) + + if ($this->var['download_mirror'] && $this->var['download_mirror_type']) { - if ($this->var['download_mirror_type']) - { - return "".LAN_dl_66.""; - } - else - { - return $dnld_link.$img.""; - } - } - else - { - return $dnld_link.$img.""; + $url = e_PLUGIN_ABS . "download/download.php?mirror." . $this->var['download_id']; + $img = defined('LAN_dl_66') ? LAN_dl_66 : "Select download mirror"; } + + return "toAttributes([ + "href" => $url, + "onclick" => $this->getAgreeTextAsHtmlEventAttribute() + ]) . ">$img"; } function sc_download_view_filesize() { - return ($this->var['download_filesize']) ? eHelper::parseMemorySize($this->var['download_filesize'], 0) : ""; + return ($this->var['download_filesize']) ? eHelper::parseMemorySize($this->var['download_filesize'], 0) : ""; } - + function sc_download_view_rating() { - + $frm = e107::getForm(); - $options = array('label'=>' ','template'=>'RATE|VOTES|STATUS'); - return $frm->rate("download", $this->var['download_id'], $options); - + $options = array('label' => ' ', 'template' => 'RATE|VOTES|STATUS'); + + return $frm->rate("download", $this->var['download_id'], $options); + /* require_once(e_HANDLER."rate_class.php"); $rater = new rater; @@ -880,74 +909,76 @@ class download_shortcodes extends e_shortcode function sc_download_report_link() { - if(isset($this->pref['download_reportbroken']) && check_class($this->pref['download_reportbroken'])) + if (isset($this->pref['download_reportbroken']) && check_class($this->pref['download_reportbroken'])) { //$url = e_PLUGIN_ABS."download/download.php?action=report&id=".$this->var['download_id']; - $url = e107::url('download','report', $this->var); - return "".LAN_dl_45.""; + $url = e107::url('download', 'report', $this->var); + + return "" . LAN_dl_45 . ""; } return ''; } - + function sc_download_view_caption() { $text = $this->var['download_category_name']; - $text .= ($this->var['download_category_description']) ? " [ ".$this->var['download_category_description']." ]" : ""; + $text .= ($this->var['download_category_description']) ? " [ " . $this->var['download_category_description'] . " ]" : ""; + return $text; } - - + + // Mirror ************************************************************************************** - - function sc_download_mirror_request() + + function sc_download_mirror_request() { - return $this->var['download_name']; + return $this->var['download_name']; } - - function sc_download_mirror_request_icon() + + function sc_download_mirror_request_icon() { - return ($this->var['download_thumb'] ? "*" : ""); + return ($this->var['download_thumb'] ? "*" : ""); } - - function sc_download_mirror_name() + + function sc_download_mirror_name() { - if(empty($this->mirror['dlmirror']['mirror_url'])) + if (empty($this->mirror['dlmirror']['mirror_url'])) { return null; } - return "".$this->mirror['dlmirror']['mirror_name'].""; + return "" . $this->mirror['dlmirror']['mirror_name'] . ""; } - - function sc_download_mirror_image() + + function sc_download_mirror_image() { - return !empty($this->mirror['dlmirror']['mirror_image']) ? "*" : ''; + return !empty($this->mirror['dlmirror']['mirror_image']) ? "*" : ''; } - - function sc_download_mirror_location() + + function sc_download_mirror_location() { - return !empty($this->mirror['dlmirror']['mirror_location']) ? $this->mirror['dlmirror']['mirror_location'] : ''; + return !empty($this->mirror['dlmirror']['mirror_location']) ? $this->mirror['dlmirror']['mirror_location'] : ''; } - - function sc_download_mirror_description() + + function sc_download_mirror_description() { - return !empty($this->mirror['dlmirror']['mirror_description']) ? e107::getParser()->toHTML($this->mirror['dlmirror']['mirror_description'], TRUE) : ''; + return !empty($this->mirror['dlmirror']['mirror_description']) ? e107::getParser()->toHTML($this->mirror['dlmirror']['mirror_description'], true) : ''; } - - function sc_download_mirror_filesize() + + function sc_download_mirror_filesize() { - if(empty($this->mirror['dlmirrorfile'][3])) + if (empty($this->mirror['dlmirrorfile'][3])) { return 0; } - return eHelper::parseMemorySize($this->mirror['dlmirrorfile'][3]); + return eHelper::parseMemorySize($this->mirror['dlmirrorfile'][3]); } - - function sc_download_mirror_link() + + function sc_download_mirror_link() { - if(empty($this->mirror['dlmirrorfile'][0])) + if (empty($this->mirror['dlmirrorfile'][0])) { return null; } @@ -955,175 +986,177 @@ class download_shortcodes extends e_shortcode $tp = e107::getParser(); $img = ''; - $click = !empty($this->pref['agree_text']) ? " onclick='return confirm(".$tp->toAttribute($tp->toJSON($tp->toHTML($this->pref['agree_text'],FALSE,'DESCRIPTION'))).")'" : ''; - - if(defined('IMAGE_DOWNLOAD')) + if (defined('IMAGE_DOWNLOAD')) { - $img = "".LAN_DOWNLOAD.""; + $img = "" . LAN_DOWNLOAD . ""; } - if(deftrue('BOOTSTRAP')) + if (deftrue('BOOTSTRAP')) { - $img = ''; - } - - return "mirror['dlmirrorfile'][0]}' title='".LAN_DOWNLOAD."' {$click}>".$img.""; + $img = ''; + } + + return "toAttributes([ + "href" => e_PLUGIN_ABS . "download/download.php?mirror.{$this->var['download_id']}.{$this->mirror['dlmirrorfile'][0]}", + "title" => LAN_DOWNLOAD, + "onclick" => $this->getAgreeTextAsHtmlEventAttribute(), + ]) . ">" . $img . ""; } - - function sc_download_mirror_requests() + + function sc_download_mirror_requests() { - return (ADMIN && !empty($this->mirror['dlmirrorfile'][2])) ? LAN_dl_73.$this->mirror['dlmirrorfile'][2] : ""; + return (ADMIN && !empty($this->mirror['dlmirrorfile'][2])) ? LAN_dl_73 . $this->mirror['dlmirrorfile'][2] : ""; } - - function sc_download_total_mirror_requests() + + function sc_download_total_mirror_requests() { - return (ADMIN && isset($this->mirror['dlmirror']['mirror_count'])) ? LAN_dl_74.$this->mirror['dlmirror']['mirror_count'] : ""; + return (ADMIN && isset($this->mirror['dlmirror']['mirror_count'])) ? LAN_dl_74 . $this->mirror['dlmirror']['mirror_count'] : ""; } - - - // --------- Download View Lans ----------------------------- - - function sc_download_view_author_lan() - { - return !empty($this->var['download_author']) ? LAN_AUTHOR : ""; - } - - function sc_download_view_authoremail_lan() - { - return ($this->var['download_author_email']) ? LAN_dl_30 : ""; - } - - function sc_download_view_authorwebsite_lan() - { - return ($this->var['download_author_website']) ? LAN_dl_31 : ""; - } - - function sc_download_view_date_lan() - { + // --------- Download View Lans ----------------------------- - return ($this->var['download_datestamp']) ? LAN_DATE: ""; - } - - function sc_download_view_image_lan() - { - return LAN_IMAGE; - } - - function sc_download_view_requested() - { + function sc_download_view_author_lan() + { + return !empty($this->var['download_author']) ? LAN_AUTHOR : ""; + } - return $this->var['download_requested']; - } - - function sc_download_view_rating_lan() - { - return LAN_RATING; - } - - function sc_download_view_filesize_lan() - { - return LAN_SIZE; - } - - function sc_download_view_description_lan() - { - return LAN_DESCRIPTION; - } - - function sc_download_view_requested_lan() - { - return LAN_dl_77; - } - - function sc_download_view_link_lan() - { - return LAN_DOWNLOAD; - } - - - // ----------- Download View : Previous and Next --------------- - - /** + function sc_download_view_authoremail_lan() + { + + return ($this->var['download_author_email']) ? LAN_dl_30 : ""; + } + + function sc_download_view_authorwebsite_lan() + { + + return ($this->var['download_author_website']) ? LAN_dl_31 : ""; + } + + function sc_download_view_date_lan() + { + + return ($this->var['download_datestamp']) ? LAN_DATE : ""; + } + + function sc_download_view_image_lan() + { + return LAN_IMAGE; + } + + function sc_download_view_requested() + { + + return $this->var['download_requested']; + } + + function sc_download_view_rating_lan() + { + return LAN_RATING; + } + + function sc_download_view_filesize_lan() + { + return LAN_SIZE; + } + + function sc_download_view_description_lan() + { + return LAN_DESCRIPTION; + } + + function sc_download_view_requested_lan() + { + return LAN_dl_77; + } + + function sc_download_view_link_lan() + { + return LAN_DOWNLOAD; + } + + + // ----------- Download View : Previous and Next --------------- + + /** * {DOWNLOAD_VIEW_PREV: x=y} - */ - function sc_download_view_prev($parm='') - { + */ + function sc_download_view_prev($parm = '') + { $sql = e107::getDb(); - $tp = e107::getParser(); - - $dlrow_id = intval($this->var['download_id']); + $tp = e107::getParser(); - $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('fa-chevron-left') : '<<'; - $class = empty($parm['class']) ? 'e-tip page-link' : $parm['class']; + $dlrow_id = intval($this->var['download_id']); + + $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('fa-chevron-left') : '<<'; + $class = empty($parm['class']) ? 'e-tip page-link' : $parm['class']; + + if ($sql->select("download", "*", "download_category='" . intval($this->var['download_category_id']) . "' AND download_id < {$dlrow_id} AND download_active > 0 && download_visible IN (" . USERCLASS_LIST . ") ORDER BY download_datestamp DESC LIMIT 1")) + { + $dlrowrow = $sql->fetch(); - if ($sql->select("download", "*", "download_category='".intval($this->var['download_category_id'])."' AND download_id < {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp DESC LIMIT 1")) - { - $dlrowrow = $sql->fetch(); - $url = e107::url('download', 'item', $dlrowrow); - return "".$icon." ".LAN_PREVIOUS."\n"; - - // return "<< ".LAN_dl_33." [".$dlrowrow['download_name']."]\n"; - } + return "" . $icon . " " . LAN_PREVIOUS . "\n"; + + // return "<< ".LAN_dl_33." [".$dlrowrow['download_name']."]\n"; + } else { $class .= ' disabled'; - return "".$icon." ".LAN_PREVIOUS."\n"; - } - } - - /** + + return "" . $icon . " " . LAN_PREVIOUS . "\n"; + } + } + + /** * {DOWNLOAD_VIEW_NEXT: x=y} */ - function sc_download_view_next($parm='') + function sc_download_view_next($parm = '') { $sql = e107::getDb(); $tp = e107::getParser(); $dlrow_id = intval($this->var['download_id']); - $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('fa-chevron-right') : '>>'; - $class = empty($parm['class']) ? 'e-tip page-link' : $parm['class']; + $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('fa-chevron-right') : '>>'; + $class = empty($parm['class']) ? 'e-tip page-link' : $parm['class']; - if ($sql->select("download", "*", "download_category='".intval($this->var['download_category_id'])."' AND download_id > {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp ASC LIMIT 1")) - { - $dlrowrow = $sql->fetch(); + if ($sql->select("download", "*", "download_category='" . intval($this->var['download_category_id']) . "' AND download_id > {$dlrow_id} AND download_active > 0 && download_visible IN (" . USERCLASS_LIST . ") ORDER BY download_datestamp ASC LIMIT 1")) + { + $dlrowrow = $sql->fetch(); extract($dlrowrow); - $url = $url = e107::url('download', 'item', $dlrowrow); + $url = $url = e107::url('download', 'item', $dlrowrow); + return "" . LAN_NEXT . " " . $icon . "\n"; + // return "[".$dlrowrow['download_name']."] ".LAN_dl_34." >>\n"; + } + else + { + $class .= ' disabled'; - return "".LAN_NEXT." ".$icon."\n"; - - // return "[".$dlrowrow['download_name']."] ".LAN_dl_34." >>\n"; - } - else - { - $class .= ' disabled'; - return "".LAN_NEXT." ".$icon."\n"; + return "" . LAN_NEXT . " " . $icon . "\n"; - } + } } - - /** + + /** * {DOWNLOAD_BACK_TO_LIST: x=y} */ - function sc_download_back_to_list($parm=null) - { - $url = e107::url('download', 'category', $this->var); + function sc_download_back_to_list($parm = null) + { + $url = e107::url('download', 'category', $this->var); // e_PLUGIN_ABS."download/download.php?action=list&id=".$this->var['download_category'] - - $title = "Back to [x]"; - $class = empty($parm['class']) ? 'e-tip page-link' : $parm['class']; - - return "lanVars($title,array('x'=>$this->var['download_category_name']))."\" href='".$url."'>".LAN_BACK.""; - } - - function sc_download_back_to_category_list() - { - if(!empty($this->parent)) + + $title = "Back to [x]"; + $class = empty($parm['class']) ? 'e-tip page-link' : $parm['class']; + + return "lanVars($title, array('x' => $this->var['download_category_name'])) . "\" href='" . $url . "'>" . LAN_BACK . ""; + } + + function sc_download_back_to_category_list() + { + if (!empty($this->parent)) { $link = e107::url('download', 'category', $this->parent); } @@ -1132,89 +1165,89 @@ class download_shortcodes extends e_shortcode $link = ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null; } - return "".LAN_dl_9.""; - } - - - // Misc stuff --------------------------------------------------------------------------------- - function sc_download_cat_newdownload_text() - { - return $this->renderNewIcon()." ".LAN_dl_36; - } - - function sc_download_cat_search() - { + return "" . LAN_dl_9 . ""; + } + + + // Misc stuff --------------------------------------------------------------------------------- + function sc_download_cat_newdownload_text() + { + return $this->renderNewIcon() . " " . LAN_dl_36; + } + + function sc_download_cat_search() + { $tp = e107::getParser(); - $text = "