1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: ContestResults |
---|
4 | Version: 1.2.a |
---|
5 | Description: Add contests management pages |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=439 |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $prefixeTable, $conf; |
---|
14 | |
---|
15 | // +-----------------------------------------------------------------------+ |
---|
16 | // Variables globales CR |
---|
17 | // +-----------------------------------------------------------------------+ |
---|
18 | define('CR_DIR' , basename(dirname(__FILE__))); |
---|
19 | define('CR_PATH' , PHPWG_PLUGINS_PATH . CR_DIR . '/'); |
---|
20 | define('CR_TABLE_1' , $prefixeTable . 'contests'); |
---|
21 | define('CR_TABLE_2' , $prefixeTable . 'contests_results'); |
---|
22 | define('CR_NAME' , 'ContestResults'); |
---|
23 | define('CR_VERSION', '1.2.a'); |
---|
24 | define('CR_ADMIN', PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CR_DIR . '/admin/admin.php'); |
---|
25 | define('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']); |
---|
29 | |
---|
30 | |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | // Triggers |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
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 |
---|
38 | if(CR_ED_STATE == 'active') add_event_handler('render_CR_content', 'get_user_language_desc'); // Textes multilangues |
---|
39 | |
---|
40 | |
---|
41 | // +-----------------------------------------------------------------------+ |
---|
42 | // Fonctions |
---|
43 | // +-----------------------------------------------------------------------+ |
---|
44 | // Gestion du menu |
---|
45 | include(CR_PATH . 'include/cr_menubar.php'); |
---|
46 | |
---|
47 | // Lien d'administration |
---|
48 | function CR_admin_menu($menu) { |
---|
49 | array_push($menu, array( |
---|
50 | 'NAME' => CR_NAME, |
---|
51 | 'URL' => CR_ADMIN |
---|
52 | )); |
---|
53 | return $menu; |
---|
54 | } |
---|
55 | |
---|
56 | // Paramètre URL |
---|
57 | function CR_section_init() { |
---|
58 | global $tokens, $page, $conf; |
---|
59 | |
---|
60 | load_language('plugin.lang', CR_PATH); |
---|
61 | include(CR_PATH . 'include/functions.php'); |
---|
62 | |
---|
63 | if ($tokens[0] == 'contests') { // on est dans la section concours |
---|
64 | $page['section'] = 'contests'; |
---|
65 | $page['title'] = l10n('Contests'); |
---|
66 | |
---|
67 | if (isset($tokens[1]) AND $tokens[1]) { // on est sur la page d'un concours |
---|
68 | $page['contest'] = explode('-', $tokens[1]); |
---|
69 | $page['contest'] = $page['contest'][0]; |
---|
70 | $page['title'] .= $conf['level_separator'] . trigger_event('render_CR_content', get_contest_name($page['contest'])); |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | // Contenu de la page |
---|
76 | function CR_index() { |
---|
77 | global $template, $page, $conf; |
---|
78 | |
---|
79 | if (isset($page['section']) and $page['section'] == 'contests') { |
---|
80 | if (isset($page['contest'])) { // on est sur la page d'un concours |
---|
81 | include(CR_PATH . 'include/cr_page.php'); |
---|
82 | } else { // on est dans la section concours |
---|
83 | include(CR_PATH . 'include/cr_main.php'); |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | // Ajoute le commentaire sur la page image |
---|
89 | function CR_comment_picture() { |
---|
90 | global $page, $template, $conf; |
---|
91 | include(CR_PATH . 'include/cr_comment_picture.php'); |
---|
92 | } |
---|
93 | |
---|
94 | ?> |
---|