r71694 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71693‎ | r71694 | r71695 >
Date:10:32, 26 August 2010
Author:questpc
Status:deferred
Tags:
Comment:
Trying to avoid patchwork messages. Message explanations.
Modified paths:
  • /trunk/extensions/CategoryBrowser/CategoryBrowserMain.php (modified) (history)
  • /trunk/extensions/CategoryBrowser/CategoryBrowserPage.php (modified) (history)
  • /trunk/extensions/CategoryBrowser/CategoryBrowser_i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryBrowser/CategoryBrowserPage.php
@@ -111,8 +111,8 @@
112112 );
113113 if ( CB_Setup::$cat_title_CI != '' ) {
114114 // case insensitive search is possible
115 - $nameFilterFields[] = wfMsg( 'cb_cat_name_filter_ci' );
116 - $nameFilterFields[] = array( '__tag' => 'input', 'type' => 'checkbox', 'onchange' => $js_setNameFilter, 'id' => 'cb_cat_name_filter_ci', 'checked' => null );
 115+ $checkbox = array( '__tag' => 'input', 'type' => 'checkbox', 'onchange' => $js_setNameFilter, 'id' => 'cb_cat_name_filter_ci', 'checked' => null );
 116+ $nameFilterFields[] = wfMsg( 'cb_cat_name_filter_ci', CB_XML::toText( $checkbox ) );
117117 }
118118 $top_tpl =
119119 array( '__tag' => 'table', 'class' => 'cb_top_container', '__end' => "\n",
Index: trunk/extensions/CategoryBrowser/CategoryBrowser_i18n.php
@@ -50,29 +50,31 @@
5151 However, browsing of pre-defined conditions should work normally.
5252 Please change or upgrade your browser, if possible.',
5353 'cb_cat_name_filter' => 'Search for category by name:',
54 - 'cb_cat_name_filter_ci' => '(case insensitive)', // @todo Please document in 'qqq'. Patchwork message?
 54+ 'cb_cat_name_filter_ci' => '(case insensitive) $1',
5555 'cb_copy_line_hint' => 'Use the [+] and [>+] buttons to copy and paste operators into the selected expression',
5656 'cb_has_subcategories' => '$1 {{PLURAL:$1|subcategory|subcategories}}',
5757 'cb_has_pages' => '$1 {{PLURAL:$1|page|pages}}',
5858 'cb_has_files' => '$1 {{PLURAL:$1|file|files}}',
5959 'cb_previous_items_link' => 'Previous',
60 - 'cb_previous_items_stats' => ' ($1 - $2)', // @todo FIXME: patchwork message. Please create complete messags with variables.
 60+ 'cb_previous_items_stats' => ' ($1 - $2)',
 61+ 'cb_previous_items_line' => '$1 $2',
6162 'cb_next_items_link' => 'Next',
62 - 'cb_next_items_stats' => ' (from $1)', // @todo FIXME: patchwork message. Please create complete messags with variables.
 63+ 'cb_next_items_stats' => ' (from $1)',
 64+ 'cb_next_items_line' => '$1 $2',
6365 'cb_cat_subcats' => 'subcategories',
6466 'cb_cat_pages' => 'pages',
6567 'cb_cat_files' => 'files',
6668 'cb_apply_button' => 'Apply',
67 - 'cb_op1_template' => '$1[$2]', // @todo Please document in 'qqq'.
68 - 'cb_op2_template' => '$1 $2 $3', // @todo Please document in 'qqq'.
 69+ 'cb_op1_template' => '$1[$2]',
 70+ 'cb_op2_template' => '$1 $2 $3',
6971 'cb_all_op' => 'All',
70 - 'cb_lbracket_op' => '(', // @todo Please document in 'qqq'.
71 - 'cb_rbracket_op' => ')', // @todo Please document in 'qqq'.
72 - 'cb_or_op' => 'or', // @todo Please document in 'qqq'.
73 - 'cb_and_op' => 'and', // @todo Please document in 'qqq'.
74 - 'cb_ge_op' => '>=', // @todo Please document in 'qqq'.
75 - 'cb_le_op' => '<=', // @todo Please document in 'qqq'.
76 - 'cb_eq_op' => '=', // @todo Please document in 'qqq'.
 72+ 'cb_lbracket_op' => '(',
 73+ 'cb_rbracket_op' => ')',
 74+ 'cb_or_op' => 'or',
 75+ 'cb_and_op' => 'and',
 76+ 'cb_ge_op' => '>=',
 77+ 'cb_le_op' => '<=',
 78+ 'cb_eq_op' => '=',
7779 'cb_edit_left_hint' => 'Move left, if possible',
7880 'cb_edit_right_hint' => 'Move right, if possible',
7981 'cb_edit_remove_hint' => 'Delete, if possible',
@@ -83,6 +85,23 @@
8486 'cb_edit_paste_right_hint' => 'Paste operator into next position, if possible',
8587 );
8688
 89+/** Message documentation (Message documentation)
 90+ * @author QuestPC
 91+ */
 92+$messages['qqq'] = array(
 93+ 'cb_cat_name_filter_ci' => 'Dialog for case insensitive category name search. Argument 1 is a script-generated html input checkbox.',
 94+ 'cb_op1_template' => 'One operand operation visualisation template. Argument 1 is an operator name. Argument 2 is operation\'s parameter.',
 95+ 'cb_op2_template' => 'Two operands operation visualisation template. Argument 1 is first parameter. Argument 2 is operator name. Argument 3 is second parameter.',
 96+ 'cb_all_op' => 'Operator to select all categories available.',
 97+ 'cb_lbracket_op' => 'Opening bracket, allows to change execution order.',
 98+ 'cb_rbracket_op' => 'Closing bracket, allows to change execution order.',
 99+ 'cb_or_op' => 'Logical "or" operator name in your language. Short (mathematical) form is preferred.',
 100+ 'cb_and_op' => 'Logical "and" operator name in your language. Short (mathematical) form is preferred.',
 101+ 'cb_ge_op' => 'Comparsion operator "greater or equal" name in your language. Short (mathematical) form is preferred.',
 102+ 'cb_le_op' => 'Comparsion operator "less or equal" name in your language. Short (mathematical) form is preferred.',
 103+ 'cb_eq_op' => 'Comparsion operator "equal" name in your language. Short (mathematical) form is preferred.',
 104+);
 105+
