1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: ContestResults |
---|
4 | Version: 1.1 |
---|
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; |
---|
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.1'); |
---|
24 | define('CR_ADMIN', PHPWG_ROOT_PATH . 'admin.php?page=plugin§ion=' . CR_DIR . '/admin/admin.php'); |
---|
25 | define('CR_PUBLIC', make_index_url(array('section' => 'contests')) . '/'); |
---|
26 | |
---|
27 | // Gestion du menu |
---|
28 | include(CR_PATH . 'include/cr_menubar.php'); |
---|
29 | |
---|
30 | // Lien d'administration |
---|
31 | function CR_admin_menu($menu){ |
---|
32 | array_push($menu, array( |
---|
33 | 'NAME' => CR_NAME, |
---|
34 | 'URL' => CR_ADMIN |
---|
35 | )); |
---|
36 | return $menu; |
---|
37 | } |
---|
38 | |
---|
39 | // Paramètre URL |
---|
40 | function CR_section_init(){ |
---|
41 | global $tokens, $page; |
---|
42 | load_language('plugin.lang', CR_PATH); |
---|
43 | if($tokens[0] == 'contests'){ |
---|
44 | $page['section'] = 'contests'; |
---|
45 | $page['title'] = l10n('Contests'); |
---|
46 | if(isset($tokens[1]) AND $tokens[1]){ |
---|
47 | $page['contest'] = explode('-', $tokens[1]); |
---|
48 | $page['contest'] = $page['contest'][0]; |
---|
49 | $page['title'] .= trigger_event('render_CR_content', get_contest_name($page['contest'])); |
---|
50 | } |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | // Contenu du la page |
---|
55 | function CR_index(){ |
---|
56 | global $template, $page, $conf, $menu; |
---|
57 | if(isset($page['section']) and $page['section'] == 'contests'){ |
---|
58 | include(CR_PATH . 'include/functions.php'); |
---|
59 | if(isset($page['contest'])) |
---|
60 | include(CR_PATH . 'include/cr_page.php'); |
---|
61 | else |
---|
62 | include(CR_PATH . 'include/cr_main.php'); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | // Ajoute le commentaire sur la page image |
---|
67 | function CR_comment_picture(){ |
---|
68 | global $page, $template, $conf; |
---|
69 | include(CR_PATH . 'include/functions.php'); |
---|
70 | include(CR_PATH . 'include/cr_comment_picture.php'); |
---|
71 | } |
---|
72 | |
---|
73 | function get_contest_name($contest){ |
---|
74 | global $conf; |
---|
75 | $query = pwg_query("SELECT name FROM " . CR_TABLE_1 . " WHERE id = " . $contest . ";"); |
---|
76 | if(pwg_db_num_rows($query)){ |
---|
77 | $result = pwg_db_fetch_assoc($query); |
---|
78 | return $conf['level_separator'] . $result['name']; |
---|
79 | }else{ |
---|
80 | return null; |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | add_event_handler('get_admin_plugin_menu_links', 'CR_admin_menu'); // Lien d'administration |
---|
85 | add_event_handler('loc_end_section_init', 'CR_section_init'); // Paramètre URL |
---|
86 | add_event_handler('loc_end_index', 'CR_index'); // Contenu du la page |
---|
87 | add_event_handler('loc_end_picture', 'CR_comment_picture', 10); // Ajoute le commentaire sur la page image |
---|
88 | add_event_handler('render_CR_content', 'get_user_language_desc'); // Textes multilangues |
---|
89 | |
---|
90 | ?> |
---|