Updated page display

Updated signature image generator
Navigation menu has been finalized
Some deprectaed templates has been removed
Fixed registration
Fixed galaxy notices messages

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2011-10-24 19:19:04 +02:00
commit 6d61e93c47
67 changed files with 10177 additions and 940 deletions

View file

@ -39,6 +39,8 @@
* documentation for further information about customizing Wootook.
*
*/
define('DISABLE_IDENTITY_CHECK', true);
require_once dirname(dirname(__FILE__)) . '/application/bootstrap.php';
define('FONT_FILE', dirname(__FILE__) . '/resources/fonts/visitor/visitor.ttf');
define('BACKGROUND_FILE', dirname(__FILE__) . '/resources/backgrounds/default.png');
@ -46,201 +48,6 @@ define('TIMEZONE', 'Europe/Paris');
date_default_timezone_set(TIMEZONE);
require_once dirname(dirname(__FILE__)) . '/db/mysql.php';
/**
*
* @todo Update the position alignment management.
* @author Greg
*
*/
class Legacies_Block_Image_Png
{
private $_format = NULL;
private $_mime = NULL;
const COLOR_RED = 'red';
const COLOR_GREEN = 'green';
const COLOR_BLUE = 'blue';
const POSITION_LEFT = 0x01;
const POSITION_RIGHT = 0x02;
const POSITION_CENTER = 0x03;
const POSITION_TOP = 0x10;
const POSITION_BOTTOM = 0x20;
const POSITION_MIDDLE = 0x30;
const POSITION_DEFAULT = 0x11;
private $_texts = array();
private $_background = NULL;
private $_font = NULL;
public function __construct()
{
$this->_setMime('image/png');
$this->_setFormat('png');
}
protected function _getFormat()
{
return $this->_format;
}
protected function _setFormat($format)
{
$this->_format = $format;
return $this;
}
protected function _getMime()
{
return $this->_mime;
}
protected function _setMime($mime)
{
$this->_mime = $mime;
return $this;
}
public function getHeaders()
{
return array(
'Content-Type' => $this->_getMime()
);
}
public function addText($content, $fontSize, $fontFile, $positionAbscix, $positionOrdinates, $angle, Array $color, $alignment = self::POSITION_DEFAULT)
{
$this->_texts[] = array(
'content' => $content,
'color' => $color,
'sizes' => $this->_getTextPositions($content, $fontSize, $fontFile, $positionAbscix, $positionOrdinates, $angle, $alignment),
'font_size' => $fontSize,
'font_file' => $fontFile,
);
return $this;
}
public function _getTextPositions($textContent, $fontSize, $fontFile, $positionAbscix, $positionOrdinates, $angle = 0, $alignment = self::POSITION_DEFAULT)
{
$dimensions = imageFtbBox($fontSize, $angle, $fontFile, $textContent);
$width = $dimensions[2] - $dimensions[0];
$height = $dimensions[1] - $dimensions[7];
switch ($alignment & 0x7) {
case self::POSITION_CENTER:
$positionAbscix -= ceil($width / 2);
break;
case self::POSITION_RIGHT:
$positionAbscix -= $width;
break;
case self::POSITION_LEFT:
default:
break;
}
switch ($alignment & 0x70) {
case self::POSITION_MIDDLE:
$positionOrdinates -= ceil($height / 2);
break;
case self::POSITION_TOP:
$positionOrdinates -= $height;
break;
case self::POSITION_BOTTOM:
default:
$width = 0;
$height = 0;
break;
}
return array(
'abscix' => $positionAbscix,
'ordinate' => $positionOrdinates,
'alignment' => $alignment,
'width' => $width,
'height' => $height,
'angle' => $angle
);
}
public function setBackground($backgroundImage)
{
$this->_background = $backgroundImage;
return $this;
}
public function setFont($fontFile)
{
$this->_font = $fontFile;
return $this;
}
public function render()
{
ob_start();
if (!is_null($this->_background)) {
$gdHandler = imageCreateFromPng($this->_background);
} else {
$gdHandler = imageCreateTrueColor();
}
foreach ($this->_texts as $text) {
$color = imageColorAllocate(
$gdHandler,
$text['color'][self::COLOR_RED],
$text['color'][self::COLOR_GREEN],
$text['color'][self::COLOR_BLUE]
);
switch ($text['sizes']['alignment'] & 0x0F) {
case self::POSITION_CENTER:
$text['sizes']['abscix'] -= floor(imageSX($gdHandler) / 2);
break;
case self::POSITION_RIGHT:
$text['sizes']['abscix'] = imageSX($gdHandler) - ($text['sizes']['abscix'] + $text['sizes']['width']) -10;
break;
case self::POSITION_LEFT:
default:
break;
}
$imageText = imageTtfText(
$gdHandler,
$text['font_size'],
$text['sizes']['angle'],
$text['sizes']['abscix'],
$text['sizes']['ordinate'],
$color,
$text['font_file'],
$text['content']
);
}
imagePng($gdHandler);
imageDestroy($gdHandler);
$imageData = ob_get_contents();
ob_end_clean();
return $imageData;
}
}
if (isset($_GET['id'])) {
$id = (int) $_GET['id'];
} else {
@ -249,11 +56,12 @@ if (isset($_GET['id'])) {
}
$textColor = array(
Legacies_Block_Image_Png::COLOR_RED => 0xEF,
Legacies_Block_Image_Png::COLOR_GREEN => 0xEF,
Legacies_Block_Image_Png::COLOR_BLUE => 0xEF
Wootook_Core_Model_Image_Png::COLOR_RED => 0xEF,
Wootook_Core_Model_Image_Png::COLOR_GREEN => 0xEF,
Wootook_Core_Model_Image_Png::COLOR_BLUE => 0xEF
);
$db = Wootook_Database::getSingleton();
$sql = <<<EOF
SELECT
users.username AS username,
@ -268,21 +76,17 @@ LEFT JOIN {{table}}planets AS planets ON planets.id_owner=users.id
WHERE users.id={$id}
EOF;
$config = Wootook_Core_Model_Config::getSingleton();
$data = array_merge(
array(
'game_name' => 'Wootook:Legacies',
'game_name' => $config['game_name'],
'date' => date('d M Y')
),
doquery($sql, '', true)
);
function number_format_custom($number)
{
return number_format($number, 0, ',', '.');
}
$image = new Legacies_Block_Image_Png();
$image = new Wootook_Core_Model_Image_Png();
$image
->setBackground(BACKGROUND_FILE)
->addText($data['game_name'], 24, FONT_FILE, 5, 37, 0, $textColor)
@ -290,14 +94,14 @@ $image
->addText('Batiments:',
14, FONT_FILE, 5, 50, 0, $textColor)
->addText(number_format_custom($data['build_points']), 14, FONT_FILE, 100, 50, 0, $textColor)
->addText(Math::render($data['build_points']), 14, FONT_FILE, 100, 50, 0, $textColor)
->addText('Flottes:', 14, FONT_FILE, 5, 70, 0, $textColor)
->addText(number_format_custom($data['fleet_points']), 14, FONT_FILE, 100, 70, 0, $textColor)
->addText(Math::render($data['fleet_points']), 14, FONT_FILE, 100, 70, 0, $textColor)
->addText('Technologies:', 14, FONT_FILE, 205, 50, 0, $textColor)
->addText(number_format_custom($data['tech_points']), 14, FONT_FILE, 320, 50, 0, $textColor)
->addText(Math::render($data['tech_points']), 14, FONT_FILE, 320, 50, 0, $textColor)
->addText('Total:', 14, FONT_FILE, 205, 70, 0, $textColor)
->addText(number_format_custom($data['total_points']), 14, FONT_FILE, 320, 70, 0, $textColor)
->addText(Math::render($data['total_points']), 14, FONT_FILE, 320, 70, 0, $textColor)
;
foreach ($image->getHeaders() as $headerName => $headerValue) {