Changeset 3875

Show
Ignore:
Timestamp:
02/21/08 14:54:55 (17 months ago)
Author:
guilhermeblanco
Message:

Updated manual pages and changed documentation naming convention (from process to parse) to follow the API

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/0.10/lib/Doctrine/Pager/Layout.php

    r3874 r3875  
    410410     * _parseTemplate 
    411411     * 
    412      * Process the template of a given page and return the processed template 
     412     * Parse the template of a given page and return the processed template 
    413413     * 
    414414     * @param array    Optional parameters to be applied in template and url mask 
     
    427427     * _parseUrlTemplate 
    428428     * 
    429      * Processes the url mask to return the correct template depending of the options sent. 
     429     * Parse the url mask to return the correct template depending of the options sent. 
    430430     * Already process the mask replacements assigned. 
    431431     * 
     
    454454     * _parseUrl 
    455455     * 
    456      * Process the url mask of a given page and return the processed url 
     456     * Parse the mask replacements of a given page 
    457457     * 
    458458     * @param $options    Optional parameters to be applied in template and url mask 
     
    477477     * _parseUrl 
    478478     * 
    479      * Process the url mask of a given page and return the processed url 
     479     * Parse the url mask of a given page and return the processed url 
    480480     * 
    481481     * @param $options    Optional parameters to be applied in template and url mask 
     
    494494        return strtr($str, $replacements); 
    495495    } 
    496      
    497      
     496 
     497 
    498498    /** 
    499499     * _parseMaskReplacements 
    500500     * 
    501      * Process the mask replacements, changing from to-be replaced mask with new masks/values 
     501     * Parse the mask replacements, changing from to-be replaced mask with new masks/values 
    502502     * 
    503503     * @param $str    String to have masks replaced 
  • branches/0.10/manual/docs/en/utilities/pagination/customizing-pager-layout.txt

    r3872 r3875  
    2020// Parses the template and returns the string of a processed page 
    2121$this->processPage($options = array()); // Needs at least page_number offset in $options array 
     22 
     23// Protected methods, although very useful 
     24 
     25// Parse the template of a given page and return the processed template 
     26$this->_parseTemplate($options = array()); 
     27 
     28// Parse the url mask to return the correct template depending of the options sent 
     29// Already process the mask replacements assigned 
     30$this->_parseUrlTemplate($options = array()); 
     31 
     32// Parse the mask replacements of a given page 
     33$this->_parseReplacementsTemplate($options = array()); 
     34 
     35// Parse the url mask of a given page and return the processed url 
     36$this->_parseUrl($options = array()); 
     37 
     38// Parse the mask replacements, changing from to-be replaced mask with new masks/values 
     39$this->_parseMaskReplacements($str); 
    2240</code> 
    2341 
     
    6583} 
    6684</code> 
     85 
     86 
     87As you may see, I have to manual process the items <<, <, > and >>. I override the **{%page}** mask by setting a raw value to it (raw value is achieved by setting the third parameter as true). Then I define the only MUST HAVE information to process the page and call it. The return is the template processed as a string. I do it to any of my custom buttons. 
     88 
     89Now supposing a totally different situation. Doctrine is framework agnostic, but many of our users use it together with Symfony. {{Doctrine_Pager}} and subclasses are 100% compatible with Symfony, but {{Doctrine_Pager_Layout}} needs some tweaks to get it working with Symfony's {{link_to}} helper function. To allow this usage with {{Doctrine_Pager_Layout}}, you have to extend it and add your custom processor over it. For example purpose (it works in Symfony), I used **{link_to}...{/link_to}** as a template processor to do this job. Here is the extended class and usage in Symfony: 
     90 
     91<code type="php"> 
     92// CLASS: 
     93 
     94class sfDoctrinePagerLayout extends Doctrine_Pager_Layout 
     95{ 
     96        public function __construct($pager, $pagerRange, $urlMask) 
     97        { 
     98                sfLoader::loadHelpers(array('Url', 'Tag')); 
     99                parent::__construct($pager, $pagerRange, $urlMask); 
     100        } 
     101 
     102 
     103        protected function _parseTemplate($options = array()) 
     104        { 
     105                $str = parent::_parseTemplate($options); 
     106 
     107                return preg_replace( 
     108                        '/\{link_to\}(.*?)\{\/link_to\}/', link_to('$1', $this->_parseUrl($options)), $str 
     109                ); 
     110        } 
     111} 
     112 
     113 
     114 
     115// USAGE: 
     116 
     117$pager_layout = new sfDoctrinePagerLayout( 
     118    $pager, 
     119    new Doctrine_Pager_Range_Sliding(array('chunk' => 5)), 
     120    '@hostHistoryList?page={%page_number}' 
     121); 
     122 
     123$pager_layout->setTemplate('[{link_to}{%page}{/link_to}]'); 
     124</code> 
  • trunk/lib/Doctrine/Pager/Layout.php

    r3874 r3875  
    410410     * _parseTemplate 
    411411     * 
    412      * Process the template of a given page and return the processed template 
     412     * Parse the template of a given page and return the processed template 
    413413     * 
    414414     * @param array    Optional parameters to be applied in template and url mask 
     
    427427     * _parseUrlTemplate 
    428428     * 
    429      * Processes the url mask to return the correct template depending of the options sent. 
     429     * Parse the url mask to return the correct template depending of the options sent. 
    430430     * Already process the mask replacements assigned. 
    431431     * 
     
    454454     * _parseUrl 
    455455     * 
    456      * Process the url mask of a given page and return the processed url 
     456     * Parse the mask replacements of a given page 
    457457     * 
    458458     * @param $options    Optional parameters to be applied in template and url mask 
     
    477477     * _parseUrl 
    478478     * 
    479      * Process the url mask of a given page and return the processed url 
     479     * Parse the url mask of a given page and return the processed url 
    480480     * 
    481481     * @param $options    Optional parameters to be applied in template and url mask 
     
    494494        return strtr($str, $replacements); 
    495495    } 
    496      
    497      
     496 
     497 
    498498    /** 
    499499     * _parseMaskReplacements 
    500500     * 
    501      * Process the mask replacements, changing from to-be replaced mask with new masks/values 
     501     * Parse the mask replacements, changing from to-be replaced mask with new masks/values 
    502502     * 
    503503     * @param $str    String to have masks replaced 
  • trunk/manual/docs/en/utilities/pagination/customizing-pager-layout.txt

    r3872 r3875  
    2020// Parses the template and returns the string of a processed page 
    2121$this->processPage($options = array()); // Needs at least page_number offset in $options array 
     22 
     23// Protected methods, although very useful 
     24 
     25// Parse the template of a given page and return the processed template 
     26$this->_parseTemplate($options = array()); 
     27 
     28// Parse the url mask to return the correct template depending of the options sent 
     29// Already process the mask replacements assigned 
     30$this->_parseUrlTemplate($options = array()); 
     31 
     32// Parse the mask replacements of a given page 
     33$this->_parseReplacementsTemplate($options = array()); 
     34 
     35// Parse the url mask of a given page and return the processed url 
     36$this->_parseUrl($options = array()); 
     37 
     38// Parse the mask replacements, changing from to-be replaced mask with new masks/values 
     39$this->_parseMaskReplacements($str); 
    2240</code> 
    2341 
     
    6583} 
    6684</code> 
     85 
     86 
     87As you may see, I have to manual process the items <<, <, > and >>. I override the **{%page}** mask by setting a raw value to it (raw value is achieved by setting the third parameter as true). Then I define the only MUST HAVE information to process the page and call it. The return is the template processed as a string. I do it to any of my custom buttons. 
     88 
     89Now supposing a totally different situation. Doctrine is framework agnostic, but many of our users use it together with Symfony. {{Doctrine_Pager}} and subclasses are 100% compatible with Symfony, but {{Doctrine_Pager_Layout}} needs some tweaks to get it working with Symfony's {{link_to}} helper function. To allow this usage with {{Doctrine_Pager_Layout}}, you have to extend it and add your custom processor over it. For example purpose (it works in Symfony), I used **{link_to}...{/link_to}** as a template processor to do this job. Here is the extended class and usage in Symfony: 
     90 
     91<code type="php"> 
     92// CLASS: 
     93 
     94class sfDoctrinePagerLayout extends Doctrine_Pager_Layout 
     95{ 
     96        public function __construct($pager, $pagerRange, $urlMask) 
     97        { 
     98                sfLoader::loadHelpers(array('Url', 'Tag')); 
     99                parent::__construct($pager, $pagerRange, $urlMask); 
     100        } 
     101 
     102 
     103        protected function _parseTemplate($options = array()) 
     104        { 
     105                $str = parent::_parseTemplate($options); 
     106 
     107                return preg_replace( 
     108                        '/\{link_to\}(.*?)\{\/link_to\}/', link_to('$1', $this->_parseUrl($options)), $str 
     109                ); 
     110        } 
     111} 
     112 
     113 
     114 
     115// USAGE: 
     116 
     117$pager_layout = new sfDoctrinePagerLayout( 
     118    $pager, 
     119    new Doctrine_Pager_Range_Sliding(array('chunk' => 5)), 
     120    '@hostHistoryList?page={%page_number}' 
     121); 
     122 
     123$pager_layout->setTemplate('[{link_to}{%page}{/link_to}]'); 
     124</code>