Show
Ignore:
Timestamp:
11/26/2007 08:41:40 AM (12 months ago)
Author:
Shadowhand
Message:

Changes to core:

  • Changed the ALL declaration in ORM to -1, instead of 100. Thanks PugFish?!
  • Broke ORM::find() into ORM::find() and ORM::find_all()
  • Added ORM::clear(), ORM::where(), and ORM::select(). Thanks PugFish?!
  • Added support in ORM for method calls like: $user->find_by_username_and_email($username, $email), to handle AND WHERE and OR WHERE
  • Added ORM::find_keys() as a helper for find_by_and_or syntax
  • Added ORM::load_result() to handle loading Database results, DRY
  • Small optimizations to ORM logic and process, and updated comments
  • Updated Auth user model to be compatible with ORM changes
  • Updated Auth role model to be compatible with ORM changes
  • Updated Kodoc with a partially-working dynamic documentation example... but still no parsing of the comments :(
  • Cleaned up Session syntax a little
  • Added description of system.404 to Event
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/kodoc/views/kodoc_html.php

    r1124 r1271  
    11<?php 
    22 
    3 $nl = "\n"; 
     3if ( ! function_exists('kodoc_html')): 
    44 
    5 foreach($classes as $name => $data): 
     5function kodoc_html($comment) 
     6{ 
     7        // Create anchors 
     8        $comment = preg_replace_callback('/<([^ ]+) ?([^>]+)?>/', 'kodoc_html_anchor', $comment); 
    69 
    7         if (strtolower($name) != 'class'): 
     10        // Break out the comment 
     11        $comment = explode("\n", $comment); 
     12 
     13        foreach($comment as $key => $line) 
     14        { 
     15                if (strpos($line, '-') === FALSE) 
     16                        continue; 
     17 
     18                // Definition lists 
     19                if (preg_match('/([a-z_]+)\s+\-\s+(.+)/', trim($line), $matches)) 
     20                { 
     21                        // Add a definition list item 
     22                        $comment[$key] = 
     23                                '<dt>'.$matches[1].'</dt>'."\n". 
     24                                '<dd>'.$matches[2].'</dd>'."\n"; 
     25 
     26                        if (isset($end)) 
     27                        { 
     28                                if ($line === $end) 
     29                                { 
     30                                        // End the DL 
     31                                        $comment[$key] .= '</dl>'."\n"; 
     32 
     33                                        // Clear the list 
     34                                        unset($end); 
     35                                } 
     36                        } 
     37                        else 
     38                        { 
     39                                // Start the comment 
     40                                $comment[$key] = '<dl>'."\n".$comment[$key]; 
     41 
     42                                // End of list 
     43                                $end = ''; 
     44                        } 
     45                } 
     46                else 
     47                { 
     48                        if ( ! isset($paragraph)) 
     49                        { 
     50                                // Start a paragraph 
     51                                $paragraph = '<p>'; 
     52 
     53                                // End of paragraph 
     54                                $end = ''; 
     55                        } 
     56 
     57                        if ($line === $end) 
     58                        { 
     59                                // Set the paragraph 
     60                                $comment[$key] = $paragraph.'</p>'."\n"; 
     61 
     62                                // Clear the paragraph 
     63                                unset($paragraph); 
     64 
     65                                continue; 
     66                        } 
     67 
     68                        // Add the line to the paragraph 
     69                        $paragraph .= $line.' '; 
     70 
     71                        // Remove the comment 
     72                        unset($comment[$key]); 
     73                } 
     74        } 
     75 
     76        // Re-form the comment 
     77        $comment = implode("\n", $comment); 
     78 
     79        // Copyright symbols 
     80        $comment = str_replace('(c)', '&copy;', $comment); 
     81 
     82        return $comment; 
     83} 
     84 
     85function kodoc_html_anchor($matches) 
     86{ 
     87        if (strpos($matches[1], '://') === FALSE) 
     88        { 
     89                // Add HTTP protocol 
     90                $matches[1] = 'http://'.$matches[1]; 
     91        } 
     92 
     93        if (empty($matches[2])) 
     94        { 
     95                // No title 
     96                return html::anchor($matches[1]); 
     97        } 
     98        else 
     99        { 
     100                // With title 
     101                return html::anchor($matches[1], $matches[2]); 
     102        } 
     103} 
     104 
     105endif; 
     106if (empty($this->kodoc) OR count($docs = $this->kodoc->get()) < 1): 
    8107 
    9108?> 
    10 <h2><?php echo $name ?></h2> 
     109<p><strong>Kodoc not loaded</strong></p> 
    11110<?php 
    12111 
     112return; 
     113endif; 
     114 
     115?> 
     116<h2><?php echo $docs['file'] ?></h2> 
     117<?php 
     118 
     119if ( ! empty($docs['comment']['about'])): 
     120 
     121        echo kodoc_html($docs['comment']['about']); 
     122 
     123endif; 
     124foreach($docs['classes'] as $class): 
     125 
     126?> 
     127<h3><?php echo $class['name'] ?></h3> 
     128<?php 
     129 
     130        if ( ! empty($class['comment']['license'])): 
     131 
     132                echo kodoc_html($docs['comment']['license']); 
     133 
    13134        endif; 
    14         $parser = new View('kodoc_html_tags'); 
    15         if (isset($data['html'])): 
    16                 // Echo out a new tag parser 
    17                 echo $parser->set('title', '')->set('html', $data['html'])->set('h', '4')->render(); 
     135        if ( ! empty($class['comment']['about'])): 
     136 
     137                echo kodoc_html($docs['comment']['about']); 
     138 
    18139        endif; 
    19         if (isset($data['methods'])): 
    20                 foreach($data['methods'] as $name => $method): 
    21                         if (isset($method['html'])): 
    22                                 echo $parser->set('title', $name)->set('html', $method['html'])->set('h', '6')->render(); 
    23                         endif; 
    24                 endforeach; 
    25         endif; 
    26          
    27 return; 
     140        foreach ($class['methods'] as $method): 
     141                $sigil = ' '.(($method['static'] == TRUE) ? '::' : '->').' '; 
     142 
     143?> 
     144<div class="method"> 
     145<h4><span class="visibility"><?php echo $method['visibility'] ?></span> <?php echo $class['name'].$sigil.$method['name'] ?></h4> 
     146<div class="method"><?php echo Kohana::debug($method['about']) ?></div> 
     147<?php 
     148 
     149                if ($method['final']): 
     150 
     151?> 
     152<p class="note">This method is <tt>final</tt> and cannot be extended.</p> 
     153<?php 
     154 
     155                endif; 
     156                if ($method['abstract']): 
     157 
     158?> 
     159<p class="note">This method is <tt>abstract</tt> and must be implemented in extended classes.</p> 
     160<?php 
     161 
     162                endif; 
     163 
     164?> 
     165</div> 
     166<?php 
     167 
     168        endforeach; 
    28169endforeach; 
    29170