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>
<?php 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);
// )) 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>
/* @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>