Show
Ignore:
Timestamp:
05/23/08 16:34:29 (22 months ago)
Author:
JensDiemer
Message:

update back_links plugin. Use plugin preferences.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/plugins_internal/back_links/back_links.py

    r1584 r1586  
    3535 
    3636 
     37from django.utils.safestring import mark_safe 
     38 
    3739from PyLucid.system.BasePlugin import PyLucidBasePlugin 
    38 from PyLucid.models import Page 
     40from PyLucid.models import Page, Plugin 
    3941 
    4042class back_links(PyLucidBasePlugin): 
    4143 
    42     def lucidTag(self, print_last_page=False, print_index=False, index="Index"): 
     44    def lucidTag(self, **kwargs): 
    4345        """ 
    4446        generate the backlinks 
     47        TODO: **kwargs only for Backwards-incompatible changes info 
    4548        """ 
     49        if self.request.debug == True and kwargs != {}: 
     50            self.page_msg( 
     51                "DeprecationWarning:" 
     52                " kwargs in back_links plugin are obsolete. Please remove them." 
     53            ) 
     54            return 
     55 
     56        # Get the preferences from the database: 
     57        preferences = self.get_preferences() 
     58        if preferences == None: 
     59            # preferences not in database -> reinit required 
     60            if self.request.debug == True: 
     61                msg = ( 
     62                    '<a href="http://www.pylucid.org/_goto/121/changes/#23-05-2008-back_links">' 
     63                    'reinit "back_links" plugin required!</a>' 
     64                ) 
     65                self.page_msg.red(mark_safe(msg)) 
     66                return 
     67 
    4668        current_page = self.context["PAGE"] 
    47         if print_last_page == True: 
     69        if preferences["print_last_page"] == True: 
    4870            print_page = current_page 
    4971        else: 
     
    5375                return "" 
    5476 
    55         data = self.backlink_data(print_page) 
     77        data = self._backlink_data(print_page) 
    5678        data.reverse() 
    5779 
    5880        context = { 
    5981            "pages": data, 
    60             "print_index": print_index, 
    61             "index": index, 
     82            "print_index": preferences["print_index"], 
     83            "index": preferences["index"], 
    6284        } 
    6385        self._render_template("back_links", context)#, debug=True) 
    6486 
    65     def backlink_data(self, parent_page): 
     87    def _backlink_data(self, parent_page): 
    6688        """ 
    6789        make a list of all pages in the current way back to the index page.