Skip to content

Commit

Permalink
Several minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 20, 2010
1 parent ff4d1ed commit 5248479
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/asset/dmChessJavascriptConfig.php
Expand Up @@ -8,7 +8,7 @@ class dmChessJavascriptConfig
$i18n,
$player;

public function __construct(dmWebResponse $response, dmHelper $helper, dmi18n $i18n, DmChessPlayer $player)
public function __construct(dmWebResponse $response, dmHelper $helper, dmI18n $i18n, DmChessPlayer $player)
{
$this->response = $response;
$this->helper = $helper;
Expand Down
22 changes: 15 additions & 7 deletions lib/model/doctrine/PluginDmChessGameTable.class.php
Expand Up @@ -6,13 +6,16 @@ class PluginDmChessGameTable extends myDoctrineTable

public function broom()
{
$this->createQuery('g')
// games created yesterday, with less than 3 moves
->where('g.created_at < ? AND g.turns < ?', array(date ("Y-m-d H:i:s", strtotime('-1 day')), 3))
// games with last move one month ago, and not finished
->orWhere('g.updated_at < ? AND g.is_finished = ?', array(date ("Y-m-d H:i:s", strtotime('-1 month')), false))
// hop!
->delete()->execute();
$this->getBroomQuery()->delete()->execute();
}

public function getBroomQuery()
{
return $this->createQuery('g')
// games created three days ago, with less than 3 moves
->where('g.created_at < ? AND g.turns < ?', array(date ("Y-m-d H:i:s", strtotime('-3 day')), 3))
// games with last move 6 months ago, and not finished
->orWhere('g.updated_at < ? AND g.is_finished = ?', array(date ("Y-m-d H:i:s", strtotime('-6 month')), false));
}

public function preload($id)
Expand All @@ -23,4 +26,9 @@ public function preload($id)
->leftJoin('players.Pieces pieces')
->fetchRecord();
}

public function getAdminListQuery(dmDoctrineQuery $query)
{
return parent::getAdminListQuery($query)->leftJoin($query->getRootAlias().'.Players');
}
}
8 changes: 5 additions & 3 deletions modules/dmChessGameAdmin/templates/_players_list.php
@@ -1,4 +1,6 @@
<?php
include_partial('dmAdminGenerator/relationForeign', array('record' => $dm_chess_game, 'alias' => 'Players', 'options' => array(
'new' => false
)));
echo $sf_context->getServiceContainer()->mergeParameter('related_records_view.options', array(
'record' => $dm_chess_game,
'alias' => 'Players',
'new' => false
))->getService('related_records_view')->render();
2 changes: 1 addition & 1 deletion modules/dmChessPlayerAdmin/config/generator.yml
Expand Up @@ -46,7 +46,7 @@ generator:
- events
form:
display:
NONE: [is_creator, is_winner, is_ai, game_id]
NONE: [is_creator, is_winner, is_ai]
Others: [code, ai_level, color, events]
class: DmChessPlayerAdminForm
fields: { }
Expand Down
21 changes: 11 additions & 10 deletions web/css/table.css
Expand Up @@ -3,7 +3,7 @@ div.dm_chess_opponent {
}

div.dm_chess_table {
height: 216px;
height: 216px;
overflow: hidden;
background: #F8F8F8;
padding: 10px;
Expand All @@ -14,24 +14,25 @@ div.dm_chess_table {
}

div.dm_chess_join_url {
background: #FFFFFF;
border: 1px solid #D4D4D4;
margin: 24px 0;
padding: 10px;
background: #FFFFFF;
border: 1px solid #D4D4D4;
margin: 24px 0;
padding: 10px;
font-size: 11px;
}

div.dm_chess_separator {
border-bottom: 1px solid #D4D4D4;
border-bottom: 1px solid #D4D4D4;
margin: 10px 0;
}

div.dm_chess_permalink a.link {
white-space: nowrap;
display: block;
white-space: nowrap;
display: block;
}

div.dm_chess_give_up {
margin-top: 20px;
margin-top: 20px;
text-align: right;
}
div.dm_chess_give_up a.link {
Expand Down Expand Up @@ -83,7 +84,7 @@ div.dm_chess_cemetery_bottom {
}

div.dm_chess_cemetery li {
display: block;
display: block;
list-style: none;
float: left;
margin-right: -24px;
Expand Down

0 comments on commit 5248479

Please sign in to comment.