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

Last change on this file since 6782 was 6782, checked in by mistic100, 14 years ago

Fixs some errors. Add results previews. Code revision.

File size: 2.9 KB
Line 
1<?php
2/*
3Plugin Name: ContestResults
4Version: 1.1
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;
14
15// +-----------------------------------------------------------------------+
16//                      Variables globales CR
17// +-----------------------------------------------------------------------+
18define('CR_DIR' , basename(dirname(__FILE__)));
19define('CR_PATH' , PHPWG_PLUGINS_PATH . CR_DIR . '/');
20define('CR_TABLE_1' , $prefixeTable . 'contests');
21define('CR_TABLE_2' , $prefixeTable . 'contests_results');
22define('CR_NAME' , 'ContestResults');
23define('CR_VERSION', '1.1');
24define('CR_ADMIN', PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . CR_DIR . '/admin/admin.php');
25define('CR_PUBLIC', make_index_url(array('section' => 'contests')) . '/');
26
27
28// +-----------------------------------------------------------------------+
29//                              Trigger
30// +-----------------------------------------------------------------------+
31add_event_handler('get_admin_plugin_menu_links', 'CR_admin_menu');      // Lien d'administration
32add_event_handler('loc_end_section_init', 'CR_section_init');           // Paramètre URL
33add_event_handler('loc_end_index', 'CR_index');                                         // Contenu du la page
34add_event_handler('loc_end_picture', 'CR_comment_picture', 10);         // Commentaire sur la page image
35
36$ED = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'ExtendedDescription';"));
37if($ED['state'] == 'active') add_event_handler('render_CR_content', 'get_user_language_desc');  // Textes multilangues
38
39// Langues
40load_language('plugin.lang', CR_PATH);
41
42// Gestion du menu
43include(CR_PATH . 'include/cr_menubar.php');
44
45// Lien d'administration
46function CR_admin_menu($menu){
47        array_push($menu, array(
48                'NAME' => CR_NAME,
49                'URL' => CR_ADMIN
50        ));
51        return $menu;
52}
53
54// Paramètre URL
55function CR_section_init(){
56    global $tokens, $page, $conf;
57        include(CR_PATH . 'include/functions.php');
58       
59    if($tokens[0] == 'contests'){
60                $page['section'] = 'contests';
61                $page['title'] = l10n('Contests');
62                if(isset($tokens[1]) AND $tokens[1]){
63                        $page['contest'] = explode('-', $tokens[1]);
64                        $page['contest'] = $page['contest'][0];
65                        $page['title'] .= $conf['level_separator'] . trigger_event('render_CR_content', get_contest_name($page['contest']));
66                }
67        }
68}
69
70// Contenu du la page
71function CR_index(){
72    global $template, $page, $conf;
73    if(isset($page['section']) and $page['section'] == 'contests'){
74                if(isset($page['contest']))
75                        include(CR_PATH . 'include/cr_page.php');
76                else
77                        include(CR_PATH . 'include/cr_main.php');
78        }
79}
80
81// Ajoute le commentaire sur la page image
82function CR_comment_picture(){
83        global $page, $template, $conf;
84        include(CR_PATH . 'include/cr_comment_picture.php'); 
85}
86
87?>
Note: See TracBrowser for help on using the repository browser.