87106 /** Russian (Русский)
88107 * @author QuestPC
89108 */
@@ -90,15 +109,16 @@
91110 'categorybrowser' => 'Просмотр категорий',
92111 'categorybrowser-desc' => 'Предоставляет специальную страницу [[Служебная:CategoryBrowser]] для выбора наиболее ёмких категорий вики сайта с целью последующей навигации с использованием AJAX-интерфейса',
93112 'cb_requires_javascript' => 'Расширение для просмотра категорий требует включения поддержки Javascript в браузере',
94 - 'cb_ie6_warning' => 'Редактор выражений не поддерживается в версии Internet Explorer 6.0 или более ранних. Возможен лишь просмотр предопределенных выражений. Пожалуйста поменяйте или обновите ваш браузер.',
 113+ 'cb_ie6_warning' => 'Редактор выражений не поддерживается в Internet Explorer версии 6.0 или более ранних.
 114+Возможен лишь просмотр предопределенных выражений.
 115+Пожалуйста поменяйте или обновите ваш браузер.',
95116 'cb_cat_name_filter' => 'Поиск категории по имени:',
96 - 'cb_cat_name_filter_ci' => '(без учёта регистра)',
 117+ 'cb_cat_name_filter_ci' => '(без учёта регистра) $1',
97118 'cb_copy_line_hint' => 'Используйте кнопки [+] и [>+] для копирования оператора в выбранное выражение',
98119 'cb_has_subcategories' => '$1 {{PLURAL:$1|подкатегория|подкатегории|подкатегорий}}',
99120 'cb_has_pages' => '$1 {{PLURAL:$1|страница|страницы|страниц}}',
100121 'cb_has_files' => '$1 {{PLURAL:$1|файл|файла|файлов}}',
101122 'cb_previous_items_link' => 'Предыдущие',
102 - 'cb_previous_items_stats' => ' ($1 - $2)',
103123 'cb_next_items_link' => 'Следующие',
104124 'cb_next_items_stats' => ' (начиная с $1)',
105125 'cb_cat_subcats' => 'подкатегорий',
Index: trunk/extensions/CategoryBrowser/CategoryBrowserMain.php
@@ -524,17 +524,23 @@
525525 # {{{ ajax link template
526526 $this->ajax_onclick = '';
527527 $this->ajax_link_text = '';
528 - $this->ajax_link_comment = '';
529528 if ( !isset( $this->ajax_link_tpl ) ) {
530529 $this->ajax_link_tpl =
531 - array(
532 - array( '__tag' => 'a', 'class' => 'cb_sublink', 'href' => '', 'onclick' => &$this->ajax_onclick, 0 => &$this->ajax_link_text ),
533 - array( '__tag' => 'span', 'class' => 'cb_comment', 0 => &$this->ajax_link_comment )
534 - );
 530+ array( '__tag' => 'a', 'class' => 'cb_sublink', 'href' => '', 'onclick' => &$this->ajax_onclick, 0 => &$this->ajax_link_text );
535531 }
536532 # }}}
537533 }
538534
 535+ function initPagerStatsTpl() {
 536+ $this->pager_stats = '';
 537+ # {{{ pager current statistics template
 538+ if ( !isset( $this->pager_stats_tpl ) ) {
 539+ $this->pager_stats_tpl =
 540+ array( '__tag' => 'span', 'class' => 'cb_comment', 0 => &$this->pager_stats );
 541+ }
 542+ # }}}
 543+ }
 544+
