Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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}");
 }
Ejemplo n.º 3
0
 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;
    }
Ejemplo n.º 5
0
 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();
 }
 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;
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
	protected function populateState($ordering = null, $direction = null)
	{
		
		$app = JFactory::getApplication();

		
		$rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
		$catId        = $app->input->getInt('id', $rootCategory->id);
		$this->setState('category.id', $catId);

		
		$params = JUDownloadHelper::getParams($catId);
		$this->setState('params', $params);

		
		if ($this->context)
		{
			
			$documentPagination = $params->get('document_pagination', 10);

			
			$limitArray = JUDownloadFrontHelper::customLimitBox();

			if (is_array($limitArray) && count($limitArray))
			{
				

				
				$limit = $app->input->getUint('limit', null);
				if (is_null($limit) || in_array($limit, $limitArray))
				{
					
					$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $documentPagination, 'uint');
				}
				else
				{
					
					$limit = $documentPagination;
				}
			}
			else
			{
				
				$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $documentPagination, 'uint');
			}

			$this->setState('list.limit', $limit);

			$this->setState('list.start', $app->input->getUint('limitstart', 0));

			$orderCol = $app->getUserStateFromRequest($this->context . '.list.ordering', 'filter_order', '', 'string');
			$this->setState('list.ordering', $orderCol);

			$listOrder = $app->getUserStateFromRequest($this->context . '.list.direction', 'filter_order_Dir', '', 'cmd');
			$this->setState('list.direction', $listOrder);
		}
		else
		{
			$this->setState('list.start', 0);
			$this->state->set('list.limit', 0);
		}
	}
Ejemplo n.º 10
0
 * ------------------------------------------------------------------------
 *
 * @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();
Ejemplo n.º 11
0
	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;
	}
Ejemplo n.º 12
0
	protected function getListQuery()
	{
		$app                    = JFactory::getApplication();
		$rootCategory           = JUDownloadFrontHelperCategory::getRootCategory();
		$categoryId             = $this->getState('category.id', $rootCategory->id);
		$getAllNestedCategories = $app->input->getInt('all', 0);

		$catFilter = true;
		
		if ($categoryId == 1 && $getAllNestedCategories == 1)
		{
			$catFilter = false;
		}

		if ($catFilter)
		{
			$categoryIdArray = array();
			if ($getAllNestedCategories == 1)
			{
				$nestedCategories = JUDownloadFrontHelperCategory::getCategoriesRecursive($categoryId, true, true);
				if (count($nestedCategories) > 0)
				{
					foreach ($nestedCategories AS $categoryObj)
					{
						$categoryIdArray[] = $categoryObj->id;
					}
				}
			}
			array_unshift($categoryIdArray, $categoryId);
			$categoryString = implode(",", $categoryIdArray);
		}

		$ordering  = $this->getState('list.ordering', '');
		$direction = $this->getState('list.direction', 'ASC');

		$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('d.*');
		$query->from('#__judownload_documents AS d');

		JUDownloadFrontHelper::optimizeListDocumentQuery($query);

		if ($catFilter)
		{
			
			$query->join('', '#__judownload_documents_xref AS dxref ON d.id = dxref.doc_id');
			$query->join('', '#__judownload_categories AS c ON c.id = dxref.cat_id');

			
			$query->where('c.id IN(' . $categoryString . ')');

			
			$query->group('d.id');
		}

		
		$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 . '))');
		}

		
		$query->where('d.featured = 1');


		
		$app = JFactory::getApplication();
		$tag = JFactory::getLanguage()->getTag();

		if ($app->getLanguageFilter())
		{
			$query->where('d.language IN (' . $db->quote($tag) . ',' . $db->quote('*') . ',' . $db->quote('') . ')');
		}

		
		$categoryRoot = JUDownloadFrontHelperCategory::getRootCategory();

		JUDownloadFrontHelperField::appendFieldOrderingPriority($query, $categoryRoot->id, $ordering, $direction);

		return $query;
	}
Ejemplo n.º 13
0
	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;
	}
