img {
	height: 30px;
	vertical-align: middle;
}
</style><?php 
foreach ($iconMap as $name => $icon) {
    echo '<div>' . $name . '=><img src="../' . $icon . '"/></div>';
}
echo "\n\n" . '   var iconSetMap=' . htmlspecialchars(json_encode($iconMap, JSON_PRETTY_PRINT)) . "\n\n";
$tableMetadata = AttributesTable::GetMetadata('newsAttributes');
EasyCsv::IterateRows_Assoc($csv, function ($row) use($tableMetadata, $iconMap) {
    $iconKey = trim($row['0']);
    $iconKey = str_replace('  ', ' ', $iconKey);
    $marker = MapController::GetFeatureWithName($row['Name']);
    if ($marker) {
        if (key_exists($iconKey, $iconMap)) {
            if ($marker->getIcon() != $iconMap[$iconKey]) {
                $marker->setIcon($iconMap[$iconKey]);
                // MapController::StoreMapFeature($marker);
            }
        } else {
            echo '<br/>missing key for: ' . $iconKey . ' | ' . $row['Name'] . '<br/></br/>';
        }
    } else {
        echo '<br/>missing marker for: ' . $row["Name"] . '<br/></br/>';
    }
});
?>


</pre>
// )) as $field) {
// echo $field;
// $u = EasyCsv::DistinctValues($csv, $field);
// sort($u);
// print_r($u);
// }
// $icons = EasyCsv::DistinctValues($csv, 'Icon');
// sort($icons);
// print_r($icons);
$tableMetadata = AttributesTable::GetMetadata('newsAttributes');
EasyCsv::IterateRows_Assoc($csv, function ($row) use($tableMetadata) {
    $marker = MapController::GetFeatureWithName($row['Name']);
    if (!$marker) {
        echo 'no marker for row: ' . print_r($row, true);
    }
    $urls = array();
    if (!empty($row['Source 1'])) {
        $urls[] = $row['Source 1'];
    }
    if (!empty($row['Source 2'])) {
        $urls[] = $row['Source 2'];
    }
    $date = strtotime($row['Date']);
    $attributes = array('paperType' => $row['Type of news'], 'transitionType' => $row['Transition'], 'transitionDate' => date('Y-m-d', $date), 'owner' => $row['Ownership'], 'community' => $row['Town'], 'url' => $urls, 'language' => $row['Language']);
    echo 'Attributes: ' . print_r(json_encode($attributes, JSON_PRETTY_PRINT)) . "\n";
    // AttributesRecord::Set($marker->getId(), $marker->getType(), $attributes, $tableMetadata);
});
?>