539545 function initSortkeyTpl() {
540546 # {{{ category sortkey hint template
541547 $this->sortkey_hint = '';
@@ -544,6 +550,51 @@
545551 # }}}
546552 }
547553
 554+ /*
 555+ * previous page AJAX link
 556+ * @param $pager instance of pager
 557+ * @param $list, when the link is available it will be rendered then pushed to the list
 558+ */
 559+ function addPrevPageLink( CB_AbstractPager $pager, array &$list ) {
 560+ $this->initPagerStatsTpl();
 561+ $this->initNavTpl();
 562+ $prev_link = '&#160;'; // &nbsp;
 563+ $link_obj = $pager->getPrevAjaxLink();
 564+ if ( $pager->offset != 0 ) {
 565+ $this->ajax_onclick = $link_obj->call;
 566+ $this->ajax_link_text = wfMsg( 'cb_previous_items_link' );
 567+ $prev_offset = $pager->getPrevOffset() + 1;
 568+ $this->pager_stats = wfMsg( 'cb_previous_items_stats', $prev_offset, $prev_offset + $pager->limit - 1 );
 569+ $this->nav_link = wfMsg( 'cb_previous_items_line', CB_XML::toText( $this->ajax_link_tpl ), CB_XML::toText( $this->pager_stats_tpl ) );
 570+ $prev_link = CB_XML::toText( $this->nav_link_tpl );
 571+ }
 572+ if ( $link_obj->placeholders || $this->nav_link != '' ) {
 573+ $list[] = $prev_link;
 574+ }
 575+ }
 576+
 577+ /*
 578+ * next page AJAX link
 579+ * @param $pager instance of pager
 580+ * @param $list, when the link is available it will be rendered then pushed to the list
 581+ */
 582+ function addNextPageLink( CB_AbstractPager $pager, array &$list ) {
 583+ $this->initPagerStatsTpl();
 584+ $this->initNavTpl();
 585+ $next_link = '&#160;'; // &nbsp;
 586+ $link_obj = $pager->getNextAjaxLink();
 587+ if ( $pager->hasMoreEntries ) {
 588+ $this->ajax_onclick = $link_obj->call;
 589+ $this->ajax_link_text = wfMsg( 'cb_next_items_link' );
 590+ $this->pager_stats = wfMsg( 'cb_next_items_stats', $pager->getNextOffset() + 1 );
 591+ $this->nav_link = wfMsg( 'cb_next_items_line', CB_XML::toText( $this->ajax_link_tpl ), CB_XML::toText( $this->pager_stats_tpl ) );
 592+ $next_link = CB_XML::toText( $this->nav_link_tpl );
 593+ }
 594+ if ( $link_obj->placeholders || $this->nav_link != '' ) {
 595+ $list[] = $next_link;
 596+ }
 597+ }
 598+