Ejemplo n.º 14
0
	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;
	}
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
 protected function populateState($ordering = null, $direction = null)
 {
     $rootCat = JUDownloadFrontHelperCategory::getRootCategory();
     $cat_id = $this->getUserStateFromRequest($this->context . '.cat_id', 'cat_id', $rootCat->id);
     $this->setState('list.cat_id', $cat_id);
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     $search = $this->getUserStateFromRequest($this->context . '.filter.search_cat', 'filter_search_cat');
     $this->setState('filter.search_cat', $search);
     $search = $this->getUserStateFromRequest($this->context . '.filter.simple_search', 'simple_search');
     $this->setState('filter.simple_search', $search);
     $search_in = $this->getUserStateFromRequest($this->context . '.filter.search_in', 'search_in', 'documents', 'none', false);
     $this->setState('filter.search_in', $search_in);
     $ordering = $this->getUserStateFromRequest($this->context . '.filter.ordering_cat', 'filter_order_cat');
     if (empty($ordering)) {
         $this->setState('filter.ordering_cat', 'lft');
     } else {
         $this->setState('filter.ordering_cat', $ordering);
     }
     $direction = $this->getUserStateFromRequest($this->context . '.filter.direction_cat', 'filter_order_Dir_cat');
     if (empty($direction)) {
         $this->setState('filter.direction_cat', 'asc');
     } else {
         $this->setState('filter.direction_cat', $direction);
     }
     parent::populateState($ordering, $direction);
 }
Ejemplo n.º 17
0
	public static function getCurrentTemplateStyle($view = '', $id = null)
	{
		$app    = JFactory::getApplication();
		$jInput = $app->input;

		
		if (!$view)
		{
			$view = $jInput->getString('view', '');
		}

		
		if ($jInput->getString('option', '') != 'com_judownload')
		{
			$view = '';
		}

		
		if (!$id)
		{
			switch ($view)
			{
				case 'form':
					$id           = $jInput->getInt('id', 0);
					$rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
					$cat_id       = $jInput->getInt('cat_id', $rootCategory->id);
					break;
				case 'document':
					$id = $jInput->getInt('id', 0);
					break;
				case 'category':
					$rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
					$id           = $jInput->getInt('id', $rootCategory->id);
					break;
			}
		}

		switch ($view)
		{
			
			case 'form':
				if ($id)
				{
					$templateStyleObject         = self::getTemplateStyleOfDocument($id);
					$documentObject              = JUDownloadHelper::getDocumentById($id);
					$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $documentObject->template_params);
				}
				else
				{
					$templateStyleObject         = self::getTemplateStyleOfCategory($cat_id);
					$categoryObject              = JUDownloadHelper::getCategoryById($cat_id);
					$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $categoryObject->template_params);
				}
				break;
			case 'document':
				$templateStyleObject         = self::getTemplateStyleOfDocument($id);
				$documentObject              = JUDownloadHelper::getDocumentById($id);
				$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $documentObject->template_params);
				break;
			
			case 'category':
				$templateStyleObject         = self::getTemplateStyleOfCategory($id);
				$categoryObject              = JUDownloadHelper::getCategoryById($id);
				$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id, $categoryObject->template_params);
				break;
			
			default:
				$templateStyleObject         = self::getDefaultTemplateStyle();
				$templateStyleObject->params = self::getTemplateStyleParams($templateStyleObject->id);
				break;
		}

		return $templateStyleObject;
	}
Ejemplo n.º 18
0
 public static function getParams($catId = null, $docId = null)
 {
     // If set docId but don't set catId -> get catId by docId
     if (!$catId && $docId) {
         $docObj = self::getDocumentById($docId);
         if ($docObj) {
             $catId = $docObj->cat_id;
         }
     }
     // Only override if cat existed, override by params of top level cat
     // Find the top level category, assign to $catId if first level cat is found
     if ($catId) {
         $path = self::getCategoryPath($catId);
         $rootCat = $path[0];
     } else {
         $rootCat = JUDownloadFrontHelperCategory::getRootCategory();
     }
     $catIdToGetParams = $rootCat->id;
     // Cache by catId
     $storeId = md5(__METHOD__ . "::{$catIdToGetParams}");
     // Set params by top level catId(or root) if it has not already set
     if (!isset(self::$cache[$storeId])) {
         // Get global config params(of root cat) by default
         $registry = new JRegistry();
         $registry->loadString($rootCat->config_params);
         // Override params from active menu if is a menu of component(Use merge to ignore empty string and null param value)
         $app = JFactory::getApplication();
         $activeMenu = $app->getMenu()->getActive();
         if ($activeMenu && $activeMenu->component == 'com_judownload') {
             $registry->merge($activeMenu->params);
         }
         self::$cache[$storeId] = $registry;
     }
     return self::$cache[$storeId];
 }
