Friday, January 20, 2006

PHP5 parent:: Object

Working with PHP5 getting you used to work with real Object Orientatet Classes. Extended Classes or using the parent:: Object in such an extended Class is nothing new.

But i did not know (till now) that it is possible to jump over an extended Class to that parent.

To explain what i mean we have this Example:

class foo {
protected $iFoo = 0;
protected function bar() {
$this->iFoo++;
echo "foo: {$this->iFoo}
";
}
}
class fooA extends foo {
protected function bar() {
$this->iFoo++;
echo 'fooA:';
parent::bar();
}
}
class fooB extends fooA {
public function bar() {
$this->iFoo++;
echo'fooB';
parent::bar();
}
}

$oFoo = new fooB();
$oFoo->bar();

In this example we have 3 Classes, each extended by the next. Normally calling $oFoo->bar(); will output: "fooBfooA:foo: 3" which indicates that it starts with the latest class fooB, then runs through fooA to foo.

But what if you need an extend on fooA, but you don't want to run through it, you just want to run through fooB->bar and then foo->bar, without fooA?

I thought there is no solution for it, but there is! If you just change the function in fooB, where it says: "parent::bar();" to "foo::bar();" it will jump directly to foo, without fooA and it is not static as you may first think!

The Result will display: "fooBfoo: 2"

Tuesday, January 10, 2006

PDF Bookmarks

When you think of PDF you automatically think of Adobe Acrobat. I use Acrobat since .. well i don't know but as long as i can remember. Normally i just take a quick look over a pdf, but nowadays it is getting more and more common to post free downloads of books as pdf's.

I found such a download about a PHP book which i thought to read over in time since i need it for work. After 10 pages (the index ;-) i had to make a break becouse of some work which had high priority and just wanted to bookmark the page i was on ... but i was unable to find such a feature...

After i had the work done i looked over Acrobat a couple of Times.. there is a bookmark Toolbar.. but where can i make myself a bookmark... well after some research in the help i found out i had to "upgrade" to Acrobat Writer.... Hello? I don't want to write PDF's ... i just want to make a Bookmark where i am.. like in the Book i read in the moment when driving to work or home by train....

I mean we are in the Year 2006... we have Browsers with Bookmarks, Winword with Bookmarks but why the hell not in Acrobat?

So i googled in the net to find some open source software... maybe there is something which is better or at least able to make personalized bookmarks.

Well i found Foxit, which is the quickest way to open PDF's i have ever seen. The Program is about 2.6 MB in size and does NOT need to install. It opened the PDF in notime... but unfortunately no Bookmark function.

Then i found a Hack from OReilly for Adobe Acrobat ... a Javascript which enables to make Bookmarks.

Unfortunately i did not find any Hack for Foxit, that would be ingenious.