Page MenuHomeCode

No OneTemporary

This document is not UTF8. It was detected as ISO-8859-1 (Latin 1) and converted to UTF8 for display.
diff --git a/controllers/explore.php b/controllers/explore.php
--- a/controllers/explore.php
+++ b/controllers/explore.php
@@ -1,51 +1,51 @@
<?php
/**
* Explore current location
-
+ *
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* This is a redirect controller to call the relevant controller,
* according to the location.
*
* It handles /explore URL
*
* @package Zed
* @subpackage Controllers
- * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
- * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*/
//
// Determines the kind of content user wants to explore
//
$explore_controller = '';
if (file_exists(STORIES_DIR . '/' . $CurrentPerso->location_global . '.xml')) {
$explore_controller = 'story';
}
//
// No relevant controller found
//
if ($explore_controller == '') {
message_die(GENERAL_ERROR, "<p>Congratulations! You've just found a shiny new place.</p><p>You've so the opportunity to define what this place should be, writing a story, preparing a puzzle or some images.</p><p>If you're interested, contact Dereckson.</p>", "Exploration error");
}
//
// Calls relevant controller
//
include($explore_controller . '.php');
?>
\ No newline at end of file
diff --git a/controllers/footer.php b/controllers/footer.php
--- a/controllers/footer.php
+++ b/controllers/footer.php
@@ -1,54 +1,54 @@
<?php
/**
* Footer
-
+ *
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* This is a redirect controller to call the relevant controller,
* according to the location.
*
* It handles and prints the footer elements (tutorial, SmartLine, html footer)
*
* @package Zed
* @subpackage Controllers
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @copyright 2010 Sébastien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*/
if (!defined('NO_FOOTER_EXTRA')) {
///
/// Tutorials div
///
if ($CurrentPerso->flags['hypership.reached'] < 1 && $controller != 'explore') {
if (!DOJO) $smarty->display('tutorial/dojo.tpl');
lang_load("tutorials.conf", "ReachHypership");
$smarty->assign('controller', $controller);
$smarty->display('tutorial/hypership_reach.tpl');
}
///
/// Footer options
///
$smarty->assign('MultiPerso', isset($_SESSION['UserWithSeveralPersos']) && $_SESSION['UserWithSeveralPersos']);
$smarty->assign('SmartLinePrint', (string)$CurrentPerso->get_flag('site.smartline.show') != "0");
$smarty->assign('SmartLineFormMethod', $CurrentPerso->get_flag('site.smartline.method'));
}
///
/// HTML output
///
lang_load('footer.conf');
$smarty->display('footer.tpl');
?>
\ No newline at end of file
diff --git a/controllers/header.php b/controllers/header.php
--- a/controllers/header.php
+++ b/controllers/header.php
@@ -1,63 +1,63 @@
<?php
/**
* Header
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* This controller handle the header (MOTD, html header)
*
* @package Zed
* @subpackage Controllers
- * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
- * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*
* @todo cache MOTD fragments (sql performance)
*/
//
// MOTD
//
//TODO: this is a potentially very intensive SQL query
$sql = 'SELECT p.perso_nickname as username, p.perso_name as name, m.motd_text FROM ' . TABLE_PERSOS . ' p, ' . TABLE_MOTD . ' m WHERE p.perso_id = m.perso_id ORDER BY rand() LIMIT 1';
if (!$result = $db->sql_query($sql)) message_die(SQL_ERROR, "Can't query MOTD", '', __LINE__, __FILE__, $sql);
$row = $db->sql_fetchrow($result);
$smarty->assign('WALL_TEXT', $row['motd_text']);
$smarty->assign('WALL_USER', $row['name']);
$smarty->assign('WALL_USER_URL', get_url('who', $row['username']));
//
// HTML output
//
//Defines DOJO if needed, and assigns DOJO/DIJIT smarty variables
if (!defined('DOJO')) {
/**
* Determines if the dojo library have or not been loaded
*
* If true, there's a code like <script src="js/dojo/dojo/dojo.js"><script>
* in the <head> block of the code.
*/
define('DOJO', defined('DIJIT'));
}
if (defined('DIJIT')) {$smarty->assign('DIJIT', true);
$smarty->assign('DOJO', DOJO);
//Prints the template
$smarty->display('header.tpl');
/**
* This constant indicates the header have been printed
*/
define('HEADER_PRINTED', true);
?>
\ No newline at end of file
diff --git a/controllers/home.php b/controllers/home.php
--- a/controllers/home.php
+++ b/controllers/home.php
@@ -1,103 +1,103 @@
-<?php
-
-/**
- * Homepage
-
- * Zed. The immensity of stars. The HyperShip. The people.
- *
- * (c) 2010, Dereckson, some rights reserved.
- * Released under BSD license.
- *
- * This controller handle the / URL.
- *
- * It prints:
- * a scene rendering from where the perso is ;
- * the home.tpl view ;
- * the messages, using the messages.tpl view.
- *
- * The controller also handle messages, marking them red and allowing their
- * suppression: /?action=msg_delete&id=8 to delete the message #8.
- *
- * @package Zed
- * @subpackage Controllers
- * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
- * @copyright 2010 Sébastien Santoro aka Dereckson
- * @license http://www.opensource.org/licenses/bsd-license.php BSD
- * @version 0.1
- * @link http://scherzo.dereckson.be/doc/zed
- * @link http://zed.dereckson.be/
- * @filesource
- *
- * @todo The homepage requires Dojo but Dojo loading here is currently a kludge, as dojo is required by hypership .tpl scene. We should create an optionnal .meta xml file format to set this kind of options.
- */
-
-//
-// Gets and manage messages
-//
-
-require_once('includes/objects/message.php');
-
-//Deletes a message if user have clicked the X
-if ($_GET['action'] == 'msg_delete') {
- //Deletes message $_GET['id']
- $id = $_GET['id'];
- $messageToDelete = new Message($id);
- if ($messageToDelete->to != $CurrentPerso->id) {
- //Not one of user message
- $smarty->assign('WAP', lang_get('NotYourMessage'));
- } elseif ($messageToDelete->flag == 2) {
- //Already deleted
- $smarty->assign('WAP', lang_get('MessageAlreadyDeleted'));
- } else {
- $messageToDelete->delete();
- $smarty->assign('NOTIFY', lang_get('MessageDeleted'));
- }
-}
-
-//Gets messages
-$newMessagesCount = 0;
-$messages = Message::get_messages($CurrentPerso->id, true, $newMessagesCount);
-if ($newMessagesCount > 0) {
- $smarty->assign('NOTIFY', sprintf(lang_get("NewMessages"), $newMessagesCount, s($newMessagesCount)));
-}
-
-//Gets scene
-require_once("includes/geo/scene.php");
-$scene = new GeoScene($CurrentPerso->location);
-$smarty->assign('SCENE', $scene);
-
-//
-// HTML output
-//
-
-//Serves header
-
-//TODO: Dojo loading here is currently a kludge, as dojo is required by
-//hypership .tpl scene. We should create an optionnal .meta xml file format
-//to set this kind of options
-if (!defined('DIJIT')) {
- /**
- * This constant indicates we need to load the Dijit (and so Dojo) library.
- */
- define('DIJIT', true);
-}
-
-$smarty->assign('PAGE_TITLE', lang_get('Welcome'));
-include('header.php');
-
-//Serves content
-if (!$scene->lastError)
- $scene->render();
-
-$smarty->display('home.tpl');
-
-if ($messages) {
- $smarty->assign('MESSAGES', $messages);
- $smarty->display('messages.tpl');
-}
-
-//Serves footer
-$smarty->assign("screen", "Home console");
-include('footer.php');
-
+<?php
+
+/**
+ * Homepage
+
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This controller handle the / URL.
+ *
+ * It prints:
+ * a scene rendering from where the perso is ;
+ * the home.tpl view ;
+ * the messages, using the messages.tpl view.
+ *
+ * The controller also handle messages, marking them red and allowing their
+ * suppression: /?action=msg_delete&id=8 to delete the message #8.
+ *
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
+ *
+ * @todo The homepage requires Dojo but Dojo loading here is currently a kludge, as dojo is required by hypership .tpl scene. We should create an optionnal .meta xml file format to set this kind of options.
+ */
+
+//
+// Gets and manage messages
+//
+
+require_once('includes/objects/message.php');
+
+//Deletes a message if user have clicked the X
+if ($_GET['action'] == 'msg_delete') {
+ //Deletes message $_GET['id']
+ $id = $_GET['id'];
+ $messageToDelete = new Message($id);
+ if ($messageToDelete->to != $CurrentPerso->id) {
+ //Not one of user message
+ $smarty->assign('WAP', lang_get('NotYourMessage'));
+ } elseif ($messageToDelete->flag == 2) {
+ //Already deleted
+ $smarty->assign('WAP', lang_get('MessageAlreadyDeleted'));
+ } else {
+ $messageToDelete->delete();
+ $smarty->assign('NOTIFY', lang_get('MessageDeleted'));
+ }
+}
+
+//Gets messages
+$newMessagesCount = 0;
+$messages = Message::get_messages($CurrentPerso->id, true, $newMessagesCount);
+if ($newMessagesCount > 0) {
+ $smarty->assign('NOTIFY', sprintf(lang_get("NewMessages"), $newMessagesCount, s($newMessagesCount)));
+}
+
+//Gets scene
+require_once("includes/geo/scene.php");
+$scene = new GeoScene($CurrentPerso->location);
+$smarty->assign('SCENE', $scene);
+
+//
+// HTML output
+//
+
+//Serves header
+
+//TODO: Dojo loading here is currently a kludge, as dojo is required by
+//hypership .tpl scene. We should create an optionnal .meta xml file format
+//to set this kind of options
+if (!defined('DIJIT')) {
+ /**
+ * This constant indicates we need to load the Dijit (and so Dojo) library.
+ */
+ define('DIJIT', true);
+}
+
+$smarty->assign('PAGE_TITLE', lang_get('Welcome'));
+include('header.php');
+
+//Serves content
+if (!$scene->lastError)
+ $scene->render();
+
+$smarty->display('home.tpl');
+
+if ($messages) {
+ $smarty->assign('MESSAGES', $messages);
+ $smarty->display('messages.tpl');
+}
+
+//Serves footer
+$smarty->assign("screen", "Home console");
+include('footer.php');
+
?>
\ No newline at end of file
diff --git a/controllers/persorequest.php b/controllers/persorequest.php
--- a/controllers/persorequest.php
+++ b/controllers/persorequest.php
@@ -1,182 +1,182 @@
<?php
/**
- * Persos requests
+ * Persos' requests
* Zed. The immensity of stars. The HyperShip. The people.
*
* (c) 2010, Dereckson, some rights reserved.
* Released under BSD license.
*
* This controller handle the /requests URL.
*
* It can also be called with the requests SmartLine command.
*
* It allows to prints a content page.
*
* This controllers uses the persorequests.tpl view.
*
* This controller offer AJAX capabilities but degrades gracefully in JS.
*
* @package Zed
* @subpackage Controllers
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @copyright 2010 Sébastien Santoro aka Dereckson
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version 0.1
* @link http://scherzo.dereckson.be/doc/zed
* @link http://zed.dereckson.be/
* @filesource
*
* @todo move the get_ship function to a Ship::from_code method
* @todo Document the request system in the API documentation
*/
///
/// Helper class and method
///
/**
* A perso request
*/
class PersoRequest {
public $message;
public $requestFlag;
public $flag;
public $store = 'perso';
public $value_allow = 1;
public $value_deny = 0;
/**
* Initialies a perso request
*
* @param string $requestFlag the request's flag
* @param string $message the message to print
* @param string $message the flag to set, according the request approve/denial
*/
function __construct ($requestFlag, $message, $flag) {
$this->requestFlag = $requestFlag;
$this->message = $message;
$this->flag = $flag;
}
}
/**
* Gets ship from specified S00001 code
*
* @param string $ship_code the ship code (e.g. S00001)
* @return Ship the Ship class instance
*/
function get_ship ($ship_code) {
require_once('includes/objects/ship.php');
static $ships;
$ship_id = substr($ship_code, 1);
if (!$ships[$ship_id]) $ships[$ship_id] = new Ship($ship_id);
return $ships[$ship_id];
}
/**
* Gets request allow URL
*
* @param PersoRequest $request the perso request to confirm
* @return string the URL to allow the request
*/
function get_request_allow_url ($request) {
return get_request_url($request->requestFlag, $request->store, $request->flag, $request->value_allow);
}
/**
* Gets request deny URL
*
* @param PersoRequest $request the perso request to confirm
* @return string the URL to deny the request
*/
function get_request_deny_url ($request) {
return get_request_url($request->requestFlag, $request->store, $request->flag, $request->value_deny);
}
/**
* Gets request URL
*
* @param string $store 'perso' or 'registry'
* @param string $key the perso flag or registry key
* @param string $value the value to store
* @return the request URL
*/
function get_request_url ($requestFlag, $store, $key, $value) {
global $Config;
$hash = md5($_SESSION['ID'] . $Config['SecretKey'] . $requestFlag . $store . $key . $value);
return "$Config[DoURL]/perso_request/$requestFlag/$store/$key/$value/$hash";
}
///
/// Get requests
///
//Loads perso request language file
lang_load('persorequest.conf');
//The array request will be passed to Smarty and will contain PersoRequest items.
$requests = array();
foreach ($CurrentPerso->flags as $flag => $value) {
if ($value && substr($flag, 0, 8) == "request.") {
if (string_starts_with($flag, 'request.api.ship.auth.')) {
//Gets ship
$ship_code = substr($flag, 22);
$ship = get_ship($ship_code);
//Adds request
$message = sprintf(lang_get('RequestShipAPIAuthenticate'), $ship->name);
$requests[] = new PersoRequest($flag, $message, substr($flag, 8));
} elseif (string_starts_with($flag, 'request.api.ship.session.')) {
//Gets ship
$ship_code = substr($flag, 25, 6);
$ship = get_ship($ship_code);
//Adds request
$message = sprintf(lang_get('RequestShipAPISessionConfirm'), $ship->name);
$request = new PersoRequest($flag, $message, substr($flag, 8));
$request->value_allow = $CurrentPerso->id;
$request->value_deny = -1;
$request->store = 'registry';
$requests[] = $request;
} else {
message_die(GENERAL_ERROR, "Unknown request flag: $flag. Please report this bug.");
}
}
}
///
/// Requests handling
///
if (count($requests) == 0) {
//If site.requests flag is at 1 but we don't have request, ignore processing
$CurrentPerso->set_flag('site.requests', 0);
//We don't die, so next controller takes relay
} else {
///
/// HTML output
///
//Serves header
define('DOJO', true);
$smarty->assign('PAGE_TITLE', lang_get('PersoRequests'));
include('header.php');
//Serves content
$smarty->assign('requests', $requests);
$smarty->display('persorequests.tpl');
//Serves footer
$smarty->assign("screen", "Perso requests");
include('footer.php');
//Dies
exit;
}
?>
\ No newline at end of file
diff --git a/controllers/profile.php b/controllers/profile.php
--- a/controllers/profile.php
+++ b/controllers/profile.php
@@ -1,308 +1,346 @@
<?php
-/*
- * Zed
- * (c) 2010, Dereckson, some rights reserved
- * Released under BSD license
+
+/**
+ * User profile
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This is a controller allowing user profile view and edit.
+ *
+ * It handles the following URLs:
+ * /who/<perso nickname> views the nickname's profile,
+ * /who/random views a random profile,
+ * /who/edit/profile edits its profileq
+ * /who/edit/account edits its account (disabled on Zed, cf. settings),
+ * /who/edit/photo(s) manages its profile's photos,
+ * /who/edit/photo/edit/<photo id> edits a photo properties,
+ * /who/edit/photo/delete/<photo id> deletes a photo,
+ * /who/edit/photo/avatar/<photo id> promotes a photo to avatar.
*
- * This code is maintained in // with Azhàr
+ * The following views are used:
+ * profile.tpl,
+ * profile_edit.tpl,
+ * user_account.tpl,
+ * profile_photo.tpl,
+ * profile_photo_edit.tpl.
+ *
+ * The following models are used:
+ * Profile,
+ * ProfilePhoto,
+ * ProfileComment.
*
- * User profile
+ * The view profile_tags.tpl is indirectly used by the Profile model.
+ *
+ * This code is maintained in // with Azhàr.
+ *
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
*/
//Loads language file
lang_load('profile.conf');
//Gets perso nickname from URL
$who = $url[1];
switch ($who) {
case 'edit':
$mode = 'edit';
$who = $CurrentPerso->nickname;
break;
case 'random':
$mode = 'view';
$who = $db->sql_query_express("SELECT perso_id FROM " . TABLE_PROFILES . " ORDER BY rand() LIMIT 1");
break;
default:
$mode = 'view';
}
if (!$who) {
message_die(GENERAL_ERROR, "Who?", "URL error");
}
//Libs
require_once('includes/objects/profile.php');
require_once('includes/objects/profilecomment.php');
require_once('includes/objects/profilephoto.php');
//Gets perso information
require_once('includes/objects/perso.php');
$perso = Perso::get($who);
if ($perso->lastError) {
message_die(GENERAL_ERROR, $perso->lastError, "Error");
}
$smarty->assign('perso', $perso);
//Gets profile
$profile = new Profile($perso->id);
//Handles form
if ($_POST['EditProfile']) {
$profile->load_from_form();
$profile->updated = time();
$profile->save_to_database();
$mode = 'view';
} elseif ($_POST['UserAccount']) {
$smarty->assign('WAP', "This form have been deprecated. You can write instead settings in the SmartLine");
} elseif ($_POST['message_type'] == 'private_message') {
//Sends a message
require_once('includes/objects/message.php');
$msg = new Message();
$msg->from = $CurrentPerso->id;
$msg->to = $perso->id;
$msg->text = $_POST['message'];
$msg->send();
if ($msg->from == $msg->to) {
$smarty->assign('NOTIFY', lang_get('MessageSentSelf'));
} else {
$smarty->assign('NOTIFY', lang_get('MessageSent'));
}
} elseif ($_POST['message_type'] == 'profile_comment') {
//New profile comment
$comment = new ProfileComment();
$comment->author = $CurrentPerso->id;
$comment->perso_id = $perso->id;
$comment->text = $_POST['message'];
$comment->publish();
$smarty->assign('NOTIFY', lang_get('CommentPublished'));
} elseif ($_FILES['photo']) {
#We've a file !
$hash = md5(microtime() . serialize($_FILES));
$extension = get_extension($_FILES['photo']['name']);
$filename = $CurrentPerso->id . '_' . $hash . '.' . $extension;
#We ignore $_FILES[photo][error] 4, this means no file has been uploaded
#(so user doesn't want upload a new file)
#See http:/www.php.net/features.file-upload and http://www.php.net/manual/en/features.file-upload.errors.php about common errors
#Not valid before PHP 4.2.0
switch ($_FILES['photo']['error']) {
case 0:
#There is no error, the file uploaded with success.
if (!move_uploaded_file($_FILES['photo']['tmp_name'], PHOTOS_DIR . '/' . $filename)) {
$errors[] = "Upload successful, but error saving it.";
} else {
//Attaches the picture to the profile
$photo = new ProfilePhoto();
$photo->name = $filename;
$photo->perso_id = $CurrentPerso->id;
$photo->description = $_POST['description'];
if ($photo->avatar) $photo->promote_to_avatar();
$photo->save_to_database();
//Generates thumbnail
if (!$photo->generate_thumbnail()) {
$smarty->assign('WAP', "Error generating thumbnail.");
}
$smarty->assign('NOTIFY', lang_get('PhotoUploaded'));
$mode = 'view';
}
break;
case 1:
$errors[] = "The file is too large.";
break;
#TODO : more explicit error messages
default:
$errors[] = "Unknown error (#" . $_FILES['photo']['error'] . ")";
break;
}
if (count($errors)) {
$smarty->assign('WAP', join($errors, '<br />'));
}
} elseif ($_POST['id']) {
//Edits photo properties
$photo = new ProfilePhoto($_POST['id']);
if ($photo->lastError) {
$smarty->assign('WAP', $photo->lastError);
$mode = 'view';
} elseif ($photo->perso_id != $CurrentPerso->id) {
$smarty->assign('WAP', lang_get('NotYourPic'));
$mode = 'view';
} else {
//OK
$wereAvatar = $photo->avatar;
$photo->load_from_form();
if (!$wereAvatar && $photo->avatar) {
//Promote to avatar
$photo->promote_to_avatar();
}
$photo->save_to_database();
}
}
//Prepares output
if ($profile->text) {
//Profile
$smarty->assign('PROFILE_TEXT', $profile->text);
$smarty->assign('PROFILE_FIXEDWIDTH', $profile->fixedwidth);
}
if ($mode == 'view') {
require_once('includes/objects/profilephoto.php');
//Self profile?
$self = $CurrentPerso->id == $profile->perso_id;
//Gets profiles comments, photos, tags
$comments = ProfileComment::get_comments($profile->perso_id);
$photos = ProfilePhoto::get_photos($profile->perso_id);
$tags = $profile->get_cached_tags();
//Records timestamp, to be able to track new comments
if ($self) $CurrentPerso->set_flag('profile.lastvisit', time());
//Template
$smarty->assign('PROFILE_COMMENTS', $comments);
$smarty->assign('PROFILE_SELF', $self);
if ($tags) $smarty->assign('PROFILE_TAGS', $tags);
$smarty->assign('USERNAME', $perso->username);
$smarty->assign('NAME', $perso->name ? $perso->name : $perso->nickname);
$template = 'profile.tpl';
} elseif ($mode == 'edit') {
switch ($url[2]) {
case 'profile':
$smarty->assign('USERNAME', $perso->name);
$smarty->assign('DIJIT', true);
$css[] = THEME . '/forms.css';
$template = 'profile_edit.tpl';
break;
case 'account':
$smarty->assign('user', $CurrentUser);
$smarty->assign('DIJIT', true);
$css[] = THEME . '/forms.css';
$template = 'user_account.tpl';
break;
case '':
$smarty->assign('NOTIFY', "What do you want to edit ? Append /profile, /account or /photos to the URL");
break;
case 'photo':
case 'photos':
$smarty->assign('USERNAME', $perso->name);
switch ($action = $url[3]) {
case '':
//Nothing to do
break;
case 'delete':
//Deletes a picture
if (!$id = $url[4]) {
$smarty->assign('WAP', "URL error. Parameter missing: picture id.");
} else {
$photo = new ProfilePhoto($id);
if ($photo->lastError) {
//Probably an non existent id (e.g. double F5, photo already deleted)
$smarty->assign('WAP', $photo->lastError);
} elseif ($photo->perso_id != $CurrentPerso->id) {
$smarty->assign('WAP', lang_get('NotYourPic'));
} else {
//OK we can delete it
$photo->delete();
$smarty->assign('NOTIFY', lang_get('PictureDeleted'));
}
}
break;
case 'edit':
if (!$id = $url[4]) {
$smarty->assign('WAP', "URL error. Parameter missing: picture id.");
} else {
$photo = new ProfilePhoto($id);
if ($photo->lastError) {
//Probably an non existent id (e.g. double F5, photo already deleted)
$smarty->assign('WAP', $photo->lastError);
} elseif ($photo->perso_id != $CurrentPerso->id) {
$smarty->assign('WAP', lang_get('NotYourPic'));
} else {
//Photo information edit form
$smarty->assign('photo', $photo);
$template = 'profile_photo_edit.tpl';
}
}
break;
case 'avatar':
//Promotes a picture to avatar
if (!$id = $url[4]) {
$smarty->assign('WAP', "URL error. Parameter missing: picture id.");
} else {
$photo = new ProfilePhoto($id);
if ($photo->lastError) {
$smarty->assign('WAP', $photo->lastError);
} elseif ($photo->perso_id != $CurrentPerso->id) {
$smarty->assign('WAP', lang_get('NotYourPic'));
} else {
//OK, promote it to avatar
$photo->promote_to_avatar();
$photo->save_to_database();
$smarty->assign('NOTIFY', lang_get('PromotedToAvatar'));
}
}
break;
default:
$smarty->assign('WAP', "Unknown URL. To delete a picture it's /delete/<picture id>. To edit it /edit/<picture id>");
break;
}
if (!$template) {
$photos = ProfilePhoto::get_photos($profile->perso_id);
if (!$smarty->_tpl_vars['NOTIFY'])
$smarty->assign('NOTIFY', "Your feedback is valued. Report any bug or suggestion on the graffiti wall.");
$template = 'profile_photo.tpl';
}
break;
default:
$smarty->assign('WAP', "URL error. You can use /edit with profile, account or photos.");
break;
}
}
//
// HTML output
//
//Photos
if (count($photos) || $photo) {
$smarty->assign('URL_PICS', PHOTOS_URL);
$css[] = 'lightbox.css';
$smarty->assign('PAGE_JS', array('prototype.js', 'effects.js', 'lightbox.js'));
$smarty->assign('PICS', $photos);
}
//Serves header
$css[] = THEME . "/profile.css";
$smarty->assign('PAGE_CSS', $css);
$smarty->assign('PAGE_TITLE', $perso->name);
include('header.php');
//Serves content
if ($template) $smarty->display($template);
//Serves footer
include('footer.php');
?>
\ No newline at end of file
diff --git a/controllers/raw.php b/controllers/raw.php
--- a/controllers/raw.php
+++ b/controllers/raw.php
@@ -1,25 +1,63 @@
<?php
-/*
- * Zed
- * (c) 2010, Dereckson, some rights reserved
- * Released under BSD license
- *
- * Raw text or HTML content
+/**
+ * Raw text ou HTML content
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This is a controller printing HTML content as is.
+ *
+ * It prints the raw.tpl view containing two variables:
+ * - PAGE_TITLE (optionnal), to add a H1 page title
+ * - CONTENT (should be defined), the content to print
+ *
+ * To use it:
+ * <code>
+ * //(1) Assign your HTML content in CONTENT smarty variable:
+ * $content = "Hello World!";
+ * $smarty->assign('CONTENT', $content);
+ *
+ * //(2) Call the raw controller
+ * include('controllers/raw.php');
+ *
+ * //That's all folk.
+ * </code>
+ *
+ * To add a title:
+ * <code>
+ * $content = "Hello World";
+ * $title = "Raw sample";
+ *
+ * $smarty->assign('PAGE_TITLE', $title);
+ * $smarty->assign('CONTENT', $content);
+ * </code>
+ *
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
*/
//
// HTML output
//
//Serves header
-$smarty->assign('PAGE_TITLE', $title);
+$smarty->assign('PAGE_TITLE', $title);à
include('header.php');
//Serves content
$smarty->display('raw.tpl');
//Serves footer
include('footer.php');
?>
\ No newline at end of file
diff --git a/controllers/request.php b/controllers/request.php
--- a/controllers/request.php
+++ b/controllers/request.php
@@ -1,51 +1,70 @@
<?php
-/*
- * Zed
- * (c) 2010, Dereckson, some rights reserved
- * Released under BSD license
+/**
+ * Requests controller
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This controller allows the perso to send requests to the HyperShip, to a
+ * specified ship, or to a specify port requiring PTA.
+ * It handle all the forms output, handling and notifications
+ * for queries from users to users.
*
- * Request
+ * It handles /request URL, is called from tutoriald.
*
- * This controllers handle all the forms output, handling and notifications
- * for queries from users to users.
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
+ *
+ * @todo complete requests implementation
+ * @todo call this controller from Ship fly out if port is a PTA
+ * @todo call this controller from HyperShip entrance pero request
*/
//
// Prepare fields
//
if (count($url) < 3) message_die(HACK_ERROR, "Expected URL: /request/code_to/code_object");
$request->to = $url[1];
$request->obj = $url[2];
//Checks if the request template exists
if (!file_exists(sprintf("skins/%s/requests/%s.tpl", THEME, $request->obj))) {
message_die(HACK_ERROR, "$url[2] isn't a valid request object code");
}
switch ($request->obj) {
case "aid.reach":
if ($request->to == "B00001")
$request->title = "Shuttle pick up request";
break;
}
//
// HTML output
//
//Serves header
define('DIJIT', true);
$smarty->assign('PAGE_TITLE', lang_get('Request'));
include('header.php');
//Serves content
$smarty->assign('request', $request);
$smarty->display("requests/$request->obj.tpl");
//Serves footer
$smarty->assign("screen", "$url[2] request");
include('footer.php');
?>
\ No newline at end of file
diff --git a/controllers/settings.php b/controllers/settings.php
--- a/controllers/settings.php
+++ b/controllers/settings.php
@@ -1,83 +1,97 @@
-<?php
-
-/*
- * Zed
- * (c) 2010, Dereckson, some rights reserved
- * Released under BSD license
- *
- * Settings
- *
- * TODO: replace the on the fly preferences.xml code generation by a
- * cached code generation
- *
- * TODO: reduce the number of for loops in this controller
- */
-
-//
-// Loads settings
-//
-
-lang_load('settings.conf');
-
-include('includes/settings/settings.php');
-$settings = new Settings('includes/settings/preferences.xml');
-
-//Selects relevant settings page
-$pages = $settings->pages;
-if (count($url) > 1) {
- //From url: /settings/account -> page account
- if (array_key_exists($url[1], $settings->pages)) {
- $page = $pages[$url[1]];
- } else {
- message_die(GENERAL_ERROR, "/settings/$url[1] isn't a valid setting page");
- }
-} else {
- //Default page
- $page = array_shift($pages);
-}
-
-//Pages links
-foreach ($settings->pages as $tmppage) {
- $pagesLinks[$tmppage->id] = $tmppage->title;
-}
-
-//
-// Handles form
-//
-if (array_key_exists('settings_page', $_POST)) {
- if ($_POST['settings_page'] == $page->id) {
- //Updates settings
- $errors = array();
- $page->handle_form($errors);
- if (count($errors)) {
- //Prints error message
- $smarty->assign('WAP', implode('<br />', $errors));
- }
- } else {
- //The field settings.page isn't the current page
- //Prints an HACK_ERROR to avoid to save properties with the same names.
- $id_current = $page->id;
- $id_toSave = $_POST['settings_page'];
- message_die(HACK_ERROR, "You're on /settings/$id_current but you want to update /settings/$id_toSave");
- }
-}
-
-//
-// HTML output
-//
-
-//Serves header
-define('DIJIT', true);
-$title = lang_get('Settings');
-$smarty->assign('PAGE_TITLE', $title);
-include('header.php');
-
-//Serves settings page;
-$smarty->assign('page', $page);
-$smarty->assign('pages', $pagesLinks);
-$smarty->display('settings_page.tpl');
-
-//Servers footer
-include('footer.php');
-
+<?php
+
+/**
+ * Settings
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This controller allows user to set its preferences, according the Settings
+ * classes and the preferences.xml document.
+ *
+ * It handles the /settings URL.
+ *
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
+ *
+ * @todo replace the on the fly preferences.xml code generation by a cached code generation
+ * @todo reduce the number of for loops in this controller
+ */
+
+//
+// Loads settings
+//
+
+lang_load('settings.conf');
+
+include('includes/settings/settings.php');
+$settings = new Settings('includes/settings/preferences.xml');
+
+//Selects relevant settings page
+$pages = $settings->pages;
+if (count($url) > 1) {
+ //From url: /settings/account -> page account
+ if (array_key_exists($url[1], $settings->pages)) {
+ $page = $pages[$url[1]];
+ } else {
+ message_die(GENERAL_ERROR, "/settings/$url[1] isn't a valid setting page");
+ }
+} else {
+ //Default page
+ $page = array_shift($pages);
+}
+
+//Pages links
+foreach ($settings->pages as $tmppage) {
+ $pagesLinks[$tmppage->id] = $tmppage->title;
+}
+
+//
+// Handles form
+//
+if (array_key_exists('settings_page', $_POST)) {
+ if ($_POST['settings_page'] == $page->id) {
+ //Updates settings
+ $errors = array();
+ $page->handle_form($errors);
+ if (count($errors)) {
+ //Prints error message
+ $smarty->assign('WAP', implode('<br />', $errors));
+ }
+ } else {
+ //The field settings.page isn't the current page
+ //Prints an HACK_ERROR to avoid to save properties with the same names.
+ $id_current = $page->id;
+ $id_toSave = $_POST['settings_page'];
+ message_die(HACK_ERROR, "You're on /settings/$id_current but you want to update /settings/$id_toSave");
+ }
+}
+
+//
+// HTML output
+//
+
+//Serves header
+define('DIJIT', true);
+$title = lang_get('Settings');
+$smarty->assign('PAGE_TITLE', $title);
+include('header.php');
+
+//Serves settings page;
+$smarty->assign('page', $page);
+$smarty->assign('pages', $pagesLinks);
+$smarty->display('settings_page.tpl');
+
+//Servers footer
+include('footer.php');
+
?>
\ No newline at end of file
diff --git a/controllers/ship.php b/controllers/ship.php
--- a/controllers/ship.php
+++ b/controllers/ship.php
@@ -1,71 +1,91 @@
<?php
-/*
- * Zed
- * (c) 2010, Dereckson, some rights reserved
- * Released under BSD license
+/**
+ * Ship
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This controller handle the /ship URL
+ *
+ * It allows the user to let personal notes about the ship.
*
- * Raw text or HTML content
+ * It uses the Ship model and the ship.tpl view
+ *
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
+ *
+ * @todo prints information indicating if we're or not in the ship
+ * @todo implement a console to control the ship
*/
//
// Load library and language file
//
require_once('includes/objects/ship.php');
lang_load('ships.conf');
//
// Ship information
//
//Gets ship from URL
if (count($url) < 2) {
//No parameter, gets ship perso is onboard
if (!$code = $CurrentPerso->location->ship_code) {
message_die(GENERAL_ERROR, "/ship/ must be followed by valid ship code.<br />/ship alone only works when you're aboard a ship", "URL error");
}
$code = 'S' . $code;
} else {
//Code have been specified
$code = $url[1];
if (!preg_match("/^S[0-9]{5}$/", $code)) {
message_die(GENERAL_ERROR, "/ship/ must be followed by valid ship code", "URL error");
}
}
//Gets ship information
$ship = Ship::get($code);
//Gets perso note about this ship
$note = $CurrentPerso->get_note($code);
//Determines the spatial relation between perso and ship
//dieprint_r($CurrentPerso->location->ship_code);
//
// Actions handling
//
if ($_REQUEST['action'] == 'ship.setnote' && $_REQUEST['note'] != $note) {
//Updates note content
$CurrentPerso->set_note($code, $_REQUEST['note']);
$note = $_REQUEST['note'];
}
//
// HTML output
//
//Serves header
$smarty->assign('PAGE_TITLE', $ship->name);
include('header.php');
//Serves content
$smarty->assign('note', $note);
$smarty->assign('ship', $ship);
$smarty->display('ship.tpl');
//Serves footer
include('footer.php');
?>
\ No newline at end of file
diff --git a/controllers/story.php b/controllers/story.php
--- a/controllers/story.php
+++ b/controllers/story.php
@@ -1,111 +1,131 @@
<?php
-/*
- * Zed
- * (c) 2010, Dereckson, some rights reserved
- * Released under BSD license
+/**
+ * Story
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This controller is a storytelling engine allowing to explore a place like
+ * in fighting fantasy gamebooks / livres dont vous êtes le héros.
+ *
+ * This controller is called by the explore controller and handles /explore URL.
*
- * Explore current location
- * For now, it's a storytelling engine like in livres dont vous êtes le héro
+ * It uses the Story classes, the story.tpl view and content/stories/*.xml as
+ * stories content datasource.
+ *
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
+ *
+ * @todo Create a separate release from Zed based on this controller and the Story library.
+ * @todo Add code to handle actions defined in choices like inventory management
*/
//
// Helper method
//
-/*
+/**
* Gets section to print to the user
* @param Story the story the section to get (yep, we could've global $story)
* @return StorySection the section, or null if not found
*/
function get_section ($story) {
global $url, $smarty, $CurrentPerso;
//If the URL contains a choice guid, use it as story progress source
//e.g. /explore/143f7200-766b-7b8b-e3f4-9fbfeeaeb5dd
if (count($url) > 1) {
$guid = $url[1];
//Ensures we've a StorySection object in the Story variable
if (!array_key_exists('StoryChoices', $_SESSION)) {
$smarty->assign('WAP', lang_get('ExpiredStorySession'));
} else {
//Gets StoryChoice (creating a dummy section to use get_choice method)
$section = new StorySection("void");
$section->choices = $_SESSION['StoryChoices'];
if (!$choice = $section->get_choice($guid)) {
$smarty->assign('WAP', lang_get('InvalidStoryGUID'));
}
//TODO: add code here to handle actions defined in choices
//e.g. item added to inventory
//Gets section
if ($section_id = $choice->goto) {
if (!array_key_exists($section_id, $story->sections)) {
message_die(GENERAL_ERROR, "Choice <em>$choice->text</em> redirects to <em>$section_id</em> but this section doesn't exist.", "Story error");
}
return $story->sections[$section_id];
-
}
}
}
if (!$CurrentPerso->location_local) {
//Gets start section
return $story->get_start_section();
}
//Gets section matching perso location
return $story->get_section_from_location($CurrentPerso->location_local);
}
//
// Opens .xml file
//
$file = STORIES_DIR . '/' . $CurrentPerso->location_global . '.xml';
if (!file_exists($file)) {
message_die(GENERAL_ERROR, "If you want to write a story for this place, contact Dereckson — $file", "No story defined");
}
//
// Gets story
//
//Loads story and tries to get the section
require_once('includes/story/story.php');
$story = new Story($file);
$section = get_section($story);
//Ensures we've a section
if (!$section) {
message_die(GENERAL_ERROR, "Nothing to do at this location. Contact Dereckson if you think it's a bug or you want to write a story here.", "Story");
}
//Performs section actions
if ($section->location_local) {
//Moves perso to section local location
$CurrentPerso->move_to(null, $section->location_local);
}
//Saves section in session, for choices handling
$_SESSION['StoryChoices'] = $section->choices;
//
// HTML output
//
//Serves header
$smarty->assign('PAGE_TITLE', $story->title);
include('header.php');
//Serves content
$smarty->assign("section", $section);
$smarty->display('story.tpl');
//Serves footer
$smarty->assign('screen', "Story, section $section->id");
include('footer.php');
?>
\ No newline at end of file
diff --git a/controllers/usersearch.php b/controllers/usersearch.php
--- a/controllers/usersearch.php
+++ b/controllers/usersearch.php
@@ -1,100 +1,119 @@
-<?php
-
-/*
- * Zed
- * (c) 2010, Dereckson, some rights reserved
- * Released under BSD license
- *
- * User search
- */
-
-//Libs
-require_once('includes/objects/ProfilePhoto.php');
-
-//
-// Does the search
-//
-
-//Search type
-switch ($resource = $url[1]) {
- case '':
-
- break;
-
- case 'online':
- $sql = "SELECT u.username, u.user_id, u.user_longname FROM " .
- TABLE_USERS . " u, " . TABLE_SESSIONS .
- " s WHERE s.online = 1 AND u.user_id = s.user_id
- ORDER BY HeureLimite DESC";
- if (!$result = $db->sql_query($sql)) {
- message_die(SQL_ERROR, "Unable to query the table", '', __LINE__, __FILE__, $sql);
- }
- $i = 0;
- while ($row = $db->sql_fetchrow($result)) {
- $users[$i]->id = $row['user_id'];
- $users[$i]->username = $row['username'];
- $users[$i]->longname = $row['user_longname'];
- $i++;
- }
-
- $title = sprintf(lang_get('UsersOnline'), $i, s($i));
- break;
-
- case 'directory':
- $sql = 'SELECT username, user_longname FROM ' . TABLE_USERS .
- ' WHERE user_active < 2 ORDER by user_longname ASC';
- if (!$result = $db->sql_query($sql)) {
- message_die(SQL_ERROR, "Unable to query the table", '', __LINE__, __FILE__, $sql);
- }
- $i = 0;
- while ($row = $db->sql_fetchrow($result)) {
- $users[$i]->username = $row['username'];
- $users[$i]->longname = $row['user_longname'];
- $i++;
- }
- $title = lang_get('Directory');
- $mode = 'directory';
- break;
-
- default:
- $smarty->assign('WAP', lang_get('Nay'));
- break;
-}
-
-switch ($mode) {
- case 'directory':
- $template = 'directory.tpl';
- $smarty->assign('USERS', $users);
- break;
-
- default:
- //Prepares avatars
- if (count($users)) {
- foreach ($users as $user) {
- $name = $user->longname ? $user->longname : $user->username;
- $user->avatar = ProfilePhoto::get_avatar($user->id, $name);
- }
- }
- $template = 'usersearch.tpl';
- $smarty->assign('TITLE', $title);
- $smarty->assign('USERS', $users);
- break;
-}
-
-//
-// HTML output
-//
-
-//Serves header
-$smarty->assign('PAGE_CSS', 'usersearch.css');
-$smarty->assign('PAGE_TITLE', $title);
-include('header.php');
-
-//Serves content
-if ($template)
- $smarty->display($template);
-
-//Serves footer
-include('footer.php');
-
+<?php
+
+/**
+ * User search
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This is a controller doing nothing else than call header and footer.
+ *
+ * The controller uses the usersearch.tpl and directory views (cf. Azhàr code)
+ *
+ * Not yet implemented, It should handle /users URL
+ *
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
+ *
+ * @todo implement it
+ */
+
+//Libs
+require_once('includes/objects/ProfilePhoto.php');
+
+//
+// Does the search
+//
+
+//Search type
+switch ($resource = $url[1]) {
+ case '':
+
+ break;
+
+ case 'online':
+ $sql = "SELECT u.username, u.user_id, u.user_longname FROM " .
+ TABLE_USERS . " u, " . TABLE_SESSIONS .
+ " s WHERE s.online = 1 AND u.user_id = s.user_id
+ ORDER BY HeureLimite DESC";
+ if (!$result = $db->sql_query($sql)) {
+ message_die(SQL_ERROR, "Unable to query the table", '', __LINE__, __FILE__, $sql);
+ }
+ $i = 0;
+ while ($row = $db->sql_fetchrow($result)) {
+ $users[$i]->id = $row['user_id'];
+ $users[$i]->username = $row['username'];
+ $users[$i]->longname = $row['user_longname'];
+ $i++;
+ }
+
+ $title = sprintf(lang_get('UsersOnline'), $i, s($i));
+ break;
+
+ case 'directory':
+ $sql = 'SELECT username, user_longname FROM ' . TABLE_USERS .
+ ' WHERE user_active < 2 ORDER by user_longname ASC';
+ if (!$result = $db->sql_query($sql)) {
+ message_die(SQL_ERROR, "Unable to query the table", '', __LINE__, __FILE__, $sql);
+ }
+ $i = 0;
+ while ($row = $db->sql_fetchrow($result)) {
+ $users[$i]->username = $row['username'];
+ $users[$i]->longname = $row['user_longname'];
+ $i++;
+ }
+ $title = lang_get('Directory');
+ $mode = 'directory';
+ break;
+
+ default:
+ $smarty->assign('WAP', lang_get('Nay'));
+ break;
+}
+
+switch ($mode) {
+ case 'directory':
+ $template = 'directory.tpl';
+ $smarty->assign('USERS', $users);
+ break;
+
+ default:
+ //Prepares avatars
+ if (count($users)) {
+ foreach ($users as $user) {
+ $name = $user->longname ? $user->longname : $user->username;
+ $user->avatar = ProfilePhoto::get_avatar($user->id, $name);
+ }
+ }
+ $template = 'usersearch.tpl';
+ $smarty->assign('TITLE', $title);
+ $smarty->assign('USERS', $users);
+ break;
+}
+
+//
+// HTML output
+//
+
+//Serves header
+$smarty->assign('PAGE_CSS', 'usersearch.css');
+$smarty->assign('PAGE_TITLE', $title);
+include('header.php');
+
+//Serves content
+if ($template)
+ $smarty->display($template);
+
+//Serves footer
+include('footer.php');
+
?>
\ No newline at end of file
diff --git a/controllers/void.php b/controllers/void.php
--- a/controllers/void.php
+++ b/controllers/void.php
@@ -1,24 +1,37 @@
<?php
-/*
- * Zed
- * (c) 2010, Dereckson, some rights reserved
- * Released under BSD license
+/**
+ * Void content
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * This is a controller doing nothing else than call header and footer.
*
- * void content
+ * @package Zed
+ * @subpackage Controllers
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
*/
//
// HTML output
//
//Serves header
$smarty->assign('PAGE_TITLE', $title);
include('header.php');
//Doesn't serve any content;
//Servers footer
include('footer.php');
?>
\ No newline at end of file
diff --git a/dev/tests/GeoPlaceTest.php b/dev/tests/GeoPlaceTest.php
--- a/dev/tests/GeoPlaceTest.php
+++ b/dev/tests/GeoPlaceTest.php
@@ -1,51 +1,76 @@
<?php
+
+/**
+ * Unit testing : class GeoPlace
+ *
+ * Zed. The immensity of stars. The HyperShip. The people.
+ *
+ * (c) 2010, Dereckson, some rights reserved.
+ * Released under BSD license.
+ *
+ * @package Zed
+ * @subpackage Tests
+ * @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
+ * @copyright 2010 Sébastien Santoro aka Dereckson
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @version 0.1
+ * @link http://scherzo.dereckson.be/doc/zed
+ * @link http://zed.dereckson.be/
+ * @filesource
+ */
+
require_once('PHPUnit/Framework.php');
require_once('../../includes/geo/place.php');
+/**
+ * Test cases for the class GeoPlace
+ */
class GeoPlaceTest extends PHPUnit_Framework_TestCase {
+ /**
+ * Tests the GeoPlace::is_valid_local_location($local_location) method.
+ */
public function testIsValidLocation () {
//Testing HyperShip Tower T2C3 format
$p0 = new GeoPlace();
$p0->location_local_format = '/^T[1-9][0-9]*C[1-6]$/';
$this->assertTrue($p0->is_valid_local_location("T1C1")); // 1
$this->assertTrue($p0->is_valid_local_location("T14C1")); // 2
$this->assertTrue($p0->is_valid_local_location("T14C6")); // 3
$this->assertTrue($p0->is_valid_local_location("T140C6")); // 4
$this->assertTrue($p0->is_valid_local_location("T14000C6")); // 5
$this->assertFalse($p0->is_valid_local_location("C1T6")); // 6
$this->assertFalse($p0->is_valid_local_location("T14000 C6")); // 7
$this->assertFalse($p0->is_valid_local_location("T4C7")); // 8
$this->assertFalse($p0->is_valid_local_location("T4C0")); // 9
$this->assertFalse($p0->is_valid_local_location("T0C0")); //10
//Unit testing is useful: this test led to fix the regexp
//from T[0-9]+C[1-6] to T[1-9][0-9]*C[1-6]
$this->assertFalse($p0->is_valid_local_location("T0C1")); //11
//Testing default format
$p1 = new GeoPlace();
$this->assertTrue($p1->is_valid_local_location("(4,62,35)")); //12
$this->assertTrue($p1->is_valid_local_location("(4, 62, 35)")); //13
$this->assertTrue($p1->is_valid_local_location("(4, 62,35)")); //14
$this->assertFalse($p1->is_valid_local_location("(4,62,-35)")); //15
$this->assertFalse($p1->is_valid_local_location("(4, 62)")); //16
-
//Testing (x, y, -z) format
$p2 = new GeoPlace();
$p2->location_local_format = '/^\(\-?[0-9]+( )*,( )*\-?[0-9]+( )*,( )*\-?[0-9]+\)$/';
$this->assertTrue($p2->is_valid_local_location("(4,62,35)")); //17
$this->assertTrue($p2->is_valid_local_location("(4, 62, 35)")); //18
$this->assertTrue($p2->is_valid_local_location("(4, 62,35)")); //19
$this->assertTrue($p2->is_valid_local_location("(4,62,-35)")); //20
$this->assertFalse($p2->is_valid_local_location("(4,62,- 35)")); //21
$this->assertFalse($p2->is_valid_local_location("(4,62, - 35)")); //22
$this->assertFalse($p2->is_valid_local_location("(4, 62)")); //23
}
}
?>

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 03:56 (55 m, 48 s ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21221
Default Alt Text
(56 KB)

Event Timeline