Diving Deep in to the moodle code...

Diving Deep in to the moodle code...

by Adam Shore -
Number of replies: 29
My designer and I have come up with a template design. I am in the process of implementing it in to a new theme.

I'm working along in the code and come across this line:

<?php echo $menu ?>

So, I understand we're getting the contents of the $menu variable. I am having a hard time finding my way around to which file implements the functionality to populate the $menu variable. I need to go and alter styling on this item.

What are some best practices for finding my way around the moodle vars like this / debugging / tracing???

Thanks for any tips.
Average of ratings: -
In reply to Adam Shore

Re: Diving Deep in to the moodle code...

by Adam Shore -
smile problem solved....
In reply to Adam Shore

Re: Diving Deep in to the moodle code...

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Adam,
The recommended practise in these forums is that, if you ask a question and later on find the solution yourself you should post your solution. This may help other participants with the same problem.
Thanks
Joseph
In reply to Joseph Rézeau

Re: Diving Deep in to the moodle code...

by Adam Shore -
I can't remember which ID tag comes out of the weblib function that returns the "logged in as" menu .. I went in and simply removed the ID tag code and left my DIV ID wrapped around the tag as such
<?php echo $menu ?>
Now, the function outputs unstyled HTML code. I can't remember for the life of me which function it was... Cheers.
In reply to Adam Shore

Re: Diving Deep in to the moodle code...

by Richard Enison -
AS,

It wouldn't be <div class="logininfo">, would it?

RLE
In reply to Adam Shore

Re: Diving Deep in to the moodle code...

by Matt Gibson -
In reply to Matt Gibson

Re: Diving Deep in to the moodle code...

by Adam Shore -
Yes - the div was called LoginInfo - thank you.

And thanks as well for the link to PHPref. The other day I was commenting to an associate about the lack of code-insight enabled PHP editors (at least on my computer)...
Is there a good OS PHP editor with code completion / insight? I have Dreamweaver. The function I miss from the Borland/MS IDE I am used to is the ctrl-click in to a class or function, property etc...
I don't even care if it's OS. Something good would be great and likely save a lot of time.

Thanks again for the link to phpXRef. That thing is very cool.
In reply to Adam Shore

Re: Diving Deep in to the moodle code...

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Try Eclipse: http://docs.moodle.org/en/Development:Setting_up_Eclipse.

(I really ought to update that document for Eclipse 3.3 and PDT. The summary is that PDT is better than PHPeclipse if you have lots of memory. Eclipse 3.2 + PHPeclipse used to use about 100Mb ram on my computer. Eclipse 3.3 + PDT is now using 500Mb, but is in many way better and I have enough memory to cope.)

In reply to Tim Hunt

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
Hi Tim,

I am using Eclipse 3.2.1 and would like to use it with PHPEclipse but I don't know which url to set in the "Edit Remote Site". Since you mention that you had been working with it in Eclipse 3.2 you may know the proper URL? I have been searching for it but got quiet confused now.
All the links I find are only compressed once - but no xml-file-link like in your link.
See e.g. download_phpeclipse-1.1.9-cvs-20060920

You may see my related post here.

If I change the URL, do I need to go through all the steps again mentioned in your above linked link or are there some differences?

I hope you could help me somehow?!

In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
sorry, this seems to be the correct_page_to_download_phpeclipse-1.1.9-cvs-20060920

Now I am on that stage that there is a manual installation possible:
manual_installation_guide

My problem though is that I have been working with phpeclipse-1.1.9-cvs-20060424 so far. In the manual there is also a part writing about having two versions - just like it is in my case. But I don't understand if in this case I should just copy the extracted files into the appropriate folder (which is the place where to find 'eclipse.exe' and a folder called 'plugins') without deleting the old version.
Reading the manual doesn't match the downloaded and extracted files though. I can find only a plugins file which seem to have all the files from the older version inside but there is not a features-folder.

Or am I on the wrong track and should really extract the files directly into the folder where eclipse.exe can be found and it will do what is needed correctly?

And what about the clean-option - would it leave my moodle-files untouched?

I don't want to break my currently working phpeclipse-version and want to make sure to be able to switch back to my older version in case the newer one won't make the debugger get working.

Does anyone has a clue or a more detailed page about this issue - I would really appreciate!


In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Sorry, I am now using Eclipse 3.3 with PDT, which is great if you have a lot of memory (My eclipse, with several copies of Moodle open, routinely uses 500Mb+).

So I am out of touch with PHPEclipse.

You can always install two copies of Eclipse on your hard disc, so you can try out the new code before risking updating your main install.
In reply to Tim Hunt

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
Hi Tim,
finally - since I couldn't get PHPEclipse working with debugging - I have decided to install Eclipse 3.3 with PDT.

Firstly, I am missing so far the feature where I could go to a used function, double clicking on it and by using Strg and clicking with the mouse at the function I could go directly into the file where the function is defined. Can you use this functionality? If yes, do you know where to turn it on?

Secondly, in Eclipse below Help-> Software Updates -> Find and Install -> new features
I have a remote site with the link http://download.eclipse.org/tools/pdt/updates/ and
a second one for zend http://downloads.zend.com/pdt.
As far as I understood I need the second one in order to be able to debug. Did you use also zend?
I have also been through the steps "Configuring for Mysql" to find here.

I have tried it out but couldn't get it working as it should.
E.g. while trying out debugging edit_multichoice_form.php the debugger terminates way before my breakpoint already in the first line of code giving a debug error in the console:
Debug Error: /moodleSue/moodle/question/type/multichoice/edit_multichoice_form.php line 14 - Class 'question_edit_form' not found

Maybe you or anybody else have an idea of what I have forgotten?

I really would love to set the debugger and the above mentioned function in order to get more into the code and understanding it better.


In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
Maybe this is important to know: I have just realized in the php-info of the browser output in Eclipse 3.3 that it still uses the old "workspace" used with Eclipse 3.2.
I have put my new "workspace_3.3.2" into the same folder of my old "workspace".
I guess I will have to correct following paths found in phpinfo:
DOCUMENT_ROOT
SCRIPT_FILENAME
session.save_path
But where to find?

In config.php I find dirroot and dataroot that should be renamed. wwwroot may be changed as well maybe? At the moment there is written "http://localhost:8080/moodle". Should and can I easily just rename e.g. "*/moodle" to "*/moodle1.8" in order to refer to the new workspace in the browser? This way I would get to my old workspace through "http://localhost:8080/moodle" and to the new workspace through "http://localhost:8080/moodle1.8".
In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you upgrade your workspace from Moodle 3.2 (that is open the old workspace with the new version of Eclipse - take a backup copy of the old workspace first) then, you can right click on an old PHP Eclipse project, and you will get an option "Covert to PDT project" in the middle of the menu.

That is what I did.
In reply to Tim Hunt

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
oh, I see. That is a very good idea! smile
I just followed your suggestions. But now after converting the project to pdt project it has the red x almost everywhere in the moodle folder where there is a html-file saying sth. like "no start tag XXX" or "start tag not closes" or "invalid character used in string..." mixed
Do you have any idea how to get rid of the errors and warnings? Maybe somewhere in the preferences?
In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Oh yes, there is an option buried somewhere for HTML files.

I was not able to get rid of all the red Xs in moodle, because there are some library files that it does not like, but we can't change them. I have having red Xs around, but I have learned to live with it because I think Eclipse is being too strict here.
In reply to Tim Hunt

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
in PHP 3.2 using PHPEclipse I had no red Xs in moodle at all. So it is something in Eclipse 3.3 I guess.

I have followed the steps in order to get rid of the Xs to find under http://docs.moodle.org/en/Setting_up_Eclipse_for_Moodle_development
but they are still there...

"Under General -> Content Types, select PHP Source File, and add *.html to the box at the bottom.

Under General -> Editors -> File Associations, if it is not already there, add *.php to the top box. With *.php selected in the top box, make sure PHP Editor is set to default in the bottom box. With *.html selected in the top box, select PHP Editor in the bottom box and click the Default button to change it, because in Moodle, most HTML files actually contain PHP code."

So did you get rid of the red Xs in your html-files? How?
Are you talking to live with those red Xs in your html-files or in other files?
In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The reason Eclipse shows more errors is that it does better validation of PHP code. Well, on the whole. Apart from one or two of the things that cause it to complain, which aren't really errors.

