Example #1
0
 * Created by Yogesh on 11/20/2015.
 * 
 */
include_once "../model/PoiController.php";
include_once "../model/UsersController.php";
include_once "../model/objects/User.php";
include_once "../model/objects/POI.php";
include_once "../model/objects/Contribution.php";
include_once "../model/objects/Category.php";
include_once "../model/objects/ParentCategory.php";
include_once "../model/CategoryController.php";
include_once "../model/ContributionController.php";
header("Content-Type: text/plain");
$cont = new ContributionController();
$data = $cont->getAll();
print_r($data);
exit;
$dataArray = array("Pokhara||Gandaki Zone, Kaski District, Nepal||http://en.wikipedia.org/wiki/Pokhara||city||28.2095379,83.9914028", "Hyatt Regency||Nepal||null||bus station||27.7193693,85.3541166", "Ason||Nepal||null||neighbourhood||27.7075079,85.3122521", "Lainchour Chowk Bus Stop||Nepal||null||bus station||27.7169967,85.316039", "Airport Bus Station||Nepal||null||bus station||27.7007168,85.3537173", "Dillibazaar stop||Nepal||null||bus station||27.7053698,85.3267594");
$currentUser = $userController->find(3);
$poiIdDummy = 56;
foreach ($dataArray as $key => $value) {
    $row = $value;
    $data = explode("||", $row);
    $category = new Category();
    $category->setUser($currentUser);
    $category->setSubCategory($data[3]);
    $poi = new POI();
    $poi->init($poiIdDummy, $data[0], $data[1], $data[4], $category, "", "", "", "", $currentUser);
    $contributionController->add($poi);
    $poiIdDummy++;
}
Example #2
0
 } else {
     $prefix = strtolower($pSplit[0]);
     $postfix = $pSplit[1];
     if ($prefix == "u" || $prefix == "p") {
         if ($prefix == "u") {
             if (array_key_exists('n', $_GET)) {
                 $name = decodeInput($_REQUEST['n']);
                 //it is a user created location
                 $lat = decodeInput($_REQUEST['lat']);
                 $long = decodeInput($_REQUEST['long']);
                 if (!is_numeric($lat) || !is_numeric($long)) {
                     redirectIndex();
                 } else {
                     $location = $lat . "," . $long;
                     $category = new Category();
                     $category->setSubCategory("custom");
                     $poi->init($name, "Nepal", $location, $category, "NA", "NA", "NA", "", new User());
                 }
             } else {
                 redirectIndex();
             }
         } else {
             if ($prefix == "p") {
                 if (is_numeric($postfix)) {
                     $poiController = new PoiController();
                     $poi = $poiController->find($postfix);
                     if ($poi) {
                     } else {
                         redirectIndex();
                     }
                 } else {
Example #3
0
 public function testPopulate()
 {
     $subCategory = new Subcategory();
     $subCategory->setId(1234);
     $subCategory->setName("Self Service");
     $category = new Category();
     $category->setId(12);
     $category->setName("Restaurantes");
     $category->setSubCategory($subCategory);
     $city = new City();
     $city->setCountry("Brasil");
     $city->setState("SP");
     $city->setName("São Paulo");
     $address = new Address();
     $address->setCity($city);
     $address->setComplement("1 Andar");
     $address->setDistrict("Vila Olímpia");
     $address->setNumber("129");
     $address->setStreet("Rua Funchal");
     $address->setZipcode("04551-069");
     $gasStation = new GasStation(array('price_gas' => 1, 23, 'price_vodka' => 23, 45));
     $placeInfo = new PlaceInfo();
     $placeInfo->setGasStation($gasStation);
     $data = new \stdClass();
     $data->id = 123;
     $data->name = "Chegamos!";
     $data->average_rating = 4;
     $data->review_count = 3;
     $data->category = $category;
     $data->subcategory = $subCategory;
     $data->address = $address;
     $data->point->lat = "-23.529366";
     $data->point->lng = "-47.467117";
     $data->main_url = "http://chegamos.com/";
     $data->other_url = "http://chegamos.com.br/";
     $data->icon_url = "http://chegamos.com/img/icon.png";
     $data->description = "Description";
     $data->created = "01/12/2010 16:19";
     $data->phone = "11 2222-3333";
     $data->extended = $placeInfo;
     $data->num_visitors = 1024;
     $data->num_photos = 5;
     $this->object->populate($data);
     $this->assertEquals(123, $this->object->getId());
     $this->assertEquals("Chegamos!", $this->object->getName());
     $this->assertEquals(4, $this->object->getAverageRating());
     $this->assertEquals("Bom", $this->object->getAverageRatingString());
     $this->assertEquals(3, $this->object->getReviewCount());
     $this->assertEquals("app\\models\\Category", \get_class((object) $this->object->getCategory()));
     $this->assertEquals("Restaurantes - Self Service", (string) $this->object->getCategory());
     $this->assertEquals("app\\models\\Address", \get_class((object) $this->object->getAddress()));
     $this->assertEquals("Rua Funchal, 129 - Vila Olímpia<br/>São Paulo - SP", (string) $this->object->getAddress());
     $this->assertEquals("-23.529366,-47.467117", (string) $this->object->getPoint());
     $this->assertEquals("http://chegamos.com/", $this->object->getMainUrl());
     $this->assertEquals("http://chegamos.com.br/", $this->object->getOtherUrl());
     $this->assertEquals("http://chegamos.com/img/icon.png", $this->object->getIconUrl());
     $this->assertEquals("Description", $this->object->getDescription());
     $this->assertEquals("01/12/2010 16:19", $this->object->getCreated());
     $this->assertEquals("11 2222-3333", $this->object->getPhone());
     $this->assertEquals("app\\models\\PlaceInfo", \get_class((object) $this->object->getPlaceInfo()));
     $this->assertEquals(1024, $this->object->getNumVisitors());
     $this->assertEquals(5, $this->object->getNumPhotos());
 }