documentation.php 27 KB
Newer Older
doctrine's avatar
doctrine committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<?php
require_once("highlight.php");
error_reporting(E_ALL);
include("top.php");
$h = new PHP_Highlight();

function render($title,$t,$e) {
    global $h;
    print $e." <a name=\"$e\"><u>".$t."</u></a><br><br>\n";
    $c = "";

    if(file_exists("docs/$e.php")) {
        rename("docs/$e.php","docs/$title - $t.php");
    }
    if(file_exists("docs/$t.php")) {
        rename("docs/$t.php","docs/$title - $t.php");
    }
    if(file_exists("docs/$title - $t.php")) {
        $c = file_get_contents("docs/$title - $t.php");
        if(substr($c,0,5) == "<?php") {
            include("docs/$title - $t.php");
        } else
            print $c."<br><br>";
    }
    $c = "";
    if(file_exists("codes/$e.php")) {
        rename("codes/$e.php","codes/$title - $t.php");
    }
    if(file_exists("codes/$t.php")) {
        rename("codes/$t.php","codes/$title - $t.php");
    }
    if(file_exists("codes/$title - $t.php")) {
        print "<table border=1 class='dashed' cellpadding=0 cellspacing=0>";
        print "<tr><td>";
zYne's avatar
zYne committed
35 36 37
         $c = file_get_contents("codes/$title - $t.php");
        $c = trim($c);

doctrine's avatar
doctrine committed
38 39 40 41 42 43 44 45 46
        $h->loadString($c);
        print $h->toHtml();
        print "</td></tr>";
        print "</table>";
    }
    print "<br>";
}

function render_block($name) {
47

doctrine's avatar
doctrine committed
48 49 50 51 52 53 54 55 56 57
    if(file_exists("docs/$name.php")) {
        $c = file_get_contents("docs/$name.php");
        if(substr($c,0,5) == "<?php") {
            include("docs/$name.php");
        } else {
            print $c."<br><br>";
        }
    }
    if(file_exists("codes/$name.php")) {
        $c = file_get_contents("codes/$name.php");
zYne's avatar
zYne committed
58
        $c = trim($c);
59 60 61 62 63 64
        renderCode($c);
    }
}
function renderCode($c = null) {
    if( ! empty($c)) {
        $h = new PHP_Highlight;
doctrine's avatar
doctrine committed
65
        $h->loadString($c);
zYne's avatar
zYne committed
66 67 68 69

        print "<table width=500 border=1 class='dashed' cellpadding=0 cellspacing=0>";
        print "<tr><td>";

doctrine's avatar
doctrine committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
        print $h->toHtml();
        print "</td></tr>";
        print "</table>";
    }
}
function array2path($array, $path = '') {
   $arrayValues = array();

   $index = 1;
   foreach ($array as $k => $value) {
       $p = ($path !== '')?$path.".".$index:$index;

       if (is_scalar($value) || is_resource($value)) {
             $arrayValues[$p] = $value;
       } elseif (is_array($value)) {
             $arrayValues[$p] = $k;
             $arrayValues = $arrayValues + array2path($value, $p);
       }
       $index++;
   }

   return $arrayValues;
}
$menu = array("Getting started" =>
                        array(
                        "Requirements",
                        "Installation",
doctrine's avatar
doctrine committed
97
                        "Compiling",
doctrine's avatar
doctrine committed
98 99 100
                        "Starting new project",
                        "Setting table definition" => array(
                                        "Introduction",
101
                                        "Table and class naming",
102
                                        "Field(Column) naming",
doctrine's avatar
doctrine committed
103 104
                                        "Data types and lengths",
                                        "Constraints and validators",
105
                                        "Default values",
106
                                        "Enum emulation",
zYne's avatar
zYne committed
107

doctrine's avatar
doctrine committed
108
                                        ),
109

doctrine's avatar
doctrine committed
110 111 112 113 114 115
                        "Record identifiers" => array(
                                        "Introduction",
                                        "Autoincremented",
                                        "Natural",
                                        "Composite",
                                        "Sequential")
doctrine's avatar
doctrine committed
116
                        ),
117
           /**
118 119 120 121 122 123 124 125 126
           "Schema reference" =>
                        array(
                        "Data types" => array(
                                        "Boolean",
                                        "Integer",
                                        "Float",
                                        "String",
                                        "Array",
                                        "Object",
127 128 129 130 131 132 133 134
                                        "Blob",
                                        "Clob",
                                        "Timestamp",
                                        "Date",
                                        "Enum",
                                        "Gzip",
                        ),

135
                        ),
136
           */
doctrine's avatar
doctrine committed
137 138
           "Basic Components" =>
                        array(
139
                        "Manager"
doctrine's avatar
doctrine committed
140
                                => array("Introduction",
141 142
                                         "Opening a new connection",
                                         "Managing connections"),
doctrine's avatar
doctrine committed
143 144 145 146 147 148 149 150 151 152
                        "Record"
                                => array("Introduction",
                                         "Creating new records",
                                         "Retrieving existing records",
                                         "Accessing properties",
                                         "Updating records",
                                         "Deleting records",
                                         "Getting record state",
                                         "Getting object copy",
                                         "Serializing",
153
                                         "Checking Existence",
doctrine's avatar
doctrine committed
154
                                         "Callbacks"),
155
                        "Connection"
doctrine's avatar
doctrine committed
156
                                => array("Introduction",
157
                                         "Available drivers",
doctrine's avatar
doctrine committed
158
                                         "Getting a table object",
159
                                         "Flushing the connection",
doctrine's avatar
doctrine committed
160
                                         "Querying the database",
161
                                         "Getting connection state"),
doctrine's avatar
doctrine committed
162 163 164 165 166 167 168 169

                        "Collection"
                                => array("Introduction",
                                         "Accessing elements",
                                         "Adding new elements",
                                         "Getting collection count",
                                         "Saving the collection",
                                         "Deleting collection",
170
                                         //"Fetching strategies",
171
                                         "Key mapping",
172
                                         "Loading related records",
doctrine's avatar
doctrine committed
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
                                         "Collection expanding",
                                         ),

                        "Table" => array("Introduction",
                                         "Getting table information",
                                         "Finder methods",
                                         "Custom table classes",
                                         "Custom finders",
                                         "Getting relation objects"),

                        "Query" => array("Introduction",
                                         "FROM - selecting tables",
                                         "LIMIT and OFFSET - limiting the query results",
                                         "WHERE - setting query conditions",
                                         "ORDER BY - sorting query results",
188 189
                                         //"Fetching strategies",
                                         //"Lazy property fetching",
doctrine's avatar
doctrine committed
190 191 192 193 194 195 196 197 198 199
                                         "Method overloading",
                                         "Relation operators",
                                         "Bound parameters",
                                         "Aggregate functions",
                                         "DQL - SQL conversion"),
                        "RawSql" => array(
                                         "Introduction",
                                         "Using SQL",
                                         "Adding components",
                                         "Method overloading"),
200 201 202
                        "DB"     => array(
                                         "Introduction",
                                         "Connecting to a database",
203 204
                                         "Using event listeners",
                                         "Chaining listeners"),
205
                                         /**
doctrine's avatar
doctrine committed
206 207 208 209 210
                        "Statement - <font color='red'>UNDER CONSTRUCTION</font>" => array("Introduction",
                                             "Setting parameters",
                                             "Getting parameters",
                                             "Getting row count",
                                             "Executing the statement"),
211
                                            */
doctrine's avatar
doctrine committed
212 213 214 215
                        "Exceptions" => array(
                                    "Overview",
                                    "List of exceptions"
                                    )
216
                        ),
doctrine's avatar
doctrine committed
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
           "Mapping object relations" =>
                        array(
                        "Introduction",
                        "Composites and aggregates",
                        "Relation aliases",
                        "Foreign key associations" => array(
                                        "One-to-One",
                                        "One-to-Many, Many-to-One",
                                        "Tree structure"),

                        "Join table associations" => array(
                                        "One-to-One",
                                        "One-to-Many, Many-to-One",
                                        "Many-to-Many",
                                        "Self-referencing"),
                        "Dealing with relations" => array(
                                        "Creating related records",
                                        "Retrieving related records",
                                        "Updating related records",
zYne's avatar
zYne committed
236 237
                                        "Deleting related records",
                                        "Working with associations"),
doctrine's avatar
doctrine committed
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
                        "Inheritance" =>
                                        array("One table many classes",
                                        "One table one class",
                                        "Column aggregation"
                                        ),
                        ),
           "Configuration" =>
                        array(
                        "Introduction",
                        "Levels of configuration",
                        "Setting attributes"    => array(
                            "Table creation",
                            "Fetching strategy",
                            "Batch size",
                            "Session lockmode",
                            "Event listener",
                            "Validation",
                            "Offset collection limit"
                            )
                        ),



           "Advanced components" => array(
                      "Eventlisteners" =>
                                      array(
                                      "Introduction",
                                      "Creating new listener",
                                      "List of events",
                                      "Listening events",
                                      "Chaining",
269 270
                                      "AccessorInvoker",
                                      "Creating a logger",
doctrine's avatar
doctrine committed
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
                                      ),
                      "Validators" => array(
                                      "Intruduction",
                                      "Validating transactions",
                                      "Analyzing the ErrorStack",
                                      "List of predefined validators"
                                      ),
                      "View"        => array(
                                      "Intoduction",
                                      "Managing views",
                                      "Using views"
                                      ),
                      "Cache"       => array(
                                      "Introduction",
                                      "Query cache"),

                      "Locking Manager" => array(
                                        "Introduction",
289 290 291 292
                                        "Examples",
                                        "Planned",
                                        "Technical Details",
                                        "Maintainer"),
doctrine's avatar
doctrine committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306
                      /**
                      "Debugger" => array(
                                        "Introduction",
                                        "Debugging actions"),
                      "Library" => array(
                                        "Introduction",
                                        "Using library functions"),
                      "Iterator" => array(
                                        "Introduction",
                                        "BatchIterator",
                                        "ExpandableIterator",
                                        "OffsetIterator")
                        */
                    ),
307
           "DQL (Doctrine Query Language)" =>
zYne's avatar
zYne committed
308 309 310 311

                            array('Introduction', 
                                  'Syntax' =>

zYne's avatar
zYne committed
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
                                  array(
                                        'FROM',
                                        'WHERE',
                                        'GROUP BY',
                                        'HAVING',
                                        'ORDER BY',
                                        'LIMIT and OFFSET',
                                        ),

                                  'Functions' => array(
                                        'Contains',
                                        'Regexp',
                                        'Like'),
                                  'Operators' => array(
                                      'Logical operators')


329

zYne's avatar
zYne committed
330
                                ),
doctrine's avatar
doctrine committed
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
           "Transactions" => array(
                        "Introduction",
                        "Unit of work",
                        "Locking strategies" =>
                            array("Pessimistic locking",
                                  "Optimistic locking"),
                        "Nesting"
                        ),
            /**
            "Developer components" => array(
                        "DataDict"  => array(
                                        "Introduction",
                                        "Usage"
                                        ),
                        "IndexGenerator" =>
                                       array(
                                        "Introduction",
                                        "Usage"),
                        "Relation"  => array(
                                        "Introduction",
                                        "Types of relations",
                                        ),
                        "Null"      => array(
                                        "Introduction",
                                        "Extremely fast null value checking"
                                        ),
                        "Access"    => array(
                                        "Introduction",
                                        "Usage"
                                        ),
                        "Configurable" => array(
                                        "Introduction",
                                        "Usage"
                                        ),
                        ),
            */
            "Technology" => array(
                "Architecture",
                "Design patterns used",
                "Speed",
                "Internal optimizations" =>

                        array("DELETE",
                              "INSERT",
                              "UPDATE"),
                ),
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
            "Real world examples" => array("User management system","Forum application","Album lister"),
            
            "Coding standards" => array(
                            "Overview" => 
                                array(
                                    "Scope",
                                    "Goals"
                                    ),
                            "PHP File Formatting" => array(
                                    "General",
                                    "Indentation",
                                    "Maximum line length",
                                    "Line termination"
                                    ),

                            "Naming Conventions" => array(
                                    "Classes",
                                    "Interfaces",
                                    "Filenames",
                                    "Functions and methods",
                                    "Variables",
                                    "Constants",
                                    "Record columns",
                                    ),


                            "Coding Style" => array(
                                    "PHP code demarcation",
                                    "Strings",
                                    "Arrays",
                                    "Classes",
                                    "Functions and methods",
                                    "Control statements",
                                    "Inline documentation"
                                    ),
                                )
doctrine's avatar
doctrine committed
413 414
            );

