Smarty
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file function.include_wiki_page_content.php

Documentation is available at function.include_wiki_page_content.php

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8. /** \file
  9.  * $Header:
  10.  *
  11.  * \author jht <jht@lj.net>
  12.  */
  13.  
  14.  
  15. /**
  16.  * \brief Smarty plugin to include specified wiki page content (transclusion)
  17.  * Usage format {include_wiki_page_content page=>'name of page' }
  18.  * or {include_wiki_page_content page=>'name of page' page_default='name of another page' }
  19.  */
  20.  
  21. #
  22. # This fuction provides transclusion in page templates.    To use transclusion
  23. # inside of content, use the Liberty 'include' plugin
  24. #
  25. # ( Transclusion is including information from one document into another.
  26. # For more on Transclusion - see: http://en.wikipedia.org/wiki/Wikipedia:Transclusion )
  27. #
  28. # This function can be used in any wiki template to include the content of any arbitrary
  29. # wiki page.    There are many possible uses.
  30. # For example, when editing pages, you want to include custom editing instructions
  31. # but want these instructions to be easily updatable by any wiki user.
  32. # Adding this line to the wiki/templates/edit_page.tpl file will automatically display
  33. # the content of the page named: 'edit notice' whenever a wiki page is edited:
  34. #
  35. #     {include_wiki_page_content page="edit notice"}
  36. #
  37. # Suppose that instead of a global notice that is the same for all pages, you want
  38. # custom tailored notices specific to each page, and want to display a default
  39. # notice for pages that don't have a custom notice defined.
  40. # Example: whenever a page named "ABC" is edited you would like to display this notice:
  41. #     "Please Keep the Lists on this Page Alphabetical!"
  42. #
  43. # Step 1: Create a new page named: "ABC - edit notice" containing the notice
  44. # The content of this page is the notice that you want shown whenever the page "ABC" is edited.
  45. # The notice can be any length and include wiki markup. 
  46. #
  47. # Step 2: Create a new page named something like: "default edit notice"
  48. # The content of this page is the notice that you want shown whenever a page without a custom edit notices is edited.
  49. # The notice can be any length and include wiki markup. 
  50. #
  51. # Step 3: Include the following line in the wiki/edit_page.tpl file at the point where you want the notice displayed:
  52. #
  53. #{include_wiki_page_content page="`$pageInfo.original_title` - edit notice" page_default="default edit notice"}
  54. #
  55. # Now whenever "ABC" is edited the custom notice will be displayed on the edit page.
  56. # Editing any other page will display the default edit notice.
  57. #
  58.  
  59.  
  60. function smarty_function_include_wiki_page_content($params&$gBitSmarty)
  61. {
  62.     global $debugger;
  63.     //
  64.     $pageName !empty$params['page'$params['page'(!empty$params['page_default'$params['page_default'NULL );
  65.     $transclusion_parsed '';
  66.     include_onceWIKI_PKG_PATH.'BitPage.php' );
  67.     $transclusion_bitpage new BitPage();
  68.     if$transclusion_page_id $transclusion_bitpage->findByPageName($pageName) ) {
  69.         $transclusion_bitpage->mPageId $transclusion_page_id;
  70.         if($transclusion_bitpage->load()) {
  71.             $transclusion_full_page_data $transclusion_bitpage->mInfo['data'];
  72.             $transclusion_parsed $transclusion_bitpage->parseData($transclusion_full_page_dataisset$transclusion_bitpage->mInfo['format_guid'?  $transclusion_bitpage->mInfo['format_guid''tikiwiki' ) ) ;
  73.         }
  74.     }
  75.  
  76.     return $transclusion_parsed;
  77. }
  78.  
  79. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:38 +0000 by phpDocumentor 1.5.0-lsces