public function display($tpl = null) { //Load pane behavior in joomla 3 jimport('joomla.html.html.tabs'); // Initialise variables. $app = JFactory::getApplication(); $user = JFactory::getUser(); $document = JFactory::getDocument(); $document->addStyleSheet('components/com_jdownloads/assets/css/jdownloads_fe.css'); $custom_css_path = JPATH_ROOT . '/components/com_jdownloads/assets/css/jdownloads_custom.css'; if (JFile::exists($custom_css_path)) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_custom.css", 'text/css', null, array()); } $document->addScript(JURI::base() . 'components/com_jdownloads/assets/js/jdownloads.js'); $document->addScriptDeclaration(' // dynamically add a new image file upload field when the prior generated fields is used function add_new_image_file(field) { // Get the number of files previously uploaded. var count = parseInt(document.getElementById(\'image_file_count\').value); var sum = parseInt(document.getElementById(\'sum_listed_images\').value); var max = parseInt(document.getElementById(\'max_sum_images\').value); // Get the name of the file that has just been uploaded. var file_name = document.getElementById("file_upload_thumb["+count+"]").value; // Hide the file upload control containing the information about the picture that was just uploaded. document.getElementById(\'new_file_row\').style.display = "none"; document.getElementById(\'new_file_row\').id = "new_file_row["+count+"]"; // Get a reference to the table containing the uploaded pictures. var table = document.getElementById(\'files_table\'); // Insert a new row with the file name and a delete button. var row = table.insertRow(table.rows.length); row.id = "inserted_file["+count+"]"; var cell0 = row.insertCell(0); cell0.innerHTML = \'<input type="text" disabled="disabled" name="inserted_file[\'+count+\']" value="\'+file_name+\'" size="40" /><input type="button" name="delete[\'+count+\']" value="' . JTEXT::_('COM_JDOWNLOADS_REMOVE') . '" onclick="delete_inserted_image_field(this)">\'; // Increment count of the number of files uploaded. ++count; if (count+sum < max){ // Insert a new file upload control in the table. var row = table.insertRow(table.rows.length); row.id = "new_file_row"; var cell0 = row.insertCell(0); cell0.innerHTML = \'<input type="file" name="file_upload_thumb[\'+count+\']" id="file_upload_thumb[\'+count+\']" size="40" accept="image/gif,image/jpeg,image/jpg,image/png" onchange="add_new_image_file(this)" />\'; } // Update the value of the file hidden input tag holding the count of files uploaded. document.getElementById(\'image_file_count\').value = count; } // user will remove the files they have previously added function delete_inserted_image_field(field) { // Get the field name. var name = field.name; // Extract the file id from the field name. var id = name.substr(name.indexOf(\'[\') + 1, name.indexOf(\']\') - name.indexOf(\'[\') - 1); // Hide the row displaying the uploaded file name. document.getElementById("inserted_file["+id+"]").style.display = "none"; // Get a reference to the uploaded file control. var control = document.getElementById("file_upload_thumb["+id+"]"); // Remove the new file control. control.parentNode.removeChild(control); // check that we have always a input field when we remove a other file var found = false; for (var i = 0; i <= 30; i++){ if (document.adminForm.elements["file_upload_thumb["+i+"]"]) { found = true; } } if (!found) add_new_image_file(field); }'); // Get model data. $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); // we must get all 'allowed' category IDs $this->authorised_cats = JDHelper::getAuthorisedJDCategories('core.create', $user); $user_rules = JDHelper::getUserRules(); $user_limits = JDHelper::getUserLimits($user_rules, 0); // Here is the place to change field attributes - defined in user groups limits if (!$user_rules->uploads_use_editor) { $this->form->setFieldAttribute('description', 'type', 'textarea'); $this->form->setFieldAttribute('description', 'rows', '4'); $this->form->setFieldAttribute('description', 'cols', '60'); $this->form->setFieldAttribute('description_long', 'type', 'textarea'); $this->form->setFieldAttribute('description_long', 'rows', '6'); $this->form->setFieldAttribute('description_long', 'cols', '60'); $this->form->setFieldAttribute('changelog', 'type', 'textarea'); $this->form->setFieldAttribute('changelog', 'rows', '4'); $this->form->setFieldAttribute('changelog', 'cols', '60'); $this->form->setFieldAttribute('custom_field_13', 'type', 'textarea'); $this->form->setFieldAttribute('custom_field_13', 'rows', '4'); $this->form->setFieldAttribute('custom_field_13', 'cols', '60'); $this->form->setFieldAttribute('custom_field_14', 'type', 'textarea'); $this->form->setFieldAttribute('custom_field_14', 'rows', '4'); $this->form->setFieldAttribute('custom_field_14', 'cols', '60'); } // activate the 'required' state if ($user_rules->form_alias && $user_rules->form_alias_x) { $this->form->setFieldAttribute('file_alias', 'required', 'true'); } if ($user_rules->form_author_mail && $user_rules->form_author_mail_x) { $this->form->setFieldAttribute('url_author', 'required', 'true'); } if ($user_rules->form_author_name && $user_rules->form_author_name_x) { $this->form->setFieldAttribute('author', 'required', 'true'); } if ($user_rules->form_website && $user_rules->form_website_x) { $this->form->setFieldAttribute('url_home', 'required', 'true'); } if ($user_rules->form_changelog && $user_rules->form_changelog_x) { $this->form->setFieldAttribute('changelog', 'required', 'true'); } if ($user_rules->form_creation_date && $user_rules->form_creation_date_x) { $this->form->setFieldAttribute('date_added', 'required', 'true'); } if ($user_rules->form_external_file && $user_rules->form_external_file_x) { $this->form->setFieldAttribute('extern_file', 'required', 'true'); } if ($user_rules->form_license && $user_rules->form_license_x) { $this->form->setFieldAttribute('license', 'required', 'true'); } if ($user_rules->form_version && $user_rules->form_version_x) { $this->form->setFieldAttribute('release', 'required', 'true'); } if ($user_rules->form_file_date && $user_rules->form_file_date_x) { $this->form->setFieldAttribute('file_date', 'required', 'true'); } if ($user_rules->form_file_language && $user_rules->form_file_language_x) { $this->form->setFieldAttribute('file_language', 'required', 'true'); } if ($user_rules->form_file_pic && $user_rules->form_file_pic_x) { $this->form->setFieldAttribute('file_pic', 'required', 'true'); } if ($user_rules->form_file_system && $user_rules->form_file_system_x) { $this->form->setFieldAttribute('system', 'required', 'true'); } if ($user_rules->form_images && $user_rules->form_images_x) { $this->form->setFieldAttribute('images', 'required', 'true'); } if ($user_rules->form_language && $user_rules->form_language_x) { $this->form->setFieldAttribute('language', 'required', 'true'); } if ($user_rules->form_mirror_1 && $user_rules->form_mirror_1_x) { $this->form->setFieldAttribute('mirror_1', 'required', 'true'); } if ($user_rules->form_mirror_2 && $user_rules->form_mirror_2_x) { $this->form->setFieldAttribute('mirror_2', 'required', 'true'); } if ($user_rules->form_password && $user_rules->form_password_x) { $this->form->setFieldAttribute('password', 'required', 'true'); } if ($user_rules->form_price && $user_rules->form_price_x) { $this->form->setFieldAttribute('price', 'required', 'true'); } if ($user_rules->form_short_desc && $user_rules->form_short_desc_x) { $this->form->setFieldAttribute('description', 'required', 'true'); } if ($user_rules->form_long_desc && $user_rules->form_long_desc_x) { $this->form->setFieldAttribute('description_long', 'required', 'true'); } if ($user_rules->form_extra_select_box_1 && $user_rules->form_extra_select_box_1_x) { $this->form->setFieldAttribute('custom_field_1', 'required', 'true'); } if ($user_rules->form_extra_select_box_2 && $user_rules->form_extra_select_box_2_x) { $this->form->setFieldAttribute('custom_field_2', 'required', 'true'); } if ($user_rules->form_extra_select_box_3 && $user_rules->form_extra_select_box_3_x) { $this->form->setFieldAttribute('custom_field_3', 'required', 'true'); } if ($user_rules->form_extra_select_box_4 && $user_rules->form_extra_select_box_4_x) { $this->form->setFieldAttribute('custom_field_4', 'required', 'true'); } if ($user_rules->form_extra_select_box_5 && $user_rules->form_extra_select_box_5_x) { $this->form->setFieldAttribute('custom_field_5', 'required', 'true'); } if ($user_rules->form_extra_short_input_1 && $user_rules->form_extra_short_input_1_x) { $this->form->setFieldAttribute('custom_field_6', 'required', 'true'); } if ($user_rules->form_extra_short_input_2 && $user_rules->form_extra_short_input_2_x) { $this->form->setFieldAttribute('custom_field_7', 'required', 'true'); } if ($user_rules->form_extra_short_input_3 && $user_rules->form_extra_short_input_3_x) { $this->form->setFieldAttribute('custom_field_8', 'required', 'true'); } if ($user_rules->form_extra_short_input_4 && $user_rules->form_extra_short_input_4_x) { $this->form->setFieldAttribute('custom_field_9', 'required', 'true'); } if ($user_rules->form_extra_short_input_5 && $user_rules->form_extra_short_input_5_x) { $this->form->setFieldAttribute('custom_field_10', 'required', 'true'); } if ($user_rules->form_extra_date_1 && $user_rules->form_extra_date_1_x) { $this->form->setFieldAttribute('custom_field_11', 'required', 'true'); } if ($user_rules->form_extra_date_2 && $user_rules->form_extra_date_2_x) { $this->form->setFieldAttribute('custom_field_12', 'required', 'true'); } if ($user_rules->form_extra_large_input_1 && $user_rules->form_extra_large_input_1_x) { $this->form->setFieldAttribute('custom_field_13', 'required', 'true'); } if ($user_rules->form_extra_large_input_2 && $user_rules->form_extra_large_input_2_x) { $this->form->setFieldAttribute('custom_field_14', 'required', 'true'); } // check the possibility to create new custom tags if (!$user_rules->uploads_allow_custom_tags) { $this->form->setFieldAttribute('tags', 'custom', 'deny'); //$this->form->setFieldAttribute( 'tags', 'mode', 'nested' ); } if (!$this->item->file_id) { // new Download // set default value for access in form when exist - use otherwise 1 for public access if ($user_rules->uploads_default_access_level) { $this->form->setValue('access', null, (int) $user_rules->uploads_default_access_level); } // Use this options only for 'creation' page (...why?) if ($user_rules->form_select_main_file && $user_rules->form_select_main_file_x) { $this->form->setFieldAttribute('file_upload', 'required', 'true'); } if ($user_rules->form_select_preview_file && $user_rules->form_select_preview_file_x) { $this->form->setFieldAttribute('preview_file_upload', 'required', 'true'); } } // user will edit a exist download so we must check the category rule if ($this->item->file_id && !$user_rules->uploads_can_change_category) { // change category field to readonly $this->form->setFieldAttribute('cat_id', 'readonly', 'true'); } $this->return_page = $this->get('ReturnPage'); if (!$this->return_page) { // seems we will create a new download about 'Add' button, so we will use the current url for return page $current_url = $_SERVER['HTTP_REFERER']; if ($current_url) { $this->return_page = base64_encode(urlencode($current_url)); } else { $this->return_page = base64_encode(urlencode(JURI::current())); } } if (empty($this->item->file_id)) { $authorised = $user->authorise('core.create', 'com_jdownloads') || count($this->authorised_cats); } else { $authorised = $this->item->params->get('access-edit'); } if ($authorised !== true) { if (empty($this->item->file_id)) { JError::raiseWarning(100, JText::_('COM_JDOWNLOADS_FRONTEND_CREATE_NO_PERMISSIONS')); } else { JError::raiseWarning(100, JText::_('COM_JDOWNLOADS_FRONTEND_EDIT_NO_PERMISSIONS')); } return false; } else { $this->view_upload_button = true; } if (isset($user_limits['upload']->sumfiles) && $user_limits['upload']->sumfiles > 0) { $upload_limits_reached = $user_limits['upload_remaining'] == 0; } else { $upload_limits_reached = false; } if ($upload_limits_reached == true) { $text = JDHelper::getOnlyLanguageSubstring($user_rules->upload_limit_daily_msg); if ($text != '') { JError::raiseNotice(100, $text); } else { JError::raiseNotice(100, JText::_('COM_JDOWNLOADS_DAILY_UPLOAD_LIMITS_REACHED_TEXT')); } return false; } $this->user_rules = $user_rules; $this->user_limits = $user_limits; $this->item->tags = new JHelperTags(); if (!empty($this->item->file_id)) { $this->item->tags->getItemTags('com_jdownloads.download.', $this->item->file_id); } if (!empty($this->item) && isset($this->item->file_id)) { $tmp = new stdClass(); $tmp->images = $this->item->images; $this->form->bind($tmp); } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } // Create a shortcut to the parameters. $params =& $this->state->params; //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->params = $params; $this->user = $user; // check whether it is in menu settings defined only a single category if ($params->get('enable_category') == 1) { $this->form->setFieldAttribute('cat_id', 'default', $params->get('catid', 1)); $this->form->setFieldAttribute('cat_id', 'readonly', 'true'); } $this->_prepareDocument(); parent::display($tpl); }
function display($tpl = null) { global $jlistConfig; // Initialise variables. $app = JFactory::getApplication(); $user = JFactory::getUser(); $userId = $user->get('id'); $jd_user_settings = JDHelper::getUserRules(); // get jD User group settings and limitations $this->user_rules = JDHelper::getUserRules(); $dispatcher = JDispatcher::getInstance(); $this->item = $this->get('Item'); $this->state = $this->get('State'); $this->user = $user; // upload icon handling $this->view_upload_button = false; if ($jd_user_settings->uploads_view_upload_icon) { // we must here check whether the user has the permissions to create new downloads // this can be defined in the components permissions but also in any category // but the upload icon is only viewed when in the user groups settings is also activated the: 'display add/upload icon' option // 1. check the component permissions if (!$user->authorise('core.create', 'com_jdownloads')) { // 2. not global permissions so we must check now every category (for a lot of categories can this be very slow) $this->authorised_cats = JDHelper::getAuthorisedJDCategories('core.create', $user); if (count($this->authorised_cats) > 0) { $this->view_upload_button = true; } } else { $this->view_upload_button = true; } } $this->ipad_user = false; // check whether we have an ipad/iphone user for flowplayer aso... if ((bool) strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') || (bool) strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')) { $this->ipad_user = true; } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } // add all needed cripts and css files $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/js/jdownloads.js'); if ($jlistConfig['view.ratings']) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/rating/js/ajaxvote.js'); } // loadscript for flowplayer if ($jlistConfig['flowplayer.use']) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/flowplayer/flowplayer-3.2.12.min.js'); // load also the ipad plugin when required if ($this->ipad_user) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/flowplayer/flowplayer.ipad-3.2.12.min.js'); } } if ($jlistConfig['use.lightbox.function']) { JHtml::_('bootstrap.framework'); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/lightbox/lightbox.js'); $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/lightbox/lightbox.css", 'text/css', null, array()); } $document->addScriptDeclaration('var live_site = "' . JURI::base() . '";'); $document->addScriptDeclaration('function openWindow (url) { fenster = window.open(url, "_blank", "width=550, height=480, STATUS=YES, DIRECTORIES=NO, MENUBAR=NO, SCROLLBARS=YES, RESIZABLE=NO"); fenster.focus(); }'); if ($jlistConfig['use.css.buttons.instead.icons']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_buttons.css", "text/css", null, array()); } $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_fe.css", "text/css", null, array()); if ($jlistConfig['view.ratings']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/rating/css/ajaxvote.css", "text/css", null, array()); } $custom_css_path = JPATH_ROOT . '/components/com_jdownloads/assets/css/jdownloads_custom.css'; if (JFile::exists($custom_css_path)) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_custom.css", 'text/css', null, array()); } $this->jd_image_path = JPATH_ROOT . '/images/jdownloads'; // Create a shortcut for $item. $item = $this->item; $item->tagLayout = new JLayoutFile('joomla.content.tags'); // Add router helpers. $item->slug = $item->file_alias ? $item->file_id . ':' . $item->file_alias : $item->file_id; $item->catslug = $item->category_alias ? $item->cat_id . ':' . $item->category_alias : $item->cat_id; $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // TODO: Change based on shownoauth //$item->readmore_link = JRoute::_(JdownloadsHelperRoute::getDownloadRoute($item->slug, $item->catslug)); // Merge download params. If this is single-download view, menu params override download params // Otherwise, download params override menu item params $this->params = $this->state->get('params'); $active = $app->getMenu()->getActive(); $temp = clone $this->params; // Check to see which parameters should take priority if ($active) { $currentLink = $active->link; // If the current view is the active item and an download view for this download, then the menu item params take priority if (strpos($currentLink, 'view=download') && strpos($currentLink, '&id=' . (string) $item->file_id)) { // $item->params are the download params, $temp are the menu item params // Merge so that the menu item params take priority $item->params->merge($temp); // Load layout from active query (in case it is an alternative menu item) if (isset($active->query['layout'])) { $this->setLayout($active->query['layout']); } } else { // Current view is not a single download, so the download params take priority here // Merge the menu item params with the download params so that the download params take priority $temp->merge($item->params); $item->params = $temp; } } else { // Merge so that download params take priority $temp->merge($item->params); $item->params = $temp; // Check for alternative layouts (since we are not in a single-download menu item) // Single-download menu item layout takes priority over alt layout for an download if ($layout = $item->params->get('download_layout')) { $this->setLayout($layout); } } $offset = $this->state->get('list.offset'); // Check the view access to the download (the model has already computed the values). if ($item->params->get('access-view') != true && ($item->params->get('show_noauth') != true && $user->get('guest'))) { JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR')); return; } $item->tags = new JHelperTags(); $item->tags->getItemTags('com_jdownloads.download', $this->item->file_id); // required for some content plugins if ($item->description_long != '') { $item->text = $item->description_long; $long_used = true; } else { $item->text = $item->description; $long_used = false; } $item->id = $item->file_id; // Process the content plugins. JPluginHelper::importPlugin('content'); // this is the event to modify the download data. if ($jlistConfig['activate.general.plugin.support'] && !$jlistConfig['use.general.plugin.support.only.for.descriptions']) { $dispatcher->trigger('onContentPrepare', array('com_jdownloads.download', &$item, &$this->params, $offset)); } $item->event = new stdClass(); // This is a request for information that should be placed immediately before the generated content. $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_jdownloads.download', &$item, &$this->params, $offset)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); // This is a request for information that should be placed immediately after the generated content. $results = $dispatcher->trigger('onContentAfterDisplay', array('com_jdownloads.download', &$item, &$this->params, $offset)); $item->event->afterDisplayContent = trim(implode("\n", $results)); // we use a little trick to get always the changes from content plugins if ($long_used) { if ($item->text != $item->description_long) { $item->description_long = $item->text; } } else { if ($item->text != $item->description) { $item->description = $item->text; } } // Increment the views counter of the download $model = $this->getModel(); $model->view(); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->item->params->get('pageclass_sfx')); $this->_prepareDocument(); parent::display($tpl); }
/** * Display the view * @return mixed False on error, null otherwise. */ public function display($tpl = null) { global $jlistConfig; $app = JFactory::getApplication(); $user = JFactory::getUser(); $jd_user_settings = JDHelper::getUserRules(); // Initialise variables $state = $this->get('State'); $items = $this->get('Items'); $pagination = $this->get('Pagination'); // upload icon handling $this->view_upload_button = false; if ($jd_user_settings->uploads_view_upload_icon) { // we must here check whether the user has the permissions to create new downloads // this can be defined in the components permissions but also in any category // but the upload icon is only viewed when in the user groups settings is also activated the: 'display add/upload icon' option // 1. check the component permissions if (!$user->authorise('core.create', 'com_jdownloads')) { // 2. not global permissions so we must check now every category (for a lot of categories can this be very slow) $this->authorised_cats = JDHelper::getAuthorisedJDCategories('core.create', $user); if (count($this->authorised_cats) > 0) { $this->view_upload_button = true; } } else { $this->view_upload_button = true; } } $this->ipad_user = false; // check whether we have an ipad/iphone user for flowplayer aso... if ((bool) strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') || (bool) strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')) { $this->ipad_user = true; } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } if ($items === false) { return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } // add all needed cripts and css files $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/js/jdownloads.js'); if ($jlistConfig['view.ratings']) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/rating/js/ajaxvote.js'); } // loadscript for flowplayer if ($jlistConfig['flowplayer.use']) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/flowplayer/flowplayer-3.2.12.min.js'); // load also the ipad plugin when required if ($this->ipad_user) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/flowplayer/flowplayer.ipad-3.2.12.min.js'); } } if ($jlistConfig['use.lightbox.function']) { JHtml::_('bootstrap.framework'); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/lightbox/lightbox.js'); $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/lightbox/lightbox.css", 'text/css', null, array()); } $document->addScriptDeclaration('var live_site = "' . JURI::base() . '";'); $document->addScriptDeclaration('function openWindow (url) { fenster = window.open(url, "_blank", "width=550, height=480, STATUS=YES, DIRECTORIES=NO, MENUBAR=NO, SCROLLBARS=YES, RESIZABLE=NO"); fenster.focus(); }'); if ($jlistConfig['use.css.buttons.instead.icons']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_buttons.css", "text/css", null, array()); } $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_fe.css", "text/css", null, array()); if ($jlistConfig['view.ratings']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/rating/css/ajaxvote.css", "text/css", null, array()); } $custom_css_path = JPATH_ROOT . '/components/com_jdownloads/assets/css/jdownloads_custom.css'; if (JFile::exists($custom_css_path)) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_custom.css", 'text/css', null, array()); } $this->jd_image_path = JPATH_ROOT . '/images/jdownloads'; $params =& $state->params; // Compute the download slugs and prepare text (runs content plugins). for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $item->tags = new JHelperTags(); $item->tags->getItemTags('com_jdownloads.download', $item->file_id); $item->slug = $item->file_alias ? $item->file_id . ':' . $item->file_alias : $item->file_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } // required for some content plugins $item->text = $item->description; $item->id = $item->file_id; $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $dispatcher->trigger('onContentPrepare', array('com_jdownloads.downloads', &$item, &$this->params, 0)); $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_jdownloads.downloads', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_jdownloads.downloads', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_jdownloads.downloads', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); // we use a little trick to get always the changes from content plugins if ($item->text != $item->description) { $item->description = $item->text; } } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->maxLevelcat = $params->get('maxLevelcat', -1); $this->assignRef('state', $state); $this->assignRef('params', $params); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); $this->_prepareDocument(); parent::display($tpl); }
/** * Display the view * * @return mixed False on error, null otherwise. */ function display($tpl = null) { global $jlistConfig; $app = JFactory::getApplication(); $user = JFactory::getUser(); $model = $this->getModel(); $jd_user_settings = JDHelper::getUserRules(); // Get some data from the models $state = $this->get('State'); $params = $state->params; $items = $this->get('Items'); jimport('joomla.html.pagination'); $pagination = new JPagination($model->getTotal(), $model->getState('list.start'), $model->getState('list.limit')); $parent = $this->get('Parent'); // upload icon handling $this->view_upload_button = false; if ($jd_user_settings->uploads_view_upload_icon) { // we must here check whether the user has the permissions to create new downloads // this can be defined in the components permissions but also in any category // but the upload icon is only viewed when in the user groups settings is also activated the: 'display add/upload icon' option // 1. check the component permissions if (!$user->authorise('core.create', 'com_jdownloads')) { // 2. not global permissions so we must check now every category (for a lot of categories can this be very slow) $this->authorised_cats = JDHelper::getAuthorisedJDCategories('core.create', $user); if (count($this->authorised_cats) > 0) { $this->view_upload_button = true; } } else { $this->view_upload_button = true; } } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } if ($items == false) { // return JError::raiseError(404, JText::_('COM_JDOWNLOADS_CATEGORY_NOT_FOUND')); } if ($parent == false) { JError::raiseError(404, JText::_('COM_JDOWNLOADS_CATEGORY_PARENT_NOT_FOUND')); return false; } // Get the tags foreach ($items as $item) { $item->tags = new JHelperTags(); $item->tags->getItemTags('com_jdownloads.category', $item->id); } // add all needed cripts and css files $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/js/jdownloads.js'); if ($jlistConfig['view.ratings']) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/rating/js/ajaxvote.js'); } if ($jlistConfig['use.lightbox.function']) { JHtml::_('bootstrap.framework'); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/lightbox/lightbox.js'); $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/lightbox/lightbox.css", 'text/css', null, array()); } $document->addScriptDeclaration('var live_site = "' . JURI::base() . '";'); $document->addScriptDeclaration('function openWindow (url) { fenster = window.open(url, "_blank", "width=550, height=480, STATUS=YES, DIRECTORIES=NO, MENUBAR=NO, SCROLLBARS=YES, RESIZABLE=NO"); fenster.focus(); }'); if ($jlistConfig['use.css.buttons.instead.icons']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_buttons.css", "text/css", null, array()); } $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_fe.css", "text/css", null, array()); if ($jlistConfig['view.ratings']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/rating/css/ajaxvote.css", "text/css", null, array()); } $custom_css_path = JPATH_ROOT . '/components/com_jdownloads/assets/css/jdownloads_custom.css'; if (JFile::exists($custom_css_path)) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_custom.css", 'text/css', null, array()); } $this->jd_image_path = JPATH_ROOT . '/images/jdownloads'; // $items = array($parent->id => $items); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->maxLevelcat = $params->get('maxLevelcat', -1); $this->assignRef('state', $state); $this->assignRef('params', $params); $this->assignRef('parent', $parent); $this->assignRef('items', $items); $this->assignRef('pagination', $pagination); $this->_prepareDocument(); parent::display($tpl); }
function display($tpl = null) { global $jlistConfig; $app = JFactory::getApplication(); $user = JFactory::getUser(); $jd_user_settings = JDHelper::getUserRules(); // Get some data from the models $state = $this->get('State'); $params = $state->params; $items = $this->get('Items'); // get the category downloads $category = $this->get('Category'); // get the selected category data $children = $this->get('Children'); // get the categories sub categories $parent = $this->get('Parent'); // get the categories parent categories $pagination = $this->get('Pagination'); // upload icon handling $this->view_upload_button = false; if ($jd_user_settings->uploads_view_upload_icon) { // we must here check whether the user has the permissions to create new downloads // this can be defined in the components permissions but also in any category // but the upload icon is only viewed when in the user groups settings is also activated the: 'display add/upload icon' option // 1. check the component permissions if (!$user->authorise('core.create', 'com_jdownloads')) { // 2. not global permissions so we must check now every category (for a lot of categories can this be very slow) $this->authorised_cats = JDHelper::getAuthorisedJDCategories('core.create', $user); if (count($this->authorised_cats) > 0) { $this->view_upload_button = true; } } else { $this->view_upload_button = true; } } $this->ipad_user = false; // check whether we have an ipad/iphone user for flowplayer aso... if ((bool) strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') || (bool) strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone')) { $this->ipad_user = true; } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // add all needed cripts and css files $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/js/jdownloads.js'); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/rating/js/ajaxvote.js'); // loadscript for flowplayer if ($jlistConfig['flowplayer.use']) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/flowplayer/flowplayer-3.2.12.min.js'); // load also the ipad plugin when required if ($this->ipad_user) { $document->addScript(JURI::base() . 'components/com_jdownloads/assets/flowplayer/flowplayer.ipad-3.2.12.min.js'); } } $document->addScriptDeclaration('live_site = "' . JURI::base() . '";'); $document->addScriptDeclaration('function openWindow (url) { fenster = window.open(url, "_blank", "width=550, height=480, STATUS=YES, DIRECTORIES=NO, MENUBAR=NO, SCROLLBARS=YES, RESIZABLE=NO"); fenster.focus(); }'); if ($jlistConfig['use.lightbox.function']) { JHtml::_('bootstrap.framework'); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/lightbox/lightbox.js'); $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/lightbox/lightbox.css", 'text/css', null, array()); } // required only for subcategories pagination $document->addScript(JURI::base() . 'components/com_jdownloads/assets/pagination/jdpagination.js'); if ($jlistConfig['use.css.buttons.instead.icons']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_buttons.css", "text/css", null, array()); } $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_fe.css", "text/css", null, array()); $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/rating/css/ajaxvote.css", "text/css", null, array()); $custom_css_path = JPATH_ROOT . '/components/com_jdownloads/assets/css/jdownloads_custom.css'; if (JFile::exists($custom_css_path)) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_custom.css", 'text/css', null, array()); } $this->jd_image_path = JPATH_ROOT . '/images/jdownloads'; if ($category == false) { return JError::raiseError(404, JText::_('COM_JDOWNLOADS_CATEGORY_NOT_FOUND')); } if ($parent == false) { return JError::raiseError(404, JText::_('COM_JDOWNLOADS_CATEGORY_PARENT_NOT_FOUND')); } // Setup the category parameters. $cparams = $category->getParams(); $category->params = clone $params; $category->params->merge($cparams); $category->tags = new JHelperTags(); $category->tags->getItemTags('com_jdownloads.category', $category->id); // Check whether category access level allows access. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); if (!in_array($category->access, $groups)) { return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); } // Compute the download slugs and prepare introtext (runs content plugins). for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; $item->slug = $item->file_alias ? $item->file_id . ':' . $item->file_alias : $item->file_id; // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } // required for some content plugins $item->text = $item->description; $item->id = $item->file_id; $item->event = new stdClass(); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_jdownloads.category', &$item, &$this->params, 0)); $results = $dispatcher->trigger('onContentAfterTitle', array('com_jdownloads.category', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_jdownloads.category', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_jdownloads.category', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); // check the result from content plugins if ($item->text != $item->description) { $item->description = $item->text; } } // Check for layout override only if this is not the active menu item // If it is the active menu item, then the view and category id will match $active = $app->getMenu()->getActive(); if (!$active || (strpos($active->link, 'view=category') === false || strpos($active->link, '&catid=' . (string) $category->id) === false)) { // Get the layout from the merged category params if ($layout = $category->params->get('category_layout')) { $this->setLayout($layout); } } elseif (isset($active->query['layout'])) { // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout) $this->setLayout($active->query['layout']); } $children = array($category->id => $children); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->maxLevel = $params->get('maxLevel', -1); $this->assignRef('state', $state); $this->assignRef('items', $items); $this->assignRef('category', $category); $this->assignRef('children', $children); $this->assignRef('params', $params); $this->assignRef('parent', $parent); $this->assignRef('pagination', $pagination); $this->assignRef('user', $user); $this->_prepareDocument(); parent::display($tpl); }
function display($tpl = null) { global $jlistConfig; // Initialise variables. $app = JFactory::getApplication(); $user = JFactory::getUser(); $userId = $user->get('id'); $jd_user_settings = JDHelper::getUserRules(); // get jD User group settings and limitations $this->user_rules = JDHelper::getUserRules(); $dispatcher = JDispatcher::getInstance(); $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->user = $user; // upload icon handling $this->view_upload_button = false; if ($jd_user_settings->uploads_view_upload_icon) { // we must here check whether the user has the permissions to create new downloads // this can be defined in the components permissions but also in any category // but the upload icon is only viewed when in the user groups settings is also activated the: 'display add/upload icon' option // 1. check the component permissions if (!$user->authorise('core.create', 'com_jdownloads')) { // 2. not global permissions so we must check now every category (for a lot of categories can this be very slow) $this->authorised_cats = JDHelper::getAuthorisedJDCategories('core.create', $user); if (count($this->authorised_cats) > 0) { $this->view_upload_button = true; } } else { $this->view_upload_button = true; } } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } // add all needed cripts and css files $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/js/jdownloads.js'); if ($jlistConfig['view.ratings']) { $document->addScript(JUri::base() . 'components/com_jdownloads/assets/rating/js/ajaxvote.js'); } $document->addScriptDeclaration('var live_site = "' . JURI::base() . '";'); $document->addScriptDeclaration('function openWindow (url) { fenster = window.open(url, "_blank", "width=550, height=480, STATUS=YES, DIRECTORIES=NO, MENUBAR=NO, SCROLLBARS=YES, RESIZABLE=NO"); fenster.focus(); }'); if ($jlistConfig['use.css.buttons.instead.icons']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_buttons.css", "text/css", null, array()); } $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_fe.css", "text/css", null, array()); if ($jlistConfig['view.ratings']) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/rating/css/ajaxvote.css", "text/css", null, array()); } $custom_css_path = JPATH_ROOT . '/components/com_jdownloads/assets/css/jdownloads_custom.css'; if (JFile::exists($custom_css_path)) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_custom.css", 'text/css', null, array()); } $this->jd_image_path = JPATH_ROOT . '/images/jdownloads'; // Create a shortcut for $item. $items =& $this->items; foreach ($items as $item) { // Add router helpers. $item->slug = $item->file_alias ? $item->file_id . ':' . $item->file_alias : $item->file_id; $item->catslug = $item->category_alias ? $item->cat_id . ':' . $item->category_alias : $item->cat_id; $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // Merge article params. If this is single-article view, menu params override article params // Otherwise, article params override menu item params $this->params = $this->state->get('params'); $active = $app->getMenu()->getActive(); $temp = clone $this->params; // Check to see which parameters should take priority if ($active) { $currentLink = $active->link; // If the current view is the active item and an download view for this download, then the menu item params take priority if (strpos($currentLink, 'view=download') && strpos($currentLink, '&id=' . (string) $item->file_id)) { // $item->params are the downloads params, $temp are the menu item params // Merge so that the menu item params take priority $item->params->merge($temp); // Load layout from active query (in case it is an alternative menu item) if (isset($active->query['layout'])) { $this->setLayout($active->query['layout']); } } else { // Current view is not a single article, so the article params take priority here // Merge the menu item params with the article params so that the article params take priority $temp->merge($item->params); $item->params = $temp; // Check for alternative layouts (since we are not in a single-article menu item) // Single-article menu item layout takes priority over alt layout for an article if ($layout = $item->params->get('download_layout')) { $this->setLayout($layout); } } } else { // Merge so that article params take priority $temp->merge($item->params); $item->params = $temp; // Check for alternative layouts (since we are not in a single-download menu item) // Single-download menu item layout takes priority over alt layout for an download if ($layout = $item->params->get('download_layout')) { $this->setLayout($layout); } } // Check the view access to the download (the model has already computed the values). if ($item->params->get('access-view') != true && ($item->params->get('show_noauth') != true && $user->get('guest'))) { JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR')); return; } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($item->params->get('pageclass_sfx')); } // Process the content plugins. JPluginHelper::importPlugin('content'); // $results = $dispatcher->trigger('onContentPrepare', array ('com_jdownloads.download', &$item, &$this->params, $offset)); $this->event = new stdClass(); //$item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_jdownloads.download', &$item, &$this->params, 0)); $this->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_jdownloads.download', &$item, &$this->params, 0)); $this->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_jdownloads.download', &$item, &$this->params, 0)); $this->event->afterDisplayContent = trim(implode("\n", $results)); $this->_prepareDocument(); parent::display($tpl); }
function display($tpl = null) { global $jlistConfig; require_once JPATH_COMPONENT . '/helpers/search.php'; // Initialise some variables $app = JFactory::getApplication(); $user = JFactory::getUser(); $pathway = $app->getPathway(); $uri = JFactory::getURI(); $jd_user_settings = JDHelper::getUserRules(); $error = null; $rows = null; $results = null; $total = 0; // Get some data from the model $areas = $this->get('areas'); $state = $this->get('state'); $searchword = $state->get('keyword'); $params = $app->getParams(); $menus = $app->getMenu(); $menu = $menus->getActive(); // add all needed cripts and css files $document = JFactory::getDocument(); $document->addScript(JURI::base() . 'components/com_jdownloads/assets/js/jdownloads.js'); $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_fe.css", "text/css", null, array()); $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_buttons.css", "text/css", null, array()); $custom_css_path = JPATH_ROOT . '/components/com_jdownloads/assets/css/jdownloads_custom.css'; if (JFile::exists($custom_css_path)) { $document->addStyleSheet(JURI::base() . "components/com_jdownloads/assets/css/jdownloads_custom.css", 'text/css', null, array()); } $document->addScriptDeclaration('var live_site = "' . JURI::base() . '";'); $document->addScriptDeclaration('function openWindow (url) { fenster = window.open(url, "_blank", "width=550, height=480, STATUS=YES, DIRECTORIES=NO, MENUBAR=NO, SCROLLBARS=YES, RESIZABLE=NO"); fenster.focus(); }'); // because the application sets a default page title, we need to get it // right from the menu item itself if (is_object($menu)) { $menu_params = new JRegistry(); $menu_params->loadString($menu->params); if (!$menu_params->get('page_title')) { $params->set('page_title', JText::_('COM_JDOWNLOADS_SEARCH')); } } else { $params->set('page_title', JText::_('COM_JDOWNLOADS_SEARCH')); } $title = $params->get('page_title'); if ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } $this->document->setTitle($title); if ($params->get('menu-meta_description')) { $this->document->setDescription($params->get('menu-meta_description')); } if ($params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $params->get('menu-meta_keywords')); } if ($params->get('robots')) { $this->document->setMetadata('robots', $params->get('robots')); } // upload icon handling $this->view_upload_button = false; if ($jd_user_settings->uploads_view_upload_icon) { // we must here check whether the user has the permissions to create new downloads // this can be defined in the components permissions but also in any category // but the upload icon is only viewed when in the user groups settings is also activated the: 'display add/upload icon' option // 1. check the component permissions if (!$user->authorise('core.create', 'com_jdownloads')) { // 2. not global permissions so we must check now every category (for a lot of categories can this be very slow) $this->authorised_cats = JDHelper::getAuthorisedJDCategories('core.create', $user); if (count($this->authorised_cats) > 0) { $this->view_upload_button = true; } } else { $this->view_upload_button = true; } } // built select lists $orders = array(); $orders[] = JHtml::_('select.option', 'newest', JText::_('COM_JDOWNLOADS_SEARCH_NEWEST_FIRST')); $orders[] = JHtml::_('select.option', 'oldest', JText::_('COM_JDOWNLOADS_SEARCH_OLDEST_FIRST')); $orders[] = JHtml::_('select.option', 'popular', JText::_('COM_JDOWNLOADS_SEARCH_MOST_POPULAR')); $orders[] = JHtml::_('select.option', 'alpha', JText::_('COM_JDOWNLOADS_SEARCH_ALPHABETICAL')); $orders[] = JHtml::_('select.option', 'category', JText::_('COM_JDOWNLOADS_SEARCH_CATEGORY')); $lists = array(); $lists['ordering'] = JHtml::_('select.genericlist', $orders, 'ordering', 'class="inputbox"', 'value', 'text', $state->get('ordering')); $searchphrases = array(); $searchphrases[] = JHtml::_('select.option', 'all', JText::_('COM_JDOWNLOADS_SEARCH_ALL_WORDS')); $searchphrases[] = JHtml::_('select.option', 'any', JText::_('COM_JDOWNLOADS_SEARCH_ANY_WORDS')); $searchphrases[] = JHtml::_('select.option', 'exact', JText::_('COM_JDOWNLOADS_SEARCH_EXACT_PHRASE')); $lists['searchphrase'] = JHtml::_('select.radiolist', $searchphrases, 'searchphrase', '', 'value', 'text', $state->get('match')); // log the search // not used currently // SearchHelper::logSearch($searchword); //limit searchword $lang = JFactory::getLanguage(); $upper_limit = $lang->getUpperLimitSearchWord(); $lower_limit = $lang->getLowerLimitSearchWord(); if (JDSearchHelper::limitSearchWord($searchword)) { $error = JText::sprintf('COM_JDOWNLOADS_ERROR_SEARCH_MESSAGE', $lower_limit, $upper_limit); } //sanatise searchword if (JDSearchHelper::santiseSearchWord($searchword, $state->get('match'))) { $error = JText::_('COM_JDOWNLOADS_ERROR_IGNOREKEYWORD'); } if (!$searchword && count(JRequest::get('post'))) { //$error = JText::_('COM_JDOWNLOADS_ERROR_ENTERKEYWORD'); } // put the filtered results back into the model // for next release, the checks should be done in the model perhaps... $state->set('keyword', $searchword); if ($error == null) { $results = $this->get('data'); $total = $this->get('total'); $pagination = $this->get('pagination'); // require_once JPATH_SITE . '/components/com_jdownloads/helpers/route.php'; for ($i = 0, $count = count($results); $i < $count; $i++) { $row =& $results[$i]->text; if ($state->get('match') == 'exact') { $searchwords = array($searchword); $needle = $searchword; } else { $searchworda = preg_replace('#\\xE3\\x80\\x80#s', ' ', $searchword); $searchwords = preg_split("/\\s+/u", $searchworda); $needle = $searchwords[0]; } $row = JDSearchHelper::prepareSearchContent($row, $needle); $searchwords = array_unique($searchwords); $searchRegex = '#('; $x = 0; foreach ($searchwords as $k => $hlword) { $searchRegex .= $x == 0 ? '' : '|'; $searchRegex .= preg_quote($hlword, '#'); $x++; } $searchRegex .= ')#iu'; $row = preg_replace($searchRegex, '<span class="highlight">\\0</span>', $row); $result =& $results[$i]; if ($result->created) { $created = JHtml::_('date', $result->created, JText::_('DATE_FORMAT_LC3')); } else { $created = ''; } $result->text = JHtml::_('content.prepare', $result->text, '', 'com_jdownloads.search'); $result->created = $created; $result->count = $i + 1; } } // Check for layout override $active = JFactory::getApplication()->getMenu()->getActive(); if (isset($active->query['layout'])) { $this->setLayout($active->query['layout']); } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->assignRef('pagination', $pagination); $this->assignRef('results', $results); $this->assignRef('lists', $lists); $this->assignRef('params', $params); $this->ordering = $state->get('ordering'); $this->searchword = $searchword; $this->origkeyword = $state->get('origkeyword'); $this->searchphrase = $state->get('match'); $this->searchareas = $areas; $this->total = $total; $this->error = $error; $this->action = $uri; parent::display($tpl); }