Esempio n. 1
0
 /**
  * Add menu items to toolbar
  *
  * @param mixed $handler_id The ID of the handler.
  */
 public function _populate_toolbar($handler_id)
 {
     if (!$this->_object) {
         return;
     } else {
         if ($this->_object->can_do('midgard:admin')) {
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'suggestion/edit/' . $this->_object->guid, MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('edit %s'), 'suggestion'), MIDCOM_TOOLBAR_ICON => $this->_config->get('default_edit_icon')));
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'suggestion/delete/' . $this->_object->guid, MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('delete %s'), 'suggestion'), MIDCOM_TOOLBAR_ICON => $this->_config->get('default_trash_icon')));
         }
         if ($this->_object->can_do('midgard:create')) {
             $url = "create?";
             $defaults = array();
             $defaults['suggestion'] = $this->_object->guid;
             $defaults['title'] = $this->_object->title;
             $defaults['description'] = $this->_object->description;
             $defaults['organization'] = $this->_object->organization;
             $defaults['url'] = $this->_object->url;
             $defaults['tags'] = '';
             $tags = net_nemein_tag_handler::get_tags_by_guid($this->_object->guid);
             if (is_array($tags)) {
                 $defaults['tags'] = implode(" ", array_keys($tags));
             }
             foreach ($defaults as $key => $value) {
                 $url .= "defaults[{$key}]={$value}&";
             }
             $url = substr($url, 0, -1);
             $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $url, MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), 'dataset from suggestion'), MIDCOM_TOOLBAR_ICON => $this->_config->get('default_new_icon')));
         }
     }
 }
Esempio n. 2
0
 /**
  * Displays the datasets page
  *
  * @param mixed $handler_id The ID of the handler.
  * @param mixed &$data The local request data.
  */
 public function _show_read($handler_id, &$data)
 {
     if (isset($this->_datasets)) {
         if (!count($this->_datasets)) {
             midcom_show_style('no_dataset');
         } else {
             $this->_request_data['handler_id'] = $handler_id;
             if ($this->_show_list) {
                 $this->_request_data['filter'] = $this->_filter;
                 midcom_show_style('dataset_list_intro');
                 midcom_show_style('dataset_list_header');
             }
             $i = 0;
             foreach ($this->_datasets as $dataset) {
                 $this->_request_data['dataset'] = $dataset;
                 $this->_request_data['permalink'] = $_MIDCOM->permalinks->create_permalink($dataset->guid);
                 $this->_request_data['organization'] = fi_opengov_datacatalog_info_dba::get_details($dataset->organization, 'organization');
                 $this->_request_data['license'] = fi_opengov_datacatalog_info_dba::get_details($dataset->license, 'license');
                 $this->_request_data['formats'] = fi_opengov_datacatalog_dataset_dba::get_formats($dataset->id);
                 /* show different page when viewing only 1 dataset */
                 if ($handler_id == 'view' && !$this->_show_list) {
                     /* fetch and populate tags */
                     $this->_request_data['tags'] = net_nemein_tag_handler::get_tags_by_guid($dataset->guid);
                     /* gather blog posts about this dataset */
                     $this->_request_data['blogposts'] = $this->_seek_blogposts();
                     /* load the comments if enabled */
                     if ($this->_config->get('allow_comments')) {
                         $comments_node = $this->_seek_comments();
                         if ($comments_node) {
                             $this->_request_data['comments_url'] = $comments_node[MIDCOM_NAV_RELATIVEURL] . "comment/{$dataset->guid}";
                         }
                     }
                     midcom_show_style('dataset_item_detailed_view');
                 } else {
                     ++$i % 2 ? $this->_request_data['class'] = 'odd' : ($this->_request_data['class'] = 'even');
                     midcom_show_style('dataset_item_view');
                 }
             }
             if ($this->_show_list) {
                 midcom_show_style('dataset_list_footer');
             }
         }
     } else {
         midcom_show_style('no_dataset');
     }
 }