Ignore:
Timestamp:
Mar 17, 2011, 8:25:13 PM (13 years ago)
Author:
mistic100
Message:

[extensions] Contest Results

  • New bloc for PWG Stuffs
  • Use new admin links and javascript implementation
  • Distinguish pending and running contests (both pending before)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ContestResults/main.inc.php

    r9572 r9745  
    22/*
    33Plugin Name: ContestResults
    4 Version: 1.3
     4Version: 1.3.b
    55Description: Add contests management pages
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=439
     
    1111if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1212
    13 global $prefixeTable, $conf;
     13global $prefixeTable, $conf, $pwg_loaded_plugins;
    1414
    1515// +-----------------------------------------------------------------------+
     
    1717// +-----------------------------------------------------------------------+
    1818define('CR_NAME' , 'Contest Results');
    19 define('CR_VERSION', '1.3');
     19define('CR_VERSION', '1.3.b');
    2020define('CR_DIR' , basename(dirname(__FILE__)));
    2121define('CR_PATH' , PHPWG_PLUGINS_PATH . CR_DIR . '/');
    2222define('CR_TABLE_1' , $prefixeTable . 'contests');
    2323define('CR_TABLE_2' , $prefixeTable . 'contests_results');
    24 define('CR_ADMIN', PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CR_DIR . '/admin/admin.php');
     24define('CR_ADMIN', get_root_url().'admin.php?page=plugin-' . CR_DIR);
    2525define('CR_PUBLIC', make_index_url(array('section' => 'contests')) . '/');
    26 
    27 $ED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
    28 define('CR_ED_STATE', $ED['state']);
     26define('CR_ED_STATE', isset($pwg_loaded_plugins['ExtendedDescription']) ? 'active' : 'unactive');
    2927
    3028
     
    3230//                                      Triggers
    3331// +-----------------------------------------------------------------------+
    34 add_event_handler('get_admin_plugin_menu_links', 'CR_admin_menu');      // Lien d'administration
    35 add_event_handler('loc_end_section_init', 'CR_section_init');           // Paramètre URL
    36 add_event_handler('loc_end_index', 'CR_index');                                         // Contenu du la page
    37 add_event_handler('loc_end_picture', 'CR_comment_picture', 10);         // Commentaire sur la page image
     32add_event_handler('loading_lang', 'CR_load_lang');                                              // Chargement des fichiers de langue
     33add_event_handler('get_admin_plugin_menu_links', 'CR_admin_menu');              // Lien d'administration
     34add_event_handler('loc_end_section_init', 'CR_section_init');                   // Paramètre URL
     35add_event_handler('loc_end_index', 'CR_index');                                                 // Contenu du la page
     36add_event_handler('loc_end_picture', 'CR_comment_picture', 10);                 // Commentaire sur la page image
     37add_event_handler('get_stuffs_modules', 'CR_register_stuffs_module');   // Ajoute un module pour PWG Stuffs
    3838if(CR_ED_STATE == 'active') add_event_handler('render_CR_content', 'get_user_language_desc');   // Textes multilangues
    3939
     
    4343// +-----------------------------------------------------------------------+
    4444include(CR_PATH . 'include/functions.php');
     45$conf['ContestResults'] = unserialize($conf['ContestResults']);
     46
    4547// Gestion du menu
    4648include(CR_PATH . 'include/cr_menubar.php');
     49
     50// Chargement des fichiers de langue et de la config
     51function CR_load_lang() {
     52        load_language('plugin.lang', CR_PATH);
     53}
    4754
    4855// Lien d'administration
     
    5966    global $tokens, $page, $conf;
    6067       
    61         load_language('plugin.lang', CR_PATH);
    62        
    6368    if ($tokens[0] == 'contests') { // on est dans la section concours
    6469                $page['section'] = 'contests';
     
    6772                if (isset($tokens[1]) AND !empty($tokens[1])) { // on est sur la page d'un concours
    6873                        $tokens[1] = explode('-', $tokens[1]);
     74                       
    6975                        if (preg_match('#^([0-9]*)$#', $tokens[1][0])) { // is_int ne marche pas parce que le chiffre est stocké en (string)
    7076                                $page['contest'] = $tokens[1][0];
    71                                 $page['title'] .= $conf['level_separator'] . trigger_event('render_CR_content', get_contest_name($page['contest']));
     77                               
     78                                if ($contest_name = get_contest_name($page['contest'])) { // vérifie si le concours existe
     79                                        $page['title'] .= $conf['level_separator'] . trigger_event('render_CR_content', $contest_name);
     80                                } else {
     81                                        page_not_found(l10n('CR_notavailable'));
     82                                }
    7283                        }
    7384                }
     
    8899}
    89100
     101// Ajoute un module pour PWG Stuffs
     102function CR_register_stuffs_module($modules) {
     103        array_push($modules, array(
     104                'path' => CR_PATH . '/stuffs_module',
     105                'name' => CR_NAME,
     106                'description' => l10n('CR_stuffs_desc'),
     107        ));
     108
     109        return $modules;
     110}
     111
    90112// Ajoute le commentaire sur la page image
    91113function CR_comment_picture() {
Note: See TracChangeset for help on using the changeset viewer.