Beispiel #1
0
 public static function getSiteInfos($siteId)
 {
     $strings = ArkeoGIS::load_strings();
     $siteInfos = array();
     $query = "SELECT si_name AS name, si_code AS code, ST_AsGeoJSON(si_geom) AS geom, si_centroid AS centroid, si_occupation AS occupation, to_char(si_creation, 'dd/mm/yyyy') AS creation, to_char(si_modification, 'dd/mm/yyyy') AS modification, si_city_name AS city_name, si_city_code AS city_code, da_name AS dbname, da_owner_id as author FROM ark_site AS si ";
     $query .= "LEFT JOIN ark_database AS da ON si.si_database_id=da.da_id ";
     $query .= "WHERE si.si_id=?";
     $infos = \core\Core::$db->fetchAll($query, array($siteId));
     if (sizeof($infos) > 1) {
         throw new \Exception("Multiple result found for a site id");
     } else {
         if (sizeof($infos) < 1) {
             return NULL;
         }
     }
     $geom = json_decode($infos[0]['geom']);
     $siteInfos['database'] = $infos[0]['dbname'];
     $siteInfos['name'] = $infos[0]['name'];
     $siteInfos['code'] = $infos[0]['code'];
     $siteInfos['author'] = \mod\user\Main::getUserFullNameById($infos[0]['author']);
     $siteInfos['geom'] = $geom->coordinates;
     $siteInfos['centroid'] = $infos[0]['centroid'];
     $siteInfos['occupation'] = $infos[0]['occupation'];
     $siteInfos['creation'] = $infos[0]['creation'];
     $siteInfos['modification'] = $infos[0]['modification'];
     $siteInfos['city']['name'] = $infos[0]['city_name'];
     $siteInfos['city']['code'] = $infos[0]['city_code'];
     // Get site periods
     $query = "SELECT sp_id AS id, (SELECT node_path FROM ark_period WHERE pe_id=sp_period_start) AS period_start_path, (SELECT node_path FROM ark_period WHERE pe_id=sp_period_end) AS period_end_path, sp_period_isrange AS isrange, sp_knowledge_type AS knowledge, sp_comment AS comment, sp_bibliography AS bibliography FROM ark_site_period WHERE sp_site_id = ?";
     $datas = array();
     $caracs = array('realestate' => array(), 'production' => array(), 'furniture' => array(), 'landscape' => array());
     foreach (\core\Core::$db->fetchAll($query, array($siteId)) as $pInfos) {
         $periodHash = md5($pInfos['period_start_path'] . $pInfos['period_end_path']);
         if (!isset($siteInfos['characteristics'][$periodHash])) {
             $datas['start'] = Arkeogis::node_path_to_array($pInfos['period_start_path'], $strings['period']);
             $datas['end'] = Arkeogis::node_path_to_array($pInfos['period_end_path'], $strings['period']);
             $datas['knowledge'] = $pInfos['knowledge'];
             $datas['comment'] = $pInfos['comment'];
             $datas['bibliography'] = $pInfos['bibliography'];
             $siteInfos['characteristics'][$periodHash]['datas'] = $datas;
             unset($datas);
         }
         $i = sizeof($periodHash);
         // Realestate
         $q = "SELECT node_path, sr_exceptional FROM ark_siteperiod_realestate LEFT JOIN ark_realestate ON ark_siteperiod_realestate.sr_realestate_id=ark_realestate.re_id WHERE ark_siteperiod_realestate.sr_site_period_id = ?";
         foreach (\core\Core::$db->fetchAll($q, array($pInfos['id'])) as $carac) {
             $siteInfos['characteristics'][$periodHash]['caracs'][$i]['realestate'][] = array(Arkeogis::node_path_to_array($carac['node_path'], $strings['realestate']), $carac['sr_exceptional']);
         }
         // Production
         $q = "SELECT node_path, sp_exceptional FROM ark_siteperiod_production LEFT JOIN ark_production ON ark_siteperiod_production.sp_production_id=ark_production.pr_id WHERE ark_siteperiod_production.sp_site_period_id = ?";
         foreach (\core\Core::$db->fetchAll($q, array($pInfos['id'])) as $carac) {
             $siteInfos['characteristics'][$periodHash]['caracs'][$i]['production'][] = array(Arkeogis::node_path_to_array($carac['node_path'], $strings['production']), $carac['sp_exceptional']);
         }
         // Furniture
         $q = "SELECT node_path, sf_exceptional FROM ark_siteperiod_furniture LEFT JOIN ark_furniture ON ark_siteperiod_furniture.sf_furniture_id=ark_furniture.fu_id WHERE ark_siteperiod_furniture.sf_site_period_id = ?";
         foreach (\core\Core::$db->fetchAll($q, array($pInfos['id'])) as $carac) {
             $siteInfos['characteristics'][$periodHash]['caracs'][$i]['furniture'][] = array(Arkeogis::node_path_to_array($carac['node_path'], $strings['furniture']), $carac['sf_exceptional']);
         }
         // Landscape
         $q = "SELECT node_path, sl_exceptional FROM ark_siteperiod_landscape LEFT JOIN ark_landscape ON ark_siteperiod_landscape.sl_landscape_id=ark_landscape.la_id WHERE ark_siteperiod_landscape.sl_site_period_id = ?";
         foreach (\core\Core::$db->fetchAll($q, array($pInfos['id'])) as $carac) {
             $siteInfos['characteristics'][$periodHash]['caracs'][$i]['landscape'][] = array(Arkeogis::node_path_to_array($carac['node_path'], $strings['landscape']), $carac['sl_exceptional']);
         }
     }
     //	\core\Core::log($siteInfos);
     return $siteInfos;
 }