zYne's avatar
zYne committed
415

doctrine's avatar
doctrine committed
416 417 418 419 420 421 422
?>


<table width="100%" cellspacing=0 cellpadding=0>
    <tr>
        <td width=50>
        <td>
zYne's avatar
zYne committed
423
        <td align="left" valign="top">
doctrine's avatar
doctrine committed
424 425 426 427 428 429 430 431
            <table width="100%" cellspacing=1 cellpadding=1>
            <tr>
                <td colspan=2 bgcolor="white">
                <img src="images/logo.jpg" align="left"><b class="title">Doctrine - PHP Data Persistence and ORM Tool</b>
                <hr>
                </td>
            </tr>
            <tr>
zYne's avatar
zYne committed
432
                <td bgcolor="white" valign="top">
doctrine's avatar
doctrine committed
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
                <?php
                if( ! isset($_REQUEST["index"])) {
                $i = 1;
                $missing = array();
                $missing[0] = 0;
                $missing[1] = 0;
                foreach($menu as $title => $titles) {
                    print $i.". <a href=\"".$_SERVER['PHP_SELF']."?index=$i#$i\">".$title."</a><br>\n";
                    $i2 = 1;
                    foreach($titles as $k => $t) {
                        $e = "$i.".$i2."";
                        if(is_array($t)) {
                            print "<dd>".$e." <a href=\"".$_SERVER['PHP_SELF']."?index=$i.$i2#$e\">".$k."</a><br>\n";

                            $i3 = 1;
                            foreach($t as $k2 => $v2) {
                                $str = "";
                                if( ! file_exists("docs/$title - $k - $v2.php")) {
                                    $missing[0]++;
                                    $str .= " [ <font color='red'>doc</font> ] ";
453
                                    touch("docs/$title - $k - $v2.php");
doctrine's avatar
doctrine committed
454 455 456 457
                                }
                                if( ! file_exists("codes/$title - $k - $v2.php")) {
                                    $missing[1]++;
                                    $str .= " [ <font color='red'>code</font> ] ";
458
                                    touch("codes/$title - $k - $v2.php");
459

doctrine's avatar
doctrine committed
460 461 462
                                }

                                $e = implode(".",array($i,$i2,$i3));
zYne's avatar
zYne committed
463
                                print "<dd><dd>".$e." <a href=\"".$_SERVER['PHP_SELF']."?index=$i.$i2#$e\">".$v2."</a>$str<br>\n";
doctrine's avatar
doctrine committed
464 465 466 467 468 469 470
                                $i3++;
                            }
                        } else {
                            $str = "";
                            if( ! file_exists("docs/$title - $t.php")) {
                                $missing[0]++;
                                $str .= " [ <font color='red'>doc</font> ] ";
471
                                touch("docs/$title - $t.php");
doctrine's avatar
doctrine committed
472 473 474 475
                            }
                            if( ! file_exists("codes/$title - $t.php")) {
                                $missing[1]++;
                                $str .= " [ <font color='red'>code</font> ] ";
476
                                touch("codes/$title - $t.php");
doctrine's avatar
doctrine committed
477
                            }
zYne's avatar
zYne committed
478
                            print "<dd>".$e." <a href=\"".$_SERVER['PHP_SELF']."?index=$i#$e\">".$t."</a>$str<br>\n";
doctrine's avatar
doctrine committed
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
                        }
                        $i2++;
                    }
                    $i++;
                }
                } else {
                    $i = 1;
                    $ex = explode(".",$_REQUEST["index"]);


                    $paths = array2path($menu);

                    if( ! isset($paths[$ex[0]]))
                        exit;

                    $break = false;
                    $tmp   = $paths;
                    foreach($tmp as $path => $title) {
                        $e = explode(".", $path);
                        if(count($e) > 2) {
                            unset($tmp[$path]);
                        }
                    }
                    $prev = 1;
                    foreach($tmp as $path => $title) {
                        if($break)
                            break;
506

doctrine's avatar
doctrine committed
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
                        if($path == $_REQUEST["index"]) {
                            $break = true;
                        } else {
                            $prev = $path;
                        }
                    }
                    $index = $_REQUEST['index'];
                    print "<table width='100%'>";
                    print "<tr><td colspan=3 align='center'><b></td></tr>";
                    print "<tr><td colspan=3 align='center'><b class='title'>".$paths[$ex[0]]."</b></td></tr>";
                    print "<tr><td align='left'><b><a href=documentation.php?index=$prev>Prev</a></b></td>";
                    print "<td align='right'><b><a href=documentation.php?index=$path>Next</a></b></td></tr>";
                    print "<tr><td>&nbsp;</td></tr>";
                    print "</table>";


                 $tmp = $ex;
                    if(count($tmp) > 2) {
                        //array_pop($tmp);
                    }
                    foreach($tmp as $k => $v) {
                        $numbers[] = $v;
                        $curr = implode(".",$numbers);
                        $stack[] = $paths[$curr];
                    }
                    if(isset($ex[1])) {
                        $name = implode(" - ", $stack);

535
                        print "<a name='$path'><b class='title'>".$paths[$curr]."</b></a><hr>";
doctrine's avatar
doctrine committed
536 537 538 539

                        $n = $numbers;

                        $o = $paths[$n[0]];
540 541
                        $numpath  = implode(".", array($n[0], $n[1]));
                        $o2 = $paths[$numpath];
doctrine's avatar
doctrine committed
542 543

                        $value = $menu[$o];
544
                        if( ! is_array($value))
doctrine's avatar
doctrine committed
545
                            exit;
546

doctrine's avatar
doctrine committed
547 548 549

                        if(in_array($o2, $value)) {
                            render_block($name);
550
                        } else {
doctrine's avatar
doctrine committed
551 552 553 554
                            $value = $menu[$o][$o2];

                            if(is_array($value)) {
                                foreach($value as $k => $title) {
555 556
                                    $numpath2 = $numpath . '.' . ($k + 1);
                                    print "<br \><a name='".$numpath2."'><b class='title'>".$title."</b></a><hr style='height: 1px' \>";
doctrine's avatar
doctrine committed
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581

                                    $s = $name." - ".$title;

                                    render_block($s);
                                }
                            }
                        }
                    } else {
                        //if( ! isset($menu[$ex[0]]))
                        //    exit;
                        $tmp = $paths[$ex[0]];
                        $i = 1;
                        foreach($menu[$tmp] as $title => $value) {
                            $n = $ex[0].".".$i;

                            if(is_scalar($value)) {
                                print "<dd>".$n.". <a href=\"documentation.php?index=".$n."\">".$value."</a><br \>\n";
                            } else {
                                print "<dd>".$n.". <a href=\"documentation.php?index=".$n."\">".$title."</a><br \>\n";
                            }
                            $i++;
                        }
                    }
                    }
                ?>
