Skip to content
Browse files

Began rebuilding on Zend Framework 2.

  • Loading branch information...
1 parent 452fb06 commit 395503bc2b190bb9ed9bd0d573a8bd55884e1153 @demiankatz committed Oct 29, 2012
Showing with 108 additions and 9,702 deletions.
  1. +15 −0 config/application.config.php
  2. +2 −0 config/autoload/.gitignore
  3. +8 −0 config/autoload/README.md
  4. +16 −0 config/autoload/global.php
  5. +16 −0 config/autoload/local.php.dist
  6. +2 −0 data/cache/.gitignore
  7. 0 { → data}/mysql.sql
  8. +0 −3 etc/php.ini
  9. +49 −0 init_autoloader.php
  10. +0 −282 lib/Gamebooks/AJAX/Edit/Approve.php
  11. +0 −85 lib/Gamebooks/AJAX/Edit/Base.php
  12. +0 −94 lib/Gamebooks/AJAX/Edit/Category.php
  13. +0 −92 lib/Gamebooks/AJAX/Edit/Country.php
  14. +0 −245 lib/Gamebooks/AJAX/Edit/File.php
  15. +0 −92 lib/Gamebooks/AJAX/Edit/FileType.php
  16. +0 −42 lib/Gamebooks/AJAX/Edit/Invalid.php
  17. +0 −941 lib/Gamebooks/AJAX/Edit/Item.php
  18. +0 −92 lib/Gamebooks/AJAX/Edit/Language.php
  19. +0 −250 lib/Gamebooks/AJAX/Edit/Link.php
  20. +0 −92 lib/Gamebooks/AJAX/Edit/LinkType.php
  21. +0 −92 lib/Gamebooks/AJAX/Edit/MaterialType.php
  22. +0 −107 lib/Gamebooks/AJAX/Edit/Note.php
  23. +0 −178 lib/Gamebooks/AJAX/Edit/People.php
  24. +0 −92 lib/Gamebooks/AJAX/Edit/Platform.php
  25. +0 −107 lib/Gamebooks/AJAX/Edit/Publisher.php
  26. +0 −92 lib/Gamebooks/AJAX/Edit/Role.php
  27. +0 −421 lib/Gamebooks/AJAX/Edit/Series.php
  28. +0 −94 lib/Gamebooks/CurrentUser.php
  29. +0 −117 lib/Gamebooks/GBDB.php
  30. +0 −197 lib/Gamebooks/ISBN.php
  31. +0 −45 lib/Gamebooks/Pages/Edit/approve.php
  32. +0 −37 lib/Gamebooks/Pages/Edit/categories.php
  33. +0 −37 lib/Gamebooks/Pages/Edit/countries.php
  34. +0 −63 lib/Gamebooks/Pages/Edit/edit_file.php
  35. +0 −89 lib/Gamebooks/Pages/Edit/edit_item.php
  36. +0 −63 lib/Gamebooks/Pages/Edit/edit_link.php
  37. +0 −51 lib/Gamebooks/Pages/Edit/edit_person.php
  38. +0 −79 lib/Gamebooks/Pages/Edit/edit_series.php
  39. +0 −40 lib/Gamebooks/Pages/Edit/files.php
  40. +0 −37 lib/Gamebooks/Pages/Edit/languages.php
  41. +0 −40 lib/Gamebooks/Pages/Edit/links.php
  42. +0 −40 lib/Gamebooks/Pages/Edit/login.php
  43. +0 −37 lib/Gamebooks/Pages/Edit/materials.php
  44. +0 −37 lib/Gamebooks/Pages/Edit/notes.php
  45. +0 −40 lib/Gamebooks/Pages/Edit/people.php
  46. +0 −37 lib/Gamebooks/Pages/Edit/platforms.php
  47. +0 −37 lib/Gamebooks/Pages/Edit/publishers.php
  48. +0 −37 lib/Gamebooks/Pages/Edit/series.php
  49. +0 −31 lib/Gamebooks/Pages/Edit/unauthorized.php
  50. +0 −103 lib/Gamebooks/Tables/Category.php
  51. +0 −103 lib/Gamebooks/Tables/Country.php
  52. +0 −202 lib/Gamebooks/Tables/File.php
  53. +0 −105 lib/Gamebooks/Tables/FileType.php
  54. +0 −1,181 lib/Gamebooks/Tables/Item.php
  55. +0 −103 lib/Gamebooks/Tables/Language.php
  56. +0 −202 lib/Gamebooks/Tables/Link.php
  57. +0 −105 lib/Gamebooks/Tables/LinkType.php
  58. +0 −129 lib/Gamebooks/Tables/MaterialType.php
  59. +0 −129 lib/Gamebooks/Tables/Note.php
  60. +0 −356 lib/Gamebooks/Tables/Person.php
  61. +0 −127 lib/Gamebooks/Tables/Platform.php
  62. +0 −129 lib/Gamebooks/Tables/Publisher.php
  63. +0 −103 lib/Gamebooks/Tables/Role.php
  64. +0 −226 lib/Gamebooks/Tables/Row.php
  65. +0 −617 lib/Gamebooks/Tables/Series.php
  66. +0 −205 lib/Gamebooks/Tables/User.php
  67. +0 −127 lib/Gamebooks/UI.php
  68. +0 −17 lib/Gamebooks/config.php
  69. +0 −34 lib/Gamebooks/util.php
  70. +0 −540 lib/Smarty/libs/Smarty.class.php
  71. +0 −136 lib/Smarty/libs/debug.tpl
  72. +0 −39 lib/Smarty/libs/plugins/block.php.php