Ejemplo n.º 19
0
	public function display($tpl = null)
	{
		$this->model  = $this->getModel();
		$this->state  = $this->get('State');
		$this->params = $this->state->get('params');
		$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, &$this->item, &$this->params, 0));
			$item->event->afterDisplayTitle = trim(implode("\n", $results));

			$results                           = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$this->item, &$this->params, 0));
			$item->event->beforeDisplayContent = trim(implode("\n", $results));

			$results                          = $dispatcher->trigger('onContentAfterDisplay', array($context, &$this->item, &$this->params, 0));
			$item->event->afterDisplayContent = trim(implode("\n", $results));
		}
		$this->pagination = $this->get('Pagination');
		$this->token      = JSession::getFormToken();

		
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode("\n", $errors));

			return false;
		}

		
		$this->show_feed = JUDLPROVERSION ? $this->params->get('rss_display_icon', 1) : 0;

		$app                  = JFactory::getApplication();
		$rootCategory         = JUDownloadFrontHelperCategory::getRootCategory();
		$this->categoryId     = $app->input->getInt('id', $rootCategory->id);
		$this->fetchAllSubCat = $app->input->getInt('all', 0);

		$rssLink        = JRoute::_(JUDownloadHelperRoute::getFeaturedRoute($this->categoryId, $this->fetchAllSubCat, false, true));
		$this->rss_link = JRoute::_($rssLink, false);

		
		$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));

		
		$this->_prepareData();
		$this->_prepareDocument();

		$this->_setBreadcrumb();

		parent::display($tpl);
	}
 protected function getInput()
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $style_id = $app->input->getInt('id', 0);
     $db->setQuery("SELECT id FROM #__judownload_categories WHERE style_id = " . $style_id);
     $catIds = $db->loadColumn();
     $rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
     $categoryTree = JUDownloadHelper::getCategoryTree($rootCategory->id);
     $html = "<div id=\"categoriestoassignstyle\" class=\"categoriestoassignstyle\">";
     $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 class=\"nav\" id=\"" . $this->id . "\">";
     foreach ($categoryTree as $category) {
         $html .= "<li>";
         $cat_style_id = "";
         if ($category->id == 1) {
             $cat_style_id = $category->style_id;
             $inherit = "";
         } elseif ($category->style_id == $style_id) {
             $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type='checkbox' name='" . $this->name . "[]' value = '" . $category->id . "' checked>";
             $cat_style_id = $style_id;
             $inherit = "";
         } elseif ($category->style_id == -1) {
             $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type='checkbox' name='" . $this->name . "[]' value = '" . $category->id . "'";
             $db->setQuery("SELECT id FROM #__judownload_categories WHERE lft <" . $category->lft . " AND rgt > " . $category->rgt);
             $parentCatIds = $db->loadColumn();
             $parentCatIds = array_reverse($parentCatIds);
             if (is_array($catIds) && !empty($catIds)) {
                 foreach ($parentCatIds as $parentCatId) {
                     if (in_array($parentCatId, $catIds)) {
                         $html .= " checked";
                     }
                 }
             }
             $html .= ">";
             foreach ($parentCatIds as $parentCatId) {
                 $styleId = $this->getStyleIdByCategoryId($parentCatId);
                 if ($styleId > -1 || $styleId == -2) {
                     $cat_style_id = $styleId;
                     break;
                 }
             }
             $inherit = "<span class=\"inherited-value\" title=\"" . JText::_("COM_JUDOWNLOAD_INHERIT") . "\">" . JText::_("COM_JUDOWNLOAD_INHERIT") . "</span>";
         } elseif ($category->style_id == -2) {
             $html .= "<input type='checkbox' name='" . $this->name . "[]' value = '" . $category->id . "'>";
             $inherit = "";
             $db->setQuery("SELECT id FROM #__judownload_template_styles WHERE home = 1");
             $cat_style_id = $db->loadResult();
         } else {
             $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type='checkbox' name='" . $this->name . "[]' value = '" . $category->id . "' />";
             $inherit = "";
             $cat_style_id = $category->style_id;
         }
         if ($cat_style_id == -2) {
             $style_title = $this->getStyleTitle(0, true);
         } else {
             $style_title = $this->getStyleTitle($cat_style_id);
         }
         $style_title = $style_title ? " [" . $style_title . "] " : "";
         $html .= "<label for=\"catid-" . $category->id . "\">" . str_repeat('<span class="gi">|—</span>', $category->level);
         if ($category->id == 1) {
             $html .= $category->title;
         } else {
             $html .= "<a href=\"" . JRoute::_('index.php?option=com_judownload&task=category.edit&id=' . $category->id) . "\">" . $category->title . "</a>";
         }
         $html .= " <span class=\"style-title\">" . $style_title . "</span>" . $inherit . "</label>";
         $html .= "</li>";
     }
     $html .= "</ul>";
     $html .= "</div>";
     return $html;
 }
