Changeset 17924


Ignore:
Timestamp:
Sep 15, 2012, 1:16:46 PM (8 years ago)
Author:
mistic100
Message:
  • ENGINE=MyISAM for table creation
  • add simple prefilter example
  • don't hardcode plugin folder
  • define VERSION auto, implemented soon in PEM
Location:
extensions/skeleton
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/skeleton/include/install.inc.php

    r17899 r17924  
    99 *    - use "if empty" for configuration vars
    1010 *    - use "IF NOT EXISTS" for table creation
     11 *
     12 * Unlike the functions in maintain.inc.php, the name of this function must be unique
     13 * and not enter in conflict with other plugins.
    1114 */
    1215
     
    2932  // add a new table
    3033        pwg_query('
    31 CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'skeleton` (
     34CREATE TABLE IF NOT EXISTS `'. $prefixeTable .'skeleton` (
    3235  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    3336  `field1` mediumint(8) DEFAULT NULL,
    3437  `field2` varchar(64) NOT NULL,
    3538  PRIMARY KEY (`id`)
    36 ) DEFAULT CHARSET=utf8
     39) ENGINE=MyISAM DEFAULT CHARSET=utf8
    3740;');
    3841
  • extensions/skeleton/include/public_events.inc.php

    r17899 r17924  
    9494}
    9595
     96/**
     97 * add a prefilter on photo page
     98 */
     99function skeleton_loc_end_picture()
     100{
     101  global $template;
     102 
     103  $template->set_prefilter('picture', 'skeleton_picture_prefilter');
     104}
     105
     106function skeleton_picture_prefilter($content)
     107{
     108  $search = '{if $display_info.author and isset($INFO_AUTHOR)}';
     109  $replace = '<div id="Skeleton" class="imageInfo">
     110                <dt>{\'Skeleton\'|@translate}</dt>
     111                <dd style="color:orange;">{\'Piwigo rocks\'|@translate}</dd>
     112        </div>
     113'.$search;
     114
     115  return str_replace($search, $replace, $content);
     116}
     117 
     118
    96119?>
  • extensions/skeleton/language/en_UK/intro.html

    r17899 r17924  
    1414    <li>New tabs for core admin pages</li>
    1515    <li>New filters and actions in the Batch Manager</li>
     16    <li>Simple template prefilter (on picture.php page)</li>
    1617  </ul>
    1718</p>
  • extensions/skeleton/language/fr_FR/intro.html

    r17899 r17924  
    1414    <li>Ajout d'onglet sur les pages d'administration existantes</li>
    1515    <li>Nouveaux filtres et actions pour le gestionnaire de lots</li>
     16    <li>Préfiltre de template simple (sur page picture.php)</li>
    1617  </ul>
    1718</p>
  • extensions/skeleton/main.inc.php

    r17899 r17924  
    2222// | Define plugin constants                                               |
    2323// +-----------------------------------------------------------------------+
    24 define('SKELETON_PATH' ,   PHPWG_PLUGINS_PATH . 'skeleton/');
     24defined('SKELETON_ID') or define('SKELETON_ID', basename(dirname(__FILE__)));
     25define('SKELETON_PATH' ,   PHPWG_PLUGINS_PATH . SKELETON_ID . '/');
    2526define('SKELETON_TABLE',   $prefixeTable . 'skeleton');
    26 define('SKELETON_ADMIN',   get_root_url() . 'admin.php?page=plugin-skeleton');
     27define('SKELETON_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . SKELETON_ID);
    2728define('SKELETON_PUBLIC',  get_absolute_root_url() . make_index_url(array('section' => 'skeleton')) . '/');
    2829define('SKELETON_DIR',     PWG_LOCAL_DIR . 'skeleton/');
    29 define('SKELETON_VERSION', '2.4.0'); // <= don't forget to manually update this constant!
     30define('SKELETON_VERSION', 'auto');
     31// this is automatically updated by PEM if you publish your plugin with SVN, otherwise you musn't forget to change it, as well as "Version" in the plugin header
    3032
    3133
     
    4244 
    4345  // new tab on photo page
    44   add_event_handler('tabsheet_before_select','skeleton_tabsheet_before_select', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     46  add_event_handler('tabsheet_before_select', 'skeleton_tabsheet_before_select', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    4547 
    4648  // new prefiler in Batch Manager
     
    6971  // NOTE: skeleton_blockmanager_apply1() and skeleton_blockmanager_apply2() can (should) be merged
    7072 
     73  // prefilter on photo page
     74  add_event_handler('loc_end_picture', 'skeleton_loc_end_picture');
     75 
    7176  // file containing all previous handlers functions
    7277  include_once(SKELETON_PATH . 'include/public_events.inc.php');
     
    9297  // apply upgrade if needed
    9398  if (
    94     $pwg_loaded_plugins['skeleton']['version'] == 'auto' or
    95     version_compare($pwg_loaded_plugins['skeleton']['version'], SKELETON_VERSION, '<')
     99    $pwg_loaded_plugins[SKELETON_ID]['version'] == 'auto' or
     100    version_compare($pwg_loaded_plugins[SKELETON_ID]['version'], SKELETON_VERSION, '<')
    96101  )
    97102  {
     
    101106   
    102107    // update plugin version in database
    103     if ($pwg_loaded_plugins['skeleton']['version'] != 'auto')
     108    if ($pwg_loaded_plugins[SKELETON_ID]['version'] != 'auto')
    104109    {
    105110      $query = '
    106111UPDATE '. PLUGINS_TABLE .'
    107112SET version = "'. SKELETON_VERSION .'"
    108 WHERE id = "skeleton"';
     113WHERE id = "'. SKELETON_ID .'"';
    109114      pwg_query($query);
    110115     
    111       $pwg_loaded_plugins['skeleton']['version'] = SKELETON_VERSION;
     116      $pwg_loaded_plugins[SKELETON_ID]['version'] = SKELETON_VERSION;
    112117     
    113118      if (defined('IN_ADMIN'))
  • extensions/skeleton/maintain.inc.php

    r17899 r17924  
    22defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    4 include_once(PHPWG_PLUGINS_PATH . 'skeleton/include/install.inc.php');
     4defined('SKELETON_ID') or define('SKELETON_ID', basename(dirname(__FILE__)));
     5include_once(PHPWG_PLUGINS_PATH . SKELETON_ID . '/include/install.inc.php');
    56
    67/**
     
    5556 
    5657  // delete table
    57   pwg_query('DROP TABLE `'.$prefixeTable.'skeleton`;');
     58  pwg_query('DROP TABLE `'. $prefixeTable .'skeleton`;');
    5859 
    5960  // delete field
Note: See TracChangeset for help on using the changeset viewer.