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:
parent
be8c6a6629
commit
cfeb6aca6d
68 changed files with 1561 additions and 1451 deletions
|
|
@ -216,4 +216,20 @@ class Legacies
|
|||
{
|
||||
self::$_response = $response;
|
||||
}
|
||||
|
||||
public static function getUrl($uri, Array $params = array())
|
||||
{
|
||||
// TODO: base path integration
|
||||
$serializedParams = array();
|
||||
foreach ($params as $paramKey => $paramValue) {
|
||||
if ($paramValue) {
|
||||
$serializedParams[] = "{$paramKey}={$paramValue}";
|
||||
}
|
||||
}
|
||||
|
||||
if (count($serializedParams) > 0) {
|
||||
return $uri . '?' . implode('&', $serializedParams);
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
}
|
||||
|
|
@ -297,7 +297,7 @@ SQL_EOF;
|
|||
{
|
||||
$clone = clone $this;
|
||||
$clone->_fields = array();
|
||||
$clone->column('COUNT(*)');
|
||||
$clone->column('1');
|
||||
|
||||
$sql = $clone->_prepareSql();
|
||||
|
||||
|
|
@ -306,7 +306,10 @@ SQL_EOF;
|
|||
|
||||
$args = func_get_args();
|
||||
$statement->execute(array_shift($args));
|
||||
return $statement->fetch(PDO::FETCH_COLUMN, 0);
|
||||
$count = $statement->rowCount();
|
||||
$statement->closeCursor();
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function count()
|
||||
|
|
@ -342,4 +345,22 @@ SQL_EOF;
|
|||
{
|
||||
return current($this->_items) !== false;
|
||||
}
|
||||
|
||||
public function getFirstItem()
|
||||
{
|
||||
if (!$this->_)
|
||||
if (count($this->_items) > 0) {
|
||||
return $this->_items[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getLastItem()
|
||||
{
|
||||
$size = count($this->_items);
|
||||
if ($size > 0) {
|
||||
return $this->_items[$size - 1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -112,18 +112,7 @@ class Legacies_Core_View
|
|||
|
||||
public function getUrl($uri, Array $params = array())
|
||||
{
|
||||
// TODO: base path integration
|
||||
$serializedParams = array();
|
||||
foreach ($params as $paramKey => $paramValue) {
|
||||
if ($paramValue) {
|
||||
$serializedParams[] = "{$paramKey}={$paramValue}";
|
||||
}
|
||||
}
|
||||
|
||||
if (count($serializedParams) > 0) {
|
||||
return $uri . '?' . implode('&', $serializedParams);
|
||||
}
|
||||
return $uri;
|
||||
return Legacies::getUrl($uri, $params);
|
||||
}
|
||||
|
||||
public function getSkinUrl($uri)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue