Announcement

Collapse
No announcement yet.

Question on PHP Syntax used in AdminCP/Index.php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question on PHP Syntax used in AdminCP/Index.php

    Hi! I have a quick question... In vB's AdminCP/Index.php, you'll find the following code for the Navigation Bar:


    PHP Code:
     
    if (can_administer('canadminusers'))
    {
    $printhr true;
    construct_nav_option($vbphrase['add_new_user'], 'user.php?do=add''|');
    construct_nav_option($vbphrase['search_for_users'], 'user.php?do=modify''|');
    construct_nav_option($vbphrase['merge_users'], 'usertools.php?do=merge''|');
    construct_nav_option($vbphrase['ban_user'], "../$modcpdir/banning.php?do=banuser"'<br />');
    construct_nav_option($vbphrase['prune_users'], 'user.php?do=prune''|');
    construct_nav_option($vbphrase['private_message_statistics'], 'usertools.php?do=pmstats''<br />');
    construct_nav_option($vbphrase['referrals'], 'usertools.php?do=referrers''|');
    construct_nav_option($vbphrase['search_ip_addresses'], 'usertools.php?do=doips''<br />');
    construct_nav_option($vbphrase['view_banned_users'], "../$modcpdir/banning.php?do=modify"'<br />');
    construct_nav_option($vbphrase['send_email_to_users'], 'email.php?do=start''|');
    construct_nav_option($vbphrase['generate_mailing_list'], 'email.php?do=genlist''<br />');
    construct_nav_option($vbphrase['access_masks'], 'accessmask.php?do=modify''<br />');
    construct_nav_group($vbphrase['users']);



    Here's my question... Some of those lines end in '|', while others end in '<br />'.

    Looking at the code, I can't figure out why a line would require one as opposed to the other.


    Can anyone help enlighten me on this?

    Thanks!
    echo $ocean_signature;

    ;)

  • #2
    The last parameter passed to "construct_nav_option", the one you are talking about, is not referenced by that function, so it is ignored. Whether or not this is intentional, well, only the developer would know.

    Comment


    • #3
      Originally posted by CarCdr

      The last parameter passed to "construct_nav_option", the one you are talking about, is not referenced by that function, so it is ignored. Whether or not this is intentional, well, only the developer would know.

      If it were really ignored, there shouldn't be any difference in how those statements are being closed. Since there is a difference - I have to assume that it means something.
      echo $ocean_signature;

      ;)

      Comment


      • #4
        Originally posted by slappy

        Differences Between HTML and XHTML
        In HTML the <br> tag has no end tag.

        I know what the <br /> tag does in general - but that doesn't help me figure out why these lines shouldn't all end in the same way.
        echo $ocean_signature;

        ;)

        Comment


        • #5
          OK. I think my first, now deleted response, was not correct. I think the answer lies in what is on the end of the sentences. I'm still searching for a correct answer as well, but it appears to lie in which file is being used and which directory that file may be located in. Althought that, alone, does not appear to be consistently applied here.

          If I find a better answer, I post it here. :-)

          Regards,
          Slappy

          Comment


          • #6
            Such an assumption would be a mistake. There is no difference in the resulting HTML. In v3.0.0 the parameter is entirely ignored. I checked the HTML output.
            If I have the following statements:
            Code:
            some_function("text1", '|');
            some_function("text2", '<br />');
            and my function is defined like this:
            Code:
            function some_function($textToOutput, $junk) {
            	 echo $textToOutput;
            }
            Then it does not matter what I pass as the second parameter, as it is not referenced.

            The last parameter passed to "construct_nav_option" is named "$extra" within that function. There is a reference to "$_extra" in the function, which is perhaps a typo, but no reference to "$extra".

            Comment


            • #7
              Originally posted by CarCdr

              Such an assumption would be a mistake. There is no difference in the resulting HTML. In v3.0.0 the parameter is entirely ignored. I checked the HTML output.

              Well, my point was that in order for me to play it safe, I have to make that assumption.

              As far as the HTML is concerned - is it possible that the difference isn't supposed to show up in the generated HTML - but rather in how the PHP is processing things?

              I still feel that it was done that way for a reason - otherwise, why have the differentiation?
              echo $ocean_signature;

              ;)

              Comment


              • #8
                CarCdr:

                Sorry, but I can't figure out what the heck you are referring to. Ocean was asking why certain "option" selections in the AdminCP NavBar, specifically in the "User" listing have different endings on different lines. Although it's not in this question, Ocean stated this question originally in another thread wondering if a "Show All Users" option could be added to the "User's" options.

                Jake Bunce posted the code Ocean included above and said it would be the code that would need to be changed. Ocean then asked why the endings of these lines were different and Jake said he didn't know, which is why Ocean posted it here.

                You keep talking about "parameter's" not being referenced and something you label as "The last parameter passed to "construct_nav_option" is named "$extra" within that function." And then you state "There is a reference to "$_extra" in the function, which is perhaps a typo, but no reference to "$extra"." Well, in the AdminCP/index.php file on my v3.0.3 vBulletin there is NO reference to either "$extra" or "$_extra".

                Ocean and I are trying to determine why some of the items in that NavBar "option" section, which includes the title "Users" and the 12 individual sub-options shown on the NavBar "Users" Menu have different endings, with "Some of those lines end in '|', while others end in '<br />'. "

                It is a question of the usage of the terminating marks in that particular php file. As far as I can see it is only an issue of displaying the NavBar "User" options and has nothing to do with defining functions. I simply don't see how your comments address this issue. It may be simply a vestage of older formats. I've changed all those in my own AdminCP/index.php file to '|' to see if anything happens.

                Regards,

                Regards,
                Slappy

                Comment


                • #9
                  OK. I changed three of the '<br />' endings to '|' ; saved the file; rebooted my "server"; and the AdminCP would not start at all. Barring the possibility I may have had a white space issue, it would seem those endings do have some purpose, as yet unknown to Ocean and to me.

                  Regards,
                  Slappy

                  Comment


                  • #10
                    Originally posted by slappy

                    OK. I changed three of the '<br />' endings to '|' ; saved the file; rebooted my "server"; and the AdminCP would not start at all. Barring the possibility I may have had a white space issue, it would seem those endings do have some purpose, as yet unknown to Ocean and to me.

                    Regards,

                    Ouch! Well, thank you for enduring that for me...
                    echo $ocean_signature;

                    ;)

                    Comment


                    • #11
                      No problem here. It's a home test version, and the "server" is just my pc. But unless I made an error with the white spaces, as I said, those endings are important for something. We just don't know why yet.

                      Regards,
                      Slappy

                      Comment


                      • #12
                        To find the function being called, "construct_nav_option", you need to look in "includes\adminfunctions_navpanel.php", not "index.php".

                        It does not matter what you pass this function as the last parameter. You could pass '<br />', '|', or 'anything you like', it will have no affect in vB 3.0.0 or 3.0.1 (the only versions I have downloaded).

                        Comment


                        • #13
                          Thank you for clarifying which file you were using to find the functions you were talking about, it didn't make any sense without that reference.

                          But as I said, I'm using v3.0.3 and I changed the adminCP/index file at the referenced location to change the line endings from '<br />' endings to '|' and couldn't get the adminCP to run at all after that. I recognize there could have been a white space problem which might have caused that to occur, but I've not had time to repeat the test again yet.

                          However, nothing you have said explains why these entries, and many others in the adminCP/index file use the different endings of '<br />' and '|' if they serve no purpose at all, unless they are simply remnants from previous versions of the software and were never updated. That really is the issue we still have had no clarity on, which is "why did they do it that way" all over that file, especially if it doesn't matter? I have looked and found a definition for the '<br />' endings in relation to xhtml (which is to act as a line break), but, as of yet, have found no description of what the '|' symbol is supposed to do as compared to the '<br />' . Clearly, each of these elements are displayed on separate lines in the AdminCP Navbar.

                          Regards,
                          Last edited by slappy; Sun 25 Jul '04, 8:48pm.
                          Slappy

                          Comment


                          • #14
                            It does not matter what the HTML definition of '<br>' is. The PHP function being called is passed some string, in this case, either the string '<br />' or the string '|'. In order for the string to become part of the HTML page, the PHP output, the function would have to do something with the string being passed.

                            This is either a bug or some unimplemented vB feature (they changed their minds and did not change the function.)

                            If I have the following script, called 'mypage.php', say, referenced in the URL 'www.mysite.com/mypage.php', then the HTML page produced (sent to the user's browser) will show exactly two lines, with some vertical whitespace between them:

                            First line.
                            Second line.


                            Script:
                            Code:
                            <?php
                             
                            /* mypage.php */
                             
                            function sendLineToBrowser($textToSend, $endingToSend) {
                            	 echo '<p>' . $textToSend . ' line.</p>';
                            }
                             
                            sendLineToBrowser('First', '<!--');
                            sendLineToBrowser('Second', '</body>');
                            ?>
                            The function sendLineToBrowser takes two arguments/parameters, named $textToSend and $endingToSend, but the latter is ignored -- it has no affect whatsoever.

                            The AdminCP function in question ALWAYS send HTML to make the option appear on separate "lines", regardless of what is passed as the last parameter. It always generates '<div>URL tag</div>'.

                            Cheers

                            http://www.crazygrrl.com/weav/intro4.php
                            Last edited by CarCdr; Sun 25 Jul '04, 9:07pm.

                            Comment


                            • #15
                              Ocean stated this question originally in another thread wondering if a "Show All Users" option could be added to the "User's" options.
                              Actually, I have run with that option on my board for quite awhile. I agree it is very handy. To add such an option, fine this code in "admincp/index.php" around line 641 in v3.0.0:
                              Code:
                              	 if (can_administer('canadminusers'))
                              	 {
                              		 $printhr = true;
                              then add this line right after it:
                              Code:
                               construct_nav_option('List All Users', 'user.php?do=find');
                              Last edited by CarCdr; Sun 25 Jul '04, 9:18pm.

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X