[6768] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: ContestResults |
---|
[9572] | 4 | Version: 1.3 |
---|
[6768] | 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 | |
---|
[9200] | 13 | global $prefixeTable, $conf; |
---|
[6768] | 14 | |
---|
| 15 | // +-----------------------------------------------------------------------+ |
---|
[9200] | 16 | // Variables globales CR |
---|
[6768] | 17 | // +-----------------------------------------------------------------------+ |
---|
[9572] | 18 | define('CR_NAME' , 'Contest Results'); |
---|
| 19 | define('CR_VERSION', '1.3'); |
---|
[6768] | 20 | define('CR_DIR' , basename(dirname(__FILE__))); |
---|
| 21 | define('CR_PATH' , PHPWG_PLUGINS_PATH . CR_DIR . '/'); |
---|
| 22 | define('CR_TABLE_1' , $prefixeTable . 'contests'); |
---|
| 23 | define('CR_TABLE_2' , $prefixeTable . 'contests_results'); |
---|
[9200] | 24 | define('CR_ADMIN', PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CR_DIR . '/admin/admin.php'); |
---|
[6768] | 25 | define('CR_PUBLIC', make_index_url(array('section' => 'contests')) . '/'); |
---|
| 26 | |
---|
[6795] | 27 | $ED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';")); |
---|
[9200] | 28 | define('CR_ED_STATE', $ED['state']); |
---|
[6782] | 29 | |
---|
[6795] | 30 | |
---|
[6782] | 31 | // +-----------------------------------------------------------------------+ |
---|
[9200] | 32 | // Triggers |
---|
[6782] | 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 |
---|
[9200] | 38 | if(CR_ED_STATE == 'active') add_event_handler('render_CR_content', 'get_user_language_desc'); // Textes multilangues |
---|
[6782] | 39 | |
---|
| 40 | |
---|
[9200] | 41 | // +-----------------------------------------------------------------------+ |
---|
| 42 | // Fonctions |
---|
| 43 | // +-----------------------------------------------------------------------+ |
---|
[9572] | 44 | include(CR_PATH . 'include/functions.php'); |
---|
[6768] | 45 | // Gestion du menu |
---|
| 46 | include(CR_PATH . 'include/cr_menubar.php'); |
---|
| 47 | |
---|
| 48 | // Lien d'administration |
---|
[9200] | 49 | function CR_admin_menu($menu) { |
---|
[6768] | 50 | array_push($menu, array( |
---|
| 51 | 'NAME' => CR_NAME, |
---|
| 52 | 'URL' => CR_ADMIN |
---|
| 53 | )); |
---|
| 54 | return $menu; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | // Paramètre URL |
---|
[9200] | 58 | function CR_section_init() { |
---|
[6782] | 59 | global $tokens, $page, $conf; |
---|
[9200] | 60 | |
---|
| 61 | load_language('plugin.lang', CR_PATH); |
---|
[6782] | 62 | |
---|
[9200] | 63 | if ($tokens[0] == 'contests') { // on est dans la section concours |
---|
[6768] | 64 | $page['section'] = 'contests'; |
---|
| 65 | $page['title'] = l10n('Contests'); |
---|
[9200] | 66 | |
---|
[9572] | 67 | if (isset($tokens[1]) AND !empty($tokens[1])) { // on est sur la page d'un concours |
---|
| 68 | $tokens[1] = explode('-', $tokens[1]); |
---|
| 69 | if (preg_match('#^([0-9]*)$#', $tokens[1][0])) { // is_int ne marche pas parce que le chiffre est stocké en (string) |
---|
| 70 | $page['contest'] = $tokens[1][0]; |
---|
| 71 | $page['title'] .= $conf['level_separator'] . trigger_event('render_CR_content', get_contest_name($page['contest'])); |
---|
| 72 | } |
---|
[6768] | 73 | } |
---|
| 74 | } |
---|
| 75 | } |
---|
| 76 | |
---|
[9200] | 77 | // Contenu de la page |
---|
| 78 | function CR_index() { |
---|
[6782] | 79 | global $template, $page, $conf; |
---|
[9200] | 80 | |
---|
| 81 | if (isset($page['section']) and $page['section'] == 'contests') { |
---|
| 82 | if (isset($page['contest'])) { // on est sur la page d'un concours |
---|
[6768] | 83 | include(CR_PATH . 'include/cr_page.php'); |
---|
[9200] | 84 | } else { // on est dans la section concours |
---|
[6768] | 85 | include(CR_PATH . 'include/cr_main.php'); |
---|
[9200] | 86 | } |
---|
[6768] | 87 | } |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | // Ajoute le commentaire sur la page image |
---|
[9200] | 91 | function CR_comment_picture() { |
---|
[6768] | 92 | global $page, $template, $conf; |
---|
| 93 | include(CR_PATH . 'include/cr_comment_picture.php'); |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | ?> |
---|