Ejemplo n.º 21
0
	protected function getAllCategoryOptions()
	{
		$rootCat = JUDownloadFrontHelperCategory::getRootCategory();

		JTable::addIncludePath(JPATH_ADMINISTRATOR . "/components/com_judownload/tables");
		$categoryTable = JTable::getInstance('Category', 'JUDownloadTable');
		$categoryTree  = $categoryTable->getTree($rootCat->id);

		foreach ($categoryTree AS $key => $cat)
		{
			$canSubmitDocument = JUDownloadFrontHelperPermission::canSubmitDocument($cat->id);

			
			if (!$canSubmitDocument)
			{
				unset($categoryTree[$key]);
				continue;
			}

			
			if ($cat->published != 1)
			{
				$categoryTree[$key]->title = "[" . $cat->title . "]";
			}

			$categoryTree[$key]->title = str_repeat('|—', $cat->level) . $categoryTree[$key]->title;
		}

		
		if (isset($this->doc) && $this->doc->cat_id)
		{
			$params = JUDownloadHelper::getParams($this->doc->cat_id);
		}
		else
		{
			$params = JUDownloadHelper::getParams(null, $this->doc_id);
		}

		if ($params->get('allow_add_doc_to_root', 0))
		{
			array_unshift($categoryTree, JHtml::_('select.option', $rootCat->id, JText::_('COM_JUDOWNLOAD_ROOT'), 'id', 'title'));
		}

		return $categoryTree;
	}
Ejemplo n.º 22
0
	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);
	}
Ejemplo n.º 23
0
 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;
     }
 }
Ejemplo n.º 24
0
 public function checkin()
 {
     $app = JFactory::getApplication();
     parent::checkin();
     $rootCat = JUDownloadFrontHelperCategory::getRootCategory();
     $cat_id = $app->input->getInt('cat_id', $rootCat->id);
     if ($app->input->getString('view', 'listcats') == 'treestructure') {
         $this->setRedirect("index.php?option=com_judownload&view=treestructure");
     } else {
         $this->setRedirect("index.php?option=com_judownload&view={$this->view_list}&cat_id={$cat_id}");
     }
 }
