Inheritance: extends MY_Controller
Ejemplo n.º 1
0
 public function pay(Marker $marker, $marks, $amount)
 {
     if (!is_numeric($amount)) {
         throw new Exception('ContractPayment requires amount as a number');
     }
     if (!is_array($marks)) {
         if (!$marks instanceof Mark) {
             throw new Exception('ContractPayment requires either an array of Marks, or a Mark as second argument');
         }
         // put the single script in an array
         $marks = array($marks);
     }
     // get each mark's key, and set status to paid
     foreach ($marks as $mark) {
         if (!$marks instanceof Mark) {
             throw new Exception('ContractPayment requires either an array of Marks as second argument');
         }
         $markIDs[] = $mark->getKey();
     }
     $markIDs = serialize($markIDs);
     $this->set('marker', $marker->getKey());
     $this->set('marks', $markIDs);
     $this->set('amount', $amount);
     $this->set('dateSent', null);
     if (!($result = $this->create())) {
         throw new Exception('Could not create new contract payment');
     }
     foreach ($marks as $mark) {
         $mark->paid();
         $mark->update();
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Draw the marker on the canvas
  * @param int $x The X (horizontal) position (in pixels) of the marker on the canvas 
  * @param int $y The Y (vertical) position (in pixels) of the marker on the canvas 
  * @param array $values The values representing the data the marker "points" to 
  * @access private
  */
 function _drawMarker($x, $y, $values = false)
 {
     parent::_drawMarker($x, $y, $values);
     if ($this->_markerStart) {
         $this->_markerStart->_drawMarker($x, $y, $values);
     }
     // Modified: Don't draw pointer if line thickness is zero
     if ($this->_getLineStyle() != 0) ImageLine($this->_canvas(), $x, $y, $x + $this->_deltaX, $y + $this->_deltaY, $this->_getLineStyle());
     $this->_markerEnd->_drawMarker($x + $this->_deltaX, $y + $this->_deltaY, $values);
 }
Ejemplo n.º 3
0
 /**
  * Creates new marker accounts from a list of emails and sends emails to new markers.
  *
  */
 function createmarkers()
 {
     if ($this->input->post('emails')) {
         $this->load->library('validation');
         $rules['emails'] = 'valid_emails|required';
         $fields['emails'] = 'referree emails';
         $this->validation->set_fields($fields);
         $this->validation->set_rules($rules);
         $this->validation->set_message('valid_emails', 'All email addresses entered into %s must be valid, seperated by commas');
         if ($this->validation->run() === TRUE) {
             $emails = explode(',', $this->input->post('emails'));
             $this->load->model('marker');
             $this->load->model('email');
             foreach ($emails as $email) {
                 $marker = new Marker();
                 $marker->setKey($email);
                 $password = $this->_createPassword();
                 $marker->set('password', $marker->makePass($password));
                 if ($marker->create()) {
                     $emailData['email'] = $email;
                     $emailData['password'] = $password;
                     $msg = $this->load->view('email/new_marker', $emailData, TRUE);
                     $subject = 'Next step in your application';
                     $emailToStore = new Email();
                     $emailToStore->set('sender', '*****@*****.**');
                     $emailToStore->set('receiver', $email);
                     $emailToStore->set('subject', $subject);
                     $emailToStore->set('message', $msg);
                     $emailToStore->create();
                     $viewData['messages'][] = "Successfully created marker account for {$email} with password {$password}";
                 } else {
                 }
             }
         }
     }
     if ($this->validation->error_string) {
         $viewData['errors'][] = $this->validation->error_string;
     }
     $viewData['token'] = $this->_token();
     $this->load->view('control/create_markers', $viewData);
 }
Ejemplo n.º 4
0
 function index()
 {
     return;
     $this->load->model('marker');
     $emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
     $words = array('dance', 'el3phant', 'cam3ra');
     $i = 1;
     foreach ($emails as $email) {
         $i++;
         if ($i > 2) {
             $i = 0;
         }
         $marker = new Marker();
         $pass = substr(uniqid(), 2, 2) . $words[$i];
         $marker->setKey($email);
         $newPass = $marker->makePass($pass);
         $marker->set('password', $newPass);
         $marker->create();
         echo '<br>Marker: ' . $email . '<br>Pass: ' . $pass;
     }
 }
Ejemplo n.º 5
0
 /**
  * Draw the marker on the canvas
  *
  * @param int $x The X (horizontal) position (in pixels) of the marker on
  *   the canvas
  * @param int $y The Y (vertical) position (in pixels) of the marker on the
  *   canvas
  * @param array $values The values representing the data the marker 'points'
  *   to
  * @access private
  */
 function _drawMarker($x, $y, $values = false)
 {
     parent::_drawMarker($x, $y, $values);
     if ($this->_markerStart) {
         $this->_markerStart->_setParent($this);
         $this->_markerStart->_drawMarker($x, $y, $values);
     }
     $this->_getLineStyle();
     $this->_canvas->line(array('x0' => $x, 'y0' => $y, 'x1' => $x + $this->_deltaX, 'y1' => $y + $this->_deltaY));
     $this->_markerEnd->_setParent($this);
     $this->_markerEnd->_drawMarker($x + $this->_deltaX, $y + $this->_deltaY, $values);
 }
Ejemplo n.º 6
0
    /**
      * Draw a sample for use with legend
      * @param int $x The x coordinate to draw the sample at
      * @param int $y The y coordinate to draw the sample at
      * @access private
      */
    function _legendSample($x, $y, &$font)
    {
        if (is_a($this->_fillStyle, "Image_Graph_Fill")) {
            $fillStyle = $this->_fillStyle->_getFillStyleAt($x -5, $y -5, 10, 10);
        } else {
            $fillStyle = $this->_getFillStyle();
        }
        if ($fillStyle != IMG_COLOR_TRANSPARENT) {
            ImageFilledRectangle($this->_canvas(), $x -5, $y -5, $x +5, $y +5, $fillStyle);
            ImageRectangle($this->_canvas(), $x -5, $y -5, $x +5, $y +5, $this->_getLineStyle());
        } else {
            ImageLine($this->_canvas(), $x -7, $y, $x +7, $y, $this->_getLineStyle());
        }

        if (($this->_marker) and ($this->_dataset)) {
            $this->_dataset->_reset();
            $point = $this->_dataset->_next();
            $prevPoint = $this->_dataset->_nearby(-2);
            $nextPoint = $this->_dataset->_nearby();

            $point = $this->_getMarkerData($point, $nextPoint, $prevPoint, $i);
            if (is_array($point)) {
                $point['MARKER_X'] = $x;
                $point['MARKER_Y'] = $y;
                unset ($point['AVERAGE_Y']);
                $this->_marker->_drawMarker($point['MARKER_X'], $point['MARKER_Y'], $point);
            }
        }

        $text = new Image_Graph_Text($x + 20, $y, $this->_title, $font);
        $text->setAlignment(IMAGE_GRAPH_ALIGN_CENTER_Y | IMAGE_GRAPH_ALIGN_LEFT);
        $this->add($text);
        $text->_done();

        return array('Width' => 20+$font->width($this->_title), 'Height' => max(10, $font->height($this->_title)));
    }
Ejemplo n.º 7
0
 function index()
 {
     $this->load->model('marker');
     $randomWords = array('africa', 'animals', 'architecture', 'art', 'australia', 'autumn', 'baby', 'band', 'barcelona', 'beach', 'berlin', 'bird', 'birthday', 'black', 'blackandwhite', 'blue', 'boston', 'bw', 'california', 'cameraphone', 'camping', 'canada', 'canon', 'car', 'cat', 'chicago', 'china', 'christmas', 'church', 'city', 'clouds', 'color', 'concert', 'cute', 'dance', 'day', 'de', 'dog', 'england', 'europe', 'fall', 'family', 'festival', 'film', 'florida', 'flower', 'flowers', 'food', 'football', 'france', 'friends', 'fun', 'garden', 'germany', 'graffiti', 'green', 'halloween', 'hawaii', 'hiking', 'holiday', 'home', 'house', 'india', 'ireland', 'island', 'italia', 'italy', 'japan', 'july', 'kids', 'la', 'lake', 'landscape', 'light', 'live', 'london', 'macro', 'may', 'me', 'mexico', 'mountain', 'mountains', 'museum', 'music', 'nature', 'new', 'newyork', 'newyorkcity', 'night', 'nikon', 'nyc', 'ocean', 'old', 'paris', 'park', 'party', 'people', 'photo', 'photography', 'photos', 'portrait', 'red', 'river', 'rock', 'rome', 'san', 'sanfrancisco', 'scotland', 'sea', 'seattle', 'show', 'sky', 'snow', 'spain', 'spring', 'street', 'summer', 'sun', 'sunset', 'taiwan', 'texas', 'thailand', 'tokyo', 'toronto', 'tour', 'travel', 'tree', 'trees', 'trip', 'uk', 'urban', 'usa', 'vacation', 'vancouver', 'washington', 'water', 'wedding', 'white', 'winter', 'yellow', 'york', 'zoo');
     $emails = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
     for ($i = 0; $i < count($emails); $i++) {
         $word1 = $randomWords[rand(0, count($randomWords))];
         $leetI = str_replace('i', '1', $word1);
         $leetE = str_replace('e', '3', $leetI);
         $word2 = ucfirst($randomWords[rand(0, count($randomWords) - 1)]);
         $hashed = md5($word2);
         $randSeed = substr($hashed, rand(0, strlen($hashed) - 1), 2);
         $pass = $leetE . $randSeed;
         $marker = new Marker();
         $marker->set('email', $emails[$i]);
         $marker->set('password', $marker->makePass($pass));
         $marker->create();
         echo 'marker email ' . $emails[$i] . ' with pass ' . $pass . '</br>';
         echo 'pass check ' . $marker->checkPass($pass) . '</br>' . '</br>';
     }
 }
Ejemplo n.º 8
0
 /**
  * Draw the marker on the canvas
  * @param int $x The X (horizontal) position (in pixels) of the marker on the canvas 
  * @param int $y The Y (vertical) position (in pixels) of the marker on the canvas 
  * @param array $values The values representing the data the marker "points" to 
  * @access private
  */
 function _drawMarker($x, $y, $values = false)
 {
     if (is_a($this->_secondaryMarker, "Image_Graph_Marker")) {
         $this->_secondaryMarker->_drawMarker($x, $y, $values);
     }
 }
Ejemplo n.º 9
0
    $marker_id = $marker->getId();
    $bathroom = new Bathroom($unisex, $key_required, $public, $handicap, $changing_table, $marker_id);
    $bathroom->save();
    return $app['twig']->render('add_bathroom.html.twig', array('bathrooms' => Bathroom::getAll(), 'markers' => Marker::getAll(), 'form_check' => false));
});
$app->get('/bathroom/{id}', function ($id) use($app) {
    $bathroom = Bathroom::find($id);
    $marker = Marker::find($id);
    $reviews = Review::getReviewsForBathroom($bathroom);
    return $app['twig']->render('bathroom.html.twig', array('bathroom' => $bathroom, 'marker' => $marker, 'reviews' => $reviews));
});
// reviews
$app->get('/add_review/{id}', function ($id) use($app) {
    $marker = Marker::find($id);
    return $app['twig']->render('add_review.html.twig', array('marker' => $marker));
});
$app->post('/add_review/{id}', function ($id) use($app) {
    $review = $_POST['review'];
    $rating = $_POST['rating'];
    //get all the necessary objects
    $marker = Marker::find($id);
    $bathroom = Bathroom::find($marker->getId());
    //create new review obj
    $new_review = new Review($rating, $review);
    $new_review->save();
    $review_id = $new_review->getId();
    $bathroom->addReview($review_id);
    $reviews = Review::getReviewsForBathroom($bathroom);
    return $app['twig']->render('bathroom.html.twig', array('bathroom' => $bathroom, 'marker' => $marker, 'reviews' => $reviews));
});
return $app;
                 $map->addEncodedPolyline($encodedPolyline);
             }
         }
     }
     // end of 1st iteration. found time and distance
 }
 if ($i == 7) {
     $org = array();
     $org = getCoord($finarr[$i]);
     //echo $org[0]['latitude'];
     //echo $org[0]['longitude'];
     $des = array();
     $des = getCoord($finarr[$i + 1]);
     //echo $des[0]['latitude'];
     //echo $des[0]['longitude'];
     $marker3 = new Marker();
     $marker3->setPrefixJavascriptVariable('marker_');
     $marker3->setPosition($org[0]['latitude'], $org[0]['longitude'], true);
     $marker3->setAnimation(Animation::DROP);
     $marker3->setOption('clickable', true);
     $marker3->setOption('flat', true);
     $marker3->setOptions(array('clickable' => true, 'flat' => true));
     $map->addMarker($marker);
     $marker4 = new Marker();
     $marker4->setPrefixJavascriptVariable('marker_two');
     $marker4->setPosition($des[0]['latitude'], $des[0]['longitude'], true);
     $marker4->setAnimation(Animation::DROP);
     $marker4->setOption('clickable', true);
     $marker4->setOption('flat', true);
     $marker4->setOptions(array('clickable' => true, 'flat' => true));
     $map->addMarker($marker4);
Ejemplo n.º 11
0
<br/>with marker:<br/>
<img src="<?php 
echo $api->getUrlPart();
?>
"/>
<?php 
$api = new GoogleStaticMapApi();
$marker = new Marker();
$marker->setColor('yellow');
$marker->setSize(Marker::SIZE_MID);
$marker->setLabel("West from center");
//TODO not working
$marker->addLocation(new LatLng(50.058516, 19.910553));
$marker->addLocation(new LatLng(50.049189, 19.904416));
$api->addMarker($marker);
$marker = new Marker();
$marker->setColor('blue');
$marker->addLocation(new LatLng(50.06477, 20.052474));
//Benedict monastery
$marker->addLocation(new LatLng(50.065941, 20.045886));
//old hospital
$api->addMarker($marker);
$api->setZoom(10);
?>
<br/>styled markers:<br/>
<img src="<?php 
echo $api->getUrlPart();
?>
"/>
	</body>
	</html>
Ejemplo n.º 12
0
 function test_delete()
 {
     $test_marker = new Marker("Pok Pok", "123 abcd street", 34.343534, 41.89089, "Restaurant");
     $test_marker->save();
     $test_marker2 = new Marker("Whiskey Soda Lounge", "678 DEF street", 41.89089, 34.343534, "Bar");
     $test_marker2->save();
     $test_marker->delete();
     $this->assertEquals([$test_marker2], Marker::getAll());
 }
Ejemplo n.º 13
0
 /**
  * Draw a sample for use with legend
  *
  * @param array &$param The parameters for the legend
  *
  * @return void
  * @access private
  */
 function _legendSample(&$param)
 {
     if (!is_array($this->_dataset)) {
         return false;
     }
     if (is_a($this->_fillStyle, 'Image_Graph_Fill')) {
         $this->_fillStyle->_reset();
     }
     $count = 0;
     $keys = array_keys($this->_dataset);
     foreach ($keys as $key) {
         $dataset =& $this->_dataset[$key];
         $count++;
         $caption = $dataset->_name ? $dataset->_name : $this->_title;
         $this->_canvas->setFont($param['font']);
         $width = 20 + $param['width'] + $this->_canvas->textWidth($caption);
         $param['maxwidth'] = max($param['maxwidth'], $width);
         $x2 = $param['x'] + $width;
         $y2 = $param['y'] + $param['height'] + 5;
         if (($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0 && $y2 > $param['bottom']) {
             $param['y'] = $param['top'];
             $param['x'] = $x2;
             $y2 = $param['y'] + $param['height'];
         } elseif (($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) == 0 && $x2 > $param['right']) {
             $param['x'] = $param['left'];
             $param['y'] = $y2;
             $x2 = $param['x'] + 20 + $param['width'] + $this->_canvas->textWidth($caption);
         }
         $x = $x0 = $param['x'];
         $y = $param['y'];
         $y0 = $param['y'];
         $x1 = $param['x'] + $param['width'];
         $y1 = $param['y'] + $param['height'];
         if (!isset($param['simulate'])) {
             $this->_getFillStyle($key);
             $this->_getLineStyle();
             $this->_drawLegendSample($x0, $y0, $x1, $y1);
             if ($this->_marker && $dataset && $param['show_marker']) {
                 $dataset->_reset();
                 $point = $dataset->_next();
                 $prevPoint = $dataset->_nearby(-2);
                 $nextPoint = $dataset->_nearby();
                 $tmp = array();
                 $point = $this->_getMarkerData($point, $nextPoint, $prevPoint, $tmp);
                 if (is_array($point)) {
                     $point['MARKER_X'] = $x + $param['width'] / 2;
                     $point['MARKER_Y'] = $y;
                     unset($point['AVERAGE_Y']);
                     $this->_marker->_drawMarker($point['MARKER_X'], $point['MARKER_Y'], $point);
                 }
             }
             $this->write($x + $param['width'] + 10, $y + $param['height'] / 2, $caption, IMAGE_GRAPH_ALIGN_CENTER_Y | IMAGE_GRAPH_ALIGN_LEFT, $param['font']);
         }
         if (($param['align'] & IMAGE_GRAPH_ALIGN_VERTICAL) != 0) {
             $param['y'] = $y2;
         } else {
             $param['x'] = $x2;
         }
     }
     unset($keys);
 }
Ejemplo n.º 14
0
 public function testToStringWithNotSupportedColor()
 {
     $m = new Marker(new \GMaps\Location\Coordinate(1.1, 2.2));
     $m->setColor("foobar");
     $this->assertEquals("size:normal|color:red|1.1,2.2", $m->__toString());
 }
Ejemplo n.º 15
0
 public function get_delete_marker($id)
 {
     Marker::find($id)->delete();
     if (Auth::user()->group != 1) {
         return Redirect::to_route(Auth::user()->username)->with('message', 'Marker deleted!');
     } else {
         return Redirect::to_action('home@marker')->with('message', 'Marker deleted!');
     }
 }
Ejemplo n.º 16
0
/**
	
	@param $start<Location> the starting location (address)
	@param $end<Location> the ending location (address)
*/
function findDirPath($start, $end, $start_stations, $end_stations)
{
    $debug = false;
    if ($start == $end) {
        return "same";
    }
    if (distance($start, $end) < 0.25) {
        return "walk";
    }
    $WALKING_SPEED = 2 / 3600;
    #echo "findDirPath<br/>";
    // determine original bounding box
    $original_box = new Box($start->point, $end->point);
    // create end marker
    $end_name = $end->name;
    if ($end_name == "") {
        $end_name = $end->getAddressString();
    }
    $end_marker = new Marker($end->point->lat, $end->point->lng, "end", $end_name);
    if ($debug) {
        echo "end marker = ";
        $end_marker->printInfo();
    }
    // create array of paths
    $open = array();
    $start_name = $start->name;
    if ($start_name == "") {
        $start_name = $start->getAddressString();
    }
    $start_marker = new Marker($start->point->lat, $start->point->lng, "start", $start_name);
    if ($debug) {
        echo "start marker = ";
        $start_marker->printInfo();
    }
    foreach ($start_stations as $station) {
        $segment = new Segment($start_marker, $station->marker, $station->marker->lines, $station->getDistance() / $WALKING_SPEED, "walking");
        $visited = array();
        $visited[] = $station->marker;
        $new_box = new Box($station->marker->point, $end_marker->point);
        $path = new Path2($segment, $new_box, $visited);
        $area = $new_box->getArea();
        $array = $open["{$area}"];
        if ($array == null) {
            $array = array();
        }
        $array[] = $path;
        #echo "adding $array<br/>";
        $open["{$area}"] = $array;
    }
    return findPath($open, $end_stations, $end_marker);
}
function getMarker2($orglat, $orglong, $deslat, $deslong)
{
    //creating map
    $map = new Map();
    $map->setPrefixJavascriptVariable('map_');
    $map->setHtmlContainerId('map_canvas');
    $map->setAsync(false);
    $map->setAutoZoom(false);
    $map->setCenter(37.806381, -122.415468, true);
    $map->setMapOption('zoom', 16);
    $map->setBound(-2.1, -3.9, 2.6, 1.4, true, true);
    $map->setMapOption('mapTypeId', MapTypeId::ROADMAP);
    $map->setMapOption('mapTypeId', 'roadmap');
    $map->setMapOption('disableDefaultUI', true);
    $map->setMapOption('disableDoubleClickZoom', true);
    $map->setMapOptions(array('disableDefaultUI' => true, 'disableDoubleClickZoom' => true));
    $map->setStylesheetOption('width', '600px');
    $map->setStylesheetOption('height', '600px');
    $map->setStylesheetOptions(array('width' => '1000px', 'height' => '800px'));
    $map->setLanguage('en');
    //creating marker
    $marker3 = new Marker();
    $marker3->setPrefixJavascriptVariable('marker_');
    $marker3->setPosition($orglat, $orglong, true);
    $marker3->setAnimation(Animation::DROP);
    $marker3->setOption('clickable', true);
    $marker3->setOption('flat', true);
    $marker3->setOptions(array('clickable' => true, 'flat' => true));
    $map->addMarker($marker);
    $marker4 = new Marker();
    $marker4->setPrefixJavascriptVariable('marker_two');
    $marker4->setPosition($deslat, $deslong, true);
    $marker4->setAnimation(Animation::DROP);
    $marker4->setOption('clickable', true);
    $marker4->setOption('flat', true);
    $marker4->setOptions(array('clickable' => true, 'flat' => true));
    $map->addMarker($marker4);
    // trying directions
    $directions = new Directions(new CurlHttpAdapter());
    $request = new DirectionsRequest();
    // Set your origin
    $request->setOrigin($marker3->getPosition(), true);
    // Set your destination
    $request->setDestination($marker4->getPosition(), true);
    $response = $directions->route($request);
    // Get the routes
    $routes = $response->getRoutes();
    // Iterate each routes
    foreach ($routes as $route) {
        // Get the bound
        $bound = $route->getBound();
        // Get the copyrights
        $copyrights = $route->getCopyrights();
        // Get the legs
        $legs = $route->getLegs();
        // Get the summary
        //$summary = $route->getSummary();
        //print_r ($summary);
        foreach ($legs as $leg) {
            // Gets the distance
            $distance = $leg->getDistance();
            //$dist = (String)$distance;
            print_r($distance);
            // Gets the duration
            $duration = $leg->getDuration();
            print_r($duration);
            //summary
            //$summary = $leg->getSummary();
            //print_r ($summary);
            // Gets the directions steps.
            $steps = $leg->getSteps();
            // Iterate each step
            foreach ($steps as $step) {
                // Gets the encoded polyline.
                $encodedPolyline = $step->getEncodedPolyline();
                $map->addEncodedPolyline($encodedPolyline);
            }
        }
    }
    // end of 1st iteration. found time and distance
    //printing the map
    $mapHelper = new MapHelper();
    echo $mapHelper->renderHtmlContainer($map);
    echo $mapHelper->renderJavascripts($map);
}
Ejemplo n.º 18
0
 function panel()
 {
     $this->load->model('marker');
     $this->load->model('assessment');
     $this->load->library('validation');
     $this->load->model('mark');
     $this->load->model('markerPref');
     // form submit names
     $updatePref = 'updatePref';
     $markerEmail = $this->session->userdata($this->_sessionAuthVar);
     $marker = new Marker();
     $marker->retrieve($markerEmail);
     $markerPref = new MarkerPref();
     $markerPref->retrieve($markerEmail);
     // do this first due to the hacky implementation - it will result in doubled validation
     // messages for every other form
     if ($this->_updatePref($marker, $markerPref)) {
         $viewData['checkpoints'][] = 'You have successfully updated your job update preferences';
     }
     // assessment fix required?
     $requireFix = array("*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**");
     $viewData['assessmentFix'] = false;
     if (in_array($this->_getUser(), $requireFix)) {
         $viewData['assessmentFix'] = true;
     }
     $this->load->model('assessmentFix');
     if ($viewData['assessmentFix']) {
         $assessmentFix = new AssessmentFix();
         $assessmentFix->setKey($this->_getUser());
         if ($assessmentFix->retrieve()) {
             $viewData['assessmentFix'] = false;
         }
     }
     if ($this->input->post('assessmentFix')) {
         if ($this->_checkToken()) {
             $this->load->library('validation');
             $rules['requireFix'] = 'required';
             $fields['requireFix'] = 'yes or no';
             $this->validation->set_rules($rules);
             $this->validation->set_fields($fields);
             if ($this->validation->run() === true) {
                 $assessmentFix = new AssessmentFix();
                 $assessmentFix->requireFix($this->input->post('requireFix'));
                 $assessmentFix->setKey($this->_getUser());
                 $assessmentFix->create();
                 $viewData['checkpoints'][] = 'You have registered for the assessment fix. You will paid a re-assessment bounty when you submit your assessment.';
                 $viewData['assessmentFix'] = false;
             }
         }
     }
     if ($this->input->post('changePassword')) {
         if ($this->_checkToken()) {
             $this->load->library('validation');
             $rules['currentPassword'] = '******';
             $rules['newPassword'] = '******';
             $rules['newPasswordRepeat'] = 'required|matches[newPassword]';
             $fields['currentPassword'] = '******';
             $fields['newPassword'] = '******';
             $fields['newPasswordRepeat'] = 'new password repeated';
             $this->validation->set_rules($rules);
             $this->validation->set_fields($fields);
             if ($this->validation->run() === true) {
                 $marker = new Marker();
                 $marker->setKey($this->_getUser());
                 $marker->retrieve();
                 if ($marker->get('password') === $marker->makePass($this->input->post('currentPassword'))) {
                     $marker->set('password', $marker->makePass($this->input->post('newPassword')));
                     $viewData['checkpoints'][] = 'You have successfully changed your password.';
                     $marker->update();
                 } else {
                     $viewData['errors'][] = 'You did not enter your current password correctly.';
                 }
             }
         }
     }
     $viewData['token'] = $this->_token();
     $viewData['markerPref'] = $markerPref;
     if ($this->session->flashdata('action')) {
         $viewData['checkpoints'][] = $this->session->flashdata('action');
     }
     $viewData['marker'] = $marker;
     $headData['js'][] = 'eb_ui';
     $viewData['assessment'] = false;
     $viewData[$updatePref] = $updatePref;
     if ($this->assessment->retrieve($marker->getKey())) {
         $viewData['assessment'] = true;
     }
     $this->load->view('html_head.php', $headData);
     $this->load->view('page_head.php', array('bodyId' => 'my account', 'userAuth' => @$this->session->userdata('email'), 'markerAuth' => @$this->session->userdata('markerEmail'), 'site_pages' => $this->config->item('site_pages')));
     $this->load->view('marker/panel', $viewData);
     $this->load->view('footer.php', array('site_base' => $this->config->item('base_url')));
 }
Ejemplo n.º 19
0
/**
    @deprecated?
*/
function loadFromArray($array)
{
    $markers = array();
    $id = "";
    foreach ($array as $marker_array) {
        $marker = new Marker($marker_array[0]['lat'], $marker_array[0]['lng'], $marker_array[0]['id'], $marker_array[0]['name']);
        $id = $marker_array[0]['id'];
        echo "functions.load: processing {$id}<br/>\n";
        $count = count($marker_array);
        for ($i = 1; $i < $count; $i++) {
            $line_array = $marker_array[$i];
            $line = new Line($line_array[0]['img'], $marker_array[0]['url'], $marker_array[0]['name']);
            $count1 = count($line_array);
            for ($j = 1; $j < $count1; $j++) {
                $connection_array = $line_array[$j];
                $connection = new Connection($connection_array[0]['id'], $connection_array[0]['type'], $connection_array[0]['start'], $connection_array[0]['end'], $connection_array[0]['duration']);
                $line->addConnection($connection);
            }
            $marker->addLine($line);
        }
        $markers[$id] = $marker;
    }
    return $markers;
}
Ejemplo n.º 20
0
/**
    Builds the marker from data in the database and returns it.
    @param id<String> the marker id
    @return <Marker> a Marker object
*/
function retrieveMarker($id)
{
    $query = "SELECT * FROM markers WHERE id='{$id}'";
    $result = mysql_query($query) or die("Unable to retrieve marker of {$id} from the database.");
    if (count($result) > 1) {
        // error! there should only be one result
        echo "algorithm.getMarker() returned more than one result.<br/>\n";
    }
    $query_array = mysql_fetch_array($result, MYSQL_BOTH);
    $marker = new Marker($query_array['lat'], $query_array['lng'], $query_array['id'], $query_array['name']);
    $query = "SELECT * FROM connections WHERE marker_id='{$id}'";
    $result = mysql_query($query) or die("Unable to retrieve connections for {$id} from the database.");
    while ($c_array = mysql_fetch_array($result, MYSQL_BOTH)) {
        $connection = new Connection($c_array['id'], $c_array['type'], $c_array['start'], $c_array['end'], $c_array['day'], $c_array['duration']);
        $line = $marker->getLine($c_array['line']);
        if ($line == null) {
            // line doesn't exist yet, so create it
            $line_query = "SELECT * FROM lines WHERE name='" . $c_array['line'] . "'";
            $line_result = mysql_query($line_query) or die("Unable to retrieve line information for " . $c_array['line'] . " from the database.");
            if (count($line_result) > 1) {
                echo "algorithm.getMarker() returned more than one result when retrieving line " . $c_array['line'];
            }
            $line_array = mysql_fetch_array($line_result, MYSQL_BOTH);
            $line = new Line($line_array['img'], $line_array['url'], $line_array['name']);
            // add the line to the marker
            $marker->addLine($line);
        }
        // add the connection to the line
        $line->addConnection($connection);
    }
    // connection loop
    // done, return marker
    return $marker;
}
Ejemplo n.º 21
0
 function __construct($width, $height, $x, $y)
 {
     parent::__construct($width, $height);
     $this->position_x = $x;
     $this->position_y = $y;
 }
Ejemplo n.º 22
0
 static function find($search_id)
 {
     $found_marker = null;
     $markers = Marker::getAll();
     foreach ($markers as $marker) {
         $marker_id = $marker->getId();
         if ($marker_id == $search_id) {
             $found_marker = $marker;
         }
     }
     return $found_marker;
 }
Ejemplo n.º 23
0
 function __construct($test)
 {
     parent::__construct($test);
     //$this->engine = new MarkParse( $text );
 }
Ejemplo n.º 24
0
/*include("small_menu_start.php");*/
$mySql = new MySql();
if (isset($_SESSION[Session::C_SESSION_USER])) {
    $session = new Session($_SESSION[Session::C_SESSION_USER], $_SESSION[Session::C_SESSION_PASS], $mySql);
}
if (!isset($session) or !$session->IsConnected()) {
    header('Location: index.php');
    exit;
}
?>
            <!-- MAIN SECTION -->
            <section class="main-section">
                <div class="small-12 columns">
                    <div class="row">
                        <h4>marqueur - <?php 
$marker = new Marker();
if (isset($_POST["id"])) {
    $marker->initProperty($_POST["id"], $_POST["firstName"], $_POST["lastName"], strtotime($_POST["birth"]));
    $marker->PageMode = $_POST["pageMode"];
    $marker->validate($mySql);
    if (!$marker->getHasError()) {
        if ($marker->PageMode == Constants::PAGE_MODE_EDIT) {
            $marker->update($mySql);
        } else {
            $marker->addNew($mySql);
        }
        header('Location: marker.php');
        exit;
    }
    echo $marker->getFullName();
} else {
Ejemplo n.º 25
0
function findS2APath($start_marker, $end_stations, $end)
{
    $debug = false;
    $WALKING_SPEED = 2 / 3600;
    if ($debug) {
        echo "findS2APath<br/>";
    }
    // verify this is a legitimate search
    foreach ($end_stations as $station) {
        if ($station->marker == $start_marker) {
            return "walk";
        }
    }
    // create end marker
    $end_name = $end->name;
    if ($end_name == "") {
        $end_name = $end->getAddressString();
    }
    $end_marker = new Marker($end->point->lat, $end->point->lng, "end", $end_name);
    if ($debug) {
        echo "end marker = ";
        $end_marker->printInfo();
    }
    // create array of paths
    $open = array();
    foreach ($start_marker->getLines() as $line) {
        foreach ($line->getConnections() as $connection) {
            // get associated marker
            $marker = getMarker($connection->id);
            if ($debug) {
                echo "retrieved marker from connection (" . $connection->id . "): ";
                $marker->printInfo();
            }
            $lines = $start_marker->getOverlapLines($marker);
            $segment = new Segment($start_marker, $marker, $lines, $connection->duration, $connection->type);
            $visited = array();
            $visited[] = $start_marker;
            $visited[] = $marker;
            $new_box = new Box($marker->point, $end_marker->point);
            $path = new Path2($segment, $new_box, $visited);
            if ($marker == $end_marker) {
                return $path;
            }
            $area = $new_box->getArea();
            $array = $open["{$area}"];
            if ($array == null) {
                $array = array();
            }
            $array[] = $path;
            $open["{$area}"] = $array;
        }
    }
    return findPath($open, $end_stations, $end_marker);
}
Ejemplo n.º 26
0
 public function copyFrom(Marker $marker)
 {
     $this->setMeasure($marker->getMeasure());
     $this->setTitle($marker->getTitle());
     $this->setColor($marker->getColor());
 }
 /**
  * Render page template with all variables
  *
  * @return string
  */
 public static function page($slug = null, $inject = array())
 {
     // CHECK $slug IS NOT NULL
     $SLUG_FULL = is_null($slug) ? SLUG_FULL : $slug;
     // Page with lang = SITE_LANG and is_homepage = 1
     if ($SLUG_FULL === '/') {
         // HOMEPAGE
         $page = CmsPage::with(array('elements' => function ($query) {
             $query->where_is_valid(1);
         }))->where_lang(SITE_LANG)->where_is_valid(VALID())->first();
         if (empty($page)) {
             return Response::error('404');
         }
         // More pages with lang = SITE_LANG and slug = SLUG_FULL
     } else {
         // MORE PAGES
         // Check slug is not lang
         if (array_key_exists(str_replace('/', '', $SLUG_FULL), Config::get('cms::settings.langs'))) {
             //Redirect al cambio lingua
             return Redirect::to_action('site@lang', array(str_replace('/', '', $SLUG_FULL)));
         }
         // Get page
         $page = self::page_base($SLUG_FULL);
         // Check page exists
         if (empty($page)) {
             // If not exists, look at SLUG_FIRST and save SLUG_LAST
             $page = self::page_base(SLUG_FIRST);
             // Check page exists
             // Not exists
             if (empty($page)) {
                 return Response::error('404');
                 // It exists and it is a ZOOM of EXTRA
             } else {
                 // Get Model to load
                 switch (getExtra($page->extra_id)) {
                     case 'blogs':
                         $model = CmsBlog::with(array('blogrels'));
                         break;
                         //case 'products':
                         //	$model = 'CmsProduct';
                         //	break;
                 }
                 // Load ZOOM if $extra exists
                 if (isset($model)) {
                     $extra = $model->where_lang(SITE_LANG)->where_slug(SLUG_LAST)->where_is_valid(VALID())->first();
                 }
             }
         }
     }
     //Bind $elements / $extra to ZONE
     if (!empty($page)) {
         // Check if SITE_ROLE < access_level -> to_login
         if (SITE_ROLE < $page->access_level) {
             return Redirect::to_action('site@login')->with('back_url', $SLUG_FULL);
         }
         // Set page_layout from DB or default if not set
         $page_layout = $page->layout;
         if (empty($page->layout)) {
             $page_layout = 'default';
         }
         //INJECT PAGE LAYOUT
         if (!empty($inject)) {
             $page_layout = !empty($inject['layout']) ? $inject['layout'] : $page_layout;
         }
         // Get layouts from config.design
         $arr_layout = Config::get('cms::theme.layout_' . $page_layout);
         // Load template
         $layout = View::make('cms::theme.' . THEME . '.layouts.' . $page_layout);
         // Bind page name
         $layout['NAME'] = $page->name;
         $layout['CLASSNAME'] = Str::slug($page->name);
         // Check layout exists
         if (!empty($arr_layout)) {
             // Bind zones as empty to avoid errors
             foreach ($arr_layout as $key => $value) {
                 $layout[strtoupper($key)] = '';
             }
         }
         // Bind contents to layout variables
         if (!empty($page)) {
             // Bind elements to $ZONE in page layout
             if (!empty($page->elements)) {
                 // Create zone array
                 $zone = array();
                 foreach ($page->elements as $item) {
                     $tmp_text = '<div id="' . $item->name . '" class="' . Config::get('cms::theme.ele_class') . '">';
                     $tmp_text .= Marker::decode($item->text);
                     $tmp_text .= '</div>';
                     $zone[$item->zone][] = $tmp_text;
                 }
                 // INJECT EXTERNAL ELEMENT INTO ZONE
                 if (!empty($inject)) {
                     // Clean content
                     // unset($zone);
                     // Append results
                     $zone[$inject['zone']][0] = $inject['view'];
                 }
                 // Bind pageitem text to ZONE which become layout variable
                 foreach ($page->elements as $item) {
                     $layout[strtoupper($item->zone)] = trim(implode("\n", $zone[$item->zone]));
                 }
             } else {
                 $new_page = CmsPage::where_lang(SITE_LANG)->where_parent_id($page->id)->where_is_valid(1)->order_by('order_id', 'asc')->first();
                 if (!empty($new_page)) {
                     return Redirect::to($new_page->slug);
                 }
             }
             // Bind $extra to layout ZONE if present
             if (!empty($extra)) {
                 //EXTRA VIEW ZOOM
                 $extra_what = CONF('cms::settings.extra_id', $page->extra_id);
                 $tmp_text = View::make('cms::theme.' . THEME . '.partials.details.' . $extra_what);
                 $tmp_text['text'] = $extra;
                 // Bind extra name
                 $layout['NAME'] = $extra->name;
                 $layout['CLASSNAME'] = Str::slug($page->name);
                 // Bind pageitem text to ZONE which become layout variable
                 $layout[strtoupper($extra->zone)] = trim(implode("\n", array($tmp_text)));
             }
         }
     } else {
         // Page not found, empty layout
         $layout = '';
     }
     //Set default title
     $title = !empty($page->title) ? $page->title : $page->name;
     //Set $extra title
     $title = isset($extra) ? $extra->name : $title;
     $title = !empty($extra->title) ? $extra->title : $title;
     $title = CmsUtility::string_style($title, Config::get('cms::theme.title_style'));
     // Add preview string to title
     if (SLUG_PREVIEW) {
         $title = LL('cms::title.preview_title', CMSLANG) . $title;
     }
     //Set default keyw
     $keyw = !empty($page->keyw) ? $page->keyw : Config::get('cms::theme.keyw');
     //Set $extra keyw
     $keyw = isset($extra) ? $extra->keyw : $keyw;
     $keyw = !empty($extra->keyw) ? $extra->keyw : $keyw;
     //Set default descr
     $descr = !empty($page->descr) ? $page->descr : Config::get('cms::theme.descr');
     //Set $extra descr
     $descr = isset($extra) ? $extra->descr : $descr;
     $descr = !empty($extra->descr) ? $extra->descr : $descr;
     //Set default template, header, footer, layout se non settati
     $template = !empty($page->template) ? $page->template : 'default';
     $header = !empty($page->header) ? $page->header : 'default';
     $footer = !empty($page->footer) ? $page->footer : 'default';
     // INJECT PAGE PARTIALS
     if (!empty($inject)) {
         $template = !empty($inject['template']) ? $inject['template'] : $template;
         $header = !empty($inject['header']) ? $inject['header'] : $header;
         $footer = !empty($inject['footer']) ? $inject['footer'] : $footer;
     }
     //APPLICATION COMPOSER
     View::composer('cms::theme.' . THEME . '.templates.' . $template, function ($view) {
         CmsRender::asset();
         //BASE JS
         Asset::container('header')->add('base_js', Config::get('application.url') . '/site/js');
         if (!isset($view->title)) {
             $view->title = Config::get('cms::theme.title');
         }
         if (!isset($view->descr)) {
             $view->descr = Config::get('cms::theme.descr');
         }
         if (!isset($view->keyw)) {
             $view->keyw = Config::get('cms::theme.keyw');
         }
         if (!isset($view->header)) {
             $view->header = '';
         }
         if (!isset($view->layout)) {
             $view->layout = '';
         }
         if (!isset($view->footer)) {
             $view->footer = '';
         }
     });
     //Prepare html buffer
     $html = View::make('cms::theme.' . THEME . '.templates.' . $template)->with('title', $title)->with('keyw', $keyw)->with('descr', $descr)->nest('header', 'cms::theme.' . THEME . '.partials.header_' . $header)->with('layout', $layout)->nest('footer', 'cms::theme.' . THEME . '.partials.footer_' . $footer);
     //Output buffer
     self::clean_code($html);
 }
Ejemplo n.º 28
0
 public function testMessageElementMoreParameters()
 {
     $marker = new Marker();
     $this->assertEquals($this->object->getMapData(array('52.429222277955134,13.359375~Capital of Germany~Crazy people here!~ ~ ~Berlin;', 'service=leaflet')), array('markers' => array(array('pos' => array(array('lat' => 52.429222277955, 'lon' => 13.359375)), 'title' => "<p>Capital of Germany\n</p>", 'text' => "<p>Crazy people here!\n</p>")), 'zoom' => 14, 'center' => array('lat' => 52.429222277955, 'lon' => 13.359375)));
     $this->assertEquals($this->object->getErrorMessages(), array(\wfMessage('multimaps-element-more-parameters', $marker->getElementName())->escaped(), \wfMessage('multimaps-element-parameters-not-processed', '"' . implode('", "', array(' ', 'Berlin')) . '"')->escaped()));
 }
Ejemplo n.º 29
0
function MARKER($marker)
{
    return Marker::decode($marker);
}
Ejemplo n.º 30
0
/**
    Retrieves the markers from the DB and loads them into an array. It creates full
    Marker objects with Line and Connection objects.
    
    @return an array of Markers
*/
function retrieveMarkers()
{
    $debug = false;
    $markers = array();
    $query = 'SELECT * FROM markers';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
    while ($line = mysql_fetch_array($result, MYSQL_BOTH)) {
        $id = $line['id'];
        $lat = $line['lat'];
        $lng = $line['lng'];
        $name = $line['name'];
        $url = $line['url'];
        if ($debug) {
            echo "building marker: {$name} ({$id})<br/>";
        }
        $marker = new Marker($lat, $lng, $id, $name);
        $marker->setURL($url);
        // grab all connections
        $conn_query = "SELECT * FROM connections WHERE id='" . $id . "'";
        $conn_result = mysql_query($conn_query) or die('Query failed: ' . mysql_error());
        $lines = array();
        $line_names = array();
        while ($conn = mysql_fetch_array($conn_result, MYSQL_BOTH)) {
            // grab all variables from DB
            $marker_id = $conn['marker_id'];
            $day = $conn['day'];
            $duration = $conn['duration'];
            $line = $conn['line'];
            $type = $conn['type'];
            $start = $conn['start'];
            $end = $conn['end'];
            if ($debug) {
                echo "-&gt;found connection: {$marker_id}<br/>";
            }
            // create a new connection
            $connection = new Connection($marker_id, $type, $start, $end, $day, $duration);
            $marker_line = $lines["{$line}"];
            if (is_null($marker_line)) {
                $marker_line = array();
            }
            $marker_line[] = $connection;
            // add it to an array. we need it later.
            if ($debug) {
                echo "-&gt;found line: {$line}<br/>";
            }
            $lines["{$line}"] = $marker_line;
            if (!in_array($line, $line_names)) {
                if ($debug) {
                    echo "adding {$line} to line_names<br/>";
                }
                $line_names[] = $line;
            }
        }
        // connection loop
        if ($debug) {
            echo "line_names count: " . count($line_names) . "<br/>";
        }
        // retrieved all connections and set them in their appropriate lines.
        // now we need to create the lines
        foreach ($line_names as $line_name) {
            if ($debug) {
                echo "-&gt;looking at line: {$line_name}<br/>";
            }
            // for each line, grab the data from the database
            $line_query = "SELECT * FROM `lines` WHERE name='" . $line_name . "'";
            $line_result = mysql_query($line_query) or die('Query failed: ' . mysql_error());
            // the line_name is the unique key for that table, so we only need to get the first one
            $line_array = mysql_fetch_array($line_result, MYSQL_BOTH);
            $lname = $line_array['name'];
            $lurl = $line_array['url'];
            $limg = $line_array['img'];
            $line = new Line($limg, $lurl, $lname);
            if ($debug) {
                echo "--&gt;found line: " . $lname . "<br/>";
            }
            // now add all the connections
            $connections = $lines["{$line_name}"];
            foreach ($connections as $connection) {
                // each one is a connection object from above. add it
                $line->addConnection($connection);
                if ($debug) {
                    echo "---&gt;adding " . $connection->id . " to {$line_name}<br/>";
                }
            }
            // now add the line to the marker
            $marker->addLine($line);
            if ($debug) {
                echo "--&gt;adding {$line_name} to {$name}<br/>";
            }
        }
        // line loop
        // the marker object is created and populated. add to the markers array.
        $markers["{$id}"] = $marker;
        if ($debug) {
            echo "adding {$id} to markers<br/>";
        }
    }
    // marker loop
    return $markers;
}