548599 function generateCatList( CB_AbstractPager $pager ) {
549600 if ( $pager->offset == -1 ) {
550601 return ''; // list has no entries
@@ -560,28 +611,14 @@
561612 )
562613 );
563614 # }}}
564 - $this->initNavTpl();
565615 $this->initAjaxLinkTpl();
566616 $this->initSortkeyTpl();
567617 # create list of categories
568 - $catlist = array(
569 - array( '__tag' => 'noscript', 'class' => 'cb_noscript', 0 => wfMsg( 'cb_requires_javascript' ) ),
570 - );
571 - # previous page AJAX link
572 - $this->nav_link = '';
573 - $prev_link = '&#160;'; // &nbsp;
574 - $link_obj = $pager->getPrevAjaxLink();
575 - if ( $pager->offset != 0 ) {
576 - $this->ajax_onclick = $link_obj->call;
577 - $prev_offset = $pager->getPrevOffset() + 1;
578 - $this->ajax_link_text = wfMsg( 'cb_previous_items_link' );
579 - $this->ajax_link_comment = wfMsg( 'cb_previous_items_stats', $prev_offset, $prev_offset + $pager->limit - 1 );
580 - $this->nav_link = CB_XML::toText( $this->ajax_link_tpl );
581 - $prev_link = CB_XML::toText( $this->nav_link_tpl );
 618+ $catlist = array();
 619+ if ( $pager instanceof CB_RootPager ) {
 620+ $catlist[] = array( '__tag' => 'noscript', 'class' => 'cb_noscript', 0 => wfMsg( 'cb_requires_javascript' ) );
582621 }
583 - if ( $link_obj->placeholders || $this->nav_link != '' ) {
584 - $catlist[] = $prev_link;
585 - }
 622+ $this->addPrevPageLink( $pager, $catlist );
586623 # generate entries list
587624 foreach ( $pager->entries as &$cat ) {
588625 // cat_title might be NULL sometimes - probably due to DB corruption?
@@ -642,20 +679,7 @@
643680 # finally add generated $cat_tpl/$cat_link to $catlist
644681 $catlist[] = CB_XML::toText( $cat_tpl );
645682 }
646 - # next page AJAX link
647 - $this->nav_link = '';
648 - $next_link = '&#160;'; // &nbsp;
649 - $link_obj = $pager->getNextAjaxLink();
650 - if ( $pager->hasMoreEntries ) {
651 - $this->ajax_onclick = $link_obj->call;
652 - $this->ajax_link_text = wfMsg( 'cb_next_items_link' );
653 - $this->ajax_link_comment = wfMsg( 'cb_next_items_stats', $pager->getNextOffset() + 1 );
654 - $this->nav_link = CB_XML::toText( $this->ajax_link_tpl );
655 - $next_link = CB_XML::toText( $this->nav_link_tpl );
656 - }
657 - if ( $link_obj->placeholders || $this->nav_link != '' ) {
658 - $catlist[] = $next_link;
659 - }
 683+ $this->addNextPageLink( $pager, $catlist );
660684 return $catlist;
661685 }
662686
@@ -670,26 +694,11 @@
671695 array( '__tag' => 'div', 'class' => 'cb_cat_item', 0 => &$page_link )
672696 );
673697 # }}}
674 - $this->initNavTpl();
675698 $this->initAjaxLinkTpl();
676699 $this->initSortkeyTpl();
677700 # create list of pages
678701 $pagelist = array();
679 - # previous page AJAX link
680 - $this->nav_link = '';
681 - $prev_link = '&#160;'; // &nbsp;
682 - $link_obj = $pager->getPrevAjaxLink();
683 - if ( $pager->offset != 0 ) {
684 - $this->ajax_onclick = $link_obj->call;
685 - $prev_offset = $pager->getPrevOffset() + 1;
686 - $this->ajax_link_text = wfMsg( 'cb_previous_items_link' );
687 - $this->ajax_link_comment = wfMsg( 'cb_previous_items_stats', $prev_offset, $prev_offset + $pager->limit - 1 );
688 - $this->nav_link = CB_XML::toText( $this->ajax_link_tpl );
689 - $prev_link = CB_XML::toText( $this->nav_link_tpl );
690 - }
691 - if ( $link_obj->placeholders || $this->nav_link != '' ) {
692 - $pagelist[] = $prev_link;
693 - }
 702+ $this->addPrevPageLink( $pager, $pagelist );
