Ignore:
Timestamp:
Jun 24, 2012, 9:18:26 PM (12 years ago)
Author:
grum
Message:

feature:2634- compatibility with Piwigo 2.4
+add some objects on js framework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GrumPluginClasses/classes/CommonPlugin.class.inc.php

    r15340 r16012  
    22/* -----------------------------------------------------------------------------
    33  class name: CommonPlugin
    4   class version  : 2.2.0
    5   plugin version : 3.2.0
    6   date           : 2010-07-28
     4  class version  : 2.3.0
     5  plugin version : 3.5.2
     6  date           : 2012-06-24
    77
    88  ------------------------------------------------------------------------------
     
    5151|         |            |   function
    5252|         |            |
     53| 2.3.0   | 2012/06/24 | * Add loadCSS() function
     54|         |            |
    5355|         |            |
    5456|         |            |
     
    6466  private $page_link; //link to admin page
    6567  private $fileLocation; //files plugin location on server
     68  private $pluginDirectory;    //directory of plugin
    6669  private $displayResult_ok;
    6770  private $displayResult_ko;
     
    122125  }
    123126
    124   /* constructor allows to initialize $prefixeTable value */
     127  /**
     128   * constructor allows to initialize $prefixeTable value
     129   * @param String $prefixeTable: prefix used for tables
     130   * @param String $filelocation: file calling the constructor (__FILE__)
     131   */
    125132  public function __construct($prefixeTable, $filelocation)
    126133  {
     
    129136    $this->fileLocation=$filelocation;
    130137    $this->prefixeTable=$prefixeTable;
     138    $this->pluginDirectory=basename(dirname($filelocation));
    131139    $this->page_link=get_root_url().'admin.php?page=plugin-'.basename(dirname($this->getFileLocation()));
    132140    //$this->page_link="admin.php?page=plugin&section=".basename(dirname($this->getFileLocation()))."/admin/".$this->plugin_admin_file.".php";
     
    150158  }
    151159
     160  /**
     161   * return the file location
     162   * @return String: file location
     163   */
    152164  public function getFileLocation()
    153165  {
     
    155167  }
    156168
     169  /**
     170   * return the plugin directory
     171   * @return String: directory
     172   */
     173  public function getDirectory()
     174  {
     175    return($this->pluginDirectory);
     176  }
     177
     178  /**
     179   * return the link of plugin in admin pages
     180   * @return String: url
     181   */
    157182  public function getAdminLink()
    158183  {
     
    160185  }
    161186
     187  /**
     188   * set the link of plugin in admin pages
     189   * @param String $link: url to set
     190   * @return String: url
     191   */
    162192  public function setAdminLink($link)
    163193  {
     
    166196  }
    167197
     198  /**
     199   * set the plugin name
     200   * @param String $name: plugin's name
     201   * @return String: plugin's name
     202   */
    168203  public function setPluginName($name)
    169204  {
     
    172207  }
    173208
     209  /**
     210   * set the plugin name for file system useage
     211   * @param String $name: plugin's name
     212   * @return String: plugin's name
     213   */
    174214  public function setPluginNameFiles($name)
    175215  {
     
    178218  }
    179219
     220  /**
     221   * get the plugin name
     222   * @return String: plugin's name
     223   */
    180224  public function getPluginName()
    181225  {
     
    183227  }
    184228
     229  /**
     230   * get the plugin name for file system useage
     231   * @return String: plugin's name
     232   */
    185233  public function getPluginNameFiles()
    186234  {
     
    192240  --------------------------------------------------------------------------- */
    193241
    194   /* this function initialize var $config with default values */
     242  /**
     243   * this function initialize var $this->config with default values
     244   */
    195245  public function initConfig()
    196246  {
     
    198248  }
    199249
    200   /* load config from CONFIG_TABLE into var $my_config */
     250  /**
     251   * load config from CONFIG_TABLE into var $this->config
     252   * @return Boolean: true if config is loaded, otherwiser false
     253   */
    201254  public function loadConfig()
    202255  {
     
    206259
    207260  /**
    208    * load config from a file into var $my_config
     261   * load config from a file into var $this->config
    209262   *
    210263   * this function don't initialize the default value !
     
    212265   *
    213266   * @param String $fileName : name of file to load
     267   * @return Boolean: true if file is loaded, otherwise false
    214268   */
    215269  public function loadConfigFromFile($fileName)
     
    218272  }
    219273
    220   /* save var $my_config into CONFIG_TABLE */
     274  /**
     275   * save var $this->config into CONFIG_TABLE
     276   * @return Boolean: true if config is saved, otherwise false
     277   */
    221278  public function saveConfig()
    222279  {
     
    224281  }
    225282
    226   /* delete config from CONFIG_TABLE */
     283  /**
     284   * delete config from CONFIG_TABLE
     285   * @return Boolean: true if config is deleted, otherwise false
     286   */
    227287  public function deleteConfig()
    228288  {
     
    234294  --------------------------------------------------------------------------- */
    235295
    236   /*
    237       initialize tables list used by the plugin
    238         $list = array('table1', 'table2')
    239         $this->tables_list['table1'] = $prefixeTable.$plugin_name.'_table1'
    240   */
     296  /**
     297   * initialize tables list used by the plugin; tables name will be prefixed
     298   * automatically
     299   *     $list = array('table1', 'table2')
     300   *     $this->tables_list['table1'] = $prefixeTable.$plugin_name.'_table1'
     301   * @param Array $list: a list of table name
     302   */
    241303  protected function setTablesList($list)
    242304  {
     
    251313  --------------------------------------------------------------------------- */
    252314
    253   /* add plugin into administration menu */
     315  /**
     316   * add plugin into administration menu; url is built automatically
     317   * @param String $menu:
     318   */
    254319  public function pluginAdminMenu($menu)
    255320  {
     
    261326        )
    262327    );
    263     /*
    264     array_push($menu,
    265                array(
    266                   'NAME' => $this->plugin_name,
    267                   'URL' => get_admin_plugin_menu_link(dirname($this->getFileLocation()).
    268                                 '/admin/'.$this->plugin_admin_file.'.php')
    269                    ));*/
    270     return $menu;
    271   }
    272 
    273   /*
    274     manage plugin integration into piwigo's admin interface
    275 
    276     to be surcharged by child's classes
    277   */
     328    return($menu);
     329  }
     330
     331  /**
     332   * manage plugin integration into piwigo's admin interface
     333   *
     334   * to be surcharged by child's classes
     335   */
    278336  public function manage()
    279337  {
    280338  }
    281339
    282   /*
    283     initialize plugin's events
    284     to be surcharged by child's classes
    285   */
     340  /**
     341   * initialize plugin's events
     342   * by default, call the loadCSS() function on the 'loc_begin_page_header' events
     343   *
     344   * to be surcharged by child's classes
     345   */
    286346  public function initEvents()
    287347  {
    288   }
     348    global $plugin_id;
     349
     350    if($plugin_id==$this->getDirectory() or !defined('IN_ADMIN'))
     351        add_event_handler('loc_begin_page_header', array(&$this, 'loadCSS'));
     352  }
     353
     354  /**
     355   * called on the 'loc_begin_page_header' event
     356   *
     357   * to be surcharged by child's classes
     358   */
     359  public function loadCSS()
     360  {
     361  }
     362
    289363
    290364  protected function debug($text, $rewrite=false)
     
    306380  }
    307381
    308   /*
    309     manage infos & errors display
    310   */
    311382  protected function displayResult($action_msg, $result)
    312383  {
Note: See TracChangeset for help on using the changeset viewer.