Beispiel #1
0
function fetchNextRow($row)
{
    global $lexemDbResult;
    global $sourceMap;
    global $currentLexem;
    $def = Model::factory('Definition')->create($row);
    $def->internalRep = AdminStringUtil::xmlizeRequired($def->internalRep);
    if (hasFlag('d')) {
        $def->internalRep = AdminStringUtil::xmlizeOptional($def->internalRep);
    }
    $lexemNames = array();
    $lexemLatinNames = array();
    while (merge_compare($def, $currentLexem) < 0) {
        $currentLexem = $lexemDbResult->fetch();
    }
    while (merge_compare($def, $currentLexem) == 0) {
        $lexemNames[] = $currentLexem[1];
        $lexemLatinNames[] = StringUtil::unicodeToLatin($currentLexem[1]);
        $currentLexem = $lexemDbResult->fetch();
    }
    SmartyWrap::assign('def', $def);
    SmartyWrap::assign('lexemNames', $lexemNames);
    SmartyWrap::assign('lexemLatinNames', $lexemLatinNames);
    SmartyWrap::assign('source', $sourceMap[$def->sourceId]);
    SmartyWrap::assign('user', userCache_get($def->userId));
}
Beispiel #2
0
 /**
  * @AjaxCallable=TRUE
  * @AjaxMethod=POST
  * @AjaxAsync=TRUE
  */
 public function loadData()
 {
     $this->load->library('geo/*');
     $this->load->model('POIModel');
     $this->load->model('LabelModel');
     // Helper functions
     function addFlag(&$res, $flag)
     {
         in_array($flag, $res['flags']) ? null : ($res['flags'][] = $flag);
     }
     function hasFlag($res, $flag)
     {
         return in_array($flag, $res);
     }
     function addLabels(&$res, $labels)
     {
         $res['labels'] = array_merge($res['labels'], $labels);
     }
     // Required params
     $vBoundsWKT = filter_input(INPUT_POST, 'vBounds', FILTER_SANITIZE_STRING);
     $zoom = filter_input(INPUT_POST, 'zoom', FILTER_VALIDATE_INT);
     // Optional params, need to normalise if not present
     $types = filter_input(INPUT_POST, 'types', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY);
     $poiId = filter_input(INPUT_POST, 'poiId', FILTER_VALIDATE_INT);
     $poiIds = filter_input(INPUT_POST, 'poiIds', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY);
     $flags = filter_input(INPUT_POST, 'flags', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY);
     $vBounds = ViewBounds::fromWKT($vBoundsWKT);
     // Normalise parameters
     if ($types === NULL) {
         $types = [];
     }
     if ($poiId === NULL) {
         $poiId = 0;
     }
     if ($poiIds === NULL) {
         $poiIds = [];
     }
     if ($flags === NULL) {
         $flags = [];
     }
     // Prepare result object
     $res = ['labels' => [], 'flags' => []];
     if ($poiId !== 0 && !hasFlag($flags, 'excludePoiLabel')) {
         $poi = POIModel::load($poiId);
         $res['labels'][] = LabelModel::loadDynamic($poiId);
         $res['poi'] = [];
         addFlag($res, 'doLabelling');
         // Load poi info
         if (hasFlag($flags, 'poiInfo')) {
             $res['poi']['info'] = $poi->toObject();
         }
         // Load poi card
         if (hasFlag($flags, 'poiCard')) {
             $res['poi']['card'] = "<div>Card</div>";
             addFlag($res, 'showCard');
         }
         // Pan to poi and fit border or adjust zoom accordingly
         if (hasFlag($flags, 'panToPoi')) {
             $border = $poi->border();
             if ($border === NULL) {
                 $vBounds->setCenter($poi->latLng());
                 $vBounds->changeZoom(14 - $zoom);
                 $zoom = 14;
             } else {
                 $borderBounds = ViewBounds::fromPolygon($border);
                 $vBounds->fitBounds($borderBounds, $zoom);
             }
             addFlag($res, 'panToCenter');
         }
     }
     if (count($poiIds) > 0) {
         // Load labels by poiIds
         addLabels($res, LabelModel::loadDynamicByIds($poiIds));
         if (hasFlag($flags, 'zoomToPois')) {
             // Load pois for their positions and borders
             $pois = POIModel::loadByIds($poiIds);
             // Expand pois
             if ($poiId !== 0) {
                 $poi = POIModel::load($poiId);
                 $pois = array_merge($pois, [$poi]);
             }
             // Initialise bounds and extend by all pois
             $bounds = new ViewBounds($pois[0]->latLng(), $pois[0]->latLng());
             for ($i = 1; $i < count($pois); $i++) {
                 if ($pois[$i]->border() === NULL) {
                     $bounds->extendByLatLng($pois[$i]->latLng());
                 } else {
                     $borderBounds = ViewBounds::fromPolygon($pois[$i]->border());
                     $bounds->extendByBounds($borderBounds);
                 }
             }
             $vBounds->fitBounds($bounds, $zoom);
             $bounds->buffer(30, 30, $zoom);
             $vBounds->fitBounds($bounds, $zoom);
         }
         addFlag($res, 'panToCenter');
         addFlag($res, 'doLabelling');
     }
     if (count($types) > 0) {
         $bounds = $vBounds->toBounds();
         if (in_array('zoomToTypes', $flags)) {
             $guard = 18;
             //                while (!LabelModel::typesWithinBounds($bounds, $types, $poiId) && --$guard > 0) {
             while (!LabelModel::oneOfTypesWithinBounds($bounds, $types, $poiId) && --$guard > 0) {
                 $vBounds->zoomOut();
                 $bounds = $vBounds->toBounds();
                 $zoom--;
                 addFlag($res, 'panToCenter');
             }
         }
         addLabels($res, LabelModel::loadDynamicByBounds($bounds, $types, $poiId));
         addFlag($res, 'doLabelling');
     }
     if ($poiId !== 0 || $types !== NULL && count($types) > 0) {
         $bounds = $vBounds->toBounds();
         $exceptIds = array_merge($poiIds, [$poiId]);
         addLabels($res, LabelModel::loadStaticDynamicByBounds($bounds, $zoom, $exceptIds, $types));
     } else {
         $bounds = $vBounds->toBounds();
         addLabels($res, LabelModel::loadStaticByBounds($bounds, $zoom));
     }
     if (hasFlag($flags, 'newPois')) {
         // Parameter '1' TO BE changed to logged-in user's id
         $bounds = $vBounds->toBounds();
         $res['new'] = LabelModel::loadNew($bounds, 1);
     }
     $res['center'] = $vBounds->getCenter()->toWKT();
     $res['zoom'] = $zoom;
     return $res;
 }