[Isocial-svn] SF.net SVN: isocial: [57] app
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <agu...@us...> - 2008-03-10 09:29:09
|
Revision: 57 http://isocial.svn.sourceforge.net/isocial/?rev=57&view=rev Author: aguidrevitch Date: 2008-03-10 02:29:13 -0700 (Mon, 10 Mar 2008) Log Message: ----------- city selection improved Modified Paths: -------------- app/controllers/profile_controller.php app/installers/city_installer.php localities_to_sql.pl Modified: app/controllers/profile_controller.php =================================================================== --- app/controllers/profile_controller.php 2008-03-09 19:52:38 UTC (rev 56) +++ app/controllers/profile_controller.php 2008-03-10 09:29:13 UTC (rev 57) @@ -14,43 +14,25 @@ if (empty($this->params['basic']['city'])) { $this->renderNothing(); } else { - $query = $this->params['basic']['city']; + $query = $this->params['basic']['city']; + $aquery = utf8_to_ascii($query); + if ($aquery != $query) { + $conditions = array( + 'first_id IS NOT NULL AND name LIKE ? OR name LIKE ?', $query . '%', $aquery . '%' + ); + } else { + $conditions = array( + 'first_id IS NOT NULL AND name LIKE ?', $query . '%' + ); + } $entries = $this->City->find('all', - array('conditions' => - array( - 'first_id IS NOT NULL AND name LIKE ?', $query . '%' - ), - 'include' => 'country', - 'limit' => 10 + array( + 'conditions' => $conditions, + 'include' => 'country', + 'limit' => 10 ) ); - - $limit = empty($entries) ? 10 : 10 - count($entries); - if ($limit) { - $aquery = utf8_to_ascii($query); - if ($aquery != $query) { - $asciied = $this->City->find('all', - array('conditions' => - array( - 'first_id IS NOT NULL AND name LIKE ?', $aquery . '%' - ), - 'include' => 'country', - 'limit' => $limit - ) - ); - } - } - - if (empty($entries) && empty($asciied)) { - $entries = array(); - } else if (empty($entries)) { - $entries = $asciied; - } else if (empty($asciied)) { - $entries = $entries; - } else { - $entries = array_merge($entries, $asciied); - } $this->renderText( $this->_city_auto_complete_result($entries, $query) ); } } Modified: app/installers/city_installer.php =================================================================== --- app/installers/city_installer.php 2008-03-09 19:52:38 UTC (rev 56) +++ app/installers/city_installer.php 2008-03-10 09:29:13 UTC (rev 57) @@ -11,8 +11,10 @@ `first_id` int(11), `second_id` int(11), `third_id` int(11), + `is_alternative` bool NOT NULL DEFAULT 0, `name` char(100) NOT NULL DEFAULT '', INDEX oid_idx (oid), + INDEX name_idx (name), FOREIGN KEY (country_id) REFERENCES countries(id) ) ENGINE=InnoDB"); Modified: localities_to_sql.pl =================================================================== --- localities_to_sql.pl 2008-03-09 19:52:38 UTC (rev 56) +++ localities_to_sql.pl 2008-03-10 09:29:13 UTC (rev 57) @@ -19,7 +19,7 @@ print "INSERT INTO countries VALUES ($id, $oid, '$name');\n"; $id++; } else { - $other{$name} = $oid; + $other{$name} ||= $oid; } } @@ -35,10 +35,13 @@ my $third_id = defined $data[11] && $other{$data[11]} ? $other{$data[11]} : 'NULL'; my @names = ($data[1], split(/\s*,\s*/, $data[2]), split(/\s*,\s*/, $data[3])); + my $i = 0; foreach my $name (@names) { + my $is_alt = $i > 0 ? 1 : 0; $name =~ s/\"/'/g; - print "INSERT INTO cities VALUES ($id, $oid, $country_id, $first_id, $second_id, $third_id, \"$name\");\n"; + print "INSERT INTO cities VALUES ($id, $oid, $country_id, $first_id, $second_id, $third_id, $is_alt, \"$name\");\n"; $id++; + $i++; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |