Changeset 1032


Ignore:
Timestamp:
03/08/09 00:00:27 (3 years ago)
Author:
diana.kelerman@…
Message:

Paginator at the end of wiki page comments + remotebox refactoring:
moved the comments stuff from RemoteBox_Load to RemoteBox_Comments.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/smf/SSI.php

    r1017 r1032  
    243243 
    244244        echo '<a href="', $scripturl, '?action=logout;sesc=', $sc, '">', $txt[108], '</a>'; 
     245} 
     246 
     247function ssi_displayPaging($count_comm, $begin_comm, $max_comm, $display) 
     248{ 
     249    if($count_comm > $max_comm) { 
     250        echo '<b>Mergi la pagina:</b> '; 
     251        for ($i = 1; $i <= $count_comm; $i += $max_comm) { 
     252            if ($i != $begin_comm) { 
     253                echo '<a href="javascript:stay()" onclick="RemoteBox_Comments('. $i .', '. $max_comm .', true, \''. $display .'\');"> 
     254                    ['. (int)(($i + $max_comm - 1) / $max_comm) . ']</a> '; 
     255            } else { 
     256                echo '<b>[' . (int)(($i + $max_comm - 1)/ $max_comm) . ']</b> '; 
     257            } 
     258        } 
     259    } 
    245260} 
    246261 
     
    326341        <div class="comments">'; 
    327342 
     343    $remotebox_display = ($display == 'show' ? 'hide' : 'show'); 
    328344    echo ' 
    329         <a href="javascript:stay()" onclick="RemoteBox_Display = (RemoteBox_Display == \'show\' ? \'hide\' : \'show\'); RemoteBox_Load();"><h3>&#187; '; 
     345        <a href="javascript:stay()" onclick="RemoteBox_Comments('. $begin_comm .', '. $max_comm .', false, \''. $remotebox_display .'\');"><h3>&#187; '; 
    330346 
    331347    if (0 == $count_comm){ 
     
    343359    if($display == 'show') { 
    344360 
    345         // Pagination 
    346         if($count_comm > $max_comm) { 
    347             echo '<b>Mergi la pagina:</b> '; 
    348             for ($i = 1; $i <= $count_comm; $i += $max_comm) { 
    349                 if ($i != $begin_comm) { 
    350                     echo '<a href="javascript:stay()" onclick="RemoteBox_BeginComm=' . $i . ';RemoteBox_Load();">[' . (int)(($i + $max_comm - 1) / $max_comm) . ']</a> '; 
    351                 } else { 
    352                     echo '<b>[' . (int)(($i + $max_comm - 1)/ $max_comm) . ']</b> '; 
    353                 } 
    354             } 
    355         } 
     361        // Front paging display 
     362        ssi_displayPaging($count_comm, $begin_comm, $max_comm, $display); 
    356363 
    357364        foreach ($posts as $post) 
     
    369376                    </div> 
    370377                </div>'; 
     378 
     379        // Back paging display 
     380        echo '<br>'; 
     381        ssi_displayPaging($count_comm, $begin_comm, $max_comm, $display); 
    371382    } 
    372383 
  • trunk/smf/ia_comments.php

    r1004 r1032  
    77$topic_id = getattr($_GET, 'topic_id'); 
    88$display = getattr($_GET, 'display', 'hide'); 
    9 $begin_comm = (int)getattr($_GET, 'begin_comm', '0'); 
     9$begin_comm = (int)getattr($_GET, 'begin_comm', '1'); 
    1010$max_comm = getattr($_GET, 'max_comm'); 
    1111 
  • trunk/www/macros/macro_remotebox.php

    r1004 r1032  
    99// NOTE: This macro requires special user permissions since it poses quite 
    1010// a few security concerns. 
    11 function macro_remotebox($args, $bypass_security = false) { 
    12     $url = getattr($args, 'url'); 
    13  
     11function macro_remotebox($url, $bypass_security = false) { 
    1412    if (!$bypass_security && !identity_can('macro-remotebox')) { 
    1513        return macro_permission_error(); 
     
    2321    $buffer .= '<div id="remotebox">remote content</div>'; 
    2422    $buffer .= '<script type="text/javascript">RemoteBox_Url="'; 
    25     $buffer .= html_escape($args['url']); 
    26     if (array_key_exists('display', $args)) { 
    27         $buffer .= '";RemoteBox_Display="' . html_escape($args['display']); 
    28     } 
    29     if (array_key_exists('max_comm', $args)) { 
    30         $buffer .= '";RemoteBox_MaxComm="' . html_escape((int)$args['max_comm']); 
    31     } 
     23    $buffer .= html_escape($url); 
    3224    $buffer .= '";</script>'; 
    3325 
  • trunk/www/macros/macro_smfcomments.php

    r1004 r1032  
    1515//      SmfComments( topic_id="400" display="hide" max_comm="5") 
    1616function macro_smfcomments($args) { 
     17    $comments = '<div id="comentarii">'; 
     18 
    1719    $topic_id = getattr($args, 'topic_id'); 
    1820    $display = getattr($args, 'display'); 
     
    3133    } 
    3234 
    33     $args = array( 
    34         'url' => IA_SMF_URL.'/ia_comments.php?topic_id='.$topic_id, 
    35         'display' => $display 
    36     ); 
    3735    if(!is_null($max_comm)) { 
    38         if(is_whole_number($max_comm)) { 
    39             $args['max_comm'] = $max_comm; 
    40         } else { 
     36        if(!is_whole_number($max_comm)) { 
    4137            return macro_error('Wrong value for argument `max_comm`'); 
    4238        } 
    4339    } 
    4440 
    45     return macro_remotebox($args, true); 
     41    $url = IA_SMF_URL . '/ia_comments.php?topic_id=' . $topic_id . '&display=' . $display; 
     42    if (!is_null($max_comm)) { 
     43        $url .= '&max_comm=' . $max_comm; 
     44    } 
     45 
     46    $comments .= macro_remotebox($url, true); 
     47    $comments .= '</div>'; 
     48 
     49    return $comments; 
    4650} 
    4751 
  • trunk/www/macros/macro_smftopic.php

    r1003 r1032  
    2323    } 
    2424 
    25     $args = array( 
    26         'url' => IA_SMF_URL.'/ia_recentposts.php?topic_id='.$topic_id.'&count='.$count 
    27     ); 
    28     return macro_remotebox($args, true); 
     25    $url = IA_SMF_URL.'/ia_recentposts.php?topic_id='.$topic_id.'&count='.$count; 
     26 
     27    return macro_remotebox($url, true); 
    2928} 
    3029 
  • trunk/www/macros/macro_smftopics.php

    r852 r1032  
    2525    } 
    2626 
    27     $args = array( 
    28         'url' => IA_SMF_URL.'/ia_recenttopics.php?board_id='.$board_id.'&count='.$count 
    29     ); 
    30     return macro_remotebox($args, true); 
     27    $url = IA_SMF_URL.'/ia_recenttopics.php?board_id='.$board_id.'&count='.$count; 
     28 
     29    return macro_remotebox($url, true); 
    3130} 
    3231 
  • trunk/www/static/js/remotebox.js

    r1004 r1032  
    55 
    66var RemoteBox_Url = ''; 
    7 var RemoteBox_Display = 'hide'; 
    8 var RemoteBox_BeginComm = 1; 
    9 var RemoteBox_MaxComm = 10; 
    107 
    11 function RemoteBox_Load() { 
     8function RemoteBox_Load(remotebox_function) { 
    129    var container = $('remotebox'); 
    1310    if (!container || !RemoteBox_Url) { 
     
    1916    container.innerHTML = '<div class="loading"> <img src="/static/images/indicator.gif" />Se incarca ...</div>'; 
    2017 
    21     var d = doSimpleXMLHttpRequest(RemoteBox_Url + "&display=" + RemoteBox_Display + 
    22             "&begin_comm=" + RemoteBox_BeginComm + 
    23             "&max_comm=" + RemoteBox_MaxComm); 
     18    var d = doSimpleXMLHttpRequest(RemoteBox_Url); 
    2419 
    2520    var ready = function(data) { 
     
    3429 
    3530    d.addCallbacks(ready, error); 
     31    d.addCallbacks(remotebox_function, null); 
     32} 
     33 
     34function RemoteBox_Comments(begin_comm, max_comm, focus_on_comments, display) { 
     35    var RemoteBox_Base_Url = RemoteBox_Url; 
     36 
     37    RemoteBox_Url = RemoteBox_Url + "&display=" + display + 
     38            "&begin_comm=" + begin_comm + 
     39            "&max_comm=" + max_comm; 
     40    if (focus_on_comments == true) { 
     41        var remotebox_function = function() { 
     42            // set the anchor to the "comentarii" element 
     43            window.location.hash = "comentarii"; 
     44        } 
     45        RemoteBox_Load(remotebox_function); 
     46    } else { 
     47        RemoteBox_Load(null); 
     48    } 
     49 
     50    RemoteBox_Url = RemoteBox_Base_Url; 
    3651} 
    3752 
  • trunk/www/views/blog_view.php

    r1004 r1032  
    3535echo '</div>'; 
    3636// blog comments 
    37 echo '<div id="comentarii">'; 
    3837if (getattr($view, 'forum_topic')) { 
    3938    echo macro_smfcomments(array('topic_id' => $view['forum_topic'], 'display' => 'show')); 
    4039} 
    41 echo '</div></div>'; 
     40echo '</div>'; 
    4241echo '</div>'; 
    4342 
  • trunk/www/views/textblock_view.php

    r1004 r1032  
    2020 
    2121// page comments 
    22 echo '<div id="comentarii">'; 
    2322if (getattr($view, 'forum_topic')) { 
    2423    require_once(IA_ROOT_DIR.'www/macros/macro_smfcomments.php'); 
    2524    echo macro_smfcomments(array('topic_id' => $view['forum_topic'], 'display' => 'hide')); 
    2625} 
    27 echo '</div>'; 
    2826 
    2927// site footer 
Note: See TracChangeset for help on using the changeset viewer.