source: extensions/ContestResults/main.inc.php @ 9975

Last change on this file since 9975 was 9975, checked in by mistic100, 13 years ago
  • many corrections
File size: 3.9 KB
RevLine 
[6768]1<?php
2/*
3Plugin Name: ContestResults
[9745]4Version: 1.3.b
[6768]5Description: Add contests management pages
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=439
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
[9745]13global $prefixeTable, $conf, $pwg_loaded_plugins;
[6768]14
15// +-----------------------------------------------------------------------+
[9200]16//                              Variables globales CR
[6768]17// +-----------------------------------------------------------------------+
[9572]18define('CR_NAME' , 'Contest Results');
[9745]19define('CR_VERSION', '1.3.b');
[6768]20define('CR_DIR' , basename(dirname(__FILE__)));
21define('CR_PATH' , PHPWG_PLUGINS_PATH . CR_DIR . '/');
22define('CR_TABLE_1' , $prefixeTable . 'contests');
23define('CR_TABLE_2' , $prefixeTable . 'contests_results');
[9745]24define('CR_ADMIN', get_root_url().'admin.php?page=plugin-' . CR_DIR);
[6768]25define('CR_PUBLIC', make_index_url(array('section' => 'contests')) . '/');
26
[6782]27
28// +-----------------------------------------------------------------------+
[9200]29//                                      Triggers
[6782]30// +-----------------------------------------------------------------------+
[9745]31add_event_handler('loading_lang', 'CR_load_lang');                                              // Chargement des fichiers de langue
32add_event_handler('get_admin_plugin_menu_links', 'CR_admin_menu');              // Lien d'administration
[9975]33add_event_handler('loc_end_section_init', 'CR_section_init');                   // Paramètre URL
[9745]34add_event_handler('loc_end_index', 'CR_index');                                                 // Contenu du la page
35add_event_handler('loc_end_picture', 'CR_comment_picture', 10);                 // Commentaire sur la page image
36add_event_handler('get_stuffs_modules', 'CR_register_stuffs_module');   // Ajoute un module pour PWG Stuffs
[6782]37
38
[9200]39// +-----------------------------------------------------------------------+
40//                                      Fonctions
41// +-----------------------------------------------------------------------+
[9572]42include(CR_PATH . 'include/functions.php');
[9745]43$conf['ContestResults'] = unserialize($conf['ContestResults']);
44
[6768]45// Gestion du menu
[9975]46if (script_basename() != 'admin') {
47        include(CR_PATH . 'include/cr_menubar.php');
48}
[6768]49
[9745]50// Chargement des fichiers de langue et de la config
51function CR_load_lang() {
52        load_language('plugin.lang', CR_PATH);
53}
54
[6768]55// Lien d'administration
[9200]56function CR_admin_menu($menu) {
[6768]57        array_push($menu, array(
58                'NAME' => CR_NAME,
59                'URL' => CR_ADMIN
60        ));
61        return $menu;
62}
63
[9975]64// Paramètre URL
[9200]65function CR_section_init() {
[6782]66    global $tokens, $page, $conf;
[9200]67       
68    if ($tokens[0] == 'contests') { // on est dans la section concours
[6768]69                $page['section'] = 'contests';
70                $page['title'] = l10n('Contests');
[9200]71               
[9572]72                if (isset($tokens[1]) AND !empty($tokens[1])) { // on est sur la page d'un concours
73                        $tokens[1] = explode('-', $tokens[1]);
[9745]74                       
[9975]75                        if (preg_match('#^([0-9]*)$#', $tokens[1][0])) { // is_int ne marche pas parce que le chiffre est stocké en (string)
[9572]76                                $page['contest'] = $tokens[1][0];
[9745]77                               
[9975]78                                if ($contest_name = get_contest_name($page['contest'])) { // vérifie si le concours existe
79                                        $page['title'] .= $conf['level_separator'] . trigger_event('render_category_name', $contest_name);
[9745]80                                } else {
81                                        page_not_found(l10n('CR_notavailable'));
82                                }
[9572]83                        }
[6768]84                }
85        }
86}
87
[9200]88// Contenu de la page
89function CR_index() {
[6782]90    global $template, $page, $conf;
[9200]91
92    if (isset($page['section']) and $page['section'] == 'contests') {
93                if (isset($page['contest'])) { // on est sur la page d'un concours
[6768]94                        include(CR_PATH . 'include/cr_page.php');
[9200]95                } else { // on est dans la section concours
[6768]96                        include(CR_PATH . 'include/cr_main.php');
[9200]97                }
[6768]98        }
99}
100
[9745]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
[6768]112// Ajoute le commentaire sur la page image
[9200]113function CR_comment_picture() {
[6768]114        global $page, $template, $conf;
115        include(CR_PATH . 'include/cr_comment_picture.php'); 
116}
117
118?>
Note: See TracBrowser for help on using the repository browser.