Permalink
Browse files

Split up some code into form.inc.php and menu.inc.php.

  • Loading branch information...
1 parent 9ba9848 commit bda4d9363e8cc0c2a418a70500e4c3c87395f054 @dmuth committed Jan 16, 2011
Showing with 131 additions and 108 deletions.
  1. +4 −108 anthrocon_dealers.module
  2. +92 −0 form.inc.php
  3. +35 −0 menu.inc.php
View
@@ -3,34 +3,13 @@
* Anthrocon dealers module.
*
* This module holds dealer and Dealer Room staff-specific functionality.
+*
+* @author Douglas Muth <http://www.dmuth.org/>
*/
-/**
-* Return an array of permissions for this module.
-*/
-function anthrocon_dealers_perm() {
- $retval = array("view dealer table sales");
- return($retval);
-}
-
-
-/**
-* Return an array of menu options.
-*/
-function anthrocon_dealers_menu() {
-
- $retval = array();
-
- $retval["admin/dealer"] = array(
- "title" => "View Dealer Tables",
- "page callback" => "anthrocon_dealers_main",
- "access arguments" => array("view dealer table sales"),
- );
-
- return($retval);
-
-} // End of anthrocon_dealers_menu()
+include_once("form.inc.php");
+include_once("menu.inc.php");
/**
@@ -52,89 +31,6 @@ function anthrocon_dealers_main() {
} // End of anthrocon_dealers_main()
-/**
-* Generate our form for viewing/downloading dealer tables.
-*/
-function anthrocon_dealers_form() {
-
- $retval = array();
-
- $retval["tables"] = array(
- "#type" => "fieldset",
- "#title" => t("Dealer Tables"),
- );
-
- $retval["tables"]["download"] = array(
- "#type" => "submit",
- "#value" => t("Download This List"),
- );
-
- $retval["tables"]["browser_dump"] = array(
- "#type" => "checkbox",
- "#title" => t("Dump to browser instead. (for testing/debugging purposes)"),
- );
-
- return($retval);
-
-} // End of anthrocon_dealers_form()
-
-
-/**
-* Our form submission handler.
-*/
-function anthrocon_dealers_form_submit($form, $form_state) {
-
- //print "<pre>"; print_r($form_state); print "</pre>"; // Debugging
-
- //
- // What button did we click?
- // We'll need this if we add more buttons later.
- //
- $op = $form_state["values"]["op"];
- $dump = $form_state["values"]["browser_dump"];
-
- //
- // Retrieve our current tables sold.
- //
- $rows = anthrocon_dealers_get_tables_sold();
-
- //
- // Get tab-delimited text
- //
- $text = anthrocon_dealers_get_tables_sold_text($rows);
-
-
- if (!$dump) {
- //
- // Start a download in the user's browser
- //
- $header = "Content-Type: octet/stream";
- drupal_set_header($header);
-
- $filename = "dealer_orders.txt";
- $header = "Content-Disposition: attachment; filename=\"$filename\"";
- drupal_set_header($header);
-
- } else {
- //
- // We're dumping to the browser. Formatting time!
- //
- print "<pre>";
-
- }
-
- //
- // And print up our text!
- //
- print $text;
-
- //
- // Not sure if I have to put an exit() call here or not.
- // For now, this seems to be working without any issues in Google Chrome.
- //
-
-} // End of anthrocon_dealers_submit()
-
/**
* Get current dealer tables that have been sold.
View
@@ -0,0 +1,92 @@
+<?php
+/**
+* Hold code that relates to forms.
+*
+* @author Douglas Muth <http://www.dmuth.org/>
+*/
+
+
+/**
+* Generate our form for viewing/downloading dealer tables.
+*/
+function anthrocon_dealers_form() {
+
+ $retval = array();
+
+ $retval["tables"] = array(
+ "#type" => "fieldset",
+ "#title" => t("Dealer Tables"),
+ );
+
+ $retval["tables"]["download"] = array(
+ "#type" => "submit",
+ "#value" => t("Download This List"),
+ );
+
+ $retval["tables"]["browser_dump"] = array(
+ "#type" => "checkbox",
+ "#title" => t("Dump to browser instead. (for testing/debugging purposes)"),
+ );
+
+ return($retval);
+
+} // End of anthrocon_dealers_form()
+
+
+/**
+* Our form submission handler.
+*/
+function anthrocon_dealers_form_submit($form, $form_state) {
+
+ //print "<pre>"; print_r($form_state); print "</pre>"; // Debugging
+
+ //
+ // What button did we click?
+ // We'll need this if we add more buttons later.
+ //
+ $op = $form_state["values"]["op"];
+ $dump = $form_state["values"]["browser_dump"];
+
+ //
+ // Retrieve our current tables sold.
+ //
+ $rows = anthrocon_dealers_get_tables_sold();
+
+ //
+ // Get tab-delimited text
+ //
+ $text = anthrocon_dealers_get_tables_sold_text($rows);
+
+
+ if (!$dump) {
+ //
+ // Start a download in the user's browser
+ //
+ $header = "Content-Type: octet/stream";
+ drupal_set_header($header);
+
+ $filename = "dealer_orders.txt";
+ $header = "Content-Disposition: attachment; filename=\"$filename\"";
+ drupal_set_header($header);
+
+ } else {
+ //
+ // We're dumping to the browser. Formatting time!
+ //
+ print "<pre>";
+
+ }
+
+ //
+ // And print up our text!
+ //
+ print $text;
+
+ //
+ // Not sure if I have to put an exit() call here or not.
+ // For now, this seems to be working without any issues in Google Chrome.
+ //
+
+} // End of anthrocon_dealers_submit()
+
+
View
@@ -0,0 +1,35 @@
+<?php
+/**
+* Functions relating to our menu and permissions.
+*
+* @author Douglas Muth <http://www.dmuth.org/>
+*/
+
+/**
+* Return an array of permissions for this module.
+*/
+function anthrocon_dealers_perm() {
+ $retval = array("view dealer table sales");
+ return($retval);
+}
+
+
+/**
+* Return an array of menu options.
+*/
+function anthrocon_dealers_menu() {
+
+ $retval = array();
+
+ $retval["admin/dealer"] = array(
+ "title" => "View Dealer Tables",
+ "page callback" => "anthrocon_dealers_main",
+ "access arguments" => array("view dealer table sales"),
+ );
+
+ return($retval);
+
+} // End of anthrocon_dealers_menu()
+
+
+

0 comments on commit bda4d93

Please sign in to comment.