Ejemplo n.º 25
0
	public static function appendFieldOrderingPriority(&$query = null, $catIds = null, $ordering = null, $direction = null)
	{
		if (!$catIds)
		{
			$catIds = JUDownloadFrontHelperCategory::getRootCategory()->id;
		}

		$storeId = md5(__METHOD__ . "::" . serialize($catIds) . "::$ordering");
		if (!isset(self::$cache[$storeId]))
		{
			$db             = JFactory::getDbo();
			$nullDate       = $db->getNullDate();
			$nowDate        = JFactory::getDate()->toSql();
			$priority_query = $db->getQuery(true);
			$priority_query->select("field.*");
			$priority_query->from("#__judownload_fields AS field");
			$priority_query->select("plg.folder");
			$priority_query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id ");
			$priority_query->join("", "#__judownload_fields_groups AS field_group ON field.group_id = field_group.id");
			$priority_query->join("", "#__judownload_categories AS c ON (
																			(
																				c.fieldgroup_id = field_group.id AND
																				c.published = 1 AND
																				c.publish_up <= " . $db->quote($nowDate) . " AND
																				(c.publish_down = " . $db->quote($nullDate) . " OR c.publish_down > " . $db->quote($nowDate) . ")
																			) OR field.group_id = 1
																		 )");
			$where   = array();
			$where[] = 'field.published = 1';
			$where[] = 'field.publish_up <= ' . $db->quote($nowDate);
			$where[] = '(field.publish_down = ' . $db->quote($nullDate) . ' OR field.publish_down > ' . $db->quote($nowDate) . ')';

			if (is_array($catIds))
			{
				$where[] = "(c.id IN (" . implode(",", $catIds) . ") OR field.group_id = 1)";
			}
			else
			{
				$where[] = "(c.id = $catIds OR field.group_id = 1)";
			}

			$where[] = 'field.allow_priority = 1';
			$where[] = 'field_group.published = 1';

			
			$priority_query->where("(" . implode(" AND ", $where) . ")", "OR");

			if ($ordering)
			{
				$where   = array();
				$where[] = "(field.id = '$ordering' OR field.field_name = '$ordering')";
				$app     = JFactory::getApplication();
				if ($app->isSite())
				{
					$where[] = "field.frontend_ordering = 1";
				}
				else
				{
					$where[] = "field.backend_list_view >= 1";
				}
				$where[] = "field.published = 1";
				$where[] = "field.publish_up <= " . $db->quote($nowDate);
				$where[] = "(field.publish_down = " . $db->quote($nullDate) . " OR field.publish_down >= " . $db->quote($nowDate) . ")";
				$priority_query->where("(" . implode(" AND ", $where) . ")", "OR");
			}
			$priority_query->group('field.id');

			$priority_query->order('field.priority ASC');

			$db->setQuery($priority_query);

			self::$cache[$storeId] = $db->loadObjectList();
		}

		$priorityFields = self::$cache[$storeId];

		$priority_order = array();
		
		$_ordering = "";
		foreach ($priorityFields AS $priorityField)
		{
			$field = JUDownloadFrontHelperField::getField($priorityField);
			if ($field)
			{
				$priority = $field->orderingPriority($query);
				if ($priority)
				{
					$priority_order[] = $priority['ordering'] . ' ' . $priority['direction'];
				}

				if ($ordering && $field->id == $ordering && $priority)
				{
					$_ordering = $priority['ordering'];
				}
			}
		}

		$priority_str = "";
		if ($priority_order)
		{
			$priority_str = implode(", ", $priority_order);
		}

		if ($_ordering)
		{
			$ordering_str = $_ordering . " " . $direction;
			if ($priority_str)
			{
				$priority_str = $ordering_str . ", " . $priority_str;
			}
		}

		if ($priority_str)
		{
			$query->order($priority_str);
		}

		return $priority_str;
	}