zYne's avatar
zYne committed
582
                <td bgcolor="white" align="left" valign="top" width=300>
doctrine's avatar
doctrine committed
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
                <?php
                    $i = 1;
                    print "<dd>-- <b><a href=documentation.php>index</a></b><br>\n";
                    foreach($menu as $title => $titles) {
                        print "<dd>".$i.". <a href=\"".$_SERVER['PHP_SELF']."?index=$i\">".$title."</a><br>\n";
                        $i++;
                    }
                ?>
                </td>
            <td>
            <tr>
            <td bgcolor="white" valign="top" colspan="2">
            <?php






            /**
            foreach($menu as $title => $titles) {
                if($i == $ex[0]) {

                print $i.". <b><a class=\"big\" name=\"$i\">".$title."</a></b><hr><br>\n";
                    $i2 = 1;
                    foreach($titles as $k => $t) {
                        $e = "$i.".$i2;

                        if(is_array($t)) {
                            $tmp = "$title - $k";

                            if( ! isset($ex[1]) || $i2 != $ex[1]) {
                                $i2++;
                                continue;
                            }

                            print $e." <b><a class=\"big\" name=\"$e\">".$k."</a></b><hr><br><br>\n";
                            foreach($t as $k2 => $t2) {
                                if( ! isset($ex[1]) || $i2 != $ex[1])
                                    break;
                                $e = "$i.".$i2.".".($k2+1);
                                render($tmp,$t2,$e);
                            }
                        } else {
                            if( ! isset($ex[1])) {
                                render($title,$t,$e);
                            }
                        }
                        $i2++;
                    }
                }
                $i++;

            }
            */
            ?>
            </td>
            </tr>
        </td>
        <td>
        </td>
    </tr>
</table>