Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from daigo75/master
Browse files Browse the repository at this point in the history
Issue #7 and #16 - Dojo sort criteria
  • Loading branch information
SemanticallyNull committed May 10, 2012
2 parents 27f8ed5 + fe90a29 commit f1b78e5
Show file tree
Hide file tree
Showing 3 changed files with 286 additions and 11 deletions.
28 changes: 24 additions & 4 deletions application/models/dojo_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function get($id = NULL, $verified = NULL, $unverified = NULL){
if ($id) {
$this->db->where('id', $id);
}

if ($verified){
$this->db->where('verified', TRUE);
}
Expand All @@ -27,8 +27,28 @@ function get($id = NULL, $verified = NULL, $unverified = NULL){
$this->db->where('verified', FALSE);
}

$this->db->order_by('country', 'desc');
$query = $this->db->get($this->dojo_table);
$this->db->select('D.name,
D.creator,
D.time,
D.country,
D.location,
D.coordinates,
D.email,
D.google_group,
D.twitter,
D.notes,
D.eb_id,
D.need_mentors,
D.stage,
D.supporter_image,
C.name AS country_name');
$this->db->from('dojos D');
$this->db->join('countries C', 'C.code = D.id', 'left');
$this->db->order_by('country_name', 'asc');
$this->db->order_by('name', 'asc');

//$query = $this->db->get($this->dojo_table);
$query = $this->db->get();
return $query->result();
}

Expand Down Expand Up @@ -142,7 +162,7 @@ function verify($dojo = NULL)
{
if($dojo){
$this->db->set('verified', 1);

if(is_array($dojo)){
foreach($dojo as $d){
$this->db->or_where('id', $d);
Expand Down
11 changes: 4 additions & 7 deletions application/views/dojo/dojo.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,17 @@
"EH" => "Western Sahara",
"YE" => "Yemen",
"YU" => "Yugoslavia",
"ZM" => "Zambia",
"ZM" => "Zambia",
"ZW" => "Zimbabwe"
);
$used_countries = array();

foreach($dojo_data as $dojo){
if (!in_array($dojo->country, $used_countries)){
$used_countries[] = $dojo->country;
echo "<br /><legend style='margin-bottom:5px;'>".$_countries[$dojo->country]."</legend>";
echo "&bull; <a href='/dojo/".$dojo->id."'>".$dojo->name."</a><br />";
}
else{
echo "&bull; <a href='/dojo/".$dojo->id."'>".$dojo->name."</a><br />";
echo "<br /><legend style='margin-bottom:5px;'>".$dojo->country_name."</legend>";
}
echo "&bull; <a href='/dojo/".$dojo->id."'>".$dojo->name."</a><br />";
}
?>
</div>
Expand All @@ -267,4 +264,4 @@
</div>
</div>
</div><!--.wrap-->
</div><!--#content-->
</div><!--#content-->
Loading

0 comments on commit f1b78e5

Please sign in to comment.