Ejemplo n.º 26
0
    protected function getInput()
    {
        $document = JFactory::getDocument();
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('cat_id_related');
        $query->from('#__judownload_categories_relations');
        $query->where('cat_id = ' . (int) $this->form->getValue('id'));
        $query->order("ordering ASC");
        $db->setQuery($query);
        $relcategories = $db->loadColumn();
        $script = '
		jQuery(document).ready(function($){
			$(".category_list").dragsort({ dragSelector: "li", dragEnd: saveOrder, placeHolderTemplate: "<li class=\'placeHolder\'></li>", dragSelectorExclude: "input, textarea, span, a.removeitem"});

            function saveOrder() {
                var data = $("#gallery li").map(function() { return $(this).data("itemid"); }).get();
            };

			$(".category_list").on("click","a.removeitem", function(event){
				event.preventDefault();
				$(this).closest("li").remove();
			});

			$(".browse_cat").bind("dblclick",function(){
				var id = $(this).find("option:selected").val();
				$.ajax({
			  		type: "POST",
			  		url:"index.php?option=com_judownload&task=categories.loadcategories",
			  		data: {id : id, type : "category"}
				}).done(function(data){
					data = $.parseJSON(data);
					$(".browse_cat").html(data.html);
					$(".active_pathway").html(data.path);
				});
			});

			$(".change_categories").click(function(){
				$(".category_selection").slideToggle(400);
			});

			$("#add_related_categories").click(function(event){
    			event.preventDefault();
    			var has_element = [];
				var current_cat = ' . JFactory::getApplication()->input->get('id', 0) . ';
				$.each( $("option:selected",".browse_cat"), function(key, value ) {
					if($(this).data("noselect")){
						return;
					}

					var selectedValue = $(this).val();
					var selectedText = $(this).text();

  					if(current_cat == selectedValue){
						alert("' . JText::_('COM_JUDOWNLOAD_CAN_NOT_ADD_CATEGORY_ITSELF_AS_RELATED_CATEGORY') . '");
						return;
					}
  					if($(".category_list > li[id=\'category-"+selectedValue+"\']").length <= 0){
  						var path = $(".active_pathway").text() + " > " + selectedText;
  						$("<li id=\\"category-"+selectedValue+"\\"><a class=\\"drag-icon\\"></a><span>"+path+"</span><input type=\\"hidden\\" name=\\"relcategories[]\\" value=\\""+selectedValue+"\\" /> <a href=\\"#\\" class=\\"removeitem\\" ><i class=\\"icon-minus\\"></i> ' . JText::_('COM_JUDOWNLOAD_REMOVE') . '</a></li>").appendTo(".category_list");
   					}else{
  						has_element.push(selectedText);
  					}
				});

                if(has_element.length == 1){
                    alert("' . JText::_('COM_JUDOWNLOAD_CATEGORY_X_ALREADY_EXISTED') . '".replace("%s", has_element[0]));
				}else if(has_element.length > 1){
				    alert("' . JText::_('COM_JUDOWNLOAD_CATEGORIES_X_ALREADY_EXISTED') . '".replace("%s", has_element.join(", ")));
				}
				return false;
			});
		});';
        $document->addScriptDeclaration($script);
        $html = "";
        $html .= "<div class=\"categories\">";
        $html .= "<ul class=\"category_list nav clearfix\">";
        if ($relcategories) {
            foreach ($relcategories as $key => $relcategory) {
                $path = JUDownloadHelper::generateCategoryPath($relcategory);
                $html .= '<li id="category-' . $relcategory . '">';
                $html .= '<a class="drag-icon"></a>';
                $html .= '<span>' . $path . '</span>';
                $html .= '<input type="hidden" name="relcategories[]" value="' . $relcategory . '" />';
                $html .= '<a class="removeitem" href="#"><i class="icon-minus"></i> ' . JText::_('COM_JUDOWNLOAD_REMOVE') . '</a>';
                $html .= "</li>";
            }
        }
        $html .= '</ul>';
        $catId = $this->form->getValue('id', 0);
        $catParentId = !$catId ? JUDownloadFrontHelperCategory::getRootCategory()->id : JUDownloadHelper::getCategoryByID($catId)->parent_id;
        $query = $db->getQuery(true);
        $query->SELECT('title, id, published, parent_id');
        $query->FROM('#__judownload_categories');
        $query->WHERE('parent_id = ' . $catParentId);
        $query->ORDER('lft');
        $db->setQuery($query);
        $categoryList = $db->loadObjectList();
        foreach ($categoryList as $key => $cat) {
            if ($cat->published != 1) {
                $cat->title = "[" . $cat->title . "]";
            }
        }
        if ($catParentId != 0) {
            $catParent = JUDownloadHelper::getCategoryByID($catParentId);
            array_unshift($categoryList, JHtml::_('select.option', $catParent->parent_id, JText::_('COM_JUDOWNLOAD_BACK_TO_PARENT_CATEGORY'), 'id', 'title'));
        }
        $html .= "<a href='#' class='change_categories' onclick='return false;'><i class=\"icon-folder\"></i> " . JText::_('COM_JUDOWNLOAD_ADD_RELATED_CATEGORIES') . "</a>";
        $html .= '<div class="category_selection" style="display: none;">';
        $html .= '<div class="active_pathway">' . JUDownloadHelper::generateCategoryPath($catParentId, 'li') . '</div>';
        $html .= JHtml::_('select.genericlist', $categoryList, 'browse_cat', 'class="inputbox browse_cat" multiple="multiple" size="8"', 'id', 'title', '', "");
        $html .= '<div class="cat_action clearfix">';
        $html .= "<button id='add_related_categories' class='btn btn-mini btn-primary'>" . JText::_('COM_JUDOWNLOAD_ADD_RELATED_CATEGORIES') . "</button>";
        $html .= "<input type='hidden' name='cat_id_related' id='cat_id_related' value='" . $this->value . "' />";
        $html .= "</div>";
        $html .= "</div>";
        $html .= '</div>';
        return $html;
    }
Ejemplo n.º 27
0
	public static function getCurrentCatId()
	{
		$app    = JFactory::getApplication();
		$option = $app->input->getString('option', '');
		$view   = $app->input->getString('view', '');
		$catId  = JUDownloadFrontHelperCategory::getRootCategory()->id;
		if ($option == 'com_judownload' && $view)
		{
			if ($view == 'document')
			{
				$docId = $app->input->getInt('id', 0);
				if ($docId > 0)
				{
					$catId = JUDownloadFrontHelperCategory::getMainCategoryId($docId);
				}
			}
			elseif ($view == 'category' || $view == 'categories')
			{
				$catId = $app->input->getInt('id', 0);
			}
		}

		return $catId;
	}
Ejemplo n.º 28
0
 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();
     }
 }
