Fixed mysql_* calls

Updated skin
Fixed minor bugs in shipyard pages display
Fixed various bugs in legacy fleet pages source code.

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2011-09-22 01:19:45 +02:00
commit cfeb6aca6d
68 changed files with 1561 additions and 1451 deletions

View file

@ -5,7 +5,7 @@ class Legacies_Empire_Block_Planet_Shipyard_Queue
{
public function getQueue()
{
return $this->getPlanet()->getShipyard()->getQueue();
return $this->getPlanet()->getShipyard()->getBuilder();
}
public function isEmpty()

View file

@ -64,6 +64,56 @@ class Legacies_Empire_Model_Planet
return self::$_instances[$id];
}
public static function factoryFromCoords($coords, $type = self::TYPE_PLANET)
{
if ($coords === null || empty($coords)) {
return new self();
}
if (!in_array($type, array(self::TYPE_PLANET, self::TYPE_DEBRIS, self::TYPE_MOON))) {
$type = self::TYPE_PLANET;
}
if (!is_array($coords)) {
$coords = explode(':', $coords);
if (count($coords) != 3) {
return new self();
}
$coords = array(
'galaxy' => $coords[0],
'system' => $coords[1],
'position' => $coords[2],
'type' => $type
);
}
if (!isset($coords['type'])) {
$coords['type'] = $type;
}
$database = Legacies_Database::getSingleton();
$collection = new Legacies_Core_Collection('planets');
$collection
->column('id')
->where('galaxy=:galaxy')
->where('system=:system')
->where('planet=:position')
->where('planet_type=:type')
->limit(1)
->load($coords)
;
$planetData = $collection->getFirstItem();
if ($planetData === null || !$planetData->getData('id')) {
return new self();
}
return self::factory($planetData->getData('id'));
}
public function _init()
{
$this->_tableName = 'planets';

View file

@ -27,7 +27,7 @@ class Legacies_Empire_Model_Planet_Builder
}
if (!isset($params['started_at'])) {
$startedAt = 0;
$startedAt = null;
} else {
$startedAt = $params['started_at'];
}
@ -128,7 +128,7 @@ class Legacies_Empire_Model_Planet_Builder
foreach ($this->getQueue() as $element) {
$elementTime = $element->getData('started_at');
if ($elementTime == 0) {
if ($elementTime === null) {
$element->setData('started_at', $startingTime);
$elementTime = $startingTime;
}
@ -199,6 +199,10 @@ class Legacies_Empire_Model_Planet_Builder
return $this;
}
if ($this->count() == 0) {
$this->_currentPlanet->setData('b_building', $time);
}
$this->enqueue(array(
'building_id' => $buildingId,
'level' => $level,

View file

@ -233,11 +233,11 @@ class Legacies_Empire_Model_User
*/
public function updateCurrentPlanet($planet)
{
if (!$planetId instanceof Legacies_Empire_Model_Planet) {
if (!$planet instanceof Legacies_Empire_Model_Planet) {
$planetCollection = $this->_preparePlanetCollection()->where('id=:id');
$planetCollection->load(array(
'id' => $planet,
'id' => $planet,
'user' => $this->getId()
));