Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-07-2005, 05:27 AM
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do you print out an object?

Been going through the new vb code. It looks like it was all switched to OOP? Is that right?

BTW, I hate OOP (never could understand it).

Not really sure why after all this time vb had to switch. Was there a good reason?

Anyway, I'm not going to switch to another bbs even though this is quite upsetting, but now I have to learn a whole bunch of new stuff.

When replying to a post, I tried to understand what the heck is going on. Where the variables are. One include calls another calls another which defines another include file in a variable which then calls back the file that called it (!!) and when you track all that down, nothing makes sense anymore.

Upshot, I figure the data is in a variable called $dataman. So I try to echo it to find out what's going on. And it says $dataman is an object. Damn. Well, how do you echo an object?

Every version of vb gets more and more complicated and I'm wondering if this will eventually turn into too much bloat. I hope you guys are thinking about this. And it would be nice if you asked for some feedback before making a change like moving to OOP. You don't have to, but it would be appreciated and maybe help the product in the end?

This may sound like a ranting complaint, but it's not meant that way. Just trying to give you feedback.
Reply With Quote
  #2  
Old 08-07-2005, 07:15 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$object->var;

$object->function();

I think :P
Reply With Quote
  #3  
Old 08-07-2005, 08:15 AM
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by TheSpecialist
$object->var;

$object->function();

I think :P
Thanks. So to get $dataman that would be

$object->dataman;
$object->function();

?

Or does that function() have to point to some actual function?
Reply With Quote
  #4  
Old 08-07-2005, 12:27 PM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Think if objects as "containers" for functions and variables The structure for the object is defined in a class. Take a look at includes/class_dm_threadpost.php.

You'll see that each class has various functions and varables defined within it. When vBulletin creates a new obkect, it uses something like:

Code:
$myObject = new vB_DataManager_Post();
Then, to access the variables and functions within the object in your code, you would use something like:

Code:
// Call a function
$myObject->verify_title("my post title here");
 
// Use a variable - prints the $post var (an array)
print_r($myObject->post);
Although OOP looks complicated when you don't know it, once you start learning it you'll relize all of the benifits it brings to a large project such as this. It seperates code in to functional, self-contained blocks (classes).

Take a look at http://www.phpfreaks.com/tutorials/48/0.php for an intro to OOP
Reply With Quote
  #5  
Old 08-07-2005, 09:47 PM
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Alan, I'll check it out.

In the meantime, perhaps you can help me. I'm trying to figure out in class_core.php how to pull out the username or userid of the current user. In the old version it would be $bbuserinfo[userid].
Inside function save() line 2285 of a virgin copy...or inside function vB_Input_Cleaner(&$registry) around line 1402, I'd like to print out the userid for debugging purposes.

Any help would be most appreciated!
Reply With Quote
  #6  
Old 08-07-2005, 09:52 PM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The userinfo is stored in the (suprisingly) userinfo array To access it use:

Code:
echo $vbulletin->userinfo['userid'];
echo $vbulletin->userinfo['username'];
echo $vbulletin->userinfo['etc...etc'];
Reply With Quote
  #7  
Old 08-07-2005, 11:38 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) For Debug Output one should use DEVDEBUG instead of echo ... doesn't destroy the Layout
2) You can "output" an object just like an array: print_r($object)
3) OOP is a great concept, although PHP (yet?) isn't "really" object-orientated.
4) In the constructor (and all Methods of Class vB_Input_Cleaner), the Userid is available as
PHP Code:
$this->registry->userinfo['userid'
Reply With Quote
  #8  
Old 08-07-2005, 11:57 PM
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Alan @ CIT
The userinfo is stored in the (suprisingly) userinfo array To access it use:

Code:
echo $vbulletin->userinfo['userid'];
echo $vbulletin->userinfo['username'];
echo $vbulletin->userinfo['etc...etc'];
Copied it directly, nothing printed out.
Tried printing random stuff on same line to make sure that the echo is working. It does. Seems that userid is not populated? I am logged in when trying it.

Quote:
Originally Posted by KirbyDE
1) For Debug Output one should use DEVDEBUG instead of echo ... doesn't destroy the Layout
Thanks. How do you use it?
Do you have to turn on debug mode? In config.php? $config=1;?

Quote:
2) You can "output" an object just like an array: print_r($object)
I didn't know you could do that with an array. I thought you had to loop through all the keys and values. Hmm, I'll have to try that.

Quote:
3) OOP is a great concept, although PHP (yet?) isn't "really" object-orientated.
Is there pretty much universal agreement on that, or is there a battle between the pro and anti OOP crowd?

Quote:
4) In the constructor (and all Methods of Class vB_Input_Cleaner), the Userid is available as
PHP Code:
$this->registry->userinfo['userid'
Couldn't get that to work either.
Tried:
echo $this->registry->userinfo['userid'];

Tried:
$test= $this->registry->userinfo['userid'];
echo $test;

etcetera...
Reply With Quote
  #9  
Old 08-08-2005, 04:38 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) Yes, Debug-Mode must be enabled to get DEVDEBUG() working.
Place
PHP Code:
$config['Misc']['debug'] = true
in config.php

2) Nobody who is seriously programming argues against OOP
There are strong arguments for OOP, but explaining that here would be too much.

3) Where exactly (Version, Linenumber in unmodified Code) did you try the echo?
Reply With Quote
  #10  
Old 08-08-2005, 04:48 AM
dwh's Avatar
dwh dwh is offline
 
Join Date: Feb 2002
Posts: 278
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KirbyDE
1) Yes, Debug-Mode must be enabled to get DEVDEBUG() working.
Place
PHP Code:
$config['Misc']['debug'] = true
in config.php

2) Nobody who is seriously programming argues against OOP
There are strong arguments for OOP, but explaining that here would be too much.

3) Where exactly (Version, Linenumber in unmodified Code) did you try the echo?
Thanks.
class_core.php version rc1
Line 2296
and
line 1434
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:44 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03908 seconds
  • Memory Usage 2,262KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (4)bbcode_php
  • (7)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete