source: extensions/GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php @ 9350

Last change on this file since 9350 was 7449, checked in by grum, 14 years ago

Enhance GPCPublicIntegration functionnalities

  • Property svn:executable set to *
File size: 2.7 KB
RevLine 
[5550]1<?php
2
3/* -----------------------------------------------------------------------------
4  class name: GPCPublicIntegration
5  class version  : 2.0.0
6  plugin version : 3.0.0
7  date           : 2010-03-30
8  ------------------------------------------------------------------------------
9  author: grum at piwigo.org
10  << May the Little SpaceFrog be with you >>
11  ------------------------------------------------------------------------------
12
13  :: HISTORY
14
15| release | date       |
16| 2.0.0   | 2010/03/30 | * Update class & function names
17|         |            |
[7449]18| 2.1.0   | 2010/10/28 | * Add the pageIsSection() function
[5550]19|         |            |
20|         |            |
21|         |            |
22|         |            |
23  ------------------------------------------------------------------------------
24
25  this class provides base functions to manage an integration into main index
26  page
27
28  - constructor GPCPublicIntegration($section)
[7449]29  - (public) function initEvents()
[5550]30  - (public) function setCallbackPageFunction($value)
[7449]31  - (public) function pageIsSection()
32  - (private) function initSection()
33  - (private) function callPage()
[5550]34
35  use initEvents() function to initialize needed triggers for updating menubar
36
37  the "callback_page_function" is called everytime a specific page is displayed
38
39----------------------------------------------------------------------------- */
40
41class GPCPublicIntegration
42{
43  var $section;         //section applied to the page viewed
44  var $callback_page_function;        //called function to display page
45
46  public function __construct($section)
47  {
48    $this->section=$section;
49    $this->callback_page_function='';
50  }
51
52  public function __destruct()
53  {
54    unset($this->section);
55    unset($this->callback_page_function);
56  }
57
[7449]58  /**
59   * initialize events to manage menu & page integration
60   */
[5550]61  public function initEvents()
62  {
63    add_event_handler('loc_end_section_init', array(&$this, 'initSection'));
64    add_event_handler('loc_end_index', array(&$this, 'callPage'));
65  }
66
67  public function setCallbackPageFunction($value)
68  {
69    $this->callback_page_function=$value;
70  }
71
[7449]72  /**
73   * initialize section in piwigo
74   */
[5550]75  public function initSection()
76  {
77    global $tokens, $page;
78
79    if ($tokens[0] == $this->section)
80    { $page['section'] = $this->section; }
81  }
82
[7449]83  /**
84   * loads the section page
85   */
[5550]86  public function callPage()
87  {
88    global $page, $user;
89
90    if($page['section'] == $this->section)
91    {
92      @call_user_func($this->callback_page_function);
93    }
94  }
95
[7449]96  /**
97   * return true if current page is the section
98   */
99  public function pageIsSection()
100  {
101    return($_SERVER['QUERY_STRING']=='/'.$this->section);
102  }
103
[5550]104} //class GPCPublicIntegration
105
106
107?>
Note: See TracBrowser for help on using the repository browser.