</pre>
Esempio n. 3
0
include_once dirname(__DIR__) . DS . 'lib' . DS . 'Localize.php';
include_once Core::LibDir() . DS . 'easycsv' . DS . 'EasyCsv.php';
$language = array();
$languageFilePath = dirname(__DIR__) . DS . 'language.csv';
if (file_exists($languageFilePath)) {
    $csv = EasyCsv::OpenCsv($languageFilePath);
    $cleaned = EasyCsv::CreateCsv(array('English', 'French'));
    //echo '<pre>';
    EasyCsv::IterateRows_Assoc($csv, function ($row, $i) use(&$language, &$cleaned) {
        if (!empty($row['English'])) {
            $language[$row['English']] = $row['French'];
            EasyCsv::AddRow($cleaned, array($row['English'], $row['French']));
        }
    });
    file_put_contents(dirname(__DIR__) . DS . 'language.json', json_encode($language, JSON_PRETTY_PRINT));
    file_put_contents(dirname(__DIR__) . DS . 'localize.csv', EasyCsv::Write($cleaned));
} else {
    $language = get_object_vars(json_decode(file_get_contents(__DIR__ . DS . 'words.json')));
}
Behavior('ajax');
Localize(function () {
    Scaffold('button.create.scheduled');
}, $language);
IncludeJS(dirname(__DIR__) . DS . 'js' . DS . 'UIFormManager.js');
IncludeJS(dirname(__DIR__) . DS . 'js' . DS . 'UIUsersFormsList.js');
IncludeJS(dirname(__DIR__) . DS . 'js' . DS . 'Language.js');
$keys = array_keys($language);
usort($keys, function ($a, $b) {
    return strlen($b) - strlen($a);
});
IncludeJSBlock('
Esempio n. 4
0
    $db->iterateAllSchedules(function ($record) use(&$csv, $fieldsNames) {
        $form = get_object_vars(json_decode($record->formData));
        $form['id'] = $record->id;
        $values = array();
        foreach ($fieldsNames as $field) {
            if (key_exists($field, $form)) {
                $values[] = $form[$field];
            } else {
                $values[] = "";
            }
        }
        EasyCsv::AddRow($csv, $values);
    });
    //header('Content-Type: application/csv;');
    //header('Content-disposition: filename="rwa-export-scheduled-' . date('Y-m-d') . '.csv"');
    echo EasyCsv::Write($csv);
    return;
}
Scaffold('user.admin.panel', array('url' => UrlFrom(__FILE__)), __DIR__ . DS . 'views');
/* @var $db ScheduleDatabase */
include_once __DIR__ . DS . 'database' . DS . 'ScheduleDatabase.php';
$db = ScheduleDatabase::GetInstance();
$total = 0;
foreach ($db->tables() as $table) {
    $updates = $db->verifyTable($table);
    if (count($updates)) {
        array_walk($updates, function ($alter) use($db) {
            $db->execute($alter);
            $count++;
        });
    }
    /* @var $layer Layer */
    print_r(array($layer->getId(), $layer->getName()));
}
$layerMap = array('community paper' => 1, 'daily paper - free' => 1, 'daily paper - paid' => 1, 'online' => 4, 'TV - private' => 3, 'TV - public' => 3, 'radio - public' => 2, 'radio - private' => 2);
if (!EasyCsv::DistinctValues($csv, 'Name')) {
    die('Expected \'Name\' field to contain unique values');
}
EasyCsv::IterateRows_Assoc($csv, function ($row) use($layerMap, $ShowNew, $ShowExisting) {
    //$typeOfNews=$row['Type of news'];
    $typeOfNews = trim(array_shift(explode(':', $row['0'])));
    if (key_exists($typeOfNews, $layerMap)) {
        if (MapController::GetFeatureWithName($row['Name'])) {
            if ($ShowSkipped) {
                echo 'Existing Marker: ' . $row['Name'] . "\n";
            }
            return;
            // skip.
        } else {
        }
        $marker = new Marker();
        $marker->setCoordinates($row['LAT_Y'], $row['LONG_X'])->setName($row['Name'])->setDescription($row['What happened?'])->setLayerId($layerMap[$typeOfNews]);
        if ($ShowNew) {
            echo 'New Marker: ' . print_r(json_encode($marker->getMetadata(), JSON_PRETTY_PRINT)) . "\n";
        }
        // MapController::StoreMapFeature($marker);
    } else {
        die('Unknown value in \'Type of News\': ' . $typeOfNews);
    }
});
?>
</pre>
Esempio n. 6
0
 public static function ExportQuarterlyForms()
 {
     include_once Core::LibDir() . DS . 'easycsv' . DS . 'EasyCsv.php';
     include_once dirname(__DIR__) . DS . 'database' . DS . 'ScheduleDatabase.php';
     $db = ScheduleDatabase::GetInstance();
     include_once __DIR__ . '/RWAForm.php';
     $fieldsNames = array_unique(array_merge(array('id', 'code', 'submitDate', 'formDate'), RWAForm::GetFieldNames('quarterly')));
     $csv = EasyCsv::CreateCsv($fieldsNames);
     $db->iterateAllQuarterlys(function ($record) use(&$csv, $fieldsNames) {
         $form = get_object_vars(json_decode($record->formData));
         $values = array();
         foreach ($fieldsNames as $field) {
             if (key_exists($field, $form)) {
                 $theValue = $form[$field];
                 if (is_object($theValue) || is_array($theValue)) {
                     $theValue = json_encode($theValue);
                 }
                 $values[] = $theValue;
             } else {
                 $values[] = "";
             }
         }
         $values[0] = $record->id;
         $values[1] = $record->code;
         $values[2] = $record->submitDate;
         $values[3] = $record->formDate;
         EasyCsv::AddRow($csv, $values);
     });
     header('Content-Type: application/csv;');
     header('Content-disposition: filename="rwa-export-quarterly-' . date('Y-m-d') . '.csv"');
     echo EasyCsv::Write($csv);
     return;
 }