694703 foreach ( $pager->entries as &$page ) {
695704 $page_title = Title::makeTitle( $page->page_namespace, $page->page_title );
696705 $page_link = CB_Setup::$skin->link( $page_title, $page_title->getPrefixedText() );
@@ -703,20 +712,7 @@
704713 }
705714 $pagelist[] = CB_XML::toText( $page_tpl );
706715 }
707 - # next page AJAX link
708 - $this->nav_link = '';
709 - $next_link = '&#160;'; // &nbsp;
710 - $link_obj = $pager->getNextAjaxLink();
711 - if ( $pager->hasMoreEntries ) {
712 - $this->ajax_onclick = $link_obj->call;
713 - $this->ajax_link_text = wfMsg( 'cb_next_items_link' );
714 - $this->ajax_link_comment = wfMsg( 'cb_next_items_stats', $pager->getNextOffset() + 1 );
715 - $this->nav_link = CB_XML::toText( $this->ajax_link_tpl );
716 - $next_link = CB_XML::toText( $this->nav_link_tpl );
717 - }
718 - if ( $link_obj->placeholders || $this->nav_link != '' ) {
719 - $pagelist[] = $next_link;
720 - }
 716+ $this->addNextPageLink( $pager, $pagelist );
721717 return $pagelist;
722718 }
723719
@@ -732,7 +728,6 @@
733729 if ( CB_Setup::$imageGalleryPerRow < 1 || !$wgCategoryMagicGallery || $wgOut->mNoGallery ) {
734730 return $this->generatePagesList( $pager );
735731 }
736 - $this->initNavTpl();
737732 $this->initAjaxLinkTpl();
738733 $this->initSortkeyTpl();
739734 # {{{ gallery container template
@@ -745,20 +740,7 @@
746741 $gallery = new ImageGallery();
747742 $gallery->setHideBadImages();
748743 $gallery->setPerRow( CB_Setup::$imageGalleryPerRow );
749 - # previous page AJAX link
750 - $prev_link = '&#160;'; // &nbsp;
751 - $this->nav_link = '';
752 - $link_obj = $pager->getPrevAjaxLink();
753 - if ( $pager->offset != 0 ) {
754 - $this->ajax_onclick = $link_obj->call;
755 - $prev_offset = $pager->getPrevOffset() + 1;
756 - $this->ajax_link_text = wfMsg( 'cb_previous_items_link' );
757 - $this->ajax_link_comment = wfMsg( 'cb_previous_items_stats', $prev_offset, $prev_offset + $pager->limit - 1 );
758 - $this->nav_link = CB_XML::toText( $this->ajax_link_tpl );
759 - }
760 - if ( $link_obj->placeholders || $this->nav_link != '' ) {
761 - $prev_link = CB_XML::toText( $this->nav_link_tpl );
762 - }
 744+ $this->addPrevPageLink( $pager, $filelist );
763745 foreach ( $pager->entries as &$file ) {
764746 $file_title = Title::makeTitle( $file->page_namespace, $file->page_title );
765747 # show the sortkey, when it does not match title name
@@ -770,25 +752,11 @@
771753 }
772754 $gallery->add( $file_title, ( $this->sortkey_hint != '' ) ? CB_XML::toText( $this->sortkey_hint_tpl ) : '' );
773755 }
774 - # next page AJAX link
775 - $next_link = '&#160;'; // &nbsp;
776 - $this->nav_link = '';
777 - $link_obj = $pager->getNextAjaxLink();
778 - if ( $pager->hasMoreEntries ) {
779 - $this->ajax_onclick = $link_obj->call;
780 - $this->ajax_link_text = wfMsg( 'cb_next_items_link' );
781 - $this->ajax_link_comment = wfMsg( 'cb_next_items_stats', $pager->getNextOffset() + 1 );
782 - $this->nav_link = CB_XML::toText( $this->ajax_link_tpl );
783 - }
784 - if ( $link_obj->placeholders || $this->nav_link != '' ) {
785 - $next_link = CB_XML::toText( $this->nav_link_tpl );
786 - }
787 - $filelist = $prev_link;
788756 if ( !$gallery->isEmpty() ) {
789757 $gallery_html = $gallery->toHTML();
790 - $filelist .= CB_XML::toText( $gallery_tpl );
 758+ $filelist[] = CB_XML::toText( $gallery_tpl );
791759 }
792 - $filelist .= $next_link;
 760+ $this->addNextPageLink( $pager, $filelist );
793761 return $filelist;
794762 }
795763

Status & tagging log