Beispiel #2
0
 public static function showthesheet($search)
 {
     if (!\mod\user\Main::userIsLoggedIn()) {
         return "not logged";
     }
     $columns = "ark_site.si_id, da_name, si_city_name, si_name, ";
     $columns .= "(SELECT pe_name_fr||'/'||pe_name_de FROM ark_period WHERE pe_id=min(sp_period_start)) AS period_start, ";
     $columns .= "(SELECT pe_name_fr||'/'||pe_name_de FROM ark_period WHERE pe_id=max(sp_period_end)) AS period_end ";
     $res = ArkeoGIS::search_sites($search, $columns, array('ark_database' => true), 1500, 'ark_site.si_id, da_id', 'ark_site.si_id', true, false);
     $total_count = $res['total_count'];
     $sites =& $res['sites'];
     $strings = ArkeoGIS::load_strings();
     foreach ($sites as $k => $row) {
         //\core\Core::log($row);
         //$sites[$k]['period_start'] = ArkeoGIS::node_path_to_str($row['period_start'], $strings['period'], '/');
         //$sites[$k]['period_end'] = ArkeoGIS::node_path_to_str($row['period_end'], $strings['period'], '/');
         $realestate = \core\Core::$db->fetchOne("SELECT array_agg(r1.node_path) FROM ark_site_period sp1 LEFT JOIN ark_siteperiod_realestate spr1 ON spr1.sr_site_period_id = sp1.sp_id LEFT JOIN ark_realestate r1 ON r1.re_id = spr1.sr_realestate_id WHERE sp1.sp_site_id = ?", array($row['si_id']));
         $furniture = \core\Core::$db->fetchOne("SELECT array_agg(f1.node_path) FROM ark_site_period sp1 LEFT JOIN ark_siteperiod_furniture spf1 ON spf1.sf_site_period_id = sp1.sp_id LEFT JOIN ark_furniture f1 ON f1.fu_id = spf1.sf_furniture_id WHERE sp1.sp_site_id = ?", array($row['si_id']));
         $production = \core\Core::$db->fetchOne("SELECT array_agg(p1.node_path) FROM ark_site_period sp1 LEFT JOIN ark_siteperiod_production spp1 ON spp1.sp_site_period_id = sp1.sp_id LEFT JOIN ark_production p1 ON p1.pr_id = spp1.sp_production_id WHERE sp1.sp_site_id = ?", array($row['si_id']));
         $landscape = \core\Core::$db->fetchOne("SELECT array_agg(l1.node_path) FROM ark_site_period sp1 LEFT JOIN ark_siteperiod_landscape spl1 ON spl1.sl_site_period_id = sp1.sp_id LEFT JOIN ark_landscape l1 ON l1.la_id = spl1.sl_landscape_id WHERE sp1.sp_site_id = ?", array($row['si_id']));
         $sites[$k]['realestate'] = implode(ArkeoGIS::node_path_array_to_str($realestate, $strings['realestate'], '/'), '<br />');
         $sites[$k]['furniture'] = implode(ArkeoGIS::node_path_array_to_str($furniture, $strings['furniture'], '/'), '<br />');
         $sites[$k]['production'] = implode(ArkeoGIS::node_path_array_to_str($production, $strings['production'], '/'), '<br />');
         $sites[$k]['landscape'] = implode(ArkeoGIS::node_path_array_to_str($landscape, $strings['landscape'], '/'), '<br />');
     }
     return $res;
 }