Exemple #1
0
 function loadView($view)
 {
     $path = base::expand($view, '/views');
     Console::debugEx(LOG_BASIC, __CLASS__, "Attempting to invoke view from %s", $path);
     if (file_exists($path)) {
         Console::debugEx(LOG_BASIC, __CLASS__, "Invoking as Pure PHP View");
         $this->path = $path;
     } else {
         throw new ViewNotFoundException("The view " . $view . " could not be found");
     }
 }
Exemple #2
0
function expandpath($path)
{
    return base::expand($path);
}
Exemple #3
0
 /**
  * @brief Embed a view inside another one
  *
  * @param string $view The view to embed
  * @param array $data Optional data to pass to the view
  */
 static function embed($view, $data = null)
 {
     $vp = base::expand($view, '/views/');
     if (file_exists($vp)) {
         if (is_array($data)) {
             View::set($data);
         }
         View::load($view);
     } else {
         if (config::get(self::KEY_EMBED_EXCEPTION, false) == true) {
             throw new ViewException("Embedded view " . $view . " not found");
         }
         printf('<div style="display:block;"><div style="color:white; background-color:red; border:dotted 1px white; padding:5px; margin:1px;">View %s not found</div></div>', $view);
     }
 }
Exemple #4
0
 public static function updateActiveCountries(callback $callback = null)
 {
     self::updateCache($callback);
     $db = new DatabaseConnection();
     $cache = base::expand('app:/cache/geonames/');
     // Update hierarchy
     cb($callback, 'Importing hierarchy ...', 1);
     $fin = fopen('compress.zlib://' . $cache . 'hierarchy.gz', 'r');
     $rows = 0;
     $ltime = 0;
     while (!feof($fin)) {
         $fd = trim(fgets($fin));
         $ds = explode("\t", $fd . "\t\t");
         $db->updateRow("REPLACE INTO geonames_hierarchy " . "(parentid,geoid,htype) " . "VALUES " . "(%d,%d,%s)", $ds[0], $ds[1], $ds[2]);
         if (microtime(true) > $ltime + 1) {
             cb($callback, 'Importing hierarchy ... ' . $rows . " records imported", 1);
             $ltime = microtime(true);
         }
         $rows++;
     }
     cb($callback, 'Imported hierarchy (' . $rows . ' records)');
     fclose($fin);
     // Pull the list of countries to import
     $rs = $db->getRows("SELECT * FROM geonames_datasets WHERE active=1");
     foreach ($rs as $ci) {
         cb($callback, 'Importing ' . $ci['setkey'] . ' ...', 1);
         $fin = fopen('compress.zlib://' . $cache . $ci['setkey'] . '.gz', 'r');
         $rows = 0;
         $ltime = 0;
         while (!feof($fin)) {
             $dl = fgets($fin);
             if (trim($dl) != '') {
                 $ds = explode("\t", $dl);
                 $db->updateRow('REPLACE INTO geonames ' . '(geoid,name,asciiname,alternatenames,' . 'latitude,longitude,featureclass,featurecode,' . 'countrycode,countrycodealt,admin1code,admin2code,' . 'admin3code,admin4code,population,elevation,' . 'gtopo30,timezone,modificationdate) ' . 'VALUES ' . '(%d,%s,%s,%s, %.5f,%.5f,%s,%s,' . '%s,%s,%s,%s, %s,%s,%d,%d,' . '%d,%s,%s)', $ds[0], $ds[1], $ds[2], $ds[3], $ds[4], $ds[5], $ds[6], $ds[7], $ds[8], $ds[9], $ds[10], $ds[11], $ds[12], $ds[13], $ds[14], $ds[15], $ds[16], $ds[17], $ds[18]);
             }
             if (microtime(true) > $ltime + 1) {
                 cb($callback, 'Importing ' . $ci['setkey'] . ' ... ' . $rows . " records imported", 1);
                 $ltime = microtime(true);
             }
             $rows++;
         }
         fclose($fin);
         cb($callback, 'Imported ' . $ci['setkey'] . " (" . $rows . " records)");
     }
 }