Sorry, we could not display the entire diff because too many files (2,278) changed.
View
15 config/application.config.php
@@ -0,0 +1,15 @@
+<?php
+return array(
+ 'modules' => array(
+ 'GeebyDeeby',
+ ),
+ 'module_listener_options' => array(
+ 'config_glob_paths' => array(
+ 'config/autoload/{,*.}{global,local}.php',
+ ),
+ 'module_paths' => array(
+ './module',
+ './vendor',
+ ),
+ ),
+);
View
2 config/autoload/.gitignore
@@ -0,0 +1,2 @@
+local.php
+*.local.php
View
8 config/autoload/README.md
@@ -0,0 +1,8 @@
+About this directory:
+=====================
+
+By default, this application is configured to load all configs in
+`./config/autoload/{,*.}{global,local}.php`. Doing this provides a
+location for a developer to drop in configuration override files provided by
+modules, as well as cleanly provide individual, application-wide config files
+for things like database connections, etc.
View
16 config/autoload/global.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Global Configuration Override
+ *
+ * You can use this file for overriding configuration values from modules, etc.
+ * You would place values in here that are agnostic to the environment and not
+ * sensitive to security.
+ *
+ * @NOTE: In practice, this file will typically be INCLUDED in your source
+ * control, so do not include passwords or other sensitive information in this
+ * file.
+ */
+
+return array(
+ // ...
+);
View
16 config/autoload/local.php.dist
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Local Configuration Override
+ *
+ * This configuration override file is for overriding environment-specific and
+ * security-sensitive configuration information. Copy this file without the
+ * .dist extension at the end and populate values as needed.
+ *
+ * @NOTE: This file is ignored from Git by default with the .gitignore included
+ * in ZendSkeletonApplication. This is a good practice, as it prevents sensitive
+ * credentials from accidentally being committed into version control.
+ */
+
+return array(
+ // ...
+);
View
2 data/cache/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
View
0 mysql.sql → data/mysql.sql
File renamed without changes.
View
3 etc/php.ini
@@ -1,3 +0,0 @@
-mysql.default_socket = /var/lib/mysql/mysql.sock
-session.save_path = /home/gamebooks/tmp
-include_path = ".:/usr/local/share/pear:/usr/local/lib/php:/home/gamebooks/lib"
View
49 init_autoloader.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * This autoloading setup is really more complicated than it needs to be for most
+ * applications. The added complexity is simply to reduce the time it takes for
+ * new developers to be productive with a fresh skeleton. It allows autoloading
+ * to be correctly configured, regardless of the installation method and keeps
+ * the use of composer completely optional. This setup should work fine for
+ * most users, however, feel free to configure autoloading however you'd like.
+ */
+
+// Composer autoloading
+if (file_exists('vendor/autoload.php')) {
+ $loader = include 'vendor/autoload.php';
+}
+
+$zf2Path = false;
+
+if (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule
+ $zf2Path = getenv('ZF2_PATH');
+} elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value
+ $zf2Path = get_cfg_var('zf2_path');
+} elseif (is_dir('vendor/ZF2/library')) {
+ $zf2Path = 'vendor/ZF2/library';
+}
+
+if ($zf2Path) {
+ if (isset($loader)) {
+ $loader->add('Zend', $zf2Path);
+ } else {
+ include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
+ Zend\Loader\AutoloaderFactory::factory(array(
+ 'Zend\Loader\StandardAutoloader' => array(
+ 'autoregister_zf' => true
+ )
+ ));
+ }
+}
+
+if (!class_exists('Zend\Loader\AutoloaderFactory')) {
+ throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
+}
View
282 lib/Gamebooks/AJAX/Edit/Approve.php
@@ -1,282 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2010.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/AJAX/Edit/Base.php';
-require_once 'Gamebooks/Tables/User.php';
-require_once 'Gamebooks/Tables/Item.php';
-require_once 'Gamebooks/Tables/Series.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides approval-related AJAX functionality.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_Approve extends AJAX_Edit_Base
-{
- /**
- * Constructor
- *
- * @access public
- */
- public function __construct()
- {
- // Override default required permission:
- $this->requiredPermission = 'Approver';
- parent::__construct();
- }
-
- /**
- * Send an email to an approved user.
- *
- * @param string $address Email address.
- *
- * @return bool
- * @access private
- */
- private function _sendApprovalEmail($address)
- {
- // If we don't have an address, report success -- we'll skip the email step:
- $address = trim($address);
- if (empty($address)) {
- return true;
- }
- $subject = GAMEBOOKS_SITE_NAME . " Membership";
- $message = "I have just approved your membership to " . GAMEBOOKS_SITE_NAME . ".\n";
- $message .= "Thanks for signing up! You can now start building \n";
- $message .= "collections and submitting reviews. Please let me know\n";
- $message .= "if you have any questions or suggestions.\n\n";
- $message .= "- " . GAMEBOOKS_SITE_OWNER;
- $from = "From: " . GAMEBOOKS_SITE_EMAIL;
- return @mail($address, $subject, $message, $from);
- }
-
- /**
- * Accept a pending user.
- *
- * @access public
- */
- public function approveUser()
- {
- if (!isset($_REQUEST['id'])) {
- $this->jsonDie('Missing ID value.');
- }
-
- $id = intval($_REQUEST['id']);
- $person_id = intval($_REQUEST['person_id']);
- $user = new User($id);
- $row = $user->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading user data.');
- }
- if ($row['Person_ID'] != 0) {
- $this->jsonDie('User already approved.');
- }
- if ($person_id === 0) {
- $this->jsonDie('Invalid Person ID.');
- }
- $user->set('Person_ID', $person_id);
- $user->set('Username', $_REQUEST['username']);
- $user->set('Name', $_REQUEST['fullname']);
- $user->set('Address', $_REQUEST['address']);
- if (!$user->save()) {
- $this->jsonDie('Cannot approve user.');
- }
- if (!$this->_sendApprovalEmail($_REQUEST['address'])) {
- $this->jsonDie('Problem sending email; user approved anyway.');
- }
- $this->jsonReportSuccess();
- }
-
- /**
- * Reject a pending user.
- *
- * @access public
- */
- public function rejectUser()
- {
- if (!isset($_REQUEST['id'])) {
- $this->jsonDie('Missing ID value.');
- }
-
- $id = intval($_REQUEST['id']);
- $user = new User($id);
- $row = $user->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading user data.');
- }
- if ($row['Person_ID'] != 0) {
- $this->jsonDie('User already approved.');
- }
- if (!$user->delete()) {
- $this->jsonDie('Cannot reject user.');
- } else {
- $this->jsonReportSuccess();
- }
- }
-
- /**
- * Approve a pending item review.
- *
- * @access public
- */
- public function approveReview()
- {
- if (!isset($_REQUEST['user_id'])) {
- $this->jsonDie('Missing User ID value.');
- }
- if (!isset($_REQUEST['item_id'])) {
- $this->jsonDie('Missing Item ID value.');
- }
- if (!isset($_REQUEST['text']) || strlen(trim($_REQUEST['text'])) == 0) {
- $this->jsonDie('Text must not be blank.');
- }
-
- $user_id = intval($_REQUEST['user_id']);
- $user = new User($user_id);
- $row = $user->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading user data.');
- }
-
- $item_id = intval($_REQUEST['item_id']);
- $item = new Item($item_id);
- $row = $item->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading item data.');
- }
-
- if (!$item->approveReview($user_id, $_REQUEST['text'])) {
- $this->jsonDie('Cannot reject review.');
- } else {
- $this->jsonReportSuccess();
- }
- }
-
- /**
- * Reject a pending item review.
- *
- * @access public
- */
- public function rejectReview()
- {
- if (!isset($_REQUEST['user_id'])) {
- $this->jsonDie('Missing User ID value.');
- }
- if (!isset($_REQUEST['item_id'])) {
- $this->jsonDie('Missing Item ID value.');
- }
-
- $user_id = intval($_REQUEST['user_id']);
- $user = new User($user_id);
- $row = $user->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading user data.');
- }
-
- $item_id = intval($_REQUEST['item_id']);
- $item = new Item($item_id);
- $row = $item->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading item data.');
- }
-
- if (!$item->rejectReview($user_id)) {
- $this->jsonDie('Cannot reject review.');
- } else {
- $this->jsonReportSuccess();
- }
- }
-
- /**
- * Approve a pending series comment.
- *
- * @access public
- */
- public function approveComment()
- {
- if (!isset($_REQUEST['user_id'])) {
- $this->jsonDie('Missing User ID value.');
- }
- if (!isset($_REQUEST['series_id'])) {
- $this->jsonDie('Missing Series ID value.');
- }
- if (!isset($_REQUEST['text']) || strlen(trim($_REQUEST['text'])) == 0) {
- $this->jsonDie('Text must not be blank.');
- }
-
- $user_id = intval($_REQUEST['user_id']);
- $user = new User($user_id);
- $row = $user->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading user data.');
- }
-
- $series_id = intval($_REQUEST['series_id']);
- $series = new Series($series_id);
- $row = $series->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading series data.');
- }
-
- if (!$series->approveComment($user_id, $_REQUEST['text'])) {
- $this->jsonDie('Cannot reject comment.');
- } else {
- $this->jsonReportSuccess();
- }
- }
-
- /**
- * Reject a pending series comment.
- *
- * @access public
- */
- public function rejectComment()
- {
- if (!isset($_REQUEST['user_id'])) {
- $this->jsonDie('Missing User ID value.');
- }
- if (!isset($_REQUEST['series_id'])) {
- $this->jsonDie('Missing Series ID value.');
- }
-
- $user_id = intval($_REQUEST['user_id']);
- $user = new User($user_id);
- $row = $user->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading user data.');
- }
-
- $series_id = intval($_REQUEST['series_id']);
- $series = new Series($series_id);
- $row = $series->getRow();
- if (!$row) {
- $this->jsonDie('Problem loading series data.');
- }
-
- if (!$series->rejectComment($user_id)) {
- $this->jsonDie('Cannot reject comment.');
- } else {
- $this->jsonReportSuccess();
- }
- }
-}
-?>
View
85 lib/Gamebooks/AJAX/Edit/Base.php
@@ -1,85 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2009.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/UI.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides all AJAX functionality for the edit module.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_Base
-{
- protected $interface;
- protected $requiredPermission = 'Content_Editor';
-
- /**
- * Constructor
- *
- * @access public
- */
- public function __construct()
- {
- // Automatically fail if the user is not logged in or has no access rights:
- $user = CurrentUser::loggedIn();
- if (!$user) {
- $this->jsonDie('User must be logged in.');
- }
- if (!CurrentUser::hasPermission($this->requiredPermission)) {
- $this->jsonDie('Permission denied.');
- }
-
- // Activate the UI in case we need it.
- $this->interface = new UI('edit');
-
- // Call the specified method.
- $method = $_GET['method'];
- if (strtolower($method) != '__construct' && method_exists($this, $method)) {
- $this->$method();
- } else {
- $this->jsonDie('Invalid method');
- }
- }
-
- /**
- * Die with a JSON-encoded error message.
- *
- * @access public
- * @param string $msg The error message to send back.
- */
- public function jsonDie($msg)
- {
- $error = array('success' => false, 'msg' => $msg);
- die(json_encode($error));
- }
-
- /**
- * Die with a JSON success status.
- *
- * @access public
- */
- public function jsonReportSuccess()
- {
- die(json_encode(array('success' => true)));
- }
-}
-?>
View
94 lib/Gamebooks/AJAX/Edit/Category.php
@@ -1,94 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2009.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/AJAX/Edit/Base.php';
-require_once 'Gamebooks/Tables/Category.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides all AJAX functionality for the edit module.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_Category extends AJAX_Edit_Base
-{
- /**
- * Display "edit category" form.
- *
- * @access public
- */
- public function edit()
- {
- if (is_numeric($_GET['id'])) {
- $category = new Category($_GET['id']);
- $row = $category->getRow();
- if (!$row) {
- die('Cannot load category');
- }
- $this->interface->assign('category', $row);
- } else {
- $this->interface->assign('category', array('Category_ID' => 'NEW'));
- }
- $this->interface->showSubPage('category_edit.tpl');
- }
-
- /**
- * Display categories list.
- *
- * @access public
- */
- public function getList()
- {
- $categories = new CategoryList();
- $categories->assign($this->interface);
- $this->interface->showSubPage('category_list.tpl');
- }
-
- /**
- * Save changes to a category.
- *
- * @access public
- */
- public function save()
- {
- // Extract values from the POST fields:
- $id = $_POST['id'] == 'NEW' ? false : intval($_POST['id']);
- $name = trim($_POST['name']);
- $desc = trim($_POST['desc']);
-
- // Validate input:
- if (empty($name)) {
- $this->jsonDie('Category name cannot be blank.');
- }
-
- // Attempt to save changes:
- $category = new Category($id);
- $category->set('Category', $name);
- $category->set('Description', $desc);
- if (!$category->save()) {
- $this->jsonDie('Problem saving changes.');
- }
-
- // If we made it this far, we can report success:
- $this->jsonReportSuccess();
- }
-}
-?>
View
92 lib/Gamebooks/AJAX/Edit/Country.php
@@ -1,92 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2009.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/AJAX/Edit/Base.php';
-require_once 'Gamebooks/Tables/Country.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides all AJAX functionality for the edit module.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_Country extends AJAX_Edit_Base
-{
- /**
- * Display "edit country" form.
- *
- * @access public
- */
- public function edit()
- {
- if (is_numeric($_GET['id'])) {
- $country = new Country($_GET['id']);
- $row = $country->getRow();
- if (!$row) {
- die('Cannot load country');
- }
- $this->interface->assign('country', $row);
- } else {
- $this->interface->assign('country', array('Country_ID' => 'NEW', 'Country_Name' => ''));
- }
- $this->interface->showSubPage('country_edit.tpl');
- }
-
- /**
- * Display countries list.
- *
- * @access public
- */
- public function getList()
- {
- $countries = new CountryList();
- $countries->assign($this->interface);
- $this->interface->showSubPage('country_list.tpl');
- }
-
- /**
- * Save changes to a country.
- *
- * @access public
- */
- public function save()
- {
- // Extract values from the POST fields:
- $id = $_POST['id'] == 'NEW' ? false : intval($_POST['id']);
- $text = trim($_POST['country']);
-
- // Validate input:
- if (empty($text)) {
- $this->jsonDie('Country cannot be blank.');
- }
-
- // Attempt to save changes:
- $country = new Country($id);
- $country->set('Country_Name', $text);
- if (!$country->save()) {
- $this->jsonDie('Problem saving changes.');
- }
-
- // If we made it this far, we can report success:
- $this->jsonReportSuccess();
- }
-}
-?>
View
245 lib/Gamebooks/AJAX/Edit/File.php
@@ -1,245 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2010.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/AJAX/Edit/Base.php';
-require_once 'Gamebooks/Tables/File.php';
-require_once 'Gamebooks/Tables/FileType.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides all AJAX functionality for the edit module.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_File extends AJAX_Edit_Base
-{
- /**
- * Display "edit file" form.
- *
- * @access public
- */
- public function edit()
- {
- if (is_numeric($_GET['id'])) {
- $file = new File($_GET['id']);
- $row = $file->getRow();
- if (!$row) {
- die('Cannot load file');
- }
- $this->interface->assign('file', $row);
- } else {
- $this->interface->assign('file', array('File_ID' => 'NEW'));
- }
- $types = new FileTypeList();
- $types->assign($this->interface);
- $this->interface->showSubPage('file_edit.tpl');
- }
-
- /**
- * Display file list.
- *
- * @access public
- */
- public function getList()
- {
- $ll = new FileList();
- $ll->assign($this->interface);
- $this->interface->showSubPage('file_list.tpl');
- }
-
- /**
- * Get a list of related people.
- *
- * @access public
- */
- public function getPersonList()
- {
- require_once 'Gamebooks/Tables/Person.php';
- $people = new PersonList();
- $this->interface->assign('peopleFiles', $people->getByFile($_GET['id']));
- $this->interface->showSubPage('file_person_list.tpl');
- }
-
- /**
- * Get a list of related items.
- *
- * @access public
- */
- public function getItemList()
- {
- require_once 'Gamebooks/Tables/Item.php';
- $items = new ItemList();
- $this->interface->assign('itemFiles', $items->getByFile($_GET['id']));
- $this->interface->showSubPage('file_item_list.tpl');
- }
-
- /**
- * Get a list of related series.
- *
- * @access public
- */
- public function getSeriesList()
- {
- require_once 'Gamebooks/Tables/Series.php';
- $series = new SeriesList();
- $this->interface->assign('seriesFiles', $series->getByFile($_GET['id']));
- $this->interface->showSubPage('file_series_list.tpl');
- }
-
- /**
- * Associate an item.
- *
- * @access public
- */
- public function linkItem()
- {
- $file_id = intval($_POST['file_id']);
- $item_id = intval($_POST['item_id']);
- $file = new File($file_id);
- if ($file->linkItem($item_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing relationship.');
- }
- }
-
- /**
- * Remove an item association.
- *
- * @access public
- */
- public function unlinkItem()
- {
- $file_id = intval($_POST['file_id']);
- $item_id = intval($_POST['item_id']);
- $file = new File($file_id);
- if ($file->unlinkItem($item_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing relationship.');
- }
- }
-
- /**
- * Associate a series.
- *
- * @access public
- */
- public function linkSeries()
- {
- $file_id = intval($_POST['file_id']);
- $series_id = intval($_POST['series_id']);
- $file = new File($file_id);
- if ($file->linkSeries($series_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing relationship.');
- }
- }
-
- /**
- * Remove a series association.
- *
- * @access public
- */
- public function unlinkSeries()
- {
- $file_id = intval($_POST['file_id']);
- $series_id = intval($_POST['series_id']);
- $file = new File($file_id);
- if ($file->unlinkSeries($series_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing relationship.');
- }
- }
-
- /**
- * Associate a person.
- *
- * @access public
- */
- public function linkPerson()
- {
- $file_id = intval($_POST['file_id']);
- $person_id = intval($_POST['person_id']);
- $file = new File($file_id);
- if ($file->linkPerson($person_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing relationship.');
- }
- }
-
- /**
- * Remove a person association.
- *
- * @access public
- */
- public function unlinkPerson()
- {
- $file_id = intval($_POST['file_id']);
- $person_id = intval($_POST['person_id']);
- $file = new File($file_id);
- if ($file->unlinkPerson($person_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing relationship.');
- }
- }
-
- /**
- * Save changes to a file.
- *
- * @access public
- */
- public function save()
- {
- // Extract values from the POST fields:
- $id = $_POST['id'] == 'NEW' ? false : intval($_POST['id']);
- $name = trim($_POST['file_name']);
- $path = trim($_POST['path']);
- $desc = trim($_POST['desc']);
- $type_id = intval($_POST['type_id']);
-
- // Validate input:
- if (empty($name)) {
- $this->jsonDie('File name cannot be blank.');
- }
- if (empty($path)) {
- $this->jsonDie('File path cannot be blank.');
- }
-
- // Attempt to save changes:
- $file = new File($id);
- $file->set('File_Name', $name);
- $file->set('File_Path', $path);
- $file->set('Description', $desc);
- $file->set('File_Type_ID', $type_id);
- if (!$file->save()) {
- $this->jsonDie('Problem saving changes.');
- }
-
- // If we made it this far, we can report success:
- $this->jsonReportSuccess();
- }
-}
-?>
View
92 lib/Gamebooks/AJAX/Edit/FileType.php
@@ -1,92 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2009.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/AJAX/Edit/Base.php';
-require_once 'Gamebooks/Tables/FileType.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides all AJAX functionality for the edit module.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_FileType extends AJAX_Edit_Base
-{
- /**
- * Display "edit file type" form.
- *
- * @access public
- */
- public function edit()
- {
- if (is_numeric($_GET['id'])) {
- $lt = new FileType($_GET['id']);
- $row = $lt->getRow();
- if (!$row) {
- die('Cannot load file type');
- }
- $this->interface->assign('fileType', $row);
- } else {
- $this->interface->assign('fileType', array('File_Type_ID' => 'NEW', 'File_Type' => ''));
- }
- $this->interface->showSubPage('file_type_edit.tpl');
- }
-
- /**
- * Display file type list.
- *
- * @access public
- */
- public function getList()
- {
- $types = new FileTypeList();
- $types->assign($this->interface);
- $this->interface->showSubPage('file_type_list.tpl');
- }
-
- /**
- * Save changes to a file type.
- *
- * @access public
- */
- public function save()
- {
- // Extract values from the POST fields:
- $id = $_POST['id'] == 'NEW' ? false : intval($_POST['id']);
- $text = trim($_POST['fileType']);
-
- // Validate input:
- if (empty($text)) {
- $this->jsonDie('File type cannot be blank.');
- }
-
- // Attempt to save changes:
- $lt = new FileType($id);
- $lt->set('File_Type', $text);
- if (!$lt->save()) {
- $this->jsonDie('Problem saving changes.');
- }
-
- // If we made it this far, we can report success:
- $this->jsonReportSuccess();
- }
-}
-?>
View
42 lib/Gamebooks/AJAX/Edit/Invalid.php
@@ -1,42 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2010.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/AJAX/Edit/Base.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides an error message when an invalid edit module is specified.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_Invalid extends AJAX_Edit_Base
-{
- /**
- * Constructor
- *
- * @access public
- */
- public function __construct()
- {
- $this->jsonDie('Invalid module.');
- }
-}
-?>
View
941 lib/Gamebooks/AJAX/Edit/Item.php
@@ -1,941 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2009.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/AJAX/Edit/Base.php';
-require_once 'Gamebooks/Tables/Item.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides all AJAX functionality for the edit module.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_Item extends AJAX_Edit_Base
-{
- /**
- * Add a platform.
- *
- * @access public
- */
- public function addPlatform()
- {
- $item = intval($_POST['item_id']);
- $plat = trim($_POST['platform_id']);
-
- $item = new Item($item);
- if ($item->addPlatform($plat)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing platform.');
- }
- }
-
- /**
- * Remove a platform.
- *
- * @access public
- */
- public function deletePlatform()
- {
- $item = intval($_POST['item_id']);
- $plat = trim($_POST['platform_id']);
-
- $item = new Item($item);
- if ($item->deletePlatform($plat)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing platform.');
- }
- }
-
- /**
- * Add an alternate title.
- *
- * @access public
- */
- public function addAltTitle()
- {
- $item = intval($_POST['item_id']);
- $title = trim($_POST['title']);
- $noteID = is_numeric($_POST['note_id']) ? intval($_POST['note_id']) : null;
-
- $item = new Item($item);
- if ($item->addAltTitle($title, $noteID)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing alternate title.');
- }
- }
-
- /**
- * Remove an alternate title.
- *
- * @access public
- */
- public function deleteAltTitle()
- {
- $item = intval($_POST['item_id']);
- $rowID = intval($_POST['row_id']);
-
- $item = new Item($item);
- if ($item->deleteAltTitle($rowID)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing alternate title.');
- }
- }
-
- /**
- * Add an ISBN.
- *
- * @access public
- */
- public function addISBN()
- {
- $item = intval($_POST['item_id']);
- $isbn = trim($_POST['isbn']);
- $validator = new ISBN($isbn);
- if (!$validator->isValid()) {
- $this->jsonDie('Invalid ISBN -- cannot save.');
- }
- $noteID = is_numeric($_POST['note_id']) ? intval($_POST['note_id']) : null;
-
- $item = new Item($item);
- if ($item->addISBN($isbn, $noteID)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing ISBN.');
- }
- }
-
- /**
- * Remove an ISBN.
- *
- * @access public
- */
- public function deleteISBN()
- {
- $item = intval($_POST['item_id']);
- $rowID = intval($_POST['row_id']);
-
- $item = new Item($item);
- if ($item->deleteISBN($rowID)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing ISBN.');
- }
- }
-
- /**
- * Add a product code.
- *
- * @access public
- */
- public function addProductCode()
- {
- $item = intval($_POST['item_id']);
- $code = trim($_POST['code']);
- $noteID = is_numeric($_POST['note_id']) ? intval($_POST['note_id']) : null;
-
- $item = new Item($item);
- if ($item->addProductCode($code, $noteID)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing product code.');
- }
- }
-
- /**
- * Remove a product code.
- *
- * @access public
- */
- public function deleteProductCode()
- {
- $item = intval($_POST['item_id']);
- $rowID = intval($_POST['row_id']);
-
- $item = new Item($item);
- if ($item->deleteProductCode($rowID)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing product code.');
- }
- }
-
- /**
- * Add a release date.
- *
- * @access public
- */
- public function addDate()
- {
- $item = intval($_POST['item_id']);
- $year = intval($_POST['year']);
- $month = intval($_POST['month']);
- $day = intval($_POST['day']);
- $noteID = is_numeric($_POST['note_id']) ? intval($_POST['note_id']) : null;
-
- $item = new Item($item);
- if ($item->addDate($year, $month, $day, $noteID)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing date.');
- }
- }
-
- /**
- * Remove a release date.
- *
- * @access public
- */
- public function deleteDate()
- {
- $item = intval($_POST['item_id']);
- $year = intval($_POST['year']);
- $month = intval($_POST['month']);
- $day = intval($_POST['day']);
-
- $item = new Item($item);
- if ($item->deleteDate($year, $month, $day)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing date.');
- }
- }
-
- /**
- * Add a credit.
- *
- * @access public
- */
- public function addCredit()
- {
- $item = intval($_POST['item_id']);
- $person = intval($_POST['person_id']);
- $role = intval($_POST['role_id']);
- $noteID = is_numeric($_POST['note_id']) ? intval($_POST['note_id']) : null;
-
- $item = new Item($item);
- if ($item->addCredit($person, $role, $noteID, intval($_POST['pos']))) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing credit.');
- }
- }
-
- /**
- * Remove a credit.
- *
- * @access public
- */
- public function deleteCredit()
- {
- $item = intval($_POST['item_id']);
- $person = intval($_POST['person_id']);
- $role = intval($_POST['role_id']);
-
- $item = new Item($item);
- if ($item->deleteCredit($person, $role)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing credit.');
- }
- }
-
- /**
- * Renumber a credit.
- *
- * @access public
- */
- public function renumberCredit()
- {
- $item = intval($_POST['item_id']);
- $person = intval($_POST['person_id']);
- $role = intval($_POST['role_id']);
- $pos = intval($_POST['pos']);
-
- $item = new Item($item);
- if ($item->renumberCredit($person, $role, $pos)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem renumbering credit.');
- }
- }
-
- /**
- * Add an image.
- *
- * @access public
- */
- public function addImage()
- {
- $item = intval($_POST['item_id']);
- $image = $_POST['image'];
- $thumb = $_POST['thumb'];
- $noteID = is_numeric($_POST['note_id']) ? intval($_POST['note_id']) : null;
-
- $item = new Item($item);
- if ($item->addImage($image, $thumb, $noteID, intval($_POST['pos']))) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing image.');
- }
- }
-
- /**
- * Remove an image.
- *
- * @access public
- */
- public function deleteImage()
- {
- $item = intval($_POST['item_id']);
- $image = intval($_POST['image_id']);
-
- $item = new Item($item);
- if ($item->deleteImage($image)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing image.');
- }
- }
-
- /**
- * Renumber an image.
- *
- * @access public
- */
- public function renumberImage()
- {
- $item = intval($_POST['item_id']);
- $image = intval($_POST['image_id']);
- $pos = intval($_POST['pos']);
-
- $item = new Item($item);
- if ($item->renumberImage($image, $pos)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem renumbering image.');
- }
- }
-
- /**
- * Add an attachment.
- *
- * @access public
- */
- public function addAttachment()
- {
- $item = intval($_POST['item_id']);
- $attach = intval($_POST['attach_id']);
- $pos = intval($_POST['pos']);
-
- $item = new Item($item);
- if ($item->addAttachment($attach, $pos)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing attached item.');
- }
- }
-
- /**
- * Remove an attachment.
- *
- * @access public
- */
- public function deleteAttachment()
- {
- $item = intval($_POST['item_id']);
- $attach = intval($_POST['attach_id']);
-
- $item = new Item($item);
- if ($item->deleteAttachment($attach)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing attached item.');
- }
- }
-
- /**
- * Renumber an attached item.
- *
- * @access public
- */
- public function renumberAttachment()
- {
- $item = intval($_POST['item_id']);
- $attach = intval($_POST['attach_id']);
- $pos = intval($_POST['pos']);
-
- $item = new Item($item);
- if ($item->renumberAttachment($attach, $pos)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem renumbering attached item.');
- }
- }
-
- /**
- * Add a description.
- *
- * @access public
- */
- public function addDescription()
- {
- $item = intval($_POST['item_id']);
-
- $item = new Item($item);
- if ($item->addDescription($_POST['source'], $_POST['desc'])) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing description.');
- }
- }
-
- /**
- * Remove a description.
- *
- * @access public
- */
- public function deleteDescription()
- {
- $item = intval($_POST['item_id']);
-
- $item = new Item($item);
- if ($item->deleteDescription($_POST['source'])) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing description.');
- }
- }
-
- /**
- * Display "edit item" form.
- *
- * @access public
- */
- public function edit()
- {
- require_once 'Gamebooks/Tables/MaterialType.php';
-
- if (is_numeric($_GET['id'])) {
- $item = new Item($_GET['id']);
- $row = $item->getRow();
- if (!$row) {
- die('Cannot load item');
- }
- $this->interface->assign('item', $row);
- } else {
- // We'll default material type to the first entry in the table --
- // this is convenient for gamebooks.org, though perhaps it should
- // be made more flexible for other sites.
- $this->interface->assign('item',
- array('Item_ID' => 'NEW', 'Material_Type_ID' => 1));
- }
-
- // We'll need material information:
- $matList = new MaterialTypeList();
- $matList->assign($this->interface);
-
- $this->interface->showSubPage('item_edit.tpl');
- }
-
- /**
- * Display attached item list.
- *
- * @access public
- */
- public function getAttachments()
- {
- $items = new ItemList();
- $this->interface->assign('item_list',
- $items->getFromCollection($_GET['id']));
- $this->interface->showSubPage('item_item_list.tpl');
- }
-
- /**
- * Display item list.
- *
- * @access public
- */
- public function getList()
- {
- $items = new ItemList();
- $items->assign($this->interface);
- $this->interface->showSubPage('item_list.tpl');
- }
-
- /**
- * Get a list of alternate titles.
- *
- * @access public
- */
- public function getAltTitles()
- {
- if (is_numeric($_GET['id'])) {
- $item = new Item($_GET['id']);
- $this->interface->assign('item_alt_titles', $item->getAltTitles());
- }
- $this->interface->showSubPage('item_alt_titles.tpl');
- }
-
- /**
- * Get a list of ISBNs.
- *
- * @access public
- */
- public function getISBNs()
- {
- if (is_numeric($_GET['id'])) {
- $item = new Item($_GET['id']);
- $this->interface->assign('ISBNs', $item->getISBNs());
- }
- $this->interface->showSubPage('item_isbns.tpl');
- }
-
- /**
- * Get a list of product codes.
- *
- * @access public
- */
- public function getProductCodes()
- {
- if (is_numeric($_GET['id'])) {
- $item = new Item($_GET['id']);
- $this->interface->assign('productCodes', $item->getProductCodes());
- }
- $this->interface->showSubPage('item_codes.tpl');
- }
-
- /**
- * Get a list of platforms.
- *
- * @access public
- */
- public function getPlatforms()
- {
- if (is_numeric($_GET['id'])) {
- require_once 'Gamebooks/Tables/Platform.php';
-
- $plats = new PlatformList();
- $this->interface->assign('item_platforms',
- $plats->getListForItem($_GET['id']));
- }
- $this->interface->showSubPage('item_platforms.tpl');
- }
-
- /**
- * Display date list.
- *
- * @access public
- */
- public function getDates()
- {
- $item = intval($_GET['id']);
- $item = new Item($item);
- $this->interface->assign('releaseDates', $item->getDates());
- $this->interface->showSubPage('item_release_dates.tpl');
- }
-
- /**
- * Display credits.
- *
- * @access public
- */
- public function getCredits()
- {
- $item = intval($_GET['id']);
- $item = new Item($item);
- $this->interface->assign('credits', $item->getCredits());
- $this->interface->showSubPage('item_credits.tpl');
- }
-
- /**
- * Display images.
- *
- * @access public
- */
- public function getImages()
- {
- $item = intval($_GET['id']);
- $item = new Item($item);
- $this->interface->assign('images', $item->getImages());
- $this->interface->showSubPage('item_images.tpl');
- }
-
- /**
- * Display description list.
- *
- * @access public
- */
- public function getDescriptions()
- {
- $item = intval($_GET['id']);
- $item = new Item($item);
- $this->interface->assign('descriptions', $item->getDescriptions());
- $this->interface->showSubPage('item_descriptions.tpl');
- }
-
- /**
- * Display adaptations list.
- *
- * @access public
- */
- public function getAdaptations()
- {
- $list = new ItemList();
- $this->interface->assign('adaptedInto', $list->getAdaptations($_GET['id']));
- $this->interface->showSubPage('item_adapt_into.tpl');
- }
-
- /**
- * Display "adapted from" list.
- *
- * @access public
- */
- public function getAdaptedFrom()
- {
- $list = new ItemList();
- $this->interface->assign('adaptedFrom', $list->getAdaptedFrom($_GET['id']));
- $this->interface->showSubPage('item_adapt_from.tpl');
- }
-
- /**
- * Display translation list.
- *
- * @access public
- */
- public function getTranslations()
- {
- $list = new ItemList();
- $this->interface->assign('translatedInto', $list->getTranslations($_GET['id']));
- $this->interface->showSubPage('item_trans_into.tpl');
- }
-
- /**
- * Display item bibliography.
- *
- * @access public
- */
- public function getItemReferences()
- {
- $list = new ItemList();
- $this->interface->assign('itemBib', $list->getReferencedBy($_GET['id']));
- $this->interface->showSubPage('item_bib.tpl');
- }
-
- /**
- * Display series bibliography.
- *
- * @access public
- */
- public function getSeriesReferences()
- {
- require_once 'Gamebooks/Tables/Series.php';
- $list = new SeriesList();
- $this->interface->assign('seriesBib', $list->getReferencedBy($_GET['id']));
- $this->interface->showSubPage('series_bib.tpl');
- }
-
- /**
- * Display person bibliography.
- *
- * @access public
- */
- public function getPersonReferences()
- {
- require_once 'Gamebooks/Tables/Person.php';
- $list = new PersonList();
- $this->interface->assign('peopleBib', $list->getReferencedBy($_GET['id']));
- $this->interface->showSubPage('people_bib.tpl');
- }
-
- /**
- * Display "translated from" list.
- *
- * @access public
- */
- public function getTranslatedFrom()
- {
- $list = new ItemList();
- $this->interface->assign('translatedFrom', $list->getTranslatedFrom($_GET['id']));
- $this->interface->showSubPage('item_trans_from.tpl');
- }
-
- /**
- * Get list for autosuggest field
- *
- * @access public
- */
- public function suggest()
- {
- $list = new ItemList();
- $suggestions = $list->getSuggestions($_GET['q'], $_GET['limit']);
- foreach($suggestions as $s) {
- $line = "{$s['Item_ID']}: {$s['Item_Name']}\n";
- echo htmlspecialchars($line);
- }
- }
-
- /**
- * Save changes to an item.
- *
- * @access public
- */
- public function save()
- {
- // Extract values from the POST fields:
- $id = $_POST['id'] == 'NEW' ? false : intval($_POST['id']);
- $name = trim($_POST['name']);
- $length = trim($_POST['len']);
- $endings = trim($_POST['endings']);
- $errata = trim($_POST['errata']);
- $thanks = trim($_POST['thanks']);
- $material = trim($_POST['material']);
-
- // Validate input:
- if (empty($name)) {
- $this->jsonDie('Item name cannot be blank.');
- }
-
- // Attempt to save changes:
- $item = new Item($id);
- $item->set('Item_Name', $name);
- $item->set('Item_Length', $length);
- $item->set('Item_Endings', $endings);
- $item->set('Item_Errata', $errata);
- $item->set('Item_Thanks', $thanks);
- $item->set('Material_Type_ID', $material);
- if (!$item->save()) {
- $this->jsonDie('Problem saving changes.');
- }
-
- // Attach the item to a series if requested.
- if (isset($_POST['series_id'])) {
- require_once 'Gamebooks/Tables/Series.php';
- $series = new Series(intval($_POST['series_id']));
- $row = $item->getRow();
- if (!$row) {
- $this->jsonDie('Unable to read newly created item.');
- }
- if (!$series->addItem($row['Item_ID'])) {
- $this->jsonDie('Unable to attach new item to series.');
- }
- }
-
- // If we made it this far, we can report success:
- $this->jsonReportSuccess();
- }
-
- /**
- * Add an adaptation to an item.
- *
- * @access public
- */
- public function addAdaptation()
- {
- $source_id = intval($_POST['source_id']);
- $adapt_id = intval($_POST['adapt_id']);
-
- if ($source_id == $adapt_id) {
- $this->jsonDie('You cannot link an item to itself.');
- }
-
- $item = new Item($source_id);
- if ($item->addAdaptation($adapt_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing relationship.');
- }
- }
-
- /**
- * Remove an adaptation from an item.
- *
- * @access public
- */
- public function deleteAdaptation()
- {
- $source_id = intval($_POST['source_id']);
- $adapt_id = intval($_POST['adapt_id']);
-
- $item = new Item($source_id);
- if ($item->deleteAdaptation($adapt_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing relationship.');
- }
- }
-
- /**
- * Add a translation to an item.
- *
- * @access public
- */
- public function addTranslation()
- {
- $source_id = intval($_POST['source_id']);
- $trans_id = intval($_POST['trans_id']);
-
- if ($source_id == $trans_id) {
- $this->jsonDie('You cannot link an item to itself.');
- }
-
- $item = new Item($source_id);
- if ($item->addTranslation($trans_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing relationship.');
- }
- }
-
- /**
- * Remove a translation from an item.
- *
- * @access public
- */
- public function deleteTranslation()
- {
- $source_id = intval($_POST['source_id']);
- $trans_id = intval($_POST['trans_id']);
-
- $item = new Item($source_id);
- if ($item->deleteTranslation($trans_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing relationship.');
- }
- }
-
- /**
- * Add an item reference to an item.
- *
- * @access public
- */
- public function addItemReference()
- {
- $item_id = intval($_POST['item_id']);
- $bib_item_id = intval($_POST['bib_item_id']);
-
- if ($item_id == $bib_item_id) {
- $this->jsonDie('You cannot link an item to itself.');
- }
-
- $item = new Item($item_id);
- if ($item->addItemReference($bib_item_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing relationship.');
- }
- }
-
- /**
- * Remove an item reference from an item.
- *
- * @access public
- */
- public function deleteItemReference()
- {
- $item_id = intval($_POST['item_id']);
- $bib_item_id = intval($_POST['bib_item_id']);
-
- $item = new Item($item_id);
- if ($item->deleteItemReference($bib_item_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing relationship.');
- }
- }
-
- /**
- * Add a series reference to an item.
- *
- * @access public
- */
- public function addSeriesReference()
- {
- $item_id = intval($_POST['item_id']);
- $series_id = intval($_POST['series_id']);
-
- $item = new Item($item_id);
- if ($item->addSeriesReference($series_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing relationship.');
- }
- }
-
- /**
- * Remove a series reference from an item.
- *
- * @access public
- */
- public function deleteSeriesReference()
- {
- $item_id = intval($_POST['item_id']);
- $series_id = intval($_POST['series_id']);
-
- $item = new Item($item_id);
- if ($item->deleteSeriesReference($series_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing relationship.');
- }
- }
-
- /**
- * Add a person reference to an item.
- *
- * @access public
- */
- public function addPersonReference()
- {
- $item_id = intval($_POST['item_id']);
- $person_id = intval($_POST['person_id']);
-
- $item = new Item($item_id);
- if ($item->addPersonReference($person_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem storing relationship.');
- }
- }
-
- /**
- * Remove a person reference from an item.
- *
- * @access public
- */
- public function deletePersonReference()
- {
- $item_id = intval($_POST['item_id']);
- $person_id = intval($_POST['person_id']);
-
- $item = new Item($item_id);
- if ($item->deletePersonReference($person_id)) {
- $this->jsonReportSuccess();
- } else {
- $this->jsonDie('Problem removing relationship.');
- }
- }
-}
-?>
View
92 lib/Gamebooks/AJAX/Edit/Language.php
@@ -1,92 +0,0 @@
-<?php
-/**
- *
- * Copyright (c) Demian Katz 2009.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-require_once 'Gamebooks/AJAX/Edit/Base.php';
-require_once 'Gamebooks/Tables/Language.php';
-
-/**
- * Edit AJAX Support
- *
- * This class provides all AJAX functionality for the edit module.
- *
- * @author Demian Katz
- * @access public
- */
-class AJAX_Edit_Language extends AJAX_Edit_Base
-{
- /**
- * Display "edit language" form.
- *
- * @access public
- */
- public function edit()
- {
- if (is_numeric($_GET['id'])) {
- $language = new Language($_GET['id']);
- $row = $language->getRow();
- if (!$row) {
- die('Cannot load language');
- }
- $this->interface->assign('language', $row);
- } else {
- $this->interface->assign('language', array('Language_ID' => 'NEW', 'Language_Name' => ''));
- }
- $this->interface->showSubPage('language_edit.tpl');
- }
-
- /**
- * Display languages list.
- *
- * @access public
- */
- public function getList()
- {
- $languages = new LanguageList();
- $languages->assign($this->interface);