source: extensions/ContestResults/main.inc.php

Last change on this file was 9975, checked in by mistic100, 13 years ago
  • many corrections
File size: 3.9 KB
Line 
1<?php
2/*
3Plugin Name: ContestResults
4Version: 1.3.b
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
13global $prefixeTable, $conf, $pwg_loaded_plugins;
14
15// +-----------------------------------------------------------------------+
16//                              Variables globales CR
17// +-----------------------------------------------------------------------+
18define('CR_NAME' , 'Contest Results');
19define('CR_VERSION', '1.3.b');
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');
24define('CR_ADMIN', get_root_url().'admin.php?page=plugin-' . CR_DIR);
25define('CR_PUBLIC', make_index_url(array('section' => 'contests')) . '/');
26
27
28// +-----------------------------------------------------------------------+
29//                                      Triggers
30// +-----------------------------------------------------------------------+
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
33add_event_handler('loc_end_section_init', 'CR_section_init');                   // Paramètre URL
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
37
38
39// +-----------------------------------------------------------------------+
40//                                      Fonctions
41// +-----------------------------------------------------------------------+
42include(CR_PATH . 'include/functions.php');
43$conf['ContestResults'] = unserialize($conf['ContestResults']);
44
45// Gestion du menu
46if (script_basename() != 'admin') {
47        include(CR_PATH . 'include/cr_menubar.php');
48}
49
50// Chargement des fichiers de langue et de la config
51function CR_load_lang() {
52        load_language('plugin.lang', CR_PATH);
53}
54
55// Lien d'administration
56function CR_admin_menu($menu) {
57        array_push($menu, array(
58                'NAME' => CR_NAME,
59                'URL' => CR_ADMIN
60        ));
61        return $menu;
62}
63
64// Paramètre URL
65function CR_section_init() {
66    global $tokens, $page, $conf;
67       
68    if ($tokens[0] == 'contests') { // on est dans la section concours
69                $page['section'] = 'contests';
70                $page['title'] = l10n('Contests');
71               
72                if (isset($tokens[1]) AND !empty($tokens[1])) { // on est sur la page d'un concours
73                        $tokens[1] = explode('-', $tokens[1]);
74                       
75                        if (preg_match('#^([0-9]*)$#', $tokens[1][0])) { // is_int ne marche pas parce que le chiffre est stocké en (string)
76                                $page['contest'] = $tokens[1][0];
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_category_name', $contest_name);
80                                } else {
81                                        page_not_found(l10n('CR_notavailable'));
82                                }
83                        }
84                }
85        }
86}
87
88// Contenu de la page
89function CR_index() {
90    global $template, $page, $conf;
91
92    if (isset($page['section']) and $page['section'] == 'contests') {
93                if (isset($page['contest'])) { // on est sur la page d'un concours
94                        include(CR_PATH . 'include/cr_page.php');
95                } else { // on est dans la section concours
96                        include(CR_PATH . 'include/cr_main.php');
97                }
98        }
99}
100
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
112// Ajoute le commentaire sur la page image
113function CR_comment_picture() {
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.