Ejemplo n.º 29
0
 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}");
 }
Ejemplo n.º 30
0
 public function cancel($key = null)
 {
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $doc_id = $app->input->getInt('id', 0);
     if ($doc_id) {
         $documentObject = JUDownloadHelper::getDocumentById($doc_id);
         $cat_id = $documentObject->cat_id;
     } else {
         $fieldCategory = JUDownloadFrontHelperField::getField('cat_id');
         $fieldData = $app->input->post->get('fields', array(), 'array');
         $cat_id = $fieldData[$fieldCategory->id]['main'];
     }
     if (!$cat_id) {
         $rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
         $cat_id = $rootCategory->id;
     }
     $files = $app->input->get("judlfiles", array(), 'array');
     $context = $this->option . ".edit." . $this->context;
     if (isset($files)) {
         $file_directory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/");
         $file_directory_tmp = $file_directory . "tmp/";
         $files = array_values($files);
         foreach ($files as $file) {
             if (isset($file['file_name']) && $file['file_name']) {
                 $file_path = $file_directory_tmp . $file['file_name'];
                 if (JFile::exists($file_path)) {
                     JFile::delete($file_path);
                 }
             }
             if (isset($file['replace']) && $file['replace']) {
                 $file_path = $file_directory_tmp . $file['replace'];
                 if (JFile::exists($file_path)) {
                     JFile::delete($file_path);
                 }
             }
         }
     }
     $app->setUserState($context . '.data', null);
     $app->setUserState($context . '.fieldsdata', null);
     $app->setUserState($context . '.changelogs', null);
     $app->setUserState($context . '.versions', null);
     $app->setUserState($context . '.files', null);
     $app->setUserState($context . '.related_documents', null);
     if ($doc_id) {
         $db = JFactory::getDbo();
         $query = "SELECT cat_id FROM #__judownload_documents_xref WHERE doc_id = {$doc_id} AND main = 1";
         $db->setQuery($query);
         $cat_id = $db->loadResult();
     }
     parent::cancel($key = null);
     if ($this->view_list == "pendingdocuments") {
         $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
     } else {
         $this->setRedirect("index.php?option=com_judownload&view=listcats&cat_id={$cat_id}");
     }
 }