I do remember that getting HTML parsed as PHP was one of the changes I did to get rid of some of the red Xs. I can't remember the rest. Here at home, I am still on 3.2 because my laptop does not have that much memory. So I will have to check other settings at work tomorrow, if I remember.
In reply to Tim Hunt

eclipse 3.3 + mark occurrences

by Süreç Özcan -
Is anyone using Eclipse 3.3 and can see the "Mark Occurrences" in a file?

I can't see it yet, maybe someone knows, where to configure it properly?

In Window -> Preferences -> General -> Editors -> Text Editors -> Annotations -> Annotations types: Occurrences
following is set in "Show in":
Text as Highlighted - checked and Highlighted
Overview ruler - checked
Color: yellow
In reply to Süreç Özcan

Re: eclipse 3.3 + mark occurrences

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
PDT doesn't do mark occurrences, which is very annoying - you actually have to read the code to find out where a variable is used, and it is easy to miss one. I have taken to using Direction Backwards in the search dialog box as a way to work round this.
In reply to Tim Hunt

Re: eclipse 3.3 + mark occurrences

by Urs Hunkler -
Picture of Core developers
Hi Tim,

I am glad to give you a little info back after I have read so many helpful eclipse infos from you:

Select a word and move to the next occurrence with CTRL-k and to the previous with SHIFT-CTRL-k smile

Urs
In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
First, I did not know that you used to be able to double click on a function name. PDT works for me holding down CTRL key on my keyboard, then clicking on the function name.

Second, I have never tried to use he Zend debugger. Sorry.

In reply to Tim Hunt

Re: Diving Deep in to the moodle code...

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Tim > I did not know that you used to be able to double click on a function name. PDT works for me holding down CTRL key on my keyboard, then clicking on the function name.

Same with me, using Eclipse SDK Version: 3.3.0, nothing happens when double-clicking a function name, but as you say, holding down CTRL key (this changes all the function names to hyperlinks) and clicking on the desired function name to get sent to that function's definition in the file where it resides.

Maybe this is configurable and Süreç has customized her keyboard shortcuts?

Joseph

In reply to Joseph Rézeau

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
Süreç: Firstly, I am missing so far the feature where I could go to a used function, double clicking on it and by using Strg and clicking with the mouse at the function I could go directly into the file where the function is defined....

sorry, first I have written Strg which is the German word of Ctrl
then second I am using it the same way you do - sometimes I double click on the functions first and do the same following procedure, but it is not needed at all. My mistake.
In reply to Tim Hunt

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
To the second part:
So if I get you right you are using the same first link I mention above (http://download.eclipse.org/tools/pdt/updates/) and that is all in order to use the debugger?
I had tried debugging right after this installation and couldn't get it working. Maybe now using the old workspace it should work. I will try again as soon as I got rid of the defects and warnings.

Or are you automatically using XDebug? In the Run->Open run dialog->PHP Script-tag I can select between XDebug and Zend Debugger - but I don't remember having installed XDebug. So I presume that it got installed automatically through the PDT installation.
Disabling Zend in the "Manage configurations" and opening "Open run dialog" throws a pop-up saying "No PHP executables locations are defined. Define a PHP executable location before continuing." Do you know what I have to type in there?



In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
I am really confused now... I have tried to use XDebug but am getting always the above dialog.
Tim, maybe you could send me your php.ini. I could compare my settings and get the XDebug running.

I have tried out also using zend and it doesn't seem to work as well. with some reason I don't have a folder to the ZendDebuggerInstallation I have to set in the php.ini:
zend_extension_manager.debug_server_ts="/full/path/to/ZendDebuggerInstallation"
e.g.
zend_extension_manager.debug_server_ts="C:\Programme\Zend\ZendDebugger-5.2.10"

Is anyone using zend and could tell me where to find the proper file?
I am trying to follow the instructions listed here.
With some reason there has not been installed the above needed folder in order to use the debugger.

At this point I am really frustrated and am looking forward for some enlightment!
In reply to Süreç Özcan

Re: Diving Deep in to the moodle code...

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Tim, maybe you could send me your php.ini. I could compare my settings and get the XDebug running.



As I said above, I don't use any debugger for PHP, so I can't really help.
In reply to Tim Hunt

Re: Diving Deep in to the moodle code...

by Süreç Özcan -
oh, now I understand - you don't use a debugger at all - got you.