Пример #1
0
 function _on_watched_dba_update($object)
 {
     // Note: the API key has to be defined in /etc/midgard/midcom.conf
     $apikey = $GLOBALS['midcom_config']['qaiku_apikey'];
     $_MIDCOM->load_library('org.openpsa.httplib');
     $message = array('channel' => 'opendata', 'source' => 'opengov.fi', 'lang' => 'fi', 'status' => '', 'external_url' => '');
     if ($object->get_parameter('fi.opengov.datacatalog', 'qaiku_id')) {
         // This is already on Qaiku, skip
         return;
     }
     if ($object instanceof midcom_baseclasses_database_article) {
         // Check that the article is a visible one
         $topic = new midcom_db_topic($object->topic);
         if ($topic->component != 'net.nehmer.blog') {
             return;
         }
         $message['status'] = "[blog] {$object->title}";
     } elseif ($object instanceof fi_opengov_datacatalog_dataset_dba) {
         // Check that the dataset is a published one
         if (!fi_opengov_datacatalog_dataset_dba::matching_license_type($object->guid, 'free')) {
             // We don't publicize closed datasets
             return;
         }
         $message['status'] = "[dataset] {$object->title}";
     } else {
         return;
     }
     $message['external_url'] = $_MIDCOM->permalinks->resolve_permalink($object->guid);
     $http = new org_openpsa_httplib();
     $json = $http->post("http://www.qaiku.com/api/statuses/update.json?apikey={$apikey}", $message);
     $qaiku = json_decode($json);
     if (is_object($qaiku) && isset($qaiku->id)) {
         $object->set_parameter('fi.opengov.datacatalog', 'qaiku_id', $qaiku->id);
     }
 }
Пример #2
0
 /**
  * Filters the dataset based on criteria
  * @param strin criteria (currently: open, closed)
  */
 private function _filter_datasets($criteria)
 {
     $_type = '';
     $_filtered = array();
     switch ($criteria) {
         case 'open':
             $_type = 'free';
             break;
         case 'closed':
             $_type = 'non-free';
             break;
     }
     if ($_type != '') {
         $this->_filter = $criteria;
         if (count($this->_datasets)) {
             $i = 0;
             foreach ($this->_datasets as $dataset) {
                 if (fi_opengov_datacatalog_dataset_dba::matching_license_type($dataset->guid, $_type)) {
                     $_filtered[] = $dataset;
                 }
                 ++$i;
             }
         }
     }
     $this->_datasets = $_filtered;
     unset($_type);
     unset($_filtered);
 }