public static function loadLanguageForTopLevelCat() { $app = JFactory::getApplication(); $view = $app->input->getString('view', ''); $id = $app->input->getInt('id', 0); if (isset($view)) { switch ($view) { case 'category': $topLevelCats = JUDownloadHelper::getCatsByLevel(1, $id); break; case 'document': $catId = JUDownloadFrontHelperCategory::getMainCategoryId($id); $topLevelCats = JUDownloadHelper::getCatsByLevel(1, $catId); break; } if (!empty($topLevelCats)) { $topLevelCat = $topLevelCats[0]; if ($view == 'category' || $view == 'document') { JUDownloadFrontHelperLanguage::loadLanguageFile('com_judownload_' . $topLevelCat->id, JPATH_SITE); } } } return; }
public function cancel($key = null) { parent::cancel($key = null); $app = JFactory::getApplication(); $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $parent_cat_id = $app->input->getInt('parent_id', $rootCat->id); $cat_id = $app->input->getInt('id', 0); if ($cat_id) { $parent_cat_id = JUDownloadHelper::getCategoryById($cat_id)->parent_id; } $this->setRedirect("index.php?option=com_judownload&view=listcats&cat_id=" . $parent_cat_id); }
public function back() { $app = JFactory::getApplication(); $doc_id = $app->input->getInt('doc_id', 0); $cat_id = JUDownloadFrontHelperCategory::getRootCategory()->id; if ($doc_id) { $docObj = JUDownloadHelper::getDocumentById($doc_id); if (isset($docObj->cat_id) && $docObj->cat_id) { $cat_id = $docObj->cat_id; } } $this->setRedirect("index.php?option=com_judownload&view=listcats&cat_id={$cat_id}"); }
public static function checkPassword($documentObject) { $isDocumentOwner = JUDownloadFrontHelperPermission::isDocumentOwner($documentObject->id); $isModerator = JUDownloadFrontHelperModerator::isModerator(); if ($isDocumentOwner) { $asset = 'com_judownload.document.' . $documentObject->id; $user = JFactory::getUser(); if ($user->authorise('judl.document.download.own.no_restrict', $asset)) { return true; } } if ($isModerator) { $mainCategory = JUDownloadFrontHelperCategory::getMainCategory($documentObject->id); $modCanDownload = JUDownloadFrontHelperModerator::checkModeratorCanDoWithDocument($mainCategory->id, 'document_download'); if ($modCanDownload) { return true; } if ($documentObject->approved < 1) { $modCanApproval = JUDownloadFrontHelperModerator::checkModeratorCanDoWithDocument($mainCategory->id, 'document_approve'); if ($modCanApproval) { return true; } } } $session = JFactory::getSession(); if ($session->get('judl-download-password-' . $documentObject->id, '') === $documentObject->download_password) { return true; } else { return false; } }
public function resetDefault() { JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $defaultConfig = '{"activate_maintenance":"0","maintenance_message":"Download area is down for maintenance.<br \\/> Please check back again soon.","number_rating_stars":5,"rating_star_width":16,"split_star":"2","enable_document_rate":"1","enable_doc_rate_in_comment_form":"1","require_doc_rate_in_comment_form":"1","can_download_can_rate":"0","rating_interval":86400,"only_calculate_last_rating":"0","rating_explanation":"1:Bad\\r\\n3:Poor\\r\\n5:Fair\\r\\n7:Good\\r\\n9:Excellent","rating_statistic":"","min_rates_to_show_rating":0,"min_rates_for_top_rated":0,"document_report_subjects":"Broken link\\r\\nCopyright infringement\\r\\nWrong category","comment_report_subjects":"Spam\\r\\nInappropriate","document_owner_use_captcha_when_report":"0","collection_allow_vote":"1","collection_allow_vote_down":"1","collection_allow_owner_vote":"0","collection_allow_guest_vote":"1","collection_desc_limit":500,"logged_events":["document.download"],"log_events_for_guest":"0","captcha_width":155,"captcha_height":50,"captcha_length":6,"captcha_color":"#050505","captcha_bg_color":"#ffffff","captcha_line_color":"#707070","captcha_noise_color":"#707070","captcha_num_lines":5,"captcha_noise_level":2,"captcha_perturbation":5,"captcha_font":"AHGBold.ttf","edit_account_details":"1","public_user_dashboard":"0","searchword_min_length":"3","searchword_max_length":"30","limit_string":"5,10,15,20,25,30,50","plugin_support":"0","activate_subscription_by_email":"1","field_attachment_directory":"media\\/com_judownload\\/field_attachments\\/","max_upload_files":5,"max_upload_file_size":10,"document_require_file":"1","legal_upload_extensions":"bmp,csv,doc,gif,ico,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,swf,txt,xcf,xls,zip,rar","check_mime_uploaded_file":"0","image_extensions":"bmp,gif,jpg,png","ignored_extensions":"","legal_mime_types":"image\\/jpeg,image\\/gif,image\\/png,image\\/bmp,application\\/x-shockwave-flash,application\\/msword,application\\/excel,application\\/pdf,application\\/powerpoint,text\\/plain,application\\/zip","auto_generate_md5_checksum":"2","auto_generate_crc32_checksum":"2","max_filesize_auto_generate_checksum":100,"allow_zip_file":"1","allow_download_multi_docs":"0","zip_one_file":"0","download_zipped_file_mode":"temp","download_one_file_no_zipped_mode":"temp","restrict_ip_download_file":"1","resume_download":"1","download_multi_parts":"1","max_download_speed":200,"download_interval":5,"no_counting_download_time":300,"max_wrong_password_times":5,"block_enter_password_time":600,"min_download_speed":10,"adjust_file_live_time":60,"zip_comment":"","max_download_times_in_day":30,"max_download_size_in_day_mb":500,"max_size_tmp_download_folder":3072,"send_noticed_email_interval":120,"google_analytics_track_download":"0","file_directory":"media\\/com_judownload\\/files\\/","download_directory":"judownload\\/","external_download_link_target":"_blank","show_rule_messages":"modal","category_fields_listview_ordering":{"id":"0","title":"0","alias":"0","parent_id":"0","rel_cats":"0","access":"0","lft":"0","fieldgroup_id":"0","criteriagroup_id":"0","featured":"0","published":"0","show_item":"0","description":"0","intro_image":"0","detail_image":"0","publish_up":"0","publish_down":"0","created_by":"0","created":"0","modified_by":"0","modified":"0","style_id":"0","layout":"0","metatitle":"0","metakeyword":"0","metadescription":"0","metadata":"0","total_categories":"0","total_documents":"0"},"template_upload_limit":"2","template_image_formats":"gif,bmp,jpg,jpeg,png","template_source_formats":"txt,less,ini,xml,js,php,css","template_font_formats":"woff,ttf,otf","template_compressed_formats":"zip","allow_add_doc_to_root":"0","reset_document_alias_when_approving":"1","store_old_file_versions":"1","document_owner_can_view_unpublished_document":"0","document_owner_can_edit_document_auto_approval":"1","auto_approval_document_threshold":0,"document_owner_can_edit_state_document":"0","document_owner_can_report_document":"1","max_recently_viewed_documents":12,"can_change_main_category":"1","can_change_secondary_categories":"1","max_cats_per_doc":10,"max_images_per_document":8,"max_tags_per_doc":10,"submit_document_interval":30,"assign_itemid_to_submit_link":"currentItemid","predefined_itemid_for_submit_link":0,"max_related_documents":12,"related_documents_ordering":"drel.ordering","related_documents_direction":"ASC","imagequality":90,"customfilters":"","sharpen":"0","canvastransparency":"1","canvascolour":"#ffffff","document_small_image_width":100,"document_small_image_height":100,"document_small_image_zoomcrop":"1","document_small_image_alignment":"c","document_big_image_width":600,"document_big_image_height":600,"document_big_image_zoomcrop":"3","document_big_image_alignment":"c","use_watermark":"0","watermark_image":"","watermark_text":"","watermark_font":"arial.ttf","watermark_fontsize":14,"watermark_fontcolor":"#ffffff","watermark_backgroundcolor":"#144274","watermark_halign":"0","watermark_valign":"0","watermark_offsetx":0,"watermark_offsety":0,"watermark_opacity":"0.8","watermark_rotate":0,"image_min_width":50,"image_min_height":50,"image_max_width":1024,"image_max_height":1024,"image_max_size":400,"document_default_icon":"default-document.png","document_icon_width":100,"document_icon_height":100,"document_icon_zoomcrop":"1","document_icon_alignment":"c","category_intro_image_width":200,"category_intro_image_height":200,"category_intro_image_zoomcrop":"1","category_intro_image_alignment":"c","category_detail_image_width":200,"category_detail_image_height":200,"category_detail_image_zoomcrop":"1","category_detail_image_alignment":"c","avatar_source":"juavatar","default_avatar":"default-avatar.png","avatar_width":120,"avatar_height":120,"avatar_zoomcrop":"1","avatar_alignment":"c","collection_default_icon":"-1","collection_icon_width":100,"collection_icon_height":100,"collection_icon_zoomcrop":"1","collection_icon_alignment":"c","document_image_filename_rule":"{image_name}","document_original_image_directory":"media\\/com_judownload\\/images\\/gallery\\/original\\/","document_small_image_directory":"media\\/com_judownload\\/images\\/gallery\\/small\\/","document_big_image_directory":"media\\/com_judownload\\/images\\/gallery\\/big\\/","document_icon_directory":"media\\/com_judownload\\/images\\/document\\/","category_image_filename_rule":"{category}","category_intro_image_directory":"media\\/com_judownload\\/images\\/category\\/intro\\/","category_detail_image_directory":"media\\/com_judownload\\/images\\/category\\/detail\\/","avatar_directory":"media\\/com_judownload\\/images\\/avatar\\/","collection_icon_directory":"media\\/com_judownload\\/images\\/collection\\/","comment_system":"default","disqus_username":"","show_comment_direction":"1","comment_ordering":"cm.created","comment_direction":"DESC","show_comment_pagination":"0","comment_pagination":10,"filter_comment_rating":"1","filter_comment_language":"0","max_comment_level":5,"auto_link_url_in_comment":"1","nofollow_link_in_comment":"1","trim_long_url_in_comment":0,"front_portion_url_in_comment":0,"back_portion_url_in_comment":0,"auto_embed_youtube_in_comment":"0","auto_embed_vimeo_in_comment":"0","video_width_in_comment":360,"video_height_in_comment":240,"can_download_can_comment":"0","comment_interval":60,"comment_interval_in_same_document":60,"auto_approval_comment_threshold":0,"auto_approval_comment_reply_threshold":0,"allow_edit_comment_within":600,"unpublish_comment_by_reporting_threshold":10,"allow_vote_comment":"1","allow_vote_down_comment":"1","can_reply_own_comment":"0","can_vote_own_comment":"0","can_subscribe_own_comment":"1","can_report_own_comment":"1","delete_own_comment":"0","document_owner_can_comment":"0","document_owner_can_comment_many_times":"0","document_owner_auto_approval_when_comment":"0","document_owner_can_reply_comment":"1","document_owner_auto_approval_when_reply_comment":"0","document_owner_use_captcha_when_comment":"1","document_owner_can_vote_comment":"1","document_owner_can_report_comment":"1","website_field_in_comment_form":"0","comment_form_editor":"wysibb","min_comment_characters":20,"max_comment_characters":1000,"bb_bold_tag":"Bold","bb_italic_tag":"Italic","bb_underline_tag":"Underline","bb_img_tag":"Picture","bb_link_tag":"Link","bb_video_tag":"Video","bb_color_tag":"Colors","bb_smilebox_tag":"Smilebox","bb_fontsize_tag":"Fontsize","bb_bulleted_list":"Bulleted-list","bb_numeric_list":"Numeric-list","bb_quote_tag":"Quotes","bb_readmore_tag":"Readmore","bb_code_tag":"Code","bb_align_left":"alignleft","bb_align_center":"aligncenter","bb_align_right":"alignright","userid_blacklist":"","forbidden_names":"","forbidden_words":"","forbidden_words_replaced_by":"***","block_ip":"0","ip_whitelist":"","ip_blacklist":"","top_comment_level":"all","top_comments_limit":100,"email_attachment_directory":"media\\/com_judownload\\/email_attachments\\/","email_upload_maxsize":10240,"email_upload_legal_extensions":"bmp,csv,doc,gif,ico,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,swf,txt,xcf,xls,zip,rar","email_check_mime":"0","email_image_legal_extensions":"bmp,gif,jpg,png","email_ignored_extensions":"","email_upload_legal_mime":"image\\/jpeg,image\\/gif,image\\/png,image\\/bmp,application\\/x-shockwave-flash,application\\/msword,application\\/excel,application\\/pdf,application\\/powerpoint,text\\/plain,application\\/zip","email_embedded_files":"0","email_charset":"UTF-8","enable_mailq":"0","use_mailq_default":"0","send_mailqs_on_pageload":"0","total_mailqs_sent_each_time":5,"mailq_max_attempts":5,"delete_error_mailq":"0","all_categories_show_category_title":"1","all_categories_subcategory_level":"-1","all_categories_show_empty_category":"1","all_categories_show_total_subcategories":"1","all_categories_show_total_documents":"1","all_categories_columns":2,"all_categories_column_class":"","all_categories_row_class":"","show_featured_label":"1","show_hot_label":"1","num_download_per_day_to_be_hot":10,"show_new_label":"1","num_day_to_show_as_new":10,"show_updated_label":"1","num_day_to_show_as_updated":10,"show_empty_field":"0","submit_form_show_tab_file":"1","submit_form_show_tab_changelog":"1","submit_form_show_tab_related":"0","submit_form_show_tab_plugin_params":"0","submit_form_show_tab_publishing":"0","submit_form_show_tab_style":"0","submit_form_show_tab_meta_data":"0","submit_form_show_tab_params":"0","submit_form_show_tab_permissions":"0","show_header_sort":"1","document_pagination":10,"show_pagination":"1","default_view_mode":"2","allow_user_select_view_mode":"1","document_columns":2,"document_column_class":"","document_row_class":"","show_download_btn_in_listview":"1","show_report_btn_in_listview":"1","list_alpha":"0-9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z","top_documents_limit":100,"show_submit_document_btn_in_category":"1","category_show_description":"1","category_desc_limit":0,"category_show_image":"1","category_image_width":200,"category_image_height":200,"related_category_ordering":"crel.ordering","related_category_direction":"ASC","show_empty_related_category":"1","show_total_subcats_of_relcat":"0","show_total_docs_of_relcat":"0","related_category_show_introtext":"1","related_category_introtext_character_limit":500,"related_category_show_intro_image":"1","related_category_intro_image_width":200,"related_category_intro_image_height":200,"vcategory_related_category_columns":2,"vcategory_related_category_column_class":"","vcategory_related_category_row_class":"","subcategory_ordering":"title","subcategory_direction":"ASC","show_empty_subcategory":"1","show_total_subcats_of_subcat":"0","show_total_docs_of_subcat":"0","subcategory_show_introtext":"1","subcategory_introtext_character_limit":500,"subcategory_show_intro_image":"1","subcategory_intro_image_width":200,"subcategory_intro_image_height":200,"vcategory_subcategory_columns":2,"vcategory_subcategory_column_class":"","vcategory_subcategory_row_class":"","display_params":{"doc":{"show_comment":"1","fields":{"title":{"details_view":"1"},"created":{"details_view":"1"},"author":{"details_view":"1"},"cat_id":{"details_view":"1"},"rating":{"details_view":"1"}}},"cat":{"show_description":"1"}},"seo_replace_title_option":"replace","seo_replace_description_option":"replace","seo_replace_keywords_option":"replace","seo_title_length":64,"seo_description_length":160,"seo_keywords_length":160,"seo_user_title":"{user_name}","seo_user_description":"{meta_description}","seo_user_keywords":"{meta_keywords}","seo_collection_title":"{collection_title}","seo_collection_description":"{meta_description}","seo_collection_keywords":"{meta_keywords}","seo_license_title":"{license_title}","seo_license_description":"{meta_description}","seo_license_keywords":"{meta_keywords}","seo_document_title":"{doc_title}","seo_document_description":"{meta_description}","seo_document_keywords":"{meta_keywords}","seo_category_title":"{cat_title}","seo_category_description":"{meta_description}","seo_category_keywords":"{meta_keywords}","seo_field_title":"{field_title}","seo_field_description":"{meta_description}","seo_field_keywords":"{meta_keywords}","seo_tag_title":"{tag_title}","seo_tag_description":"{meta_description}","seo_tag_keywords":"{meta_keywords}","sef_category_full_path":"0","sef_document_full_path":"0","sef_categories":"categories","sef_tree":"tree","sef_featured":"featured","sef_list_all":"list-all","sef_list_alpha":"list-alpha","sef_tags":"tags","sef_tag":"tag","sef_collections":"collections","sef_collection":"collection","sef_advanced_search":"advsearch","sef_search":"search","sef_searchby":"searchby","sef_guest_subscribe":"guest-subscribe","sef_license":"license","sef_maintenance":"maintenance","sef_documents":"modal-documents","sef_error_download":"error-download","sef_contact":"contact","sef_comment_tree":"comment-tree","sef_top_comments":"top-comments","sef_top_documents_latest":"latest-documents","sef_top_documents_featured":"top-featured-documents","sef_top_documents_recent_modified":"recent-modified-documents","sef_top_documents_recent_updated":"recent-updated-documents","sef_top_documents_popular":"popular-documents","sef_top_documents_most_downloaded":"most-downloaded-documents","sef_top_documents_most_rated":"most-rated-documents","sef_top_documents_top_rated":"top-rated-documents","sef_top_documents_latest_rated":"latest-rated-documents","sef_top_documents_most_commented":"most-commented-documents","sef_top_documents_latest_commented":"latest-commented-documents","sef_top_documents_recently_viewed":"recent-viewed-documents","sef_top_documents_alpha_ordered":"alpha-ordered-documents","sef_top_documents_random":"random-documents","sef_top_documents_random_fast":"random-fast-documents","sef_top_documents_random_featured":"random-featured-documents","sef_add":"add","sef_edit":"edit","sef_delete":"delete","sef_publish":"publish","sef_unpublish":"unpublish","sef_checkin":"checkin","sef_approve":"approve","sef_download":"download","sef_subscribe":"subscribe","sef_unsubscribe":"unsubscribe","sef_activate_subscription":"activate-subscription","sef_print":"print","sef_download_email_attachment":"download-attachment","sef_redirect_url":"redirect-url","sef_dashboard":"dashboard","sef_profile":"profile","sef_user_documents":"documents","sef_published":"published","sef_unpublished":"unpublished","sef_pending":"pending","sef_user_subscriptions":"subscriptions","sef_user_comments":"comments","sef_mod_documents":"mod-documents","sef_mod_comments":"mod-comments","sef_mod_comment":"mod-comment","sef_mod_pending_documents":"mod-pending-documents","sef_mod_pending_document":"mod-pending-document","sef_mod_pending_comments":"mod-pending-comments","sef_mod_pending_comment":"mod-pending-comment","sef_mod_permissions":"mod-permissions","sef_mod_permission":"mod-permission","sef_root_cat":"root","sef_rss":"rss","sef_changelogs":"changelogs","sef_versions":"versions","sef_latest_version":"latest","sef_report":"report","sef_layout":"layout","sef_page":"page-","sef_all":"all","sef_new_document":"new-document","sef_comment":"comment","sef_component":"component","sef_file":"file","sef_raw_data":"raw-data","sef_space":"-","rss_display_icon":"1","rss_number_items_in_feed":10,"rss_show_thumbnail":"1","rss_thumbnail_source":"icon","rss_thumbnail_alignment":"left","rss_email":"none","load_jquery":"2","load_jquery_ui":"2"}'; $db = JFactory::getDbo(); $query = 'UPDATE #__judownload_categories SET config_params=' . $db->quote($defaultConfig) . ' WHERE id = ' . $rootCat->id; $db->setQuery($query); if ($db->execute()) { $this->setRedirect("index.php?option=com_judownload&view=globalconfig&layout=edit", JText::_('COM_JUDOWNLOAD_GLOBAL_CONFIG_RESET_DEFAULT_SUCCESS')); } else { $this->setRedirect("index.php?option=com_judownload&view=globalconfig&layout=edit", JText::_('COM_JUDOWNLOAD_GLOBAL_CONFIG_RESET_DEFAULT_FAILED')); } }
public function getInput() { $categories = JUDownloadHelper::getCatsByLevel(1); $rootCategory = JUDownloadFrontHelperCategory::getRootCategory(); $document = JFactory::getDocument(); $script = 'jQuery(document).ready(function($){ $("#cat-' . $rootCategory->id . '").change(function(){ if($(this).is(":checked")){ $(this).parent().parent().find(".category-checkbox").attr("disabled", true).prop("checked", true); }else{ $(this).parent().parent().find(".category-checkbox").attr("disabled", false).prop("checked", false); } }); });'; $document->addScriptDeclaration($script); $relCatIds = array(); if ($this->form->getValue('id')) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('c.id'); $query->from('#__judownload_categories AS c'); $query->join('', '#__judownload_emails_xref AS exref ON (exref.cat_id = c.id)'); $query->join('', '#__judownload_emails AS e ON (exref.email_id = e.id)'); $query->where('exref.email_id = ' . $this->form->getValue('id')); $db->setQuery($query); $relCatIds = $db->loadColumn(); } $html = '<div id="categoriestoassignemail" class="categoriestoassignemail">'; $html .= '<ul id="' . $this->id . '" class="nav">'; $html .= '<li>'; $html .= '<input id="cat-' . $rootCategory->id . '" name="' . $this->name . '[]" value = "' . $rootCategory->id . '" ' . (in_array($rootCategory->id, $relCatIds) ? 'checked="checked"' : '') . ' class="input" type="checkbox" />'; $html .= '<label for="cat-' . $rootCategory->id . '">' . str_repeat('<span class="gi">|—</span>', $rootCategory->level) . $rootCategory->title . '</label>'; $html .= '</li>'; if ($categories) { foreach ($categories as $category) { $html .= '<li>'; $attr = ''; if (in_array($rootCategory->id, $relCatIds)) { $attr = 'checked="checked" disabled="disabled"'; } elseif (in_array($category->id, $relCatIds)) { $attr = 'checked="checked"'; } $html .= '<input id="cat-' . $category->id . '" class="input category-checkbox" type="checkbox" name="' . $this->name . '[]" value = "' . $category->id . '" ' . $attr . '/>'; $html .= '<label for="cat-' . $category->id . '">' . str_repeat('<span class="gi">|—</span>', $category->level) . $category->title . '</label>'; $html .= '</li>'; } } $html .= '</ul></div>'; return $html; }
public function display($tpl = null) { $app = JFactory::getApplication(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $levelOptions = array(); $levelOptions[] = JHtml::_('select.option', 1, 1); $levelOptions[] = JHtml::_('select.option', 5, 5); $levelOptions[] = JHtml::_('select.option', 10, 10); $levelOptions[] = JHtml::_('select.option', 15, 15); $levelOptions[] = JHtml::_('select.option', 20, 20); $levelOptions[] = JHtml::_('select.option', 25, 25); $levelOptions[] = JHtml::_('select.option', 30, 30); $this->levelOptions = $levelOptions; $boolean = array(); $boolean[] = JHtml::_('select.option', 0, JText::_('JNO')); $boolean[] = JHtml::_('select.option', 1, JText::_('JYES')); $this->boolean = $boolean; $this->layout = $this->getLayout(); if ($this->layout == 'rebuildrating' || $this->layout == 'resizeimages') { $categoryList = $this->get('CategoryList'); foreach ($categoryList as $key => $value) { $categoryList[$key]->id = $value->id; $categoryList[$key]->title = '|— ' . $value->title; } $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); array_unshift($categoryList, array('id' => $rootCat->id, 'title' => 'Root')); $this->categoryList = $categoryList; } if ($this->layout == 'rebuildrating') { $this->criteriaGroups = $this->get("CriteriaGroups"); } $errors = $app->getUserState("import_file_errors"); if (isset($errors)) { $this->errors = $errors; $app->setUserState("import_file_errors", null); } $this->addToolBar(); if ($this->getLayout() == "rebuildrating") { $app->setUserState("cats", null); $app->setUserState('criteria_groups', null); $app->setUserState('total_documents', null); } parent::display($tpl); $this->setDocument(); }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->model = $this->getModel(); $this->app = JFactory::getApplication(); $cat_id = $this->item->cat_id ? $this->item->cat_id : $this->app->input->get('cat_id'); $this->params = JUDownloadHelper::getParams(null, $this->item->id); if ($cat_id == JUDownloadFrontHelperCategory::getRootCategory()->id && !$this->params->get('allow_add_doc_to_root', 0)) { JError::raiseError(500, JText::_('COM_JUDOWNLOAD_CAN_NOT_ADD_DOCUMENT_TO_ROOT_CATEGORY')); return false; } if ($tempDocument = JUDownloadHelper::getTempDocument($this->item->id)) { $editPendingDocLink = '<a href="index.php?option=com_judownload&task=document.edit&approve=1&id=' . $tempDocument->id . '">' . $tempDocument->title . '</a>'; JError::raiseNotice('', JText::sprintf('COM_JUDOWNLOAD_THIS_DOCUMENT_HAS_PENDING_DOCUMENT_X_PLEASE_APPROVE_PENDING_DOCUMENT_FIRST', $editPendingDocLink)); } if ($this->item->approved < 0) { $oriDocId = abs($this->item->approved); $oriDocObj = JUDownloadHelper::getDocumentById($oriDocId); $editOriDocLink = '<a href="index.php?option=com_judownload&task=document.edit&id=' . $oriDocId . '">' . $oriDocObj->title . '</a>'; JError::raiseNotice('', JText::sprintf('COM_JUDOWNLOAD_ORIGINAL_DOCUMENT_X', $editOriDocLink)); } $this->script = $this->get('Script'); $this->plugins = $this->get('Plugins'); $this->fieldsetDetails = $this->model->getCoreFields('details'); $this->fieldsetPublishing = $this->model->getCoreFields('publishing'); $this->fieldsetTemplateStyleAndLayout = $this->model->getCoreFields('template_style'); $this->fieldsetMetadata = $this->model->getCoreFields('metadata'); $this->fieldCatid = JUDownloadFrontHelperField::getField('cat_id', $this->item); $this->fieldGallery = JUDownloadFrontHelperField::getField('gallery', $this->item); $this->files = $this->get('Files'); $this->changeLogs = $this->get('ChangeLogs'); $this->versions = $this->get('Versions'); $this->extraFields = $this->get('ExtraFields'); $this->fieldsData = $this->app->getUserState("com_judownload.edit.document.fieldsdata", array()); $this->relatedDocuments = $this->get('RelatedDocuments'); $this->canDo = JUDownloadHelper::getActions('com_judownload', 'category', $this->item->cat_id); $this->addToolBar(); $this->setDocument(); parent::display($tpl); }
protected function getInput() { $fieldgroup_id = $this->form->getValue('id'); $rootCategory = JUDownloadFrontHelperCategory::getRootCategory(); $categoryTree = JUDownloadHelper::getCategoryTree($rootCategory->id); $html = "<div id=\"categoriestoassignfieldgroup\" class=\"categoriestoassignfieldgroup\">"; if ($this->form->getValue('id') == 1) { $html .= '<input type="text" class="readonly" readonly="readonly" value="' . JText::_('JALL') . '"/>'; } else { $select_cat_class = 'select-cat'; $html .= '<div class="btn-group pull-left">'; $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', !jQuery(this).is(\':checked\')); });">' . JText::_('JGLOBAL_SELECTION_INVERT') . '</button>'; $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', false); });">' . JText::_('JGLOBAL_SELECTION_NONE') . '</button>'; $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', true); });">' . JText::_('JGLOBAL_SELECTION_ALL') . '</button>'; $html .= '</div>'; $html .= "<ul id=\"" . $this->id . "\" class=\"nav\">"; $html .= "<li>"; $html .= "<input id=\"catid-" . $rootCategory->id . "\" type=\"checkbox\" value=\"" . $rootCategory->id . "\" disabled=\"true\" />"; $html .= "<label for=\"catid-" . $rootCategory->id . "\">" . str_repeat('<span class="gi">|—</span>', $rootCategory->level) . $rootCategory->title . "</label>"; $html .= "</li>"; foreach ($categoryTree as $category) { if ($category->id == $rootCategory->id) { continue; } $link_edit_fieldgroup = ''; $html .= "<li>"; if ($category->selected_fieldgroup == -1 && $category->fieldgroup_id > 0) { $html .= "<span class=\"inherited-value\" title=\"" . JText::_("COM_JUDOWNLOAD_INHERIT") . "\">" . JText::_('COM_JUDOWNLOAD_INHERIT') . "</span>"; } elseif ($category->fieldgroup_id == $fieldgroup_id) { $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type=\"checkbox\" value=\"" . $category->id . "\" checked=\"checked\" name=\"" . $this->name . "[]\"/>"; } elseif ($category->fieldgroup_id > 0) { $link_edit_fieldgroup = "<span><a href=\"index.php?option=com_judownload&task=fieldgroup.edit&id=" . $category->fieldgroup_id . "\" title=\"" . $this->getFieldGroupName($category->fieldgroup_id) . "\" >[" . $this->getFieldGroupName($category->fieldgroup_id) . "]</a></span>"; $html .= "<input id=\"catid-" . $category->id . "\" type=\"checkbox\" checked=\"checked\" value=\"" . $category->id . "\" disabled=\"true\" />"; } else { $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type=\"checkbox\" value=\"" . $category->id . "\" name=\"" . $this->name . "[]\"/>"; } $html .= "<label for=\"catid-" . $category->id . "\">" . str_repeat('<span class="gi">|—</span>', $category->level) . $category->title . "</label>"; $html .= $link_edit_fieldgroup; $html .= "</li>"; } $html .= "</ul>"; } $html .= "</div>"; return $html; }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $app = JFactory::getApplication(); $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $fastAddError = $app->getUserState('com_judownload.categories.fastadderror'); $fastAddSuccess = $app->getUserState('com_judownload.categories.fastaddsuccess'); $this->cat_id = $app->input->getInt('cat_id', $rootCat->id); $this->params = JUDownloadHelper::getParams($this->cat_id); $this->canDoCat = JUDownloadHelper::getActions('com_judownload', 'category', $this->cat_id); $this->rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $this->allowAddDoc = $this->params->get('allow_add_doc_to_root', 0) && $this->cat_id == $this->rootCat->id || $this->cat_id != $this->rootCat->id; $this->docGroupCanDoManage = $this->groupCanDoCatManage = JUDownloadHelper::checkGroupPermission("document.edit"); $this->docGroupCanDoDelete = $this->groupCanDoCatDelete = JUDownloadHelper::checkGroupPermission("documents.delete"); $this->catGroupCanDoManage = $this->groupCanDoCatManage = JUDownloadHelper::checkGroupPermission("category.edit"); $this->catGroupCanDoDelete = $this->groupCanDoCatDelete = JUDownloadHelper::checkGroupPermission("categories.delete"); // if ($fastAddSuccess) { $app->enqueueMessage($fastAddSuccess); $app->setUserState('com_judownload.categories.fastaddsuccess', ''); } if ($fastAddError) { $app->enqueueMessage($fastAddError, 'error'); $app->setUserState('com_judownload.categories.fastadderror', ''); } $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->model = $this->getModel(); $this->addToolBar(); $this->setDocument(); parent::display($tpl); }
protected function getListQuery() { $db = $this->getDbo(); $date = JFactory::getDate(); $now = $date->toSql(); $nullDate = $db->getNullDate(); $query = $db->getQuery(true); $query->select('d.id, d.title, d.alias, d.created, d.access'); $query->from('#__judownload_documents AS d'); $query->join('', '#__judownload_documents_xref AS dxref ON dxref.doc_id = d.id AND dxref.main = 1'); $query->select('c.title AS category_title'); $query->join('', '#__judownload_categories AS c ON c.id = dxref.cat_id'); $categoryIdArrayCanAccess = JUDownloadFrontHelperCategory::getAccessibleCategoryIds(); if (is_array($categoryIdArrayCanAccess) && count($categoryIdArrayCanAccess) > 0) { $query->where('c.id IN(' . implode(",", $categoryIdArrayCanAccess) . ')'); } else { $query->where('c.id IN("")'); } $query->select('vl.title AS access_title'); $query->join('LEFT', '#__viewlevels AS vl ON vl.id = d.access'); $access = $this->getState('filter.access'); if ($access) { $query->where('d.access = ' . (int) $access); } $categoryId = $this->getState('filter.catid'); if (is_numeric($categoryId)) { $query->where('c.id = ' . (int) $categoryId); } $query->where('c.published = 1'); $query->where('c.publish_up <= ' . $db->quote($now)); $query->where('(c.publish_down = ' . $db->quote($nullDate) . ' OR c.publish_down > ' . $db->quote($now) . ')'); $featured = $this->getState('filter.featured', ''); if ($featured !== '') { $query->where('d.featured = ' . (int) $featured); } $licenseid = $this->getState('filter.licenseid'); if ($licenseid) { $query->SELECT('l.title AS license_title'); $query->JOIN('LEFT', '#__judownload_licenses AS l ON l.id = d.license_id'); $query->where('l.id = ' . $db->quote($licenseid)); } $query->where('d.approved = 1'); $query->where('d.published = 1'); $query->where('d.publish_up <= ' . $db->quote($now)); $query->where('(d.publish_down = ' . $db->quote($nullDate) . ' OR d.publish_down > ' . $db->quote($now) . ')'); $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('d.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->getEscaped($search, true) . '%'); $query->where('d.title LIKE ' . $search); } } $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol) { $query->order($orderCol . ' ' . $orderDirn); } return $query; }
protected function _setBreadcrumb() { $categoryId = JUDownloadFrontHelperCategory::getMainCategoryId($this->item->id); $app = JFactory::getApplication(); $pathway = $app->getPathway(); $pathwayArray = array(); if ($categoryId) { $pathwayArray = JUDownloadFrontHelperBreadcrumb::getBreadcrumbCategory($categoryId); } else { $pathwayArray[] = JUDownloadFrontHelperBreadcrumb::getRootPathway(); } $linkDocument = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id)); $pathwayArray[] = JUDownloadFrontHelperBreadcrumb::createPathwayItem($this->item->title, $linkDocument); if ($this->_layout == 'changelogs') { $pathwayArray[] = JUDownloadFrontHelperBreadcrumb::createPathwayItem('CHANGELOGS'); } elseif ($this->_layout == 'versions') { $pathwayArray[] = JUDownloadFrontHelperBreadcrumb::createPathwayItem('VERSIONS'); } elseif ($this->_layout == 'print') { $pathwayArray[] = JUDownloadFrontHelperBreadcrumb::createPathwayItem('PRINT'); $document = JFactory::getDocument(); $document->setMetaData('robots', 'noindex, nofollow'); } $pathway->setPathway($pathwayArray); }
public function getTotalDocumentsAssignTag($tagId) { $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); $levelsStr = implode(',', $levels); $db = $this->getDbo(); $nullDate = $db->getNullDate(); $nowDate = JFactory::getDate()->toSql(); $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__judownload_documents AS d'); $query->join('', '#__judownload_documents_xref AS dxmain ON d.id = dxmain.doc_id AND dxmain.main = 1'); $query->join('', '#__judownload_categories AS cmain ON cmain.id = dxmain.cat_id'); $categoryIdArrayCanAccess = JUDownloadFrontHelperCategory::getAccessibleCategoryIds(); if (is_array($categoryIdArrayCanAccess) && count($categoryIdArrayCanAccess) > 0) { $query->where('cmain.id IN(' . implode(",", $categoryIdArrayCanAccess) . ')'); } else { $query->where('cmain.id IN("")'); } $query->where('d.approved = 1'); $query->where('d.published = 1'); $query->where('(d.publish_up = ' . $db->quote($nullDate) . ' OR d.publish_up <= ' . $db->quote($nowDate) . ')'); $query->where('(d.publish_down = ' . $db->quote($nullDate) . ' OR d.publish_down >= ' . $db->quote($nowDate) . ')'); if ($user->get('guest')) { $query->where('d.access IN (' . $levelsStr . ')'); } else { $query->where('(d.access IN (' . $levelsStr . ') OR (d.created_by = ' . $user->id . '))'); } $app = JFactory::getApplication(); $languageTag = JFactory::getLanguage()->getTag(); if ($app->getLanguageFilter()) { $query->where('d.language IN (' . $db->quote($languageTag) . ',' . $db->quote('*') . ',' . $db->quote('') . ')'); } $query->join('', '#__judownload_tags_xref AS tag_xref ON tag_xref.doc_id = d.id'); $query->join('', '#__judownload_tags AS tag ON tag.id = tag_xref.tag_id'); $query->where('tag.published = 1'); $query->where('(tag.publish_up = ' . $db->quote($nullDate) . ' OR tag.publish_up <= ' . $db->quote($nowDate) . ')'); $query->where('(tag.publish_down = ' . $db->quote($nullDate) . ' OR tag.publish_down >= ' . $db->quote($nowDate) . ')'); $query->where('tag.id =' . $tagId); $db->setQuery($query); return (int) $db->loadResult(); }
public static function getRootPathway() { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); $categoryRoot = JUDownloadFrontHelperCategory::getRootCategory(); $needles = array( 'tree' => array((int) $categoryRoot->id) ); $findMenuTreeRoot = JUDownloadHelperRoute::findItemId($needles, true); $rootPathway = new stdClass; if ($findMenuTreeRoot) { $menuTreeRoot = $menus->getItem($findMenuTreeRoot); $rootPathway->name = $menuTreeRoot->title; $rootPathway->link = JRoute::_($menuTreeRoot->link); } else { $rootPathway->name = html_entity_decode(JText::_('COM_JUDOWNLOAD_ROOT'), ENT_COMPAT, 'UTF-8'); $rootPathway->link = JUDownloadHelperRoute::getTreeRoute($categoryRoot->id); } return $rootPathway; }
* ------------------------------------------------------------------------ * * @copyright Copyright (C) 2010-2015 JoomUltra Co., Ltd. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author JoomUltra Co., Ltd * @website http://www.joomultra.com * @----------------------------------------------------------------------@ */ // No direct access to this file defined('_JEXEC') or die('Restricted access'); JHtml::_('behavior.modal'); $app = JFactory::getApplication(); $db = JFactory::getDbo(); $user = JFactory::getUser(); $userId = $user->id; $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $cat_id = $app->input->getInt('cat_id', $rootCat->id); $listOrder_cat = $this->escape($this->state->get('filter.ordering_cat')); $listDirn_cat = $this->escape($this->state->get('filter.direction_cat')); $search_cat = $this->escape($this->state->get('filter.search_cat')); $saveOrder_cat = $listOrder_cat == 'lft' && $this->canDoCat->get('judl.category.edit.state'); $model = $this->getModel(); $list_cat = $model->getListCategory($cat_id, $listOrder_cat, $listDirn_cat); $ordering = $listOrder_cat == 'lft'; $this->ordering = array(); $intro_image_path = JUri::root(true) . "/" . JUDownloadFrontHelper::getDirectory("category_intro_image_directory", "media/com_judownload/images/category/intro/"); $detail_image_path = JUri::root(true) . "/" . JUDownloadFrontHelper::getDirectory("category_detail_image_directory", "media/com_judownload/images/category/detail/"); foreach ($list_cat as $cat) { $this->ordering[] = $cat->id; } $originalOrders = array();
public function parse(&$segments) { $total = count($segments); $vars = array(); for ($i = 0; $i < $total; $i++) { $segments[$i] = preg_replace('/:/', '-', $segments[$i], 1); } $params = JUDownloadHelper::getParams(); $app = JFactory::getApplication('site'); $menu = $app->getMenu(); $activeMenu = $menu->getActive(); $indexLastSegment = $total - 1; $endSegment = end($segments); $searchViewApproveComment = array_search(JApplication::stringURLSafe('mod-comment'), $segments); if ($searchViewApproveComment !== false) { $vars['view'] = 'modcomment'; if (isset($segments[$searchViewApproveComment + 1])) { $vars['id'] = (int) $segments[$searchViewApproveComment + 1]; } if (isset($segments[$searchViewApproveComment + 2])) { if ($segments[$searchViewApproveComment + 2] == JApplication::stringURLSafe('approve')) { $vars['approve'] = 1; } } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } if (isset($segments[0]) && $segments[0] == JApplication::stringURLSafe('comment')) { if (isset($segments[2])) { switch ($segments[2]) { case JApplication::stringURLSafe('edit') : $vars['task'] = 'modcomment.edit'; if (isset($segments[1])) { $vars['id'] = (int) $segments[1]; } break; case JApplication::stringURLSafe('approve') : $vars['task'] = 'modpendingcomment.edit'; if (isset($segments[1])) { $vars['id'] = (int) $segments[1]; } break; case JApplication::stringURLSafe('subscribe') : $vars['task'] = 'subscribe.save'; if (isset($segments[1])) { $vars['comment_id'] = (int) $segments[1]; } break; case JApplication::stringURLSafe('unsubscribe') : $vars['task'] = 'subscribe.remove'; if (isset($segments[3])) { $vars['sub_id'] = (int) $segments[3]; } if (isset($segments[4])) { $vars['code'] = $segments[4]; } break; case JApplication::stringURLSafe('delete') : $vars['task'] = 'document.deleteComment'; if (isset($segments[1])) { $vars['comment_id'] = (int) $segments[1]; } break; default : break; } if (isset($vars['task'])) { return $vars; } } } $searchViewReportComment = array_search(JApplication::stringURLSafe('comment'), $segments); if ($searchViewReportComment !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewReportComment, $validArrayIndex)) { if (isset($segments[$searchViewReportComment + 2])) { if ($segments[$searchViewReportComment + 2] == JApplication::stringURLSafe('report')) { $vars['view'] = 'report'; if (isset($segments[$searchViewReportComment + 1])) { $vars['comment_id'] = (int) $segments[$searchViewReportComment + 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } } } $searchViewModeratorPermission = array_search(JApplication::stringURLSafe('mod-permission'), $segments); if ($searchViewModeratorPermission !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewModeratorPermission, $validArrayIndex)) { $vars['view'] = 'modpermission'; if (isset($segments[$searchViewModeratorPermission + 1])) { $vars['id'] = (int) $segments[$searchViewModeratorPermission + 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } if (isset($segments[0]) && $segments[0] == JApplication::stringURLSafe('user-subscriptions')) { if (isset($segments[2])) { if ($segments[2] == JApplication::stringURLSafe('unsubscribe')) { $vars['task'] = 'usersubscriptions.unsubscribe'; if (isset($segments[1])) { $vars['sub_id'] = (int) $segments[1]; } return $vars; } } } if (isset($segments[0]) && $segments[0] == JApplication::stringURLSafe('email')) { if (isset($segments[1]) && $segments[1] == JApplication::stringURLSafe('download-attachment')) { $vars['task'] = 'email.downloadattachment'; if (isset($segments[2])) { $vars['mail_id'] = (int) $segments[2]; } if (isset($segments[3])) { $vars['file'] = $segments[3]; } if (isset($segments[4])) { $vars['code'] = $segments[4]; } } return $vars; } $searchViewModeratorPermissions = array_search(JApplication::stringURLSafe('mod-permissions'), $segments); if ($searchViewModeratorPermissions !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewModeratorPermissions, $validArrayIndex)) { $vars['view'] = 'modpermissions'; $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewProfile = array_search(JApplication::stringURLSafe('profile'), $segments); if ($searchViewProfile !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewProfile, $validArrayIndex)) { $vars['view'] = 'profile'; $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewModeratorPendingDocuments = array_search(JApplication::stringURLSafe('mod-pending-documents'), $segments); if ($searchViewModeratorPendingDocuments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewModeratorPendingDocuments, $validArrayIndex)) { $vars['view'] = 'modpendingdocuments'; $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewModeratorPendingComments = array_search(JApplication::stringURLSafe('mod-pending-comments'), $segments); if ($searchViewModeratorPendingComments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewModeratorPendingComments, $validArrayIndex)) { $vars['view'] = 'modpendingcomments'; $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewModeratorComments = array_search(JApplication::stringURLSafe('mod-comments'), $segments); if ($searchViewModeratorComments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewModeratorComments, $validArrayIndex)) { $vars['view'] = 'modcomments'; $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewModeratorDocuments = array_search(JApplication::stringURLSafe('mod-documents'), $segments); if ($searchViewModeratorDocuments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewModeratorDocuments, $validArrayIndex)) { $vars['view'] = 'moddocuments'; $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } if (isset($segments[0]) && $segments[0] == JApplication::stringURLSafe('subscribe')) { if (isset($segments[1]) && $segments[1] == JApplication::stringURLSafe('activate')) { $vars['task'] = 'subscribe.activate'; if (isset($segments[2])) { $vars['code'] = $segments[2]; } if (isset($segments[3])) { $vars['id'] = (int) $segments[3]; } if (isset($segments[4])) { $vars['doc_id'] = (int) $segments[4]; } return $vars; } } $searchViewSearch = array_search(JApplication::stringURLSafe('search'), $segments); if ($searchViewSearch !== false) { $validArrayIndex = array(0, 1, 2, 3); if (in_array($searchViewSearch, $validArrayIndex)) { $vars['view'] = 'search'; if (isset($segments[$searchViewSearch - 1])) { if ($segments[$searchViewSearch - 1] == JApplication::stringURLSafe('all')) { $vars['sub_cat'] = 1; if (isset($segments[$searchViewSearch - 2])) { $vars['cat_id'] = (int) $segments[$searchViewSearch - 2]; } } else { $vars['cat_id'] = (int) $segments[$searchViewSearch - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment]) && $previousIndexSegment > $searchViewSearch) { $vars['searchword'] = $segments[$previousIndexSegment]; $previousIndexSegment -= 1; } return $vars; } } $searchViewCategories = array_search(JApplication::stringURLSafe('categories'), $segments); if ($searchViewCategories !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewCategories, $validArrayIndex)) { $vars['view'] = 'categories'; if (isset($segments[$searchViewCategories + 1])) { $vars['id'] = (int) $segments[$searchViewCategories + 1]; } if (isset($segments[$searchViewCategories + 2])) { JUDownloadHelperRoute::parseLayout($segments[$searchViewCategories + 2], $vars, $params); } return $vars; } } $searchViewAdvancedSearch = array_search(JApplication::stringURLSafe('advanced-search'), $segments); if ($searchViewAdvancedSearch !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewAdvancedSearch, $validArrayIndex)) { $vars['view'] = 'advsearch'; $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewCommentTree = array_search(JApplication::stringURLSafe('comment-tree'), $segments); if ($searchViewCommentTree !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewCommentTree, $validArrayIndex)) { $vars['view'] = 'commenttree'; if (isset($segments[$searchViewCommentTree + 1])) { $vars['id'] = (int) $segments[$searchViewCommentTree + 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewDocuments = array_search(JApplication::stringURLSafe('modal-documents'), $segments); if ($searchViewDocuments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewDocuments, $validArrayIndex)) { $vars['view'] = 'documents'; if (isset($segments[$searchViewDocuments + 1])) { $vars['tmpl'] = $segments[$searchViewDocuments + 1]; } if (isset($segments[$searchViewDocuments + 2])) { $vars['function'] = $segments[$searchViewDocuments + 2]; } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewDownloadError = array_search(JApplication::stringURLSafe('error-download'), $segments); if ($searchViewDownloadError !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewDownloadError, $validArrayIndex)) { $vars['view'] = 'downloaderror'; $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment]) && $previousIndexSegment > $searchViewDownloadError) { $vars['return'] = $segments[$previousIndexSegment]; } return $vars; } } $searchViewLicense = array_search(JApplication::stringURLSafe('license'), $segments); if ($searchViewLicense !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewLicense, $validArrayIndex)) { $vars['view'] = 'license'; if (isset($segments[$searchViewLicense + 1])) { $vars['id'] = (int) $segments[$searchViewLicense + 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewMaintenance = array_search(JApplication::stringURLSafe('maintenance'), $segments); if ($searchViewMaintenance !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewMaintenance, $validArrayIndex)) { $vars['view'] = 'maintenance'; $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewSearchBy = array_search(JApplication::stringURLSafe('search-by'), $segments); if ($searchViewSearchBy !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewSearchBy, $validArrayIndex)) { $vars['view'] = 'searchby'; if (isset($segments[$searchViewSearchBy + 1])) { $vars['field_id'] = (int) $segments[$searchViewSearchBy + 1]; } if (isset($segments[$searchViewSearchBy + 2])) { $vars['value'] = $segments[$searchViewSearchBy + 2]; } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewTag = array_search(JApplication::stringURLSafe('tag'), $segments); if ($searchViewTag !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewTag, $validArrayIndex)) { $vars['view'] = 'tag'; if (isset($segments[$searchViewTag + 1])) { $vars['id'] = (int) $segments[$searchViewTag + 1]; } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewTags = array_search(JApplication::stringURLSafe('tags'), $segments); if ($searchViewTags !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewTags, $validArrayIndex)) { $vars['view'] = 'tags'; $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewTopComments = array_search(JApplication::stringURLSafe('top-comments'), $segments); if ($searchViewTopComments !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewTopComments, $validArrayIndex)) { $vars['view'] = 'topcomments'; $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchViewTree = array_search(JApplication::stringURLSafe('tree'), $segments); if ($searchViewTree !== false) { $validArrayIndex = array(0, 1); if (in_array($searchViewTree, $validArrayIndex)) { $vars['view'] = 'tree'; $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('root')) { $rootCategory = JUDownloadFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$previousIndexSegment]; } $previousIndexSegment -= 1; } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree' ) { $vars['id'] = $activeMenu->query['id']; } } return $vars; } } $orderTypeTopDocuments = array(); $orderTypeTopDocuments[] = JApplication::stringURLSafe('latest-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('top-featured-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('recent-modified-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('recent-updated-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('popular-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('most-downloaded-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('most-rated-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('top-rated-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('latest-rated-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('most-commented-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('latest-commented-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('recent-viewed-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('alpha-ordered-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('random-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('random-fast-documents'); $orderTypeTopDocuments[] = JApplication::stringURLSafe('random-featured-documents'); if (!empty($orderTypeTopDocuments)) { foreach ($orderTypeTopDocuments as $orderTypeTopDocumentItem) { $searchViewTopDocuments = array_search($orderTypeTopDocumentItem, $segments); if ($searchViewTopDocuments !== false) { break; } } if ($searchViewTopDocuments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchViewTopDocuments, $validArrayIndex)) { $vars['view'] = 'topdocuments'; switch ($segments[$searchViewTopDocuments]) { case JApplication::stringURLSafe('latest-documents'): $vars['ordertype'] = 'new'; break; case JApplication::stringURLSafe('top-featured-documents'): $vars['ordertype'] = 'featured'; break; case JApplication::stringURLSafe('recent-modified-documents'): $vars['ordertype'] = 'recent_modified'; break; case JApplication::stringURLSafe('recent-updated-documents'): $vars['ordertype'] = 'recent_updated'; break; case JApplication::stringURLSafe('popular-documents'): $vars['ordertype'] = 'popular'; break; case JApplication::stringURLSafe('most-downloaded-documents'): $vars['ordertype'] = 'most_downloaded'; break; case JApplication::stringURLSafe('most-rated-documents'): $vars['ordertype'] = 'most_rated'; break; case JApplication::stringURLSafe('top-rated-documents'): $vars['ordertype'] = 'top_rated'; break; case JApplication::stringURLSafe('latest-rated-documents'): $vars['ordertype'] = 'latest_rated'; break; case JApplication::stringURLSafe('most-commented-documents'): $vars['ordertype'] = 'most_commented'; break; case JApplication::stringURLSafe('latest-commented-documents'): $vars['ordertype'] = 'latest_commented'; break; case JApplication::stringURLSafe('recent-viewed-documents'): $vars['ordertype'] = 'recently_viewed'; break; case JApplication::stringURLSafe('alpha-ordered-documents'): $vars['ordertype'] = 'alpha_ordered'; break; case JApplication::stringURLSafe('random-documents'): $vars['ordertype'] = 'random'; break; case JApplication::stringURLSafe('random-fast-documents'): $vars['ordertype'] = 'random_fast'; break; case JApplication::stringURLSafe('random-featured-documents'): $vars['ordertype'] = 'random_featured'; break; default: $vars['ordertype'] = 'new'; break; } if (isset($segments[$searchViewTopDocuments - 1])) { if ($segments[$searchViewTopDocuments - 1] == JApplication::stringURLSafe('root')) { $rootCategory = JUDownloadFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$searchViewTopDocuments - 1]; } } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree' ) { $vars['id'] = $activeMenu->query['id']; } } if (isset($segments[$searchViewTopDocuments + 1])) { if ($segments[$searchViewTopDocuments + 1] == JApplication::stringURLSafe('all')) { $vars['all'] = 1; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } } $searchSefRedirectUrl = array_search(JApplication::stringURLSafe('redirect-url'), $segments); if ($searchSefRedirectUrl !== false) { $vars['task'] = 'document.redirecturl'; if (isset($segments[$searchSefRedirectUrl - 1])) { $vars['field_id'] = (int) $segments[$searchSefRedirectUrl - 1]; } if (isset($segments[$searchSefRedirectUrl - 2])) { $vars['doc_id'] = (int) $segments[$searchSefRedirectUrl - 2]; } return $vars; } $searchSefTaskRawData = array_search(JApplication::stringURLSafe('raw-data'), $segments); if ($searchSefTaskRawData !== false) { $vars['task'] = 'rawdata'; if (isset($segments[$searchSefTaskRawData - 1])) { $vars['field_id'] = (int) $segments[$searchSefTaskRawData - 1]; } if (isset($segments[$searchSefTaskRawData - 2])) { $vars['doc_id'] = (int) $segments[$searchSefTaskRawData - 2]; } return $vars; } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { if (isset($segments[$searchSefCollection + 1])) { if ($segments[$searchSefCollection + 1] == JApplication::stringURLSafe('add')) { $vars['task'] = 'collection.add'; return $vars; } } } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { if (isset($segments[$searchSefCollection + 2])) { if ($segments[$searchSefCollection + 2] == JApplication::stringURLSafe('edit')) { if (isset($segments[$searchSefCollection - 1])) { $vars['user_id'] = (int) $segments[$searchSefCollection - 1]; } $vars['id'] = (int) $segments[$searchSefCollection + 1]; $vars['task'] = 'collection.edit'; return $vars; } } } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { if (isset($segments[$searchSefCollection + 2])) { if ($segments[$searchSefCollection + 2] == JApplication::stringURLSafe('delete')) { $vars['cid'] = (int) $segments[$searchSefCollection + 1]; $vars['task'] = 'collections.delete'; return $vars; } } } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { if (isset($segments[$searchSefCollection + 1])) { if ($segments[$searchSefCollection + 1] == JApplication::stringURLSafe('new-collection')) { $vars['id'] = 0; $vars['view'] = 'collection'; JUDownloadHelperRoute::parseLayout($segments[$searchSefCollection + 2], $vars, $params); return $vars; } } } $searchSefCollection = array_search(JApplication::stringURLSafe('collection'), $segments); if ($searchSefCollection !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefCollection, $validArrayIndex)) { $vars['view'] = 'collection'; if (isset($segments[$searchSefCollection - 1])) { if ($segments[$searchSefCollection - 1] != 'root') { $vars['user_id'] = (int) $segments[$searchSefCollection - 1]; } } if (isset($segments[$searchSefCollection + 1])) { $vars['id'] = (int) $segments[$searchSefCollection + 1]; } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchSefReportDocument = array_search(JApplication::stringURLSafe('report'), $segments); if ($searchSefReportDocument !== false) { $vars['view'] = 'report'; if (isset($segments[$searchSefReportDocument - 1])) { $vars['doc_id'] = (int) $segments[$searchSefReportDocument - 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } $searchSefSubscribeDocumentForGuest = array_search(JApplication::stringURLSafe('guest-subscribe'), $segments); if ($searchSefSubscribeDocumentForGuest !== false) { $vars['view'] = 'subscribe'; if (isset($segments[$searchSefSubscribeDocumentForGuest - 1])) { $vars['doc_id'] = (int) $segments[$searchSefSubscribeDocumentForGuest - 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } $searchSefListAll = array_search('list-all', $segments); if ($searchSefListAll !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefListAll, $validArrayIndex)) { $vars['view'] = 'listall'; if (isset($segments[$searchSefListAll - 1])) { if ($segments[$searchSefListAll - 1] == JApplication::stringURLSafe('root')) { $rootCategory = JUDownloadFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$searchSefListAll - 1]; } } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree' ) { $vars['id'] = $activeMenu->query['id']; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } return $vars; } } $searchSefListAlpha = array_search(JApplication::stringURLSafe('list-alpha'), $segments); if ($searchSefListAlpha !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefListAlpha, $validArrayIndex)) { $vars['view'] = 'listalpha'; if (isset($segments[$searchSefListAlpha - 1])) { if ($segments[$searchSefListAlpha - 1] == JApplication::stringURLSafe('root')) { $rootCategory = JUDownloadFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$searchSefListAlpha - 1]; } } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree' ) { $vars['id'] = $activeMenu->query['id']; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { if ($previousIndexSegment > $searchSefListAlpha) { $vars['alpha'] = $segments[$previousIndexSegment]; } } return $vars; } } $searchSefFeatured = array_search(JApplication::stringURLSafe('featured'), $segments); if ($searchSefFeatured !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefFeatured, $validArrayIndex)) { $vars['view'] = 'featured'; if (isset($segments[$searchSefFeatured - 1])) { if ($segments[$searchSefFeatured - 1] == JApplication::stringURLSafe('root')) { $rootCategory = JUDownloadFrontHelperCategory::getRootCategory(); $vars['id'] = $rootCategory->id; } else { $vars['id'] = (int) $segments[$searchSefFeatured - 1]; } } else { if ($activeMenu && isset($activeMenu->query) && isset($activeMenu->query['view']) && isset($activeMenu->query['id']) && $activeMenu->query['view'] == 'tree' ) { $vars['id'] = $activeMenu->query['id']; } } if (isset($segments[$searchSefFeatured + 1])) { if ($segments[$searchSefFeatured + 1] == JApplication::stringURLSafe('all')) { $vars['all'] = 1; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefCollections = array_search(JApplication::stringURLSafe('collections'), $segments); if ($searchSefCollections !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefCollections, $validArrayIndex)) { $vars['view'] = 'collections'; if (isset($segments[$searchSefCollections - 1])) { if ($segments[$searchSefCollections - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefCollections - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefDashboard = array_search(JApplication::stringURLSafe('dashboard'), $segments); if ($searchSefDashboard !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefDashboard, $validArrayIndex)) { $vars['view'] = 'dashboard'; if (isset($segments[$searchSefDashboard - 1])) { if ($segments[$searchSefDashboard - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefDashboard - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefUserComments = array_search(JApplication::stringURLSafe('comments'), $segments); if ($searchSefUserComments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefUserComments, $validArrayIndex)) { $vars['view'] = 'usercomments'; if (isset($segments[$searchSefUserComments - 1])) { if ($segments[$searchSefUserComments - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefUserComments - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefUserDocuments = array_search(JApplication::stringURLSafe('documents'), $segments); if ($searchSefUserDocuments !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefUserDocuments, $validArrayIndex)) { $vars['view'] = 'userdocuments'; if (isset($segments[$searchSefUserDocuments - 1])) { if ($segments[$searchSefUserDocuments - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefUserDocuments - 1]; } } if (isset($segments[$searchSefUserDocuments + 1])) { if ($segments[$searchSefUserDocuments + 1] == JApplication::stringURLSafe('published')) { $vars['filter'] = 'published'; } elseif ($segments[$searchSefUserDocuments + 1] == JApplication::stringURLSafe('unpublished')) { $vars['filter'] = 'unpublished'; } elseif ($segments[$searchSefUserDocuments + 1] == JApplication::stringURLSafe('pending')) { $vars['filter'] = 'pending'; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { if ($segments[$previousIndexSegment] == JApplication::stringURLSafe('rss')) { $vars['format'] = 'feed'; $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefUserSubscriptions = array_search(JApplication::stringURLSafe('user-subscriptions'), $segments); if ($searchSefUserSubscriptions !== false) { $validArrayIndex = array(0, 1, 2); if (in_array($searchSefUserSubscriptions, $validArrayIndex)) { $vars['view'] = 'usersubscriptions'; if (isset($segments[$searchSefUserSubscriptions - 1])) { if ($segments[$searchSefUserSubscriptions - 1] != JApplication::stringURLSafe('root')) { $vars['id'] = (int) $segments[$searchSefUserSubscriptions - 1]; } } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefSearchBy = array_search(JApplication::stringURLSafe('search-by'), $segments); if ($searchSefSearchBy !== false) { $validArrayIndex = array(0, 1); if (in_array($searchSefSearchBy, $validArrayIndex)) { $vars['view'] = 'searchby'; if (isset($segments[$searchSefSearchBy + 1])) { $vars['field_id'] = (int) $segments[$searchSefSearchBy + 1]; } if (isset($segments[$searchSefSearchBy + 2])) { $vars['value'] = $segments[$searchSefSearchBy + 2]; } $previousIndexSegment = $total - 1; $isPaged = JUDownloadHelperRoute::parsePagination($vars, $segments, $params); if ($isPaged) { $previousIndexSegment -= 1; } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefContact = array_search(JApplication::stringURLSafe('contact'), $segments); if ($searchSefContact !== false) { if ($searchSefContact == $indexLastSegment || $searchSefContact == ($indexLastSegment - 1)) { $vars['view'] = 'contact'; if (isset($segments[$searchSefContact - 1])) { $vars['doc_id'] = (int) $segments[$searchSefContact - 1]; } $previousIndexSegment = $total - 1; if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); } return $vars; } } $searchSefCheckIn = array_search(JApplication::stringURLSafe('checkin'), $segments); if ($searchSefCheckIn !== false) { $vars['task'] = 'forms.checkin'; if (isset($segments[$searchSefCheckIn - 1])) { $vars['id'] = (int) $segments[$searchSefCheckIn - 1]; } return $vars; } $searchSefAdd = array_search(JApplication::stringURLSafe('add'), $segments); if ($searchSefAdd !== false) { $vars['task'] = 'form.add'; if (isset($segments[$searchSefAdd - 1])) { $vars['cat_id'] = (int) $segments[$searchSefAdd - 1]; } return $vars; } $searchSefEdit = array_search(JApplication::stringURLSafe('edit'), $segments); if ($searchSefEdit !== false) { $vars['task'] = 'form.edit'; if (isset($segments[$searchSefEdit - 1])) { $vars['id'] = (int) $segments[$searchSefEdit - 1]; } return $vars; } $searchSefDelete = array_search(JApplication::stringURLSafe('delete'), $segments); if ($searchSefDelete !== false) { $vars['task'] = 'forms.delete'; if (isset($segments[$searchSefDelete - 1])) { $vars['id'] = (int) $segments[$searchSefDelete - 1]; } return $vars; } $searchNewDocument = array_search(JApplication::stringURLSafe('new-document'), $segments); if ($searchNewDocument !== false) { $vars['view'] = 'form'; $vars['layout'] = 'edit'; if (isset($segments[$searchNewDocument - 1])) { $vars['cat_id'] = (int) $segments[$searchNewDocument - 1]; } return $vars; } $searchSefApprove = array_search(JApplication::stringURLSafe('approve'), $segments); if ($searchSefApprove !== false) { if ($searchSefApprove == $indexLastSegment) { $vars['task'] = 'modpendingdocument.edit'; $vars['approve'] = 1; } else { $vars['view'] = 'form'; $vars['layout'] = 'edit'; $vars['approve'] = 1; } if (isset($segments[$searchSefApprove - 1])) { $vars['id'] = (int) $segments[$searchSefApprove - 1]; } return $vars; } $searchSefPublish = array_search(JApplication::stringURLSafe('publish'), $segments); if ($searchSefPublish !== false) { $vars['task'] = 'forms.publish'; if (isset($segments[$searchSefPublish - 1])) { $vars['id'] = (int) $segments[$searchSefPublish - 1]; } return $vars; } $searchSefUnPublish = array_search(JApplication::stringURLSafe('unpublish'), $segments); if ($searchSefUnPublish !== false) { $vars['task'] = 'forms.unpublish'; if (isset($segments[$searchSefUnPublish - 1])) { $vars['id'] = (int) $segments[$searchSefUnPublish - 1]; } return $vars; } $searchSefSubscribe = array_search(JApplication::stringURLSafe('subscribe'), $segments); if ($searchSefSubscribe !== false) { $vars['task'] = 'subscribe.save'; if (isset($segments[$searchSefSubscribe - 1])) { $vars['doc_id'] = (int) $segments[$searchSefSubscribe - 1]; } return $vars; } $searchSefUnSubscribe = array_search(JApplication::stringURLSafe('unsubscribe'), $segments); if ($searchSefUnSubscribe !== false) { $vars['task'] = 'subscribe.remove'; if (isset($segments[$searchSefUnSubscribe + 1])) { $vars['sub_id'] = (int) $segments[$searchSefUnSubscribe + 1]; } if (isset($segments[$searchSefUnSubscribe + 2])) { $vars['code'] = $segments[$searchSefUnSubscribe + 2]; } return $vars; } $searchSefDownload = array_search(JApplication::stringURLSafe('download'), $segments); if ($searchSefDownload !== false) { $vars['task'] = 'download.download'; if (isset($segments[$searchSefDownload - 3])) { if ($segments[$searchSefDownload - 3] == JApplication::stringURLSafe('file')) { $vars['file_id'] = (int) $segments[$searchSefDownload - 2]; if ($segments[$searchSefDownload - 1] != JApplication::stringURLSafe('latest')) { $vars['version'] = $segments[$searchSefDownload - 1]; } return $vars; } } if (isset($segments[$searchSefDownload - 1])) { if ($segments[$searchSefDownload - 1] != JApplication::stringURLSafe('latest')) { $vars['version'] = $segments[$searchSefDownload - 1]; } if (isset($segments[$searchSefDownload - 2])) { $vars['doc_id'] = (int) $segments[$searchSefDownload - 2]; } } return $vars; } $previousIndexSegment = $indexLastSegment; if (isset($segments[$previousIndexSegment])) { $isPaged = preg_match('/' . preg_quote(JApplication::stringURLSafe('page') . '-') . '[0-9]*+/', $segments[$previousIndexSegment]); if ($isPaged) { if ($indexLastSegment == 0) { if (is_object($activeMenu) && $activeMenu->component == 'com_judownload') { $vars = $activeMenu->query; JUDownloadHelperRoute::parsePagination($vars, $segments, $params); return $vars; } } $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isFeed = $segments[$previousIndexSegment] == JApplication::stringURLSafe('rss') ? true : false; if ($isFeed) { $vars['format'] = 'feed'; if ($indexLastSegment == 0) { if (is_object($activeMenu) && $activeMenu->component == 'com_judownload') { $vars = $activeMenu->query; $vars['format'] = 'feed'; return $vars; } } $previousIndexSegment -= 1; } } if (isset($segments[$previousIndexSegment])) { $isLayout = JUDownloadHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params); if ($isLayout) { $previousIndexSegment -= 1; } } if (!empty($segments)) { $reverseSegments = array_reverse($segments); foreach ($reverseSegments as $segmentItemKey => $segmentItem) { if (preg_match('/^\d+\-.+/', $segmentItem)) { $indexAlias = $indexLastSegment - $segmentItemKey; break; } } if (isset($indexAlias) && isset($segments[$indexAlias])) { if (strpos($segments[$indexAlias], '-') === false) { $itemId = (int) $segments[$indexAlias]; $itemAlias = substr($segments[$indexAlias], strlen($itemId) + 1); } else { list($itemId, $itemAlias) = explode('-', $segments[$indexAlias], 2); } if (is_numeric($itemId)) { $categoryObject = JUDownloadHelper::getCategoryById($itemId); if (is_object($categoryObject) && isset($categoryObject->alias) && $categoryObject->alias == $itemAlias) { $vars['view'] = 'category'; $vars['id'] = $itemId; JUDownloadHelperRoute::parsePagination($vars, $segments, $params); return $vars; } $documentObject = JUDownloadHelper::getDocumentById($itemId); if (is_object($documentObject) && isset($documentObject->alias) && $documentObject->alias == $itemAlias) { $vars['id'] = $itemId; if (isset($vars['layout'])) { if ($vars['layout'] == 'edit') { $vars['view'] = 'form'; } else { $vars['view'] = 'document'; } } if (!isset($vars['view'])) { $vars['view'] = 'document'; } if ($vars['view'] == 'document') { if (isset($segments[$indexAlias + 1])) { if ($segments[$indexAlias + 1] == JApplication::stringURLSafe('print')) { $vars['print'] = 1; $vars['tmpl'] = 'component'; $vars['layout'] = 'print'; } elseif ($segments[$indexAlias + 1] == JApplication::stringURLSafe('changelogs')) { $vars['layout'] = 'changelogs'; } elseif ($segments[$indexAlias + 1] == JApplication::stringURLSafe('versions')) { $vars['layout'] = 'versions'; } } } JUDownloadHelperRoute::parsePagination($vars, $segments, $params); return $vars; } if (is_object($categoryObject) && isset($categoryObject->id) && $categoryObject->id) { $vars['view'] = 'category'; $vars['id'] = $itemId; JUDownloadHelperRoute::parsePagination($vars, $segments, $params); return $vars; } if (is_object($documentObject) && isset($documentObject->id) && $documentObject->id) { $vars['id'] = $itemId; if (isset($vars['layout'])) { if ($vars['layout'] == 'edit') { $vars['view'] = 'form'; } else { $vars['view'] = 'document'; } } if (!isset($vars['view'])) { $vars['view'] = 'document'; } if ($vars['view'] == 'document') { if (isset($segments[$indexAlias + 1])) { if ($segments[$indexAlias + 1] == JApplication::stringURLSafe('print')) { $vars['print'] = 1; $vars['tmpl'] = 'component'; $vars['layout'] = 'print'; } elseif ($segments[$indexAlias + 1] == JApplication::stringURLSafe('changelogs')) { $vars['layout'] = 'changelogs'; } elseif ($segments[$indexAlias + 1] == JApplication::stringURLSafe('versions')) { $vars['layout'] = 'versions'; } } } JUDownloadHelperRoute::parsePagination($vars, $segments, $params); return $vars; } } } } if (is_object($activeMenu) && $activeMenu->component == 'com_judownload') { $vars = $activeMenu->query; } return $vars; }
public function getDocsForRating(array $cats, array $criteriaGroups, $limit, $start) { $docsCats = array(); $db = $this->getDbo(); $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $query = $db->getQuery(true); $query->select('id'); $query->from('#__judownload_criterias_groups'); $query->where('published != 1'); $db->setQuery($query); $criteriaGroupsUnpublished = $db->loadColumn(); if (empty($cats[0]) || in_array($rootCat->id, $cats)) { $query = $db->getQuery(true); $query->select('id AS cat_id, parent_id, lft, rgt, level, selected_criteriagroup'); $query->from('#__judownload_categories'); if (!empty($criteriaGroups) && !empty($criteriaGroups[0])) { $query->where('criteriagroup_id IN (' . implode(',', $criteriaGroups) . ')'); } if (!empty($criteriaGroupsUnpublished)) { $query->where('criteriagroup_id NOT IN (' . implode(',', $criteriaGroupsUnpublished) . ')'); } $db->setQuery($query); $groupCats = $db->loadObjectList(); if (!empty($groupCats)) { foreach ($groupCats as $group) { $docsCats[] = $group->cat_id; } } } else { foreach ($cats as $cat) { $query = $db->getQuery(true); $query->select('lft, rgt'); $query->from('#__judownload_categories'); $query->where('id = ' . $cat); $db->setQuery($query); $left_rigth = $db->loadObject(); if ($left_rigth) { $query = $db->getQuery(true); $query->select('id'); $query->from('#__judownload_categories'); $query->where('lft >= ' . $left_rigth->lft); $query->where('rgt <= ' . $left_rigth->rgt); if (!empty($criteriaGroups) && !empty($criteriaGroups[0])) { $query->where('criteriagroup_id IN (' . implode(',', $criteriaGroups) . ')'); } if (!empty($criteriaGroupsUnpublished)) { $query->where('criteriagroup_id NOT IN (' . implode(',', $criteriaGroupsUnpublished) . ')'); } $db->setQuery($query); $subCats = $db->loadColumn(); if (!empty($subCats)) { $docsCats = array_merge($docsCats, $subCats); } } } } if (!empty($docsCats)) { $query = "SELECT doc_id FROM #__judownload_documents_xref WHERE cat_id IN (" . implode(',', $docsCats) . ") ORDER BY doc_id"; if ($start == 0) { $db->setQuery($query); $allDocs = $db->loadColumn(); $app = JFactory::getApplication(); $app->setUserState('total_documents', count($allDocs)); } $query .= " LIMIT {$start},{$limit}"; $db->setQuery($query); $docIds = $db->loadColumn(); return $docIds; } else { return array(); } }
public function validateCriteria($data) { $documentId = $data['doc_id']; $params = JUDownloadHelper::getParams(null, $documentId); $dataValid = array(); $canRateDocument = JUDownloadFrontHelperPermission::canRateDocument($documentId); if ($canRateDocument && $params->get('enable_doc_rate_in_comment_form', 1)) { $mainCatId = JUDownloadFrontHelperCategory::getMainCategoryId($documentId); $criteriaArray = JUDownloadFrontHelperCriteria::getCriteriasByCatId($mainCatId); $postCriteria = $data['criteria']; if (count($criteriaArray) > 0) { foreach ($criteriaArray AS $key => $criteria) { if ($criteria->required) { if (isset($postCriteria[$criteria->id]) && $postCriteria[$criteria->id] > 0 && $postCriteria[$criteria->id] <= 10) { $criteria->value = $postCriteria[$criteria->id]; } else { echo JText::_('Invalid Field ' . $criteria->title); exit; } } else { if (isset($postCriteria[$criteria->id]) && $postCriteria[$criteria->id] > 0 && $postCriteria[$criteria->id] <= 10) { $criteria->value = $postCriteria[$criteria->id]; } else { unset($criteriaArray[$key]); } } } $dataValid['criteria_array'] = $criteriaArray; } else { if ($params->get('require_doc_rate_in_comment_form', 1)) { if (($data['judl_comment_rating_single'] <= 0) && ($data['judl_comment_rating_single'] > 10)) { return false; } $dataValid['ratingValue'] = $data['judl_comment_rating_single']; } } } return $dataValid; }
public function delete() { JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN')); $cid = JFactory::getApplication()->input->get('id', array(), 'array'); if (!is_array($cid) || count($cid) < 1) { JError::raiseWarning(500, JText::_('COM_JUDOWNLOAD_NO_ITEM_SELECTED')); $this->setRedirect($this->getReturnPage()); } else { $model = $this->getModel(); jimport('joomla.utilities.arrayhelper'); JArrayHelper::toInteger($cid); if ($model->delete($cid)) { $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); } else { $this->setMessage($model->getError()); } $isDocumentPublished = JUDownloadFrontHelperDocument::isDocumentPublished($cid[0]); if ($isDocumentPublished) { $mainCategoryId = JUDownloadFrontHelperCategory::getMainCategoryId($cid[0]); $this->setRedirect(JRoute::_(JUDownloadHelperRoute::getCategoryRoute($mainCategoryId), false)); } else { $this->setRedirect($this->getReturnPage()); } } }
public function getSubCategories($parentId, $ordering = 'title', $direction = 'ASC') { $params = $this->getState('params'); $showEmptyCategory = $params->get('show_empty_subcategory', 1); $user = JFactory::getUser(); $levels = $user->getAuthorisedViewLevels(); $levelsStr = implode(',', $levels); $db = JFactory::getDbo(); $nullDate = $db->getNullDate(); $nowDate = JFactory::getDate()->toSql(); $query = $db->getQuery(true); $query->select('*'); $query->from('#__judownload_categories'); $query->where('parent_id=' . $parentId); $query->where('published = 1'); $query->where('(publish_up = ' . $db->quote($nullDate) . ' OR publish_up <= ' . $db->quote($nowDate) . ')'); $query->where('(publish_down = ' . $db->quote($nullDate) . ' OR publish_down >= ' . $db->quote($nowDate) . ')'); $query->where('access IN (' . $levelsStr . ')'); $app = JFactory::getApplication(); $tag = JFactory::getLanguage()->getTag(); if ($app->getLanguageFilter()) { $query->where('language IN (' . $db->quote($tag) . ',' . $db->quote('*') . ',' . $db->quote('') . ')'); } $query->order($ordering . ' ' . $direction); $db->setQuery($query); $subCategoriesBefore = $db->loadObjectList(); $subCategoriesAfter = array(); foreach ($subCategoriesBefore AS $category) { $showTotalSubCats = $params->get('show_total_subcats_of_subcat', 0); $showTotalChildDocs = $params->get('show_total_docs_of_subcat', 0); $nestedCategories = null; if ($showTotalChildDocs || $showTotalSubCats) { $nestedCategories = JUDownloadFrontHelperCategory::getCategoriesRecursive($category->id, true, true, true, false, false, true); if ($showTotalChildDocs) { $category->total_documents = JUDownloadFrontHelperCategory::getTotalDocumentsInCategory($category->id, $nestedCategories); } if ($showTotalSubCats) { $category->total_nested_categories = JUDownloadFrontHelperCategory::getTotalSubCategoriesInCategory($category->id, $nestedCategories); } } $registry = new JRegistry; $registry->loadString($category->images); $category->images = $registry->toObject(); $category->link = JRoute::_(JUDownloadHelperRoute::getCategoryRoute($category->id)); if (!$showEmptyCategory) { if (is_null($nestedCategories)) { $nestedCategories = JUDownloadFrontHelperCategory::getCategoriesRecursive($category->id, true, true, true, false, false, true); } if (!isset($category->total_nested_categories)) { $category->total_nested_categories = JUDownloadFrontHelperCategory::getTotalSubCategoriesInCategory($category->id, $nestedCategories); } if (!isset($category->total_documents)) { $category->total_documents = JUDownloadFrontHelperCategory::getTotalDocumentsInCategory($category->id, $nestedCategories); } if (($category->total_nested_categories > 0) || ($category->total_documents > 0)) { $subCategoriesAfter[] = $category; } } else { $subCategoriesAfter[] = $category; } } return $subCategoriesAfter; }
public function setSessionCommentForm($documentId) { $session = JFactory::getSession(); $app = JFactory::getApplication(); $criteriaRatingValues = array('judl-comment-rating-single' => $app->input->getFloat('judl_comment_rating_single', 0)); $mainCatId = JUDownloadFrontHelperCategory::getMainCategoryId($documentId); $criteriaArray = JUDownloadFrontHelperCriteria::getCriteriasByCatId($mainCatId); if (count($criteriaArray)) { foreach ($criteriaArray AS $value) { $criteriaRatingValues[$value->id] = $app->input->getString('criteria-' . $value->id, ''); } } $commentForm = array(); $commentForm['rating'] = $criteriaRatingValues; $commentForm['title'] = $app->input->getString('title', ''); $commentForm['guest_name'] = $app->input->getString('guest_name', ''); $commentForm['guest_email'] = $app->input->getString('guest_email', ''); $commentForm['comment'] = $app->input->getString('comment', ''); $commentForm['parent_id'] = $app->input->getInt('parent_id', ''); $commentForm['comment_language'] = $app->input->getString('comment_language', '*'); if ($app->input->getString('website', '')) { $commentForm['website'] = $app->input->getString('website', ''); } $session->set('judownload_commentform_' . $documentId, $commentForm); }
public static function isEmptyCat($catId) { $categoryIdArrayCanAccess = JUDownloadFrontHelperCategory::getAccessibleCategoryIds(); if (empty($categoryIdArrayCanAccess)) { return true; } $user = JFactory::getUser(); $levelsArray = $user->getAuthorisedViewLevels(); $levelString = implode(',', $levelsArray); $db = JFactory::getDBO(); $nullDate = $db->getNullDate(); $nowDate = JFactory::getDate()->toSql(); $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__judownload_categories AS c'); $query->where('c.parent_id = ' . $catId); $query->where('c.published = 1'); $query->where('(c.publish_up = ' . $db->quote($nullDate) . ' OR c.publish_up <= ' . $db->quote($nowDate) . ')'); $query->where('(c.publish_down = ' . $db->quote($nullDate) . ' OR c.publish_down >= ' . $db->quote($nowDate) . ')'); $query->where('c.access IN (' . $levelString . ')'); $query->where('c.id IN (' . implode(",", $categoryIdArrayCanAccess) . ')'); $app = JFactory::getApplication(); $tagLanguage = JFactory::getLanguage()->getTag(); if ($app->getLanguageFilter()) { $query->where('c.language IN (' . $db->quote($tagLanguage) . ',' . $db->quote('*') . ')'); } $db->setQuery($query); $totalSubCats = $db->loadResult(); $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__judownload_documents AS d'); $query->where('dx.cat_id = ' . $catId); $query->where('d.approved = 1'); $query->where('d.published = 1'); $query->where('(d.publish_up = ' . $db->quote($nullDate) . ' OR d.publish_up <= ' . $db->quote($nowDate) . ')'); $query->where('(d.publish_down = ' . $db->quote($nullDate) . ' OR d.publish_down >= ' . $db->quote($nowDate) . ')'); if ($user->get('guest')) { $query->where('d.access IN (' . $levelString . ')'); } else { $query->where('(d.access IN (' . $levelString . ') OR (d.created_by = ' . $user->id . '))'); } $query->join('INNER', '#__judownload_documents_xref AS dx ON d.id = dx.doc_id'); $query->where('dx.cat_id IN (' . implode(",", $categoryIdArrayCanAccess) . ')'); $app = JFactory::getApplication(); $tagLanguage = JFactory::getLanguage()->getTag(); if ($app->getLanguageFilter()) { $query->where('d.language IN (' . $db->quote($tagLanguage) . ',' . $db->quote('*') . ')'); } $query->group('d.id'); $db->setQuery($query); $totalDocuments = $db->loadResult(); if (!$totalSubCats && !$totalDocuments) { return true; } else { return false; } }
public function display($tpl = null) { $app = JFactory::getApplication(); $categoryId = $app->input->getInt('id', 1); $this->category = JUDownloadFrontHelperCategory::getCategory($categoryId); $error = array(); if (!JUDownloadFrontHelperPermission::canDoCategory($this->category->id, true, $error)) { $user = JFactory::getUser(); if ($user->id) { return JError::raiseError($error['code'], $error['message']); } else { $uri = JUri::getInstance(); $loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false); $app = JFactory::getApplication(); $app->redirect($loginUrl, JText::_('COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'), 'warning'); return false; } } $model = $this->getModel(); $this->model = $model; $this->state = $this->get('State'); $this->params = $this->state->params; if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->parent_id = $this->category->id; $this->subcategory_level = (int) $this->params->get('all_categories_subcategory_level', -1); $this->all_categories = $model->getCategoriesRecursive($this->category->id, $this->subcategory_level); $firstCategory = $this->all_categories[0]; $this->category->total_childs = $firstCategory->total_childs; $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
public function delete() { $app = JFactory::getApplication(); $documentid = $app->input->post->get('documentid', array(), 'array'); $app->input->set('cid', $documentid); $_POST['cid'] = $documentid; $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $cat_id = $app->input->getInt('cat_id', $rootCat->id); parent::delete(); $this->setRedirect("index.php?option=com_judownload&view={$this->view_list}&cat_id={$cat_id}"); }
public static function getMenuItemIdArrayOfViewCategoryTreeLevel0And1() { $menuItemIdsOfViewCategoryTree = self::getMenuItemIdArrayOfViewCategoryTree(); $menuItemIds = array(); $categoryObjectListLevel1 = JUDownloadHelper::getCatsByLevel(); if ($categoryObjectListLevel1) { foreach ($categoryObjectListLevel1 AS $categoryObjectLevel1) { if (isset($menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id])) { $menuItemIds[$categoryObjectLevel1->id] = $menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id]; } } $categoryRoot = JUDownloadFrontHelperCategory::getRootCategory(); if (isset($menuItemIdsOfViewCategoryTree[$categoryRoot->id])) { $menuItemIds[$categoryRoot->id] = $menuItemIdsOfViewCategoryTree[$categoryRoot->id]; } } return $menuItemIds; }
public function display($tpl = null) { $model = $this->getModel(); $this->model = $model; $this->state = $this->get('State'); $params = $this->state->params; $this->params = $params; $this->token = JSession::getFormToken(); $this->root_category = JUDownloadFrontHelperCategory::getRootCategory(); $categoryId = $this->state->get('category.id', $this->root_category->id); if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } $error = array(); if (!JUDownloadFrontHelperPermission::canDoCategory($categoryId, true, $error)) { $user = JFactory::getUser(); if ($user->id) { return JError::raiseError($error['code'], $error['message']); } else { $uri = JUri::getInstance(); $loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false); $app = JFactory::getApplication(); $app->redirect($loginUrl, JText::_('COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'), 'warning'); return false; } } $topLevelCats = JUDownloadHelper::getCatsByLevel(1, $categoryId); if (is_array($topLevelCats) && count($topLevelCats) > 0) { $this->tl_catid = $topLevelCats[0]->id; } $this->category = JUDownloadFrontHelperCategory::getCategory($categoryId); $this->show_feed = JUDLPROVERSION ? $this->params->get('rss_display_icon', 1) : 0; $this->rss_link = JRoute::_(JUDownloadHelperRoute::getCategoryRoute($this->category->id, null, true)); if (isset($this->category->images) && !empty($this->category->images) && !empty($this->category->images->detail_image)) { $this->category->images->detail_image_src = JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('category_detail_image_directory', 'media/com_judownload/images/category/detail/', true) . $this->category->images->detail_image; } $this->category->images->detail_image_width = (int) $this->params->get('category_image_width', 200); $this->category->images->detail_image_height = (int) $this->params->get('category_image_height', 200); if ($this->params->get('category_show_description', 1)) { $this->category->description = $this->category->introtext . $this->category->fulltext; } else { $this->category->description = $this->category->fulltext; } $categoryDescLimit = (int) $this->params->get('category_desc_limit', 0); if ($categoryDescLimit > 0) { $this->category->description = JUDownloadFrontHelperString::truncateHtml($this->category->description, $categoryDescLimit); } if ($this->params->get('plugin_support', 0)) { $this->category->description = JHtml::_('content.prepare', $this->category->description, '', 'com_judownload.category'); } $this->category->class_sfx = htmlspecialchars($this->category->class_sfx); $relatedCatOrdering = $this->params->get('related_category_ordering', 'crel.ordering'); $relatedCatDirection = $this->params->get('related_category_direction', 'ASC'); $this->related_cats = $model->getRelatedCategories($this->category->id, $relatedCatOrdering, $relatedCatDirection); if (is_array($this->related_cats) && count($this->related_cats) > 0) { foreach ($this->related_cats AS $relatedCategory) { if (isset($relatedCategory->images->intro_image) && !empty($relatedCategory->images->intro_image)) { $relatedCategory->images->intro_image_src = JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judownload/images/category/intro/', true) . $relatedCategory->images->intro_image; } $relatedCategory->images->intro_image_width = (int) $this->params->get('related_category_intro_image_width', 200); $relatedCategory->images->intro_image_height = (int) $this->params->get('related_category_intro_image_height', 200); if ($this->params->get('related_category_show_introtext', 1)) { $relatedCategoryDescLimit = (int) $this->params->get('related_category_introtext_character_limit', 500); if ($relatedCategoryDescLimit > 0) { $relatedCategory->introtext = JUDownloadFrontHelperString::truncateHtml($relatedCategory->introtext, $relatedCategoryDescLimit); } if ($params->get('plugin_support', 0)) { $relatedCategory->introtext = JHtml::_('content.prepare', $relatedCategory->introtext, '', 'com_judownload.category'); } } else { $relatedCategory->introtext = ''; } } } $subCatOrdering = $this->params->get('subcategory_ordering', 'title'); $subCatDirection = $this->params->get('subcategory_direction', 'ASC'); $this->subcategories = $model->getSubCategories($this->category->id, $subCatOrdering, $subCatDirection); if (is_array($this->subcategories) && count($this->subcategories) > 0) { foreach ($this->subcategories AS $subCategory) { if (isset($subCategory->images->intro_image) && !empty($subCategory->images->intro_image)) { $subCategory->images->intro_image_src = JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judownload/images/category/intro/', true) . $subCategory->images->intro_image; } $subCategory->images->intro_image_width = (int) $this->params->get('subcategory_intro_image_width', 200); $subCategory->images->intro_image_height = (int) $this->params->get('subcategory_intro_image_height', 200); if ($this->params->get('subcategory_show_introtext', 1)) { $subCategoryDescLimit = (int) $this->params->get('subcategory_introtext_character_limit', 500); if ($subCategoryDescLimit > 0) { $subCategory->introtext = JUDownloadFrontHelperString::truncateHtml($subCategory->introtext, $subCategoryDescLimit); } if ($this->params->get('plugin_support', 0)) { $subCategory->introtext = JHtml::_('content.prepare', $subCategory->introtext, '', 'com_judownload.category'); } } else { $subCategory->introtext = ''; } } } $this->category->can_submit_doc = JUDownloadFrontHelperPermission::canSubmitDocument($this->category->id); if ($this->category->can_submit_doc && $this->params->get('show_submit_document_btn_in_category', 1)) { $this->category->submit_doc_link = JUDownloadFrontHelperDocument::getAddDocumentLink($this->category->id); } $this->items = array(); if ($this->category->show_item) { $user = JFactory::getUser(); $uri = JUri::getInstance(); $this->items = $this->get('Items'); foreach ($this->items as $item) { $documentItemid = JUDownloadHelperRoute::findItemIdOfDocument($item->id); $item->report_link = JRoute::_(JUDownloadHelperRoute::getReportDocumentRoute($item->id)); if ($item->checked_out > 0 && $item->checked_out != $user->get('id')) { if (JUDownloadFrontHelperPermission::canCheckInDocument($item->id)) { $item->checkin_link = JRoute::_('index.php?option=com_judownload&task=forms.checkin&id=' . $item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri))); } } else { $item->edit_link = JRoute::_('index.php?option=com_judownload&task=form.edit&id=' . $item->id . '&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id)); if ($item->published == 1) { $item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.unpublish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id)); } else { $item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.publish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id)); } } $item->delete_link = JRoute::_('index.php?option=com_judownload&task=forms.delete&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id)); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $item->event = new stdClass(); $context = 'com_judownload.document_list'; $results = $dispatcher->trigger('onContentAfterTitle', array($context, &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array($context, &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); } $this->pagination = $this->get('Pagination'); } $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->_prepareData(); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
public function validateFields($fieldsData, $docId) { $app = JFactory::getApplication(); $params = JUDownloadHelper::getParams(); $db = JFactory::getDbo(); $nullDate = $db->getNullDate(); $nowDate = JFactory::getDate()->toSql(); $error = false; $isNew = $docId == 0 ? true : false; $categoriesField = JUDownloadFrontHelperField::getField('cat_id', $docId); if ($this->getDocumentSubmitType($docId) == 'submit' && $categoriesField->canSubmit() || $this->getDocumentSubmitType($docId) == 'edit' && $categoriesField->canEdit()) { $fieldValueCategories = $fieldsData[$categoriesField->id]; $categoriesField->is_new = $isNew; $categoriesField->fields_data = $fieldsData; $fieldValueCategories = $categoriesField->filterField($fieldValueCategories); $valid = $categoriesField->PHPValidate($fieldValueCategories); if ($valid === true) { $fieldsData[$categoriesField->id] = $fieldValueCategories; $catId = $fieldsData[$categoriesField->id]['main']; } else { $this->setError($valid); if ($isNew) { return false; } $catId = JUDownloadFrontHelperCategory::getMainCategoryId($docId); $error = true; unset($fieldsData[$categoriesField->id]); } } else { $catId = JUDownloadFrontHelperCategory::getMainCategoryId($docId); } $form = $this->getFormDefault(); $xml_field_name_publishing = array(); $elementsInPublishing = $form->xpath('//fieldset[@name="publishing"]/field | //field[@fieldset="publishing"]'); foreach ($elementsInPublishing as $elementsInPublishingKey => $elementsInPublishingVal) { $elementInPublishing = $elementsInPublishingVal->attributes(); $xml_field_name_publishing[] = (string) $elementInPublishing['name']; } $query = $db->getQuery(true); $query->select("field.*"); $query->from("#__judownload_fields AS field"); $query->select("plg.folder"); $query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id"); $query->join("", "#__judownload_fields_groups AS field_group ON field_group.id = field.group_id"); $query->join("", "#__judownload_categories AS c ON (c.fieldgroup_id = field.group_id OR field.group_id = 1 )"); $query->where("field_group.published = 1"); $query->where("field.published = 1"); $query->where('field.publish_up <= ' . $db->quote($nowDate)); $query->where('(field.publish_down = ' . $db->quote($nullDate) . ' OR field.publish_down >= ' . $db->quote($nowDate) . ')'); $query->where("(c.id = " . $catId . " OR field.group_id = 1)"); $query->where("field.field_name != 'cat_id'"); if ($app->isSite() && !$params->get('submit_form_show_tab_publishing', 0)) { if (!empty($xml_field_name_publishing)) { $query->where('field.field_name NOT IN (' . implode(',', $db->quote($xml_field_name_publishing)) . ')'); } } $query->group('field.id'); $db->setQuery($query); $fields = $db->loadObjectList(); foreach ($fields as $field) { $fieldObj = JUDownloadFrontHelperField::getField($field, $docId); if ($this->getDocumentSubmitType($docId) == 'submit' && $fieldObj->canSubmit() || $this->getDocumentSubmitType($docId) == 'edit' && $fieldObj->canEdit()) { $fieldValue = isset($fieldsData[$field->id]) ? $fieldsData[$field->id] : null; $fieldObj->is_new = $isNew; $fieldObj->fields_data = $fieldsData; $fieldValue = $fieldObj->filterField($fieldValue); $valid = $fieldObj->PHPValidate($fieldValue); if ($valid === true) { $fieldsData[$field->id] = $fieldValue; } else { $error = true; unset($fieldsData[$field->id]); $this->setError($valid); } } } if ($error) { return false; } else { return $fieldsData; } }
public function docChangeCategory() { $app = JFactory::getApplication(); if ($app->input->get('action', '') == 'update-maincat') { $ori_cat_id = $app->input->getInt('ori_cat_id', 0); $ori_cat = JUDownloadHelper::getCategoryById($ori_cat_id); $data['ori_field_group_id'] = 0; $data['new_field_group_id'] = 0; $data['new_field_group_name'] = ""; $data['path'] = ""; if ($ori_cat) { $data['ori_field_group_id'] = $ori_cat->fieldgroup_id; } $new_cat_id = $app->input->getInt('new_cat_id', 0); $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); $params = JUDownloadHelper::getParams(); if ($rootCat->id == $new_cat_id && !$params->get('allow_add_doc_to_root', 0)) { return ""; } $new_cat = JUDownloadHelper::getCategoryById($new_cat_id); if ($new_cat) { $db = JFactory::getDbo(); $query = "SELECT id, name FROM #__judownload_fields_groups WHERE id = " . $new_cat->fieldgroup_id . " AND published = 1"; $db->setQuery($query); $fieldgroup = $db->loadObject(); if ($fieldgroup) { $data['new_field_group_id'] = $fieldgroup->id; $data['new_field_group_name'] = $fieldgroup->name; } $data['path'] = JUDownloadHelper::generateCategoryPath($new_cat_id); } if ($data['ori_field_group_id'] != $data['new_field_group_id']) { $data['msg_field_group'] = JText::_('COM_JUDOWNLOAD_CHANGE_MAIN_CATEGORY_CAUSE_CHANGE_FIELD_GROUP_WARNING'); } $documentId = $app->input->getInt('id', 0); $data['message_style'] = JText::_('COM_JUDOWNLOAD_INHERIT'); if ($documentId) { $documentObject = JUDownloadHelper::getDocumentById($documentId); if ($documentObject->style_id == -1) { $oldStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($documentId->cat_id); $newStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($new_cat->id); if ($oldStyleObject->template_id != $newStyleObject->template_id) { $data['msg_style'] = JText::_('COM_JUDOWNLOAD_CHANGE_MAIN_CATEGORY_CAUSE_CHANGE_TEMPLATE_WARNING'); } } $newTemplateStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($new_cat->id); $data['message_style'] = JText::_('COM_JUDOWNLOAD_INHERIT') . ' (' . $newTemplateStyleObject->title . ' [' . $newTemplateStyleObject->template_title . ' ]' . ')'; } return json_encode($data); } elseif ($app->input->getInt('action', '') == 'insert_secondary_cat') { $cat_id_str = $app->input->get('secondary_cat_id', '', 'string'); $html = ''; if (!empty($cat_id_str)) { $cat_id_arr = explode(",", $cat_id_str); foreach ($cat_id_arr as $key => $cat_id) { $html .= "<li id=\"cat-" . $cat_id . "\"><a class=\"drag-icon\"></a><span>" . JUDownloadHelper::generateCategoryPath($cat_id) . "</span><a href=\"#\" onclick=\"return false\" class=\"remove-secondary-cat\" ><i class=\"icon-minus fa fa-minus-circle\"></i> " . JText::_('COM_JUDOWNLOAD_REMOVE') . "</a></li>"; } } return $html; } }
public function display($tpl = null) { $this->state = $this->get('State'); $this->token = JSession::getFormToken(); $this->params = $this->state->params; $app = JFactory::getApplication(); $submit_simple_search = $app->input->getString('submit_simple_search', ''); if (isset($submit_simple_search) && $submit_simple_search == "search") { $model = $this->getModel(); $model->resetState(); } $this->model = $this->getModel(); $user = JFactory::getUser(); $uri = JUri::getInstance(); $this->items = $this->get('Items'); foreach ($this->items as $item) { $item->report_link = JRoute::_(JUDownloadHelperRoute::getReportDocumentRoute($item->id)); if ($item->checked_out > 0 && $item->checked_out != $user->get('id')) { if (JUDownloadFrontHelperPermission::canCheckInDocument($item->id)) { $item->checkin_link = JRoute::_('index.php?option=com_judownload&task=forms.checkin&id=' . $item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri))); } } else { $item->edit_link = JRoute::_('index.php?option=com_judownload&task=form.edit&id=' . $item->id . '&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id)); if ($item->published == 1) { $item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.unpublish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id)); } else { $item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.publish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id)); } } $item->delete_link = JRoute::_('index.php?option=com_judownload&task=forms.delete&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id)); $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $item->event = new stdClass(); $context = 'com_judownload.document_list'; $results = $dispatcher->trigger('onContentAfterTitle', array($context, &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array($context, &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); } $this->pagination = $this->get('Pagination'); $this->searchword = trim($app->input->getString('searchword', '')); $this->searchword = JUDownloadFrontHelper::UrlDecode($this->searchword); $this->cat_id = $app->input->getInt('cat_id', 0); $this->sub_cat = $app->input->getInt('sub_cat', 0); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $nestedCategories = JUDownloadFrontHelperCategory::getCategoriesRecursive(1, false, false, true); $options = array(); $parent_cat_level = 0; foreach ($nestedCategories AS $key => $categoryObj) { if ($key == 0) { $parent_cat_level = $categoryObj->level; } $options[] = JHtml::_('select.option', $categoryObj->id, str_repeat('-.', ($categoryObj->level - $parent_cat_level)) . $categoryObj->title); } $this->cat_select_list = JHtml::_('select.genericList', $options, 'cat_id', '', 'value', 'text', $this->cat_id); $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); $this->_prepareData(); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
protected function _prepareQuery($fieldNames, $filter) { if (empty($fieldNames)) { return false; } $db = $this->getDbo(); $fieldNames = array_map(function ($element) { $element = 'd.' . $element; return $element; }, $fieldNames); $catIds = isset($filter['csv_cat_filter']) ? $filter['csv_cat_filter'] : array(); $rootCat = JUDownloadFrontHelperCategory::getRootCategory(); if (count($catIds) == 1 && $catIds[0] == $rootCat->id) { $catIds = array(); } if (isset($filter['csv_sub_cat']) && !empty($catIds)) { $tmp = array(); foreach ($catIds as $catId) { $categoryTree = JUDownloadHelper::getCategoryTree($catId); foreach ($categoryTree as $category) { $tmp[] = $category->id; } } $catIds = array_unique(array_merge($catIds, $tmp)); } $tags = $filter['csv_tag_filter']; $tags = array_filter($tags); $licenses = array_filter($filter['licenses']); $query = $db->getQuery(true); $query->select(implode(',', $fieldNames))->from("#__judownload_documents AS d")->join("", "#__judownload_documents_xref AS dx ON dx.doc_id = d.id")->join("", "#__judownload_categories AS c ON dx.cat_id = c.id"); if (!empty($catIds)) { $query->where("dx.cat_id IN (" . implode(',', $catIds) . ")"); } if (!empty($tags)) { $query->join("LEFT", "#__judownload_tags_xref AS tx ON tx.doc_id = d.id"); $query->where("tx.tag_id IN (" . implode(",", $tags) . ")"); } if (!empty($filter['csv_publishing_filter'])) { $filterConditions = array(); $nullDate = $db->getNullDate(); $now = JFactory::getDate()->toSql(); foreach ($filter['csv_publishing_filter'] as $value) { $condition = array(); switch (trim($value)) { case 'published': $condition[] = 'd.published = 1'; $condition[] = '(d.publish_up = ' . $db->quote($nullDate) . ' OR d.publish_up <= ' . $db->quote($now) . ')'; $condition[] = '(d.publish_down = ' . $db->quote($nullDate) . ' OR d.publish_down >= ' . $db->quote($now) . ')'; $condition[] = 'd.approved = 1'; break; case 'unpublished': $condition[] = 'd.published = 0'; $condition[] = 'd.approved = 1'; break; case 'pending': $condition[] = 'd.publish_up < ' . $db->quote($now); $condition[] = 'd.published = 1'; $condition[] = 'd.approved = 1'; break; case 'expired': $condition[] = 'd.publish_down < ' . $db->quote($now); $condition[] = 'd.published = 1'; $condition[] = 'd.approved = 1'; break; case 'pending_approval': $condition[] = 'd.approved = 0 '; break; case 'approved': $condition[] = 'd.approved = 1'; break; } if (!empty($condition)) { $filterConditions[] = '( ' . implode(' AND ', $condition) . ' )'; } } if (!empty($filterConditions)) { $query->where('(' . implode(' OR ', $filterConditions) . ')'); } } $offset = JFactory::getUser()->getParam('timezone', JFactory::getConfig()->get('offset')); if (!empty($filter['csv_created_from_filter'])) { $time = JFactory::getDate($filter['csv_created_from_filter'], $offset)->toSql(); $query->where('d.created >= ' . $db->quote($time)); } if (!empty($filter['csv_created_to_filter'])) { $time = JFactory::getDate($filter['csv_created_to_filter'], $offset)->toSql(); $query->where('d.created <= ' . $db->quote($time)); } if (!empty($licenses)) { $query->where('d.license_id IN (' . implode(',', $licenses) . ')'); } $query->group('d.id'); return $query; }