Ignore:
Timestamp:
Dec 18, 2005 12:16:03 AM (18 years ago)
Author:
scdev
Message:

detabbed all files ;P

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/PageNumbers.inc.php

    r41 r42  
    1414 * @version   1.61
    1515 */
    16  
     16
    1717require_once dirname(__FILE__) . '/Prefs.inc.php';
    1818
    1919class PageNumbers {
    20    
     20
    2121    var $total_items;       // Total quantity of items.
    2222    var $total_pages;       // The total number of pages.
     
    3232    var $set_page_number_initialized = false;
    3333    var $set_total_items_initialized = false;
    34    
     34
    3535    // These are initialized in the constructor.
    3636    var $per_page_options;
     
    4343    var $right_dbl_arrow;
    4444    var $right_dbl_arrow_disabled;
    45        
     45
    4646    /**
    4747     * PageNumbers constructor. All arguments are depreciated. Use set* functions instead.
     
    5151        // Default options for the quantity per page links.
    5252        $this->per_page_options = array(25, 50, 100, 200);
    53        
     53
    5454        // Default options for the page number links.
    5555        $this->left_arrow = _("back");
     
    6161        $this->right_dbl_arrow = '<strong>&raquo;</strong>';
    6262        $this->right_dbl_arrow_disabled = '<span style="color: #aaaaaa;"><strong>&raquo;</strong></span>';
    63        
    64         // Default url base. This will be set manually after instantiation 
     63
     64        // Default url base. This will be set manually after instantiation
    6565        // in special cases like using a /my/page/# scheme.
    6666        $this->url_base = $_SERVER['PHP_SELF'] . '?page_number=';
    6767    }
    68    
     68
    6969    /**
    7070     * Set the number of items per page.
     
    8888        $this->set_per_page_initialized = true;
    8989    }
    90    
     90
    9191    /**
    9292     * Set the current page number.
     
    112112        $this->set_page_number_initialized = true;
    113113    }
    114    
     114
    115115    /**
    116116     * Set the total number of items.
     
    119119    {
    120120        if (is_numeric($total_items) && $total_items > 0) {
    121             $this->total_items = $total_items;       
    122         } else {
    123             $this->total_items = 0;       
     121            $this->total_items = $total_items;
     122        } else {
     123            $this->total_items = 0;
    124124        }
    125125        $this->set_total_items_initialized = true;
    126126    }
    127    
     127
    128128    /**
    129129     * After $total_items or other options are set, this function calculates
    130      * all the other numbers needed. If you set any variables manually, 
     130     * all the other numbers needed. If you set any variables manually,
    131131     * for example if $page_number comes from
    132132     * some place other than the GET or POST array, you should call this
     
    146146            App::logMsg(sprintf('set_total_items not initialized'), LOG_ERR, __FILE__, __LINE__);
    147147        }
    148    
     148
    149149        // If the specified page exceedes total pages or is less than 1, set the page to 1.
    150150        if ($this->_per_page * $this->current_page >= $this->total_items + $this->_per_page || $this->_per_page * $this->current_page < 1) {
    151151            $this->current_page = 1;
    152152        }
    153        
     153
    154154        // The first item to be shown on this page.
    155155        $this->first_item = ($this->current_page - 1) * $this->_per_page;
    156        
     156
    157157        // The last item to be shown on this page.
    158158        if ($this->total_items < $this->current_page * $this->_per_page) {
     
    161161            $this->last_item = $this->current_page * $this->_per_page - 1;
    162162        }
    163        
     163
    164164        // Zeroing. Just in case. Paranoia. Yeah, negative numbers perturb me.
    165165        if ($this->first_item < 1) {
     
    172172            $this->total_items = 0;
    173173        }
    174                
     174
    175175        // The total number of pages.
    176176        $this->total_pages = ceil($this->total_items / $this->_per_page);
    177        
     177
    178178        // Figure out how many page number links to print.
    179179        if ($this->total_pages >= $this->max_num_links) {
     
    183183        }
    184184    }
    185    
     185
    186186    /**
    187187     * Returns the SQL code to limit query to items that are on current page.
     
    195195            return '';
    196196        }
    197     } 
     197    }
    198198
    199199    /**
     
    221221    /**
    222222     * Outputs an App::oHREF compatible url that goes to the page $page_number.
    223      * Depends on $this->base_url to build the url onto. This is used in the 
     223     * Depends on $this->base_url to build the url onto. This is used in the
    224224     * page_number.ihtml template.
    225225     *
     
    247247    {
    248248        $page_numbers = array();
    249        
     249
    250250        for ($i = 1; $i < $this->total_pages; $i++) {
    251251            $page_numbers[] = array(
     
    255255            );
    256256        }
    257        
     257
    258258        return $page_numbers;
    259259    }
     
    267267    {
    268268        $page_numbers_string = '';
    269        
     269
    270270        if ($this->current_page > $this->total_pages - floor($this->_num_links / 2)) {
    271271            $high_num = $this->total_pages;
     
    278278            $high_num = $low_num + $this->_num_links - 1;
    279279        }
    280        
     280
    281281        if ($this->current_page != 1) {
    282282            // Print "first" and "previous" page links.
     
    299299            }
    300300        }
    301        
     301
    302302        if ($this->_num_links > 0) {
    303303            // Print the current page number.
    304304            $page_numbers_string .= sprintf('<strong>%s</strong>&nbsp;', $this->current_page);
    305305        }
    306        
     306
    307307        if ($this->current_page < $this->total_pages) {
    308308            // Print links to specific page numbers after the current page.
     
    325325            }
    326326        }
    327        
     327
    328328        return $page_numbers_string;
    329329    }
    330    
     330
    331331    function printPageNumbers($carry_args=null)
    332332    {
    333333        echo $this->getPageNumbers($carry_args);
    334334    }
    335    
     335
    336336}
    337337
Note: See TracChangeset for help on using the changeset viewer.