Annotation of db/prgsrc/drupal/modules/chgk_db/chgk_db.module, revision 1.5
1.1 roma7 1: <?php
2: /**********************
3: *
4: * Tournament
5: *
6: *********************/
7:
8: require_once(dirname(__FILE__)."/classes/DbPackage.class.php");
9:
10:
11: /**
12: * Implementation of hook_menu().
13: */
14: function chgk_db_menu() {
15: $items['print'] = array(
16: 'path' => 'print',
17: 'page callback' => 'chgk_db_print',
1.2 roma7 18: 'page arguments' => array(1),
1.1 roma7 19: 'access callback' => "chgk_db_access",
20: );
1.4 roma7 21: $items['fb2'] = array(
22: 'path' => 'fb2',
23: 'page callback' => 'chgk_db_fb2',
24: 'page arguments' => array(1),
25: 'access callback' => "chgk_db_access",
26: );
1.1 roma7 27: return $items;
28: }
29:
30: /**
31: * Implementation of hook_theme().
32: */
33: function chgk_db_theme() {
34: $items['chgk_db_print'] = array(
35: 'arguments' => array(
36: 'title' =>'',
37: 'content' => ''
38: ),
39: 'template'=>'templates/chgk_db_print'
40: );
41: $items['chgk_db_field'] = array(
42: 'arguments' => array(
43: 'field' => NULL
44: )
45: );
46: $items['chgk_db_tour'] = array(
47: 'arguments' => array(
1.3 roma7 48: 'tour'=>NULL,
49: 'alone' => TRUE
1.1 roma7 50: ),
51: 'template'=>'templates/chgk_db_tour'
52: );
53:
1.4 roma7 54: $items['chgk_db_tour_fb2'] = array(
55: 'arguments' => array(
56: 'tour'=>NULL,
57: 'alone' => TRUE
58: ),
59: 'template'=>'templates/chgk_db_tour_fb2'
60: );
61:
62:
1.1 roma7 63: $items['chgk_db_question'] = array(
64: 'arguments' => array(
1.2 roma7 65: 'question'=>NULL
1.1 roma7 66: ),
67: 'template'=>'templates/chgk_db_question'
1.2 roma7 68: );
69:
1.4 roma7 70: $items['chgk_db_question_fb2'] = array(
71: 'arguments' => array(
72: 'question'=>NULL
73: ),
74: 'template'=>'templates/chgk_db_question_fb2'
75: );
76:
77:
1.3 roma7 78: $items['chgk_db_jeopardy_question'] = array(
79: 'arguments' => array(
80: 'question'=>NULL
81: ),
82: 'template'=>'templates/chgk_db_jeopardy_question'
83: );
84:
1.2 roma7 85: $items['chgk_db_champ_full'] = array(
86: 'arguments' => array(
87: 'tour' => NULL
88: ),
89: 'template'=>'templates/chgk_db_champ_full'
90: );
1.4 roma7 91: $items['chgk_db_fb2'] = array(
92: 'arguments' => array('tournament'=>''),
93: 'template' => 'templates/chgk_db_fb2'
94: );
1.1 roma7 95: return $items;
96: }
97:
98: function chgk_db_print($string) {
1.2 roma7 99: $tournament = DbPackage::newFromDb($string);
100: print $tournament->getPrintVersion();
1.1 roma7 101: }
102:
1.4 roma7 103: function chgk_db_fb2($string) {
104: $tournament = DbPackage::newFromDb($string);
105: $tournament->getAll();
106: $xml = theme('chgk_db_fb2', $tournament);
1.5 ! roma7 107: $filename = "$string.fb2";
! 108: $zipname = $filename.".zip";
! 109:
! 110: header("Content-Type: application/octet-stream\n");
! 111: header("Content-Type: application/force-download\n");
! 112: header("Content-Type: application/download\n");
! 113: header("Content-Type: application/x-zip-compressed; name=$filename\n");
! 114: header("Content-Disposition: attachment; filename=$filename.zip \n");
! 115: chdir(file_directory_temp());
! 116: $f = fopen ($filename, "w");
! 117: fputs($f, $xml);
! 118: fclose($f);
! 119: system("zip $zipname $filename>/dev/null");
! 120: print passthru("cat $zipname");
1.4 roma7 121: exit;
122: #print $tournament->getFb2();
123: }
124:
1.1 roma7 125:
126: function chgk_db_access() {
127: return TRUE;
128: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>