├── .gitignore ├── .probo.yml ├── CHANGELOG.txt ├── LICENSE.txt ├── README.md ├── circle.yml ├── css ├── dkan-flaticon.css ├── dkan_dataset.css ├── dkan_dataset.css.orig └── dkan_dataset_btn.css ├── dkan-module-init.sh ├── dkan.make ├── dkan_dataset.admin.inc ├── dkan_dataset.api.php ├── dkan_dataset.features.inc ├── dkan_dataset.forms.inc ├── dkan_dataset.info ├── dkan_dataset.install ├── dkan_dataset.make ├── dkan_dataset.module ├── dkan_dataset.pages.inc ├── dkan_dataset.strongarm.inc ├── dkan_dataset.theme.inc ├── fonts ├── dkan-flaticon.eot ├── dkan-flaticon.svg ├── dkan-flaticon.ttf └── dkan-flaticon.woff ├── images ├── sprite-ckan-icons.png └── sprite-resource-icons.png ├── import └── rdf.php ├── includes ├── Dataset.inc ├── getRemoteFileInfo.php └── getRemoteFileInfoExample.php ├── js ├── dataset.js ├── dkan_forms.js ├── dkan_forms.slugify.js └── dkan_tooltip.js ├── modules ├── dkan_dataset_api │ ├── dkan_dataset_api.inc │ ├── dkan_dataset_api.info │ ├── dkan_dataset_api.module │ └── tests │ │ ├── dkan_dataset_api.test │ │ └── files │ │ └── test.csv ├── dkan_dataset_content_types │ ├── dkan_dataset_content_types.api.php │ ├── dkan_dataset_content_types.features.field_base.inc │ ├── dkan_dataset_content_types.features.field_instance.inc │ ├── dkan_dataset_content_types.features.inc │ ├── dkan_dataset_content_types.features.taxonomy.inc │ ├── dkan_dataset_content_types.field_group.inc │ ├── dkan_dataset_content_types.info │ ├── dkan_dataset_content_types.license_field.inc │ ├── dkan_dataset_content_types.module │ ├── dkan_dataset_content_types.strongarm.inc │ └── includes │ │ └── language_code_list.php ├── dkan_dataset_groups │ ├── default_images │ │ └── group.png │ ├── dkan_dataset_groups.context.inc │ ├── dkan_dataset_groups.facetapi_defaults.inc │ ├── dkan_dataset_groups.features.field_base.inc │ ├── dkan_dataset_groups.features.field_instance.inc │ ├── dkan_dataset_groups.features.inc │ ├── dkan_dataset_groups.info │ ├── dkan_dataset_groups.install │ ├── dkan_dataset_groups.module │ ├── dkan_dataset_groups.strongarm.inc │ ├── dkan_dataset_groups.views_default.inc │ └── modules │ │ └── dkan_dataset_groups_perms │ │ ├── dkan_dataset_groups_perms.features.inc │ │ ├── dkan_dataset_groups_perms.features.og_features_permission.inc │ │ ├── dkan_dataset_groups_perms.info │ │ └── dkan_dataset_groups_perms.module ├── dkan_dataset_rest_api │ ├── .gitignore │ ├── README.md │ ├── dkan_dataset_rest_api.features.inc │ ├── dkan_dataset_rest_api.info │ ├── dkan_dataset_rest_api.module │ └── dkan_dataset_rest_api.services.inc └── dkan_dataset_voting │ ├── dkan_dataset_voting.features.field_base.inc │ ├── dkan_dataset_voting.features.field_instance.inc │ ├── dkan_dataset_voting.features.inc │ ├── dkan_dataset_voting.info │ ├── dkan_dataset_voting.module │ └── dkan_dataset_voting.strongarm.inc └── tests ├── composer.json ├── composer.lock ├── dkan_dataset.test ├── dkan_dataset_class.test ├── getRemoteFileInfoTest.php └── getUrlTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | vendor 3 | bin 4 | -------------------------------------------------------------------------------- /.probo.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: Setup QA site 3 | # Currently this "Script" is not documented in probo's docs, but it fixes the issue of 4 | # Probo reporting back immediately that probo is completely ready when it's not. Note that 5 | # we need to use 'script:' instead of 'command:' 6 | plugin: Script 7 | script: | 8 | # Fail right away. 9 | set -e 10 | # Start in the right folder of our checkout (/src) 11 | cd $SRC_DIR; 12 | # Modify SRC_DIR so it matchs dkan-module-init.sh requirements. 13 | DKAN_MODULE=`ls *.info | cut -d'.' -f1` 14 | cd .. 15 | mv $SRC_DIR ./$DKAN_MODULE 16 | cd $DKAN_MODULE 17 | export SRC_DIR=`pwd` 18 | 19 | echo "" 20 | echo "Build $BUILD_ID " 21 | echo "" 22 | 23 | echo "" 24 | echo "-------> Run 'bash dkan-init.sh':" 25 | echo "" 26 | # Create the proper folder structure 27 | export DATABASE_URL="mysql://root:strongpassword@127.0.0.1/dkan" 28 | time bash dkan-module-init.sh --deps --build=$DATABASE_URL 29 | #Set a symlink so that probo can serve the site. 30 | 31 | echo "" 32 | echo "-------> Symlink ./docroot to var/www/html:" 33 | echo "" 34 | ln -s $SRC_DIR/docroot /var/www/html 35 | chmod -R 777 /var/www/html/sites/default/files 36 | 37 | echo "" 38 | echo "The url of this build should be at:" 39 | echo " https://$BUILD_ID.probo.build" 40 | echo "" 41 | echo "Known Issues (1/22/2016):" 42 | echo " - Site may give a SQL error on initial load. Give it a few seconds and then refresh and it should work. This is due to the container apache waking up before the MYSQL. Probo.ci knows, but they say it's not at the top of the priority since few are having that issue." 43 | echo " - You should usually choose: the Build Permalink (blue button) for doing site QA. If you don't any new commits may blow away the site while you are viewing it as well as the data. 'View Site' Green button shows the latest build, so it can change while you are interacting with it." 44 | echo "" 45 | -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | 7.x-1.x 2 | -------------------------- 3 | - Upgrade Features to 7.x-2.9 4 | - Make date facet use "day" granularity. 5 | 6 | 7.x-1.11 2016-02-02 7 | -------------------------- 8 | - Fix some bugs breaking the resource links on dataset pages 9 | - Re-arranged group links on group landing pages; membership links now in sidebar rather than tabs 10 | - For long fields in the "additional info" custom metadata table on dataset pages, limit the row height for fields displaying extremely long text values 11 | - Add a list of related visualizations (if using the [Visualization Entity](https://github.com/NuCivic/visualization_entity) module) to resource pages 12 | - Move group-level permission export into new dkan_dataset_groups_perms module 13 | - Fixed counting of datasets, broken when a dataset belongs to more than one group 14 | - Hide "add resource" button on datasets from users who do not have permission to do so 15 | - Numerous small improvements and bug fixes 16 | 17 | 7.x-1.10 2015-11-10 18 | -------------------------- 19 | - NOTE: 7.x-1.10 Was re-released on 2015-11-18 to address bugs in the teaser preview links. 20 | - Various improvements to dataset teaser displays. 21 | - Support for external previews (opening catalogued resources instantly in third-party visualization services, including ArcGIS and CartoDB) 22 | - Support for Flaticon at module level, so vector icons work on any theme 23 | - Minor improvements and bugfixes 24 | 25 | 7.x-1.9 2015-09-17 26 | -------------------------- 27 | - Fixed issues around the group/publisher field in search indexes and facets 28 | - When multiple resources are available for a dataset, new option to download all as zip file 29 | - Improvements for resource display in dataset pages and teasers 30 | - New hooks to allow additional license options https://github.com/NuCivic/dkan/issues/447 31 | - Numerous small improvements and bugfixes 32 | 33 | 7.x-1.8 2015-04-02 34 | -------------------------- 35 | - Several recline.js tweaks 36 | - Updated open_data_schema_map to include module that allows to hook your own custom output formatters (xml example included) 37 | - Security updates for contrib modules 38 | 39 | 40 | 41 | 7.x-1.7 2015-02-20 42 | -------------------------- 43 | - Adds Project Open Data v1.1 schema through open_data_schema_map update 44 | - Adds dkan data.json v1.1 complaint implementation through open_data_schema_map_dkan update 45 | - Adds Panels implementation for dkan_dataset_groups: http://docs.getdkan.com/dkan-documentation/dkan-users-guide/customize-dkan-pages-layouts-and-components-using-panels 46 | - Updates to dkan_dataset stylesheet to make them radix compatible 47 | - Security updates for several modules 48 | 49 | 7.x-1.6 50 | --------- 51 | - Creating taxonomies during setup test 52 | - Updating ref_field patch 53 | - Replacing dkan_dataset_api with open_data_schema_map 54 | 55 | 7.x-1.4 2014-10-10 56 | -------------------------- 57 | - Many warnings fixed with proper isset calls 58 | - Changes in make file (fixed versions on some components) 59 | - Additional Info block on dataset page 60 | - Added docx as allowed format for field_upload 61 | - 62 | 63 | 7.x-1.1 2013-06-27 64 | ------------------ 65 | - Change references to NuCivic organization on github 66 | - Several bug fixes 67 | - Some changes for Project Open Data compliance, including data.json self-reference 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Circle CI](https://circleci.com/gh/NuCivic/dkan_dataset.svg?style=svg)](https://circleci.com/gh/NuCivic/dkan_dataset) 2 | 3 | **DEPRECATED:** This module has been moved into [DKAN core](https://github.com/NuCivic/dkan) for release 7.x-1.13. To maintain backward compatibility with DKAN 7.x-1.12 and subsequent patch releases this project will remain on Github but new features will be applied directly to the DKAN core folder `modules/dkan/dkan_dataset`. 4 | 5 | # DKAN Dataset 6 | 7 | This is a Drupal module containing the content types and other functionality to publish Open Data sets in Drupal. 8 | 9 | DKAN Dataset is a standalone module that can be added to any existing Drupal 7 site. 10 | 11 | DKAN Dataset is part of the [DKAN](https://drupal.org/project/dkan "DKAN homepage") project which includes the [DKAN profile](https://drupal.org/project/dkan "DKAN homepage") which creates a standalone Open Data portal, and [DKAN Datastore](https://drupal.org/project/dkan_datastore "DKAN Datastore homepage") which is a module that can be coupled with DKAN Dataset to offer a datastore and data previews. 12 | 13 | DKAN Dataset is currently managed in code on Github but is mirrored on Drupal.org. 14 | 15 | ## INSTALLATION 16 | 17 | This module REQUIRES implementers to use "drush make". If you only use "drush download" you will miss key dependencies for required modules and libraries. 18 | 19 | See installation instructions here: http://docs.getdkan.com/dkan-documentation/dkan-developers/adding-dkan-features-existing-drupal-site#Installing_DKAN_Dataset 20 | 21 | ## Contributing 22 | 23 | We are accepting issues in the dkan issue thread only -> https://github.com/NuCivic/dkan/issues -> Please label your issue as **"component: dkan_dataset"** after submitting so we can identify problems and feature requests faster. 24 | 25 | If you can, please cross reference commits in this repo to the corresponding issue in the dkan issue thread. You can do that easily adding this text: 26 | 27 | ``` 28 | NuCivic/dkan#issue_id 29 | ``` 30 | 31 | to any commit message or comment replacing **issue_id** with the corresponding issue id. 32 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | ## Customize the test machine 2 | machine: 3 | 4 | timezone: 5 | America/New_York # Set the timezone 6 | 7 | # Version of ruby to use 8 | php: 9 | version: '5.5.11' 10 | 11 | # Override /etc/hosts 12 | #hosts: 13 | #circlehost: 127.0.0.1 14 | #dev.mycompany.com: 127.0.0.1 15 | 16 | # Add some environment variables 17 | environment: 18 | # For xvfb / selenium setup (not sure why) 19 | #DISPLAY: ':99.0' 20 | DATABASE_URL: mysql://ubuntu:@127.0.0.1:3306/circle_test 21 | ## Customize checkout 22 | ## Note: Only post is supported. 23 | checkout: 24 | post: 25 | # Remove the extra composer stuff that circleci loads and that is causing conflicts with drush. 26 | - rm -rf ~/.composer 27 | 28 | ## Customize dependencies 29 | dependencies: 30 | 31 | cache_directories: 32 | #- "test/vendor" 33 | #- "~/.composer" 34 | #- "~/.drush" 35 | #- "~/backups" 36 | #- "test/sites/default" 37 | pre: 38 | - echo "memory_limit = 256M" > ~/.phpenv/versions/5.5.11/etc/conf.d/memory.ini 39 | override: 40 | - mkdir $CIRCLE_ARTIFACTS/junit 41 | - 'bash dkan-module-init.sh --deps --build=$DATABASE_URL' 42 | - 'ahoy drush --yes runserver :8888': 43 | background: true 44 | 45 | # Setup display for selenium 46 | #- sh -e /etc/init.d/xvfb start 47 | #- sleep 3 48 | 49 | - wget http://selenium-release.storage.googleapis.com/2.48/selenium-server-standalone-2.48.2.jar 50 | - java -jar selenium-server-standalone-2.48.2.jar -quiet -p 4444 -log shut_up_selenium : 51 | background: true 52 | pre: 53 | - echo "memory_limit = 256M" > ~/.phpenv/versions/5.5.11/etc/conf.d/memory.ini 54 | post: 55 | - sudo apt-get install -y x11vnc 56 | - x11vnc -forever -nopw: 57 | background: true 58 | # we automatically cache and restore many dependencies between 59 | # builds. If you need to, you can add custom paths to cache: 60 | #cache_directories: 61 | # - "custom_1" # relative to the build directory 62 | # - "~/custom_2" # relative to the user's home directory 63 | 64 | ## Customize database setup 65 | database: 66 | override: 67 | # replace CircleCI's generated database.yml 68 | #- cp config/database.yml.ci config/database.yml 69 | #- bundle exec rake db:create db:schema:load 70 | 71 | ## Customize test commands 72 | test: 73 | override: 74 | # Fix for behat bug not recognizing symlinked feature files. 75 | # - bash dkan/test/circle-behat.sh docroot/profiles/dkan/modules/dkan/dkan_workflow/test/features docroot/profiles/dkan/test/features: 76 | - bash dkan/test/circle-behat.sh docroot/profiles/dkan/test/features: 77 | parallel: true 78 | post: 79 | - echo $CIRCLE_ARTIFACTS; cp -av dkan/test/assets $CIRCLE_ARTIFACTS: 80 | parallel: true 81 | # - bundle exec rake jasmine:ci: # add an extra test type 82 | # environment: 83 | # RAILS_ENV: test 84 | # RACK_ENV: test 85 | 86 | ## Customize deployment commands 87 | #deployment: 88 | # staging: 89 | # branch: master 90 | # heroku: 91 | # appname: foo-bar-123 92 | 93 | ## Custom notifications 94 | #notify: 95 | # webhooks: 96 | # # A list of hashes representing hooks. Only the url field is supported. 97 | # - url: https://someurl.com/hooks/circle 98 | -------------------------------------------------------------------------------- /css/dkan-flaticon.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'dkan-flaticon'; 3 | src:url('../fonts/dkan-flaticon.eot?-w5vqwy'); 4 | src:url('../fonts/dkan-flaticon.eot?#iefix-w5vqwy') format('embedded-opentype'), 5 | url('../fonts/dkan-flaticon.woff?-w5vqwy') format('woff'), 6 | url('../fonts/dkan-flaticon.ttf?-w5vqwy') format('truetype'), 7 | url('../fonts/dkan-flaticon.svg?-w5vqwy#dkan-flaticon') format('svg'); 8 | font-weight: normal; 9 | font-style: normal; 10 | } 11 | 12 | [class^="icon-"], [class*=" icon-"] { 13 | font-family: 'dkan-flaticon'; 14 | speak: none; 15 | font-style: normal; 16 | font-weight: normal; 17 | font-variant: normal; 18 | text-transform: none; 19 | line-height: 1; 20 | 21 | /* Better Font Rendering =========== */ 22 | -webkit-font-smoothing: antialiased; 23 | -moz-osx-font-smoothing: grayscale; 24 | /*text-shadow: 1px 1px 1px rgba(0,0,0,0.004);*/ 25 | } 26 | 27 | 28 | 29 | .icon-dm:before { 30 | content: "\e600"; 31 | } 32 | .icon-ds2:before { 33 | content: "\e601"; 34 | } 35 | .icon-g22:before { 36 | content: "\e602"; 37 | } 38 | .icon-gp2:before { 39 | content: "\e603"; 40 | } 41 | .icon-z1:before { 42 | content: "\e604"; 43 | } 44 | .icon-aac:before { 45 | content: "\e605"; 46 | } 47 | .icon-ai:before { 48 | content: "\e606"; 49 | } 50 | .icon-aif:before { 51 | content: "\e607"; 52 | } 53 | .icon-api:before { 54 | content: "\e608"; 55 | } 56 | .icon-apk:before { 57 | content: "\e609"; 58 | } 59 | .icon-app6:before { 60 | content: "\e60a"; 61 | } 62 | .icon-asf1:before { 63 | content: "\e60b"; 64 | } 65 | .icon-asp:before { 66 | content: "\e60c"; 67 | } 68 | .icon-aspx:before { 69 | content: "\e60d"; 70 | } 71 | .icon-asx2:before { 72 | content: "\e60e"; 73 | } 74 | .icon-avi4:before { 75 | content: "\e60f"; 76 | } 77 | .icon-bak:before { 78 | content: "\e610"; 79 | } 80 | .icon-bat8:before { 81 | content: "\e611"; 82 | } 83 | .icon-bin6:before { 84 | content: "\e612"; 85 | } 86 | .icon-bmp2:before { 87 | content: "\e613"; 88 | } 89 | .icon-cab:before { 90 | content: "\e614"; 91 | } 92 | .icon-cad1:before { 93 | content: "\e615"; 94 | } 95 | .icon-cdr2:before { 96 | content: "\e616"; 97 | } 98 | .icon-cer:before { 99 | content: "\e617"; 100 | } 101 | .icon-cfg2:before { 102 | content: "\e618"; 103 | } 104 | .icon-cfm2:before { 105 | content: "\e619"; 106 | } 107 | .icon-cgi2:before { 108 | content: "\e61a"; 109 | } 110 | .icon-class3:before { 111 | content: "\e61b"; 112 | } 113 | .icon-com:before { 114 | content: "\e61c"; 115 | } 116 | .icon-cpl2:before { 117 | content: "\e61d"; 118 | } 119 | .icon-cpp1:before { 120 | content: "\e61e"; 121 | } 122 | .icon-crx:before { 123 | content: "\e61f"; 124 | } 125 | .icon-csr:before { 126 | content: "\e620"; 127 | } 128 | .icon-css5:before { 129 | content: "\e621"; 130 | } 131 | .icon-csv2:before { 132 | content: "\e622"; 133 | } 134 | .icon-cue2:before { 135 | content: "\e623"; 136 | } 137 | .icon-cur1:before { 138 | content: "\e624"; 139 | } 140 | .icon-dat2:before { 141 | content: "\e625"; 142 | } 143 | .icon-data:before { 144 | content: "\e626"; 145 | } 146 | .icon-db2:before { 147 | content: "\e627"; 148 | } 149 | .icon-dbf2:before { 150 | content: "\e628"; 151 | } 152 | .icon-dds2:before { 153 | content: "\e629"; 154 | } 155 | .icon-dem2:before { 156 | content: "\e62a"; 157 | } 158 | .icon-dll2:before { 159 | content: "\e62b"; 160 | } 161 | .icon-dmg3:before { 162 | content: "\e62c"; 163 | } 164 | .icon-dmp2:before { 165 | content: "\e62d"; 166 | } 167 | .icon-doc2:before { 168 | content: "\e62e"; 169 | } 170 | .icon-docx:before { 171 | content: "\e62f"; 172 | } 173 | .icon-drv1:before { 174 | content: "\e630"; 175 | } 176 | .icon-dtd2:before { 177 | content: "\e631"; 178 | } 179 | .icon-dwg2:before { 180 | content: "\e632"; 181 | } 182 | .icon-dxf1:before { 183 | content: "\e633"; 184 | } 185 | .icon-elf2:before { 186 | content: "\e634"; 187 | } 188 | .icon-eps2:before { 189 | content: "\e635"; 190 | } 191 | .icon-eps5:before { 192 | content: "\e636"; 193 | } 194 | .icon-exe3:before { 195 | content: "\e637"; 196 | } 197 | .icon-fla2:before { 198 | content: "\e638"; 199 | } 200 | .icon-flash10:before { 201 | content: "\e639"; 202 | } 203 | .icon-flv:before { 204 | content: "\e63a"; 205 | } 206 | .icon-fnt:before { 207 | content: "\e63b"; 208 | } 209 | .icon-fon1:before { 210 | content: "\e63c"; 211 | } 212 | .icon-gam2:before { 213 | content: "\e63d"; 214 | } 215 | .icon-gbr1:before { 216 | content: "\e63e"; 217 | } 218 | .icon-ged2:before { 219 | content: "\e63f"; 220 | } 221 | .icon-gif3:before { 222 | content: "\e640"; 223 | } 224 | .icon-gpx1:before { 225 | content: "\e641"; 226 | } 227 | .icon-gz:before { 228 | content: "\e642"; 229 | } 230 | .icon-gzip2:before { 231 | content: "\e643"; 232 | } 233 | .icon-hqz:before { 234 | content: "\e644"; 235 | } 236 | .icon-html9:before { 237 | content: "\e645"; 238 | } 239 | .icon-ibooks1:before { 240 | content: "\e646"; 241 | } 242 | .icon-icns:before { 243 | content: "\e647"; 244 | } 245 | .icon-ico2:before { 246 | content: "\e648"; 247 | } 248 | .icon-ics2:before { 249 | content: "\e649"; 250 | } 251 | .icon-iff:before { 252 | content: "\e64a"; 253 | } 254 | .icon-indd2:before { 255 | content: "\e64b"; 256 | } 257 | .icon-iso1:before { 258 | content: "\e64c"; 259 | } 260 | .icon-iso4:before { 261 | content: "\e64d"; 262 | } 263 | .icon-jar8:before { 264 | content: "\e64e"; 265 | } 266 | .icon-jpg3:before { 267 | content: "\e64f"; 268 | } 269 | .icon-js2:before { 270 | content: "\e650"; 271 | } 272 | .icon-json:before { 273 | content: "\e651"; 274 | } 275 | .icon-jsp2:before { 276 | content: "\e652"; 277 | } 278 | .icon-key35:before { 279 | content: "\e653"; 280 | } 281 | .icon-kml1:before { 282 | content: "\e654"; 283 | } 284 | .icon-kmz:before { 285 | content: "\e655"; 286 | } 287 | .icon-lnk2:before { 288 | content: "\e656"; 289 | } 290 | .icon-log2:before { 291 | content: "\e657"; 292 | } 293 | .icon-lua:before { 294 | content: "\e658"; 295 | } 296 | .icon-m3u:before { 297 | content: "\e659"; 298 | } 299 | .icon-m4a1:before { 300 | content: "\e65a"; 301 | } 302 | .icon-m4v2:before { 303 | content: "\e65b"; 304 | } 305 | .icon-macho:before { 306 | content: "\e65c"; 307 | } 308 | .icon-max2:before { 309 | content: "\e65d"; 310 | } 311 | .icon-mdb2:before { 312 | content: "\e65e"; 313 | } 314 | .icon-mdf2:before { 315 | content: "\e65f"; 316 | } 317 | .icon-mid:before { 318 | content: "\e660"; 319 | } 320 | .icon-mim:before { 321 | content: "\e661"; 322 | } 323 | .icon-mov2:before { 324 | content: "\e662"; 325 | } 326 | .icon-mp4:before { 327 | content: "\e663"; 328 | } 329 | .icon-mp36:before { 330 | content: "\e664"; 331 | } 332 | .icon-mpa:before { 333 | content: "\e665"; 334 | } 335 | .icon-mpg3:before { 336 | content: "\e666"; 337 | } 338 | .icon-msg2:before { 339 | content: "\e667"; 340 | } 341 | .icon-msi2:before { 342 | content: "\e668"; 343 | } 344 | .icon-nes1:before { 345 | content: "\e669"; 346 | } 347 | .icon-object4:before { 348 | content: "\e66a"; 349 | } 350 | .icon-odb2:before { 351 | content: "\e66b"; 352 | } 353 | .icon-odc2:before { 354 | content: "\e66c"; 355 | } 356 | .icon-odf2:before { 357 | content: "\e66d"; 358 | } 359 | .icon-odg:before { 360 | content: "\e66e"; 361 | } 362 | .icon-odi2:before { 363 | content: "\e66f"; 364 | } 365 | .icon-odp2:before { 366 | content: "\e670"; 367 | } 368 | .icon-ods2:before { 369 | content: "\e671"; 370 | } 371 | .icon-odt:before { 372 | content: "\e672"; 373 | } 374 | .icon-odt5:before { 375 | content: "\e673"; 376 | } 377 | .icon-odx:before { 378 | content: "\e674"; 379 | } 380 | .icon-ogg:before { 381 | content: "\e675"; 382 | } 383 | .icon-otf:before { 384 | content: "\e676"; 385 | } 386 | .icon-otf1:before { 387 | content: "\e677"; 388 | } 389 | .icon-pages4:before { 390 | content: "\e678"; 391 | } 392 | .icon-pct2:before { 393 | content: "\e679"; 394 | } 395 | .icon-pdb2:before { 396 | content: "\e67a"; 397 | } 398 | .icon-pdf19:before { 399 | content: "\e67b"; 400 | } 401 | .icon-pif2:before { 402 | content: "\e67c"; 403 | } 404 | .icon-pkg2:before { 405 | content: "\e67d"; 406 | } 407 | .icon-pl2:before { 408 | content: "\e67e"; 409 | } 410 | .icon-png3:before { 411 | content: "\e67f"; 412 | } 413 | .icon-pps2:before { 414 | content: "\e680"; 415 | } 416 | .icon-ppt:before { 417 | content: "\e681"; 418 | } 419 | .icon-pptx2:before { 420 | content: "\e682"; 421 | } 422 | .icon-ps:before { 423 | content: "\e683"; 424 | } 425 | .icon-psd3:before { 426 | content: "\e684"; 427 | } 428 | .icon-pub2:before { 429 | content: "\e685"; 430 | } 431 | .icon-python3:before { 432 | content: "\e686"; 433 | } 434 | .icon-ra:before { 435 | content: "\e687"; 436 | } 437 | .icon-rar2:before { 438 | content: "\e688"; 439 | } 440 | .icon-raw2:before { 441 | content: "\e689"; 442 | } 443 | .icon-rdf:before { 444 | content: "\e68a"; 445 | } 446 | .icon-rm:before { 447 | content: "\e68b"; 448 | } 449 | .icon-rom2:before { 450 | content: "\e68c"; 451 | } 452 | .icon-rpm2:before { 453 | content: "\e68d"; 454 | } 455 | .icon-rss29:before { 456 | content: "\e68e"; 457 | } 458 | .icon-rtf:before { 459 | content: "\e68f"; 460 | } 461 | .icon-sav:before { 462 | content: "\e690"; 463 | } 464 | .icon-sdf:before { 465 | content: "\e691"; 466 | } 467 | .icon-sitx2:before { 468 | content: "\e692"; 469 | } 470 | .icon-sql3:before { 471 | content: "\e693"; 472 | } 473 | .icon-sql5:before { 474 | content: "\e694"; 475 | } 476 | .icon-srt:before { 477 | content: "\e695"; 478 | } 479 | .icon-svg1:before { 480 | content: "\e696"; 481 | } 482 | .icon-swf1:before { 483 | content: "\e697"; 484 | } 485 | .icon-sys:before { 486 | content: "\e698"; 487 | } 488 | .icon-tar1:before { 489 | content: "\e699"; 490 | } 491 | .icon-tex:before { 492 | content: "\e69a"; 493 | } 494 | .icon-tga2:before { 495 | content: "\e69b"; 496 | } 497 | .icon-thm1:before { 498 | content: "\e69c"; 499 | } 500 | .icon-tiff1:before { 501 | content: "\e69d"; 502 | } 503 | .icon-tmp:before { 504 | content: "\e69e"; 505 | } 506 | .icon-torrent:before { 507 | content: "\e69f"; 508 | } 509 | .icon-ttf2:before { 510 | content: "\e6a0"; 511 | } 512 | .icon-txt2:before { 513 | content: "\e6a1"; 514 | } 515 | .icon-uue2:before { 516 | content: "\e6a2"; 517 | } 518 | .icon-vb:before { 519 | content: "\e6a3"; 520 | } 521 | .icon-vcd2:before { 522 | content: "\e6a4"; 523 | } 524 | .icon-vcf2:before { 525 | content: "\e6a5"; 526 | } 527 | .icon-vob:before { 528 | content: "\e6a6"; 529 | } 530 | .icon-wav2:before { 531 | content: "\e6a7"; 532 | } 533 | .icon-wma1:before { 534 | content: "\e6a8"; 535 | } 536 | .icon-wmv2:before { 537 | content: "\e6a9"; 538 | } 539 | .icon-wpd2:before { 540 | content: "\e6aa"; 541 | } 542 | .icon-wps:before { 543 | content: "\e6ab"; 544 | } 545 | .icon-wsf2:before { 546 | content: "\e6ac"; 547 | } 548 | .icon-xhtml:before { 549 | content: "\e6ad"; 550 | color: #55a1ce; 551 | } 552 | .icon-xlr2:before { 553 | content: "\e6ae"; 554 | } 555 | .icon-xls1:before { 556 | content: "\e6af"; 557 | } 558 | .icon-xlsx:before { 559 | content: "\e6b0"; 560 | } 561 | .icon-xml5:before { 562 | content: "\e6b1"; 563 | } 564 | .icon-yuv2:before { 565 | content: "\e6b2"; 566 | } 567 | .icon-zip6:before { 568 | content: "\e6b3"; 569 | } 570 | -------------------------------------------------------------------------------- /css/dkan_dataset_btn.css: -------------------------------------------------------------------------------- 1 | .resource-list .btn { 2 | position: absolute; 3 | top: 0; 4 | right: 0; 5 | display: block; 6 | margin: -7px -15px -7px 0; 7 | padding: 7px 15px; 8 | } 9 | ul.primary li a.btn, .btn { 10 | display: inline-block; 11 | padding: 4px 10px 4px; 12 | margin-bottom: 0; 13 | font-size: 13px; 14 | line-height: 18px; 15 | color: #333; 16 | text-align: center; 17 | text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); 18 | vertical-align: middle; 19 | cursor: pointer; 20 | background-color: #F7F7F7; 21 | background-image: -moz-linear-gradient(top, white, #EAEAEA); 22 | background-image: -ms-linear-gradient(top, white, #EAEAEA); 23 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(white), to(#EAEAEA)); 24 | background-image: -webkit-linear-gradient(top, white, #EAEAEA); 25 | background-image: -o-linear-gradient(top, white, #EAEAEA); 26 | background-image: linear-gradient(top, white, #EAEAEA); 27 | background-repeat: repeat-x; 28 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eaeaea', GradientType=0); 29 | border-color: #EAEAEA #EAEAEA #C4C4C4; 30 | border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); 31 | filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); 32 | border: 1px solid #CCC; 33 | border-bottom-color: #B3B3B3; 34 | -webkit-border-radius: 4px; 35 | -moz-border-radius: 4px; 36 | border-radius: 4px; 37 | -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 2px rgba(0, 0, 0, .05); 38 | -moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); 39 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 2px rgba(0, 0, 0, .05); 40 | font-weight: bold; 41 | } 42 | .btn-primary, a.btn-primary, ul.primary li a.btn-primary:hover, #toolbar ul.primary li a.btn-primary:hover, .btn-primary:hover, .btn-warning, .btn-warning:hover, .btn-danger, .btn-danger:hover, .btn-success, .btn-success:hover, .btn-info, .btn-info:hover, .btn-inverse, .btn-inverse:hover { 43 | color: white; 44 | text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); 45 | background-color: #085871; 46 | background-color: #206B82; 47 | background-image: -moz-linear-gradient(top, #30778D, #085871); 48 | background-image: -ms-linear-gradient(top, #30778D, #085871); 49 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#30778D), to(#085871)); 50 | background-image: -webkit-linear-gradient(top, #30778D, #085871); 51 | background-image: -o-linear-gradient(top, #30778D, #085871); 52 | background-image: linear-gradient(top, #30778D, #085871); 53 | background-repeat: repeat-x; 54 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#30778d', endColorstr='#085871', GradientType=0); 55 | border-color: #085871 #085871 #03202A; 56 | border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); 57 | filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); 58 | } -------------------------------------------------------------------------------- /dkan-module-init.sh: -------------------------------------------------------------------------------- 1 | 2 | # Name of the current module. 3 | DKAN_MODULE=`ls *.info | cut -d'.' -f1` 4 | 5 | # DKAN branch or tag to use. 6 | DKAN_VERSION="7.x-1.x" 7 | 8 | COMPOSER_PATH="$HOME/.config/composer/vendor/bin" 9 | 10 | if [[ "$PATH" != *"$COMPOSER_PATH"* ]]; then 11 | echo "> Composer PATH is not set. Adding temporarily.. (you should add to your .bashrc)" 12 | echo "PATH (prior) = $PATH" 13 | export PATH="$PATH:$COMPOSER_PATH" 14 | fi 15 | 16 | # Try to grab archived dkan to speed up bootstrap. 17 | URL="https://s3-us-west-2.amazonaws.com/nucivic-data-dkan-archives/dkan-$DKAN_VERSION.tar.gz" 18 | if wget -q "$URL"; then 19 | mv dkan-$DKAN_VERSION.tar.gz ../ 20 | cd .. 21 | tar -xzf dkan-$DKAN_VERSION.tar.gz 22 | # We need to fix the archive process to delete this file. 23 | rm -rf dkan/docroot/sites/default/settings.php 24 | mv $DKAN_MODULE dkan/ 25 | mv dkan $DKAN_MODULE 26 | cd $DKAN_MODULE 27 | set -e 28 | cd dkan 29 | bash dkan-init.sh dkan --skip-init --deps 30 | cd .. 31 | ahoy drush "-y --verbose si minimal --sites-subdir=default --account-pass='admin' --db-url=$DATABASE_URL install_configure_form.update_status_module=\"'array\(FALSE,FALSE\)'\"" 32 | else 33 | wget -O /tmp/dkan-init.sh https://raw.githubusercontent.com/NuCivic/dkan/$DKAN_VERSION/dkan-init.sh 34 | # Make sure the download was at least successful. 35 | if [ $? -ne 0 ] ; then 36 | echo "" 37 | echo "[Error] Failed to download the dkan-init.sh script from github dkan. Branch: $DKAN_BRANCH . Perhaps someone deleted the branch?" 38 | echo "" 39 | exit 1 40 | fi 41 | # Only stop on errors starting now. 42 | set -e 43 | # OK, run the script. 44 | bash /tmp/dkan-init.sh $DKAN_MODULE $@ --skip-reinstall --branch=$DKAN_VERSION 45 | fi 46 | 47 | ahoy dkan module-link $DKAN_MODULE 48 | ahoy dkan module-make $DKAN_MODULE 49 | 50 | # Use the backup if available. 51 | if [ -f backups/last_install.sql ];then 52 | ahoy drush sql-drop -y && 53 | ahoy dkan sqlc < backups/last_install.sql && \ 54 | echo "Installed dkan from backup" 55 | else 56 | ahoy dkan reinstall 57 | fi 58 | 59 | ahoy drush en $DKAN_MODULE -y 60 | 61 | #Fix for behat bug not recognizing symlinked feature files or files outside it's root. See https://jira.govdelivery.com/browse/CIVIC-1005 62 | #cp dkan_workflow/test/features/dkan_workflow.feature dkan/test/features/. 63 | -------------------------------------------------------------------------------- /dkan.make: -------------------------------------------------------------------------------- 1 | core = 7.x 2 | api = 2 3 | 4 | projects[] = drupal 5 | 6 | projects[dkan][type] = profile 7 | projects[dkan][download][type] = git 8 | projects[dkan][download][url] = git://github.com/nucivic/dkan.git 9 | projects[dkan][download][revision] = 7.x-1.x 10 | -------------------------------------------------------------------------------- /dkan_dataset.admin.inc: -------------------------------------------------------------------------------- 1 | 'fieldset', 16 | '#title' => t('Available preview descriptions'), 17 | '#collapsible' => TRUE, 18 | '#collapsed' => FALSE, 19 | ); 20 | 21 | $form['preview_list']['preview_list_table'] = array( 22 | '#prefix' => '
', 23 | '#suffix' => '
', 24 | '#markup' => _dkan_dataset_preview_list_table(), 25 | ); 26 | 27 | $form['external_previews'] = array( 28 | '#type' => 'fieldset', 29 | '#title' => t('External Preview Settings'), 30 | '#description' => t('Enable or disable external preview links for all resource formats. Modify the list of available resource formats !here.', array( 31 | '!here' => l(t('here'), 'admin/structure/taxonomy/format'), 32 | )), 33 | '#collapsible' => FALSE, 34 | ); 35 | $form['external_previews']['formats'] = array( 36 | '#prefix' => '
', 37 | '#suffix' => '
', 38 | '#theme' => 'dkan_dataset_preview_settings_external_table_form', 39 | '#caption' => t('Enabled Preview Providers'), 40 | '#header' => array(t('Format'), t('Enabled Previews')), 41 | 'rows' => array(), 42 | ); 43 | $format_vocabulary = taxonomy_vocabulary_machine_name_load('format'); 44 | $formats = taxonomy_get_tree($format_vocabulary->vid); 45 | $previews = dkan_dataset_teaser_get_external_previews(); 46 | 47 | 48 | // We will check to see if the preview is is already toggled in the variable. 49 | // If not, we chekck the defaults set by the preview definition. 50 | foreach ($formats as $format) { 51 | $default_value = array(); 52 | $preview_options = array(); 53 | foreach ($previews as $machine_name => $preview) { 54 | // The local preview is not optional. 55 | if ($machine_name == 'dkan') { 56 | continue; 57 | } 58 | // Restrict available options to sugested formats 59 | if (in_array($format->name, $preview['suggested_formats'])) { 60 | $preview_options[$machine_name] = $preview['name']; 61 | } 62 | if (in_array($format->name, $preview['format'])) { 63 | $default_value[] = $machine_name; 64 | } 65 | } 66 | $form['external_previews']['formats']['rows'][] = array( 67 | 'format' => array( 68 | '#markup' => $format->name, 69 | ), 70 | "dkan_dataset_format_previews_tid{$format->tid}" => array( 71 | '#type' => 'checkboxes', 72 | '#tree' => TRUE, 73 | '#title' => 'whatever', 74 | '#title_display' => 'invisible', 75 | '#options' => $preview_options, 76 | '#attributes' => array(), 77 | '#default_value' => $default_value, 78 | ), 79 | ); 80 | } 81 | 82 | $form['dkan_dataset_teaser_preview_label'] = array( 83 | '#type' => 'textfield', 84 | '#default_value' => variable_get('dkan_dataset_teaser_preview_label', ''), 85 | '#title' => t('Label for local data preview'), 86 | '#description' => t('Any compatible format (like CSV) can be displayed in 87 | the local DKAN data preview. If you enter, for instance, "Data.gov" in 88 | this field, the link to the preview will read "Data.gov Preview." Leave 89 | blank to simply display the word "Preview".'), 90 | ); 91 | 92 | return system_settings_form($form); 93 | } 94 | 95 | /** 96 | * Menu Callback for DKAN Dataset settings. 97 | */ 98 | function dkan_dataset_api_menu_settings() { 99 | drupal_goto('admin/config/services/odsm'); 100 | } 101 | 102 | /** 103 | * Menu Callback for DKAN Dataset form settings. 104 | */ 105 | function dkan_dataset_form_settings() { 106 | $form = array(); 107 | $form['dkan_dataset_form_additional_info'] = array( 108 | '#type' => 'checkbox', 109 | '#title' => t('Divide Dataset form into main form and "Additional Data" (CKAN style).'), 110 | '#default_value' => variable_get('dkan_dataset_form_additional_info', 1), 111 | ); 112 | $form['dkan_dataset_form_pod_validation'] = array( 113 | '#type' => 'checkbox', 114 | '#title' => t('Validate dataset form according to Project Open Data (more strict 115 | than default DKAN validation).'), 116 | '#description' => t('By default, DKAN make only a small number of metadata fields required to 117 | create datasets. Enable this setting to make all fields required by Project Open Data 118 | be required fields on the dataset form. Note: "Publisher" is a required Project Open Data 119 | field that is usually mapped to the "Group" field in DKAN. Use the setting below to make 120 | this field required as well.'), 121 | '#default_value' => variable_get('dkan_dataset_form_pod_validation', 0), 122 | ); 123 | $form['dkan_dataset_form_group_validation'] = array( 124 | '#type' => 'checkbox', 125 | '#title' => t('Require datasets to have a group.'), 126 | '#description' => t('Enable to force users to set a specific group for every dataset. 127 | If you are leaving this un-checked and therefore making groups optional for datasets, 128 | be aware that you may end up with an empty "publisher" field in your data.json 129 | and DCAT endpoints if you do not have a fallback value set in 130 | Open Data Schema Map for those endpoints. 131 | Also note that a user who is not a member of any group will not be able 132 | to create new datasets if this is enabled.'), 133 | '#default_value' => variable_get('dkan_dataset_form_group_validation', 0), 134 | ); 135 | 136 | return system_settings_form($form); 137 | } 138 | 139 | /** 140 | * Create table of available formats. 141 | * @todo This should be a theme function. 142 | * @return string Formatted table 143 | */ 144 | function _dkan_dataset_preview_list_table() { 145 | $vars = array( 146 | 'header' => array(t('Preview Type'), t('Information')), 147 | 'rows' => array(), 148 | ); 149 | 150 | $previews = dkan_dataset_teaser_get_external_previews(); 151 | foreach ($previews as $preview) { 152 | $info = $preview['description'] . '
' . t('Suggested formats:') . ' '; 153 | $info .= implode(', ', $preview['suggested_formats']) . ''; 154 | $vars['rows'][] = array($preview['name'], $info); 155 | } 156 | return theme('table', $vars); 157 | } 158 | -------------------------------------------------------------------------------- /dkan_dataset.api.php: -------------------------------------------------------------------------------- 1 | t('Third-Party Mapping Service'), 28 | 'description' => t('A longer description of the preview.') 29 | 'link_callback' => 'mymodule_preview_link', 30 | 'suggested_format' => array('geojson'), 31 | ); 32 | } 33 | 34 | /** 35 | * @} End of "addtogroup hooks". 36 | */ 37 | -------------------------------------------------------------------------------- /dkan_dataset.features.inc: -------------------------------------------------------------------------------- 1 | "1"); 13 | } 14 | } 15 | 16 | /** 17 | * Implements hook_views_api(). 18 | */ 19 | function dkan_dataset_views_api($module = NULL, $api = NULL) { 20 | return array("api" => "3.0"); 21 | } 22 | -------------------------------------------------------------------------------- /dkan_dataset.info: -------------------------------------------------------------------------------- 1 | name = DKAN Dataset 2 | description = Custom elements for Datasets. 3 | core = 7.x 4 | package = DKAN 5 | version = 7.x-1.x-dev 6 | project = dkan_dataset 7 | dependencies[] = autocomplete_deluxe 8 | dependencies[] = beautytips 9 | dependencies[] = chosen 10 | dependencies[] = ctools 11 | dependencies[] = date 12 | dependencies[] = date_popup 13 | dependencies[] = double_field 14 | dependencies[] = entity 15 | dependencies[] = entityreference 16 | dependencies[] = features 17 | dependencies[] = field_group 18 | dependencies[] = field_group_table 19 | dependencies[] = filefield_sources 20 | dependencies[] = jquery_update 21 | dependencies[] = libraries 22 | dependencies[] = link 23 | dependencies[] = link_iframe_formatter 24 | dependencies[] = multistep 25 | dependencies[] = ref_field_sync 26 | dependencies[] = remote_stream_wrapper 27 | dependencies[] = search_api 28 | dependencies[] = select_or_other 29 | dependencies[] = strongarm 30 | dependencies[] = token 31 | dependencies[] = uuid 32 | dependencies[] = views 33 | features[ctools][] = strongarm:strongarm:1 34 | features[ctools][] = views:views_default:3.0 35 | features[features_api][] = api:2 36 | features[variable][] = pathauto_node_dataset_pattern 37 | features[variable][] = pathauto_node_resource_pattern 38 | files[] = tests/dkan_dataset.test 39 | files[] = tests/dkan_dataset_class.test 40 | -------------------------------------------------------------------------------- /dkan_dataset.install: -------------------------------------------------------------------------------- 1 | fields(array( 15 | 'weight' => 2, 16 | )) 17 | ->condition('type', 'module') 18 | ->condition('name', 'dkan_dataset') 19 | ->execute(); 20 | 21 | _dkan_dataset_disable_og_extras_group_members_view(); 22 | } 23 | 24 | /** 25 | * Disable the og_extras_members view. 26 | * 27 | * If we do not disable this view, there will be conflicts with the 28 | * dkan_og_extras_members view. 29 | */ 30 | function _dkan_dataset_disable_og_extras_group_members_view() { 31 | $views_status = variable_get('views_defaults', array()); 32 | $views_status['og_extras_members'] = TRUE; 33 | variable_set('views_defaults', $views_status); 34 | 35 | if (function_exists('views_invalidate_cache')) { 36 | views_invalidate_cache(); 37 | } 38 | } 39 | 40 | /** 41 | * Implements hook_update_N(). 42 | */ 43 | function dkan_dataset_update_7001() { 44 | _dkan_dataset_disable_og_extras_group_members_view(); 45 | } 46 | 47 | /** 48 | * Some fields were moved from Open Data Federal Extras module to 49 | * the DKAN Core so an update is needed in order to rename the fields 50 | * if they already exist on the DB. 51 | */ 52 | function dkan_dataset_update_7002() { 53 | // Rename fields. 54 | dkan_rename_field('field_odfe_is_part_of', 'field_is_part_of'); 55 | dkan_rename_field('field_odfe_data_dictionary_type', 'field_data_dictionary_type'); 56 | dkan_rename_field('field_odfe_landing_page', 'field_landing_page'); 57 | dkan_rename_field('field_odfe_conforms_to', 'field_conforms_to'); 58 | dkan_rename_field('field_odfe_rights', 'field_rights'); 59 | dkan_rename_field('field_odfe_language', 'field_language'); 60 | 61 | // Change callback function on 'field_language'. 62 | $field_language_base = field_info_field('field_language'); 63 | $allowed_values_function = $field_language_base['settings']['allowed_values_function']; 64 | 65 | if ($allowed_values_function != 'dkan_dataset_content_types_allowed_language_values') { 66 | $field_language_base['settings']['allowed_values_function'] = 'dkan_dataset_content_types_allowed_language_values'; 67 | field_update_field($field_language_base); 68 | } 69 | } 70 | 71 | /** 72 | * Migrate values from old 'field_odfe_category' field if present to the new 73 | * 'field_pod_theme'. 74 | * 75 | * @throws \DrupalUpdateException if the 'field_pod_theme' field is not part of the dataset content type. 76 | */ 77 | function dkan_dataset_update_7003() { 78 | 79 | // Check if the 'field_odfe_category' field exists. 80 | // If the field does not exist then no data needs to be migrated. 81 | $field_exists = field_info_instance('node', 'field_odfe_category', 'dataset'); 82 | if (!$field_exists) { 83 | return TRUE; 84 | } 85 | 86 | // Check if the 'field_pod_theme' field exists. 87 | $field_exists = field_info_instance('node', 'field_pod_theme', 'dataset'); 88 | if (!$field_exists) { 89 | throw new DrupalUpdateException("The 'field_pod_theme' does not exist. The update could not be applied."); 90 | } 91 | 92 | // Get all datasets that have some value on the 'field_odfe_category' field. 93 | $dataset_ids = db_select('field_data_field_odfe_category', 'odfec') 94 | ->fields('odfec', array('entity_id')) 95 | ->execute() 96 | ->fetchCol(); 97 | $dataset_ids = array_unique($dataset_ids); 98 | 99 | // Process all datasets. 100 | foreach($dataset_ids as $dataset_id) { 101 | // Load dataset. 102 | $dataset = node_load($dataset_id); 103 | $dataset_wrapper = entity_metadata_wrapper('node', $dataset); 104 | // Get all values in 'field_odfe_category' field. 105 | $categories = $dataset_wrapper->field_odfe_category; 106 | foreach($categories as $category) { 107 | // Save each value on the new 'field_pod_theme' field. 108 | $dataset_wrapper->field_pod_theme[] = $category->value()->name; 109 | } 110 | // Save updated dataset. 111 | $dataset_wrapper->save(); 112 | } 113 | 114 | // The data was migrated. Delete old field. 115 | field_delete_field('field_odfe_category'); 116 | 117 | // Delete 'odfe_theme' vocabulary since it's not needed anymore. 118 | $vocabulary = taxonomy_vocabulary_machine_name_load('odfe_theme'); 119 | taxonomy_vocabulary_delete($vocabulary->vid); 120 | } 121 | -------------------------------------------------------------------------------- /dkan_dataset.make: -------------------------------------------------------------------------------- 1 | core = 7.x 2 | api = 2 3 | 4 | ; Leaflet Draw Widget specific 5 | projects[leaflet_draw_widget][download][type] = git 6 | projects[leaflet_draw_widget][download][url] = "https://github.com/NuCivic/leaflet_draw_widget.git" 7 | projects[leaflet_draw_widget][download][revision] = "967c8bb3eb13f3b70f28a4b487074b23591f1075" 8 | projects[leaflet_draw_widget][subdir] = contrib 9 | projects[leaflet_draw_widget][type] = module 10 | 11 | includes[leaflet_draw_widget_make] = https://raw.githubusercontent.com/NuCivic/leaflet_draw_widget/967c8bb3eb13f3b70f28a4b487074b23591f1075/leaflet_widget.make 12 | 13 | ; Recline specific 14 | projects[recline][download][type] = git 15 | projects[recline][download][url] = https://github.com/NuCivic/recline.git 16 | projects[recline][download][branch] = 7.x-1.x 17 | projects[recline][subdir] = contrib 18 | 19 | includes[recline_make] = https://raw.githubusercontent.com/NuCivic/recline/7.x-1.x/recline.make 20 | 21 | ; Contrib Modules 22 | projects[autocomplete_deluxe][subdir] = contrib 23 | projects[autocomplete_deluxe][version] = 2.1 24 | 25 | projects[beautytips][download][type] = git 26 | projects[beautytips][download][branch] = 7.x-2.x 27 | projects[beautytips][download][url] = "http://git.drupal.org/project/beautytips.git" 28 | projects[beautytips][download][revision] = "f9a8b5b" 29 | projects[beautytips][patch][849232] = http://drupal.org/files/include-excanvas-via-libraries-api-d7-849232-13.patch 30 | projects[beautytips][subdir] = contrib 31 | projects[beautytips][type] = module 32 | 33 | projects[chosen][version] = 2.0-beta5 34 | projects[chosen][subdir] = contrib 35 | 36 | projects[context][version] = 3.6 37 | projects[context][subdir] = contrib 38 | 39 | projects[ctools][version] = 1.9 40 | projects[ctools][subdir] = contrib 41 | 42 | projects[date][version] = 2.9 43 | projects[date][subdir] = contrib 44 | 45 | projects[double_field][version] = 2.4 46 | projects[double_field][subdir] = contrib 47 | 48 | projects[entity][download][full_version] = 7.x-1.7 49 | projects[entity][patch][2341611] = https://www.drupal.org/files/issues/entity-multivalue-token-replacement-fix-2341611-0.patch 50 | projects[entity][patch][2564119] = https://www.drupal.org/files/issues/Use-array-in-foreach-statement-2564119-1.patch 51 | projects[entity][subdir] = contrib 52 | 53 | projects[entityreference][version] = 1.1 54 | projects[entityreference][subdir] = contrib 55 | 56 | projects[eva][version] = 1.2 57 | projects[eva][subdir] = contrib 58 | 59 | projects[facetapi][subdir] = contrib 60 | projects[facetapi][version] = 1.5 61 | 62 | projects[facetapi_pretty_paths][subdir] = contrib 63 | projects[facetapi_pretty_paths][version] = 1.4 64 | 65 | projects[facetapi_bonus][version] = 1.2 66 | projects[facetapi_bonus][subdir] = contrib 67 | 68 | projects[features][version] = 2.10 69 | projects[features][subdir] = contrib 70 | 71 | projects[field_group][version] = 1.5 72 | projects[field_group][patch][2042681] = http://drupal.org/files/issues/field-group-show-ajax-2042681-8.patch 73 | projects[field_group][subdir] = contrib 74 | 75 | projects[field_group_table][download][type] = git 76 | projects[field_group_table][download][url] = "https://github.com/nuams/field_group_table.git" 77 | projects[field_group_table][download][revision] = 5b0aed9396a8cfd19a5b623a5952b3b8cacd361c 78 | projects[field_group_table][subdir] = contrib 79 | projects[field_group_table][type] = module 80 | 81 | projects[filefield_sources][version] = 1.10 82 | projects[filefield_sources][subdir] = contrib 83 | 84 | projects[file_resup][version] = 1.x-dev 85 | projects[file_resup][subdir] = contrib 86 | 87 | projects[gravatar][download][type] = git 88 | projects[gravatar][download][url] = "http://git.drupal.org/project/gravatar.git" 89 | projects[gravatar][download][branch] = 7.x-1.x 90 | projects[gravatar][download][revision] = bb2f81e 91 | projects[gravatar][patch][1568162] = http://drupal.org/files/views-display-user-picture-doesn-t-display-gravatar-1568162-10.patch 92 | projects[gravatar][subdir] = contrib 93 | projects[gravatar][type] = module 94 | 95 | projects[imagecache_actions][download][type] = git 96 | projects[imagecache_actions][download][url] = "http://git.drupal.org/project/imagecache_actions.git" 97 | projects[imagecache_actions][download][revision] = cd19d2a 98 | projects[imagecache_actions][subdir] = contrib 99 | projects[imagecache_actions][type] = module 100 | 101 | projects[jquery_update][version] = 2.7 102 | projects[jquery_update][subdir] = contrib 103 | 104 | projects[libraries][version] = 2.2 105 | projects[libraries][subdir] = contrib 106 | 107 | projects[link][version] = 1.4 108 | projects[link][subdir] = contrib 109 | 110 | projects[link_iframe_formatter][download][type] = git 111 | projects[link_iframe_formatter][download][url] = "http://git.drupal.org/project/link_iframe_formatter.git" 112 | projects[link_iframe_formatter][download][revision] = 228f9f4 113 | projects[link_iframe_formatter][patch][2287233] = https://www.drupal.org/files/issues/link_iframe_formatter-coding-standards.patch 114 | projects[link_iframe_formatter][subdir] = contrib 115 | projects[link_iframe_formatter][type] = module 116 | 117 | projects[multistep][download][type] = git 118 | projects[multistep][download][url] = "http://git.drupal.org/project/multistep.git" 119 | projects[multistep][download][revision] = 3b0d40a 120 | projects[multistep][subdir] = contrib 121 | projects[multistep][type] = module 122 | 123 | projects[og][version] = 2.9 124 | projects[og][patch][1090438] = http://drupal.org/files/issues/og-add_users_and_entities_with_drush-1090438-12.patch 125 | projects[og][patch][2549071] = https://www.drupal.org/files/issues/og_actions-bug-vbo-delete.patch 126 | projects[og][patch][2301831] = https://www.drupal.org/files/issues/og-missing-permission-roles-2301831-1.patch 127 | projects[og][subdir] = contrib 128 | 129 | projects[og_extras][version] = 1.2 130 | projects[og_extras][subdir] = contrib 131 | projects[og_extras][type] = module 132 | 133 | projects[pathauto][version] = 1.2 134 | projects[pathauto][subdir] = contrib 135 | 136 | projects[ref_field][download][type] = git 137 | projects[ref_field][download][url] = "http://git.drupal.org/project/ref_field.git" 138 | ; Updated Patch to fix the ton of notices this module throws. Hasn't been maintained since 2012! 139 | projects[ref_field][patch][2360019] = https://www.drupal.org/files/issues/ref_field-delete-insert-warning-2360019-5.patch 140 | projects[ref_field][download][revision] = 9dbf7cf 141 | projects[ref_field][subdir] = contrib 142 | projects[ref_field][type] = module 143 | 144 | projects[remote_stream_wrapper][version] = 1.0-rc1 145 | projects[remote_stream_wrapper][subdir] = contrib 146 | 147 | projects[select_or_other][version] = 2.22 148 | projects[select_or_other][subdir] = contrib 149 | 150 | projects[search_api][version] = 1.18 151 | projects[search_api][subdir] = contrib 152 | 153 | projects[search_api_db][version] = 1.5 154 | projects[search_api_db][subdir] = contrib 155 | 156 | projects[strongarm][version] = 2.0 157 | projects[strongarm][subdir] = contrib 158 | 159 | projects[token][version] = 1.6 160 | projects[token][subdir] = contrib 161 | 162 | projects[uuid][version] = 1.0-beta2 163 | projects[uuid][subdir] = contrib 164 | 165 | projects[views][version] = 3.14 166 | projects[views][subdir] = contrib 167 | 168 | projects[views_responsive_grid][version] = 1.3 169 | projects[views_responsive_grid][subdir] = contrib 170 | 171 | projects[views_bulk_operations][version] = 3.3 172 | projects[views_bulk_operations][subdir] = contrib 173 | 174 | 175 | ; Libraries 176 | 177 | libraries[chosen][type] = libraries 178 | libraries[chosen][download][type] = get 179 | libraries[chosen][download][url] = https://github.com/harvesthq/chosen/releases/download/v1.3.0/chosen_v1.3.0.zip 180 | libraries[chosen][destination] = libraries 181 | 182 | libraries[slugify][type] = libraries 183 | libraries[slugify][download][type] = git 184 | libraries[slugify][download][url] = "https://github.com/pmcelhaney/jQuery-Slugify-Plugin.git" 185 | libraries[slugify][directory_name] = slugify 186 | libraries[slugify][download][revision] = "79133a1bdfd3ac80d500d661a722b85c03a01da3" 187 | 188 | libraries[arc][type] = libraries 189 | libraries[arc][download][type] = git 190 | libraries[arc][download][url] = "https://github.com/semsol/arc2.git" 191 | libraries[arc][download][revision] = "44c396ab54178086c09499a1704e31a977b836d2" 192 | libraries[arc][subdir] = "ARC2" 193 | 194 | libraries[excanvas][download][type] = git 195 | libraries[excanvas][download][url] = "https://github.com/arv/ExplorerCanvas.git" 196 | libraries[excanvas][download][sha1] = "aa989ea9d9bac748638f7c66b0fc88e619715da6" 197 | -------------------------------------------------------------------------------- /dkan_dataset.pages.inc: -------------------------------------------------------------------------------- 1 | field_dataset_ref->value(); 14 | 15 | if (isset($ref[0])) { 16 | drupal_goto('node/' . $ref[0]->nid); 17 | } 18 | else { 19 | drupal_set_message(t('There is no dataset associated with this resource.')); 20 | } 21 | return ''; 22 | } 23 | 24 | /** 25 | * Callback for 'Add Resouce' tab. 26 | */ 27 | function dkan_dataset_add_resource($node) { 28 | drupal_goto('node/add/resource', array('query' => array('dataset' => $node->nid))); 29 | } 30 | 31 | /** 32 | * Callback for 'Download Dataset'. 33 | */ 34 | function dkan_dataset_download($node) { 35 | $node = entity_metadata_wrapper('node', $node); 36 | $resources = $node->field_resources->value(); 37 | if (isset($resources)) { 38 | $files = array(); 39 | foreach ($resources as $resource) { 40 | // Node could be empty if it has been deleted. 41 | if (!$resource || !node_access('view', $resource)) { 42 | continue; 43 | } 44 | $resource_wrapper = entity_metadata_wrapper('node', $resource); 45 | if (isset($resource->field_upload[LANGUAGE_NONE])) { 46 | $files[] = drupal_realpath($resource->field_upload[LANGUAGE_NONE][0]['uri']); 47 | } 48 | } 49 | _dkan_dataset_zip($files, $node); 50 | } 51 | } 52 | 53 | function _dkan_dataset_zip($files, $node) { 54 | $zip = new ZipArchive; 55 | $file_path = tempnam(file_directory_temp(), 'zip'); 56 | $zip_open = $zip->open($file_path, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE); 57 | if ($zip_open === TRUE) { 58 | foreach ($files as $file) { 59 | if (file_exists($file)) { 60 | if (!$zip->addFile(realpath($file), basename($file))) { 61 | drupal_set_message(t('!file could not be added to Zip.', array('!file' => $file)), 'error'); 62 | } 63 | } 64 | else { 65 | drupal_set_message('!file not found.', array('!file' => $file), 'error'); 66 | } 67 | } 68 | $zip->close(); 69 | $filename = _dkan_dataset_zip_filename($node->title->value()); 70 | $headers = array( 71 | 'Content-type' => 'application/zip', 72 | 'Content-Disposition' => 'attachment; filename="' . $filename . '"', 73 | 'Content-Length' => filesize($file_path) 74 | ); 75 | file_transfer('temporary://' . basename($file_path), $headers); 76 | } 77 | else { 78 | drupal_set_message(t('Unable to create file !filename.', array('!filename' => check_plain($filename))), 'error'); 79 | drupal_access_denied(); 80 | return FALSE; 81 | } 82 | } 83 | 84 | function _dkan_dataset_zip_filename($title) { 85 | $filename = strtr(drupal_strtolower($title), array(' ' => '-', '_' => '-', '[' => '-', ']' => '')); 86 | $filename = preg_replace('/[^A-Za-z0-9\-_]/', '', $filename); 87 | $filename = preg_replace('/\-+/', '-', $filename); 88 | return $filename . '-All-' . date('Y-m-d_Hi') . '.zip'; 89 | } 90 | -------------------------------------------------------------------------------- /dkan_dataset.strongarm.inc: -------------------------------------------------------------------------------- 1 | disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 15 | $strongarm->api_version = 1; 16 | $strongarm->name = 'pathauto_node_dataset_pattern'; 17 | $strongarm->value = 'dataset/[node:title]'; 18 | $export['pathauto_node_dataset_pattern'] = $strongarm; 19 | 20 | $strongarm = new stdClass(); 21 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 22 | $strongarm->api_version = 1; 23 | $strongarm->name = 'pathauto_node_resource_pattern'; 24 | $strongarm->value = 'dataset/[node:field-dataset-ref:0:title]/resource/[node:uuid]'; 25 | $export['pathauto_node_resource_pattern'] = $strongarm; 26 | 27 | return $export; 28 | } 29 | -------------------------------------------------------------------------------- /fonts/dkan-flaticon.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetDKAN/dkan_dataset/75dffacfd5ca47862e4caa587991939a665ae8f2/fonts/dkan-flaticon.eot -------------------------------------------------------------------------------- /fonts/dkan-flaticon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetDKAN/dkan_dataset/75dffacfd5ca47862e4caa587991939a665ae8f2/fonts/dkan-flaticon.ttf -------------------------------------------------------------------------------- /fonts/dkan-flaticon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetDKAN/dkan_dataset/75dffacfd5ca47862e4caa587991939a665ae8f2/fonts/dkan-flaticon.woff -------------------------------------------------------------------------------- /images/sprite-ckan-icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetDKAN/dkan_dataset/75dffacfd5ca47862e4caa587991939a665ae8f2/images/sprite-ckan-icons.png -------------------------------------------------------------------------------- /images/sprite-resource-icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetDKAN/dkan_dataset/75dffacfd5ca47862e4caa587991939a665ae8f2/images/sprite-resource-icons.png -------------------------------------------------------------------------------- /includes/Dataset.inc: -------------------------------------------------------------------------------- 1 | entityCondition('entity_type', 'node') 53 | ->entityCondition('bundle', 'group') 54 | ->propertyCondition('title', $fields['og_group_ref'][LANGUAGE_NONE][0]['title']) 55 | ->range(0, 1); 56 | $result = $query->execute(); 57 | if (isset($result['node'])) { 58 | // If OG exists fix the field array so node_save works. 59 | reset($result['node']); 60 | $fields['og_group_ref'][LANGUAGE_NONE][0]['target_id'] = key($result['node']); 61 | unset($fields['og_group_ref'][LANGUAGE_NONE][0]['title']); 62 | } 63 | else { 64 | // If OG does not exists remove group reference. 65 | unset($fields['og_group_ref']); 66 | } 67 | } 68 | } 69 | 70 | /** 71 | * Uploads the file previous to resource saving. 72 | * 73 | * Adapted from defaultcontent/plugins/file.inc 74 | * 75 | * @param object $resource 76 | * an object that represents a file field 77 | */ 78 | protected static function populateResourceFieldUpload($resource) { 79 | if (isset($resource->field_upload)) { 80 | foreach ($resource->field_upload as $lang => $items) { 81 | foreach ($items as $key => $item) { 82 | $file = (object) $item; 83 | $fids = db_select('file_managed', 'f') 84 | ->condition('uri', $file->uri) 85 | ->fields('f', array('fid')) 86 | ->execute() 87 | ->fetchCol(); 88 | if (!empty($fids) && isset($fids[0]) && is_object($fids[0])) { 89 | file_delete($fid[0]); 90 | } 91 | // Ugly hacky workaround around binary/base64 data 92 | // (two consecutive saves). 93 | $file = file_save_data($item['file'], $item['uri']); 94 | $data = base64_decode($item['file']); 95 | $file = file_save_data($data, $item['uri']); 96 | $file->display = isset($item['display']) ? $item['display'] : NULL; 97 | $file->description = isset($item['description']) ? $item['description'] : NULL; 98 | $file->map = $item['map']; 99 | $file->grid = $item['grid']; 100 | $file->graph = $item['graph']; 101 | $file->timeline = $item['timeline']; 102 | $file->transform = $item['transform']; 103 | file_save($file); 104 | $resource->field_upload[$lang][$key] = (array) $file; 105 | } 106 | } 107 | } 108 | return $resource; 109 | } 110 | 111 | /** 112 | * Instantiates a Dataset object. 113 | * 114 | * Use this function instead of new Dataset($slug) 115 | * to ommit instantiating the same dataset twice 116 | * 117 | * @param string $title_or_nid 118 | * A string that represents one of the following: 119 | * - the node dataset title 120 | * - the node id 121 | */ 122 | public static function instance($title_or_nid) { 123 | static $datasets; 124 | // print_r($title_or_nid) 125 | if (!is_numeric($title_or_nid)) { 126 | $title = $title_or_nid; 127 | $slug = Dataset::slugify($title); 128 | $dataset = new Dataset($title); 129 | } 130 | else { 131 | $nid = $title_or_nid; 132 | $dataset = new Dataset($nid); 133 | $slug = $dataset->created ? Dataset::slugify($dataset->title) : FALSE; 134 | } 135 | if ($slug) { 136 | if (!isset($datasets[$slug])) { 137 | $datasets[$slug] = $dataset; 138 | } 139 | return $datasets[$slug]; 140 | } 141 | return $slug; 142 | } 143 | 144 | /** 145 | * Preloads dataset based on dataset nid. 146 | * 147 | * @param string $nid 148 | * A string that represents the dataset node id 149 | */ 150 | protected function preload($nid) { 151 | $node = node_load($nid); 152 | if ($node) { 153 | $this->title = $node->title; 154 | $this->dataset = $node; 155 | // Removed unset($this->dataset->field_resources);. 156 | $this->created = TRUE; 157 | } 158 | } 159 | 160 | /** 161 | * Preloads Dataset's Resources. 162 | */ 163 | protected function preloadResources() { 164 | if ($this->created) { 165 | $this->resources = array(); 166 | // Load resources. 167 | foreach ($this->dataset->field_resources[$this->dataset->language] as $key => $resource) { 168 | $this->resources[] = node_load($resource['target_id']); 169 | } 170 | } 171 | } 172 | /** 173 | * Constructor. 174 | * 175 | * Do not call directly, but use Dataset::instance($title_or_nid) instead. 176 | * 177 | * @param string $title_or_nid 178 | * A string that represents one of the following: 179 | * - the node dataset title 180 | * - the node id 181 | */ 182 | protected function __construct($title_or_nid) { 183 | // Set our name after sanitizing it. 184 | if (!is_numeric($title_or_nid)) { 185 | $this->title = $title_or_nid; 186 | // Try to load dataset instance from database. 187 | $query = new EntityFieldQuery(); 188 | $query->entityCondition('entity_type', 'node') 189 | ->entityCondition('bundle', 'dataset') 190 | ->propertyCondition('title', $this->title) 191 | ->range(0, 1); 192 | $result = $query->execute(); 193 | if (isset($result['node'])) { 194 | $this->preload($result['node']); 195 | } 196 | } 197 | else { 198 | $this->preload($title_or_nid); 199 | } 200 | } 201 | 202 | /** 203 | * Increments revision for the dataset and sets a log for the resource. 204 | * 205 | * @param string $log 206 | * A string to be used as the log message for the revision instance. 207 | */ 208 | public function incrementRevision($log) { 209 | if (isset($this->dataset->nid)) { 210 | $this->dataset->revision = 1; 211 | $this->dataset->log = $log; 212 | $this->datasetUpdated = TRUE; 213 | } 214 | } 215 | 216 | /** 217 | * Populates dataset fields. 218 | * 219 | * @param array $fields 220 | * An associative array containing the dataset node fields 221 | */ 222 | public function attachFields($fields) { 223 | Dataset::populateOgReference($fields); 224 | $this->dataset = Dataset::asobject($fields); 225 | // Populate basic properties. 226 | $this->dataset->title = $this->title; 227 | $this->dataset->status = '1'; 228 | $this->dataset->promote = '0'; 229 | $this->dataset->sticky = '0'; 230 | $this->dataset->type = 'dataset'; 231 | $this->dataset->language = LANGUAGE_NONE; 232 | $this->dataset->comment = '1'; 233 | $this->dataset->translate = '0'; 234 | $this->datasetUpdated = TRUE; 235 | } 236 | 237 | /** 238 | * Populates resource fields. 239 | * 240 | * @param array $resource 241 | * An associative array containing the resource node fields 242 | */ 243 | public function attachResource($resource) { 244 | $resource = Dataset::asobject($resource); 245 | $resource = Dataset::populateResourceFieldUpload($resource); 246 | // Populate basic properties. 247 | $resource->status = '1'; 248 | $resource->promote = '0'; 249 | $resource->sticky = '0'; 250 | $resource->type = 'resource'; 251 | $resource->language = LANGUAGE_NONE; 252 | $resource->comment = '0'; 253 | $resource->translate = '0'; 254 | // Attach resource. 255 | $slug = Dataset::slugify($resource->title); 256 | $this->resources[$slug] = $resource; 257 | $this->resourcesUpdated = TRUE; 258 | } 259 | 260 | /** 261 | * Save the populated datasets and resources. 262 | */ 263 | public function save() { 264 | if ($this->datasetUpdated) { 265 | $this->dataset->title = $this->title; 266 | node_save($this->dataset); 267 | $this->datasetUpdated = FALSE; 268 | $this->created = TRUE; 269 | } 270 | if ($this->resourcesUpdated) { 271 | $this->dataset->field_resources = array(); 272 | foreach ($this->resources as $key => $resource) { 273 | $this->resources[$key]->field_dataset_ref[LANGUAGE_NONE][] = array( 274 | 'target_id' => $this->dataset->nid, 275 | 'target_type' => $this->dataset->type, 276 | ); 277 | node_save($this->resources[$key]); 278 | $this->dataset->field_resources[LANGUAGE_NONE][] = array( 279 | 'target_id' => $this->resources[$key]->nid, 280 | 'target_type' => $this->resources[$key]->type, 281 | ); 282 | } 283 | if (count($this->dataset->field_resources[LANGUAGE_NONE])) { 284 | node_save($this->dataset); 285 | } 286 | $this->resourcesUpdated = FALSE; 287 | } 288 | } 289 | 290 | /** 291 | * Delete the populated dataset and resources. 292 | * @param boolean $delete_resources 293 | * Boolean to indicate if resources should be deleted. 294 | */ 295 | public function delete($delete_resources = FALSE) { 296 | if ($this->created) { 297 | $to_delete = array(); 298 | $to_delete[] = $this->dataset->nid; 299 | if ($delete_resources) { 300 | foreach ($this->resources as $key => $resource) { 301 | $to_delete[] = $resource->nid; 302 | } 303 | } 304 | node_delete_multiple($to_delete); 305 | } 306 | return count(node_load_multiple($to_delete)) === 0 ? TRUE : FALSE; 307 | } 308 | } 309 | -------------------------------------------------------------------------------- /includes/getRemoteFileInfo.php: -------------------------------------------------------------------------------- 1 | url = $url; 16 | $this->agent = $agent; 17 | $this->followRedirect = $followRedirect; 18 | $this->tmp = $tmp; 19 | } 20 | 21 | /** 22 | * Retrieves headers from url. 23 | */ 24 | public function curl_header($url, $agent, $followRedirect, $tmp) { 25 | $info = array(); 26 | 27 | $ch = curl_init(); 28 | curl_setopt($ch, CURLOPT_USERAGENT, $agent); 29 | curl_setopt($ch, CURLOPT_URL, $url); 30 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 31 | curl_setopt($ch, CURLOPT_TIMEOUT, 5); 32 | curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); 33 | curl_setopt($ch, CURLOPT_FILETIME, true); 34 | curl_setopt($ch, CURLOPT_NOBODY, true); 35 | curl_setopt($ch, CURLOPT_HEADER, true); 36 | 37 | curl_setopt($ch, CURLOPT_COOKIESESSION, true); 38 | curl_setopt($ch, CURLOPT_COOKIE, ""); 39 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followRedirect); 40 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 41 | curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 42 | $http_heading = curl_exec($ch); 43 | if (!$http_heading) { 44 | return NULL; 45 | } 46 | $info['header'] = $this->httpParseHeaders($http_heading); 47 | $info['info'] = curl_getinfo($ch); 48 | curl_close($ch); 49 | // If the server didn't support HTTP HEAD, use the shim. 50 | if ((!empty($info['header']['X-Error-Message']) && trim($info['header']['X-Error-Message']) == 'HEAD is not supported') 51 | || empty($info['header']['Content-Type'])) { 52 | return $this->curl_head_shim($url, $agent, $followRedirect, $tmp); 53 | } 54 | else { 55 | return $info; 56 | } 57 | } 58 | 59 | /** 60 | * Saves file to temp dir to parse header. 61 | */ 62 | private function curl_head_shim($url, $agent, $followRedirect, $tmp) { 63 | $info = array(); 64 | $ch = curl_init(); 65 | $output = fopen('/dev/null', 'w'); 66 | $header_dir = $tmp . '/curl_header'; 67 | $headerfile = fopen($header_dir, 'w+'); 68 | curl_setopt($ch, CURLOPT_URL, $url); 69 | curl_setopt($ch, CURLOPT_FILE, $output); 70 | curl_setopt($ch, CURLOPT_WRITEHEADER, $headerfile); 71 | curl_setopt($ch, CURLOPT_TIMEOUT, 3); 72 | curl_setopt($ch, CURLOPT_HEADER, true); 73 | curl_setopt($ch, CURLOPT_USERAGENT, $agent); 74 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followRedirect); 75 | curl_setopt($ch, CURLOPT_MAXREDIRS, 10); 76 | curl_exec($ch); 77 | fclose($headerfile); 78 | $http_heading = file_get_contents($header_dir); 79 | unset($header_dir); 80 | $info['info'] = curl_getinfo($ch); 81 | curl_close($ch); 82 | $info['header'] = $this->httpParseHeaders($http_heading); 83 | return $info; 84 | } 85 | 86 | /** 87 | * Gets header info for requested file. 88 | */ 89 | public function getInfo() { 90 | if (!isset($this->info)) { 91 | $this->info = $this->curl_header($this->url, $this->agent, $this->followRedirect, $this->tmp); 92 | } 93 | return $this->info; 94 | } 95 | 96 | /** 97 | * Returns the content type for a remote file. 98 | */ 99 | public function getType() { 100 | if ($info = $this->getInfo()) { 101 | $type = $info['header']['Content-Type']; 102 | if ($explode = explode(";", $type)) { 103 | return $explode[0]; 104 | } 105 | else { 106 | return $type; 107 | } 108 | } 109 | else { 110 | return NULL; 111 | } 112 | } 113 | 114 | /** 115 | * Retrieves URL from end of string. 116 | */ 117 | function getNameFromUrl() { 118 | $basename = basename($this->url); 119 | $name = explode('.', $basename); 120 | if (count($name) > 2) { 121 | $name = parse_url($basename); 122 | if (isset($name['path'])) { 123 | return $name['path']; 124 | } 125 | } 126 | elseif (count($name) == 1) { 127 | return $name[0]; 128 | } 129 | return FALSE; 130 | } 131 | 132 | /** 133 | * Finds filename from Content Disposition header. 134 | */ 135 | public function checkDisposition($disposition) { 136 | if (preg_match('/.*?filename=(.+)/i', $disposition, $matches)) { 137 | return trim($matches[1]); 138 | } 139 | elseif (preg_match('/.*?filename="(.+?)"/i', $disposition, $matches)) { 140 | return trim($matches[1]); 141 | } 142 | elseif (preg_match('/.*?filename=([^; ]+)/i', $header, $matches)) { 143 | return trim($matches[1]); 144 | } 145 | elseif ($exploded = explode('filename=', $disposition)) { 146 | return trim($exploded[1]); 147 | } 148 | } 149 | 150 | /** 151 | * Returns the name for a remote file. 152 | * 153 | * This doesn't just check the end of the string for the filename because 154 | * a file URL like this 155 | * https://data.expamle.gov/api/views/abc-123/rows.csv?accessType=DOWNLOAD will 156 | * have a filename of 'this_file_name.csv' in the Content Disposition. 157 | */ 158 | public function getName() { 159 | if ($info = $this->getInfo()) { 160 | // Check Location for proper URL. 161 | if (isset($info['header']['Location']) && valid_url($info['header']['Location'])) { 162 | if ($name = $this->getNameFromUrl($this->url)) { 163 | return $name; 164 | } 165 | } 166 | // Check content disposition. 167 | if (isset($info['header']['Content-Disposition'])) { 168 | return $this->checkDisposition($info['header']['Content-Disposition']); 169 | } 170 | elseif (isset($info['header']['Content-disposition'])) { 171 | return $this->checkDisposition($info['header']['Content-disposition']); 172 | } 173 | elseif (isset($info['header']['content-disposition'])) { 174 | return $this->checkDisposition($info['header']['content-disposition']); 175 | } 176 | // Check URL for filename at end of string. 177 | if ($name = $this->getNameFromUrl($this->url)) { 178 | return $name; 179 | } 180 | else { 181 | return NULL; 182 | } 183 | } 184 | else { 185 | return NULL; 186 | } 187 | } 188 | 189 | /** 190 | * Converts headers from curl request to array. 191 | */ 192 | public function httpParseHeaders($raw_headers) { 193 | $headers = array(); 194 | $key = ''; 195 | foreach (explode("\n", $raw_headers) as $i => $h) { 196 | $h = explode(':', $h, 2); 197 | if (isset($h[1])) { 198 | if (!isset($headers[$h[0]])) { 199 | $headers[$h[0]] = trim($h[1]); 200 | } 201 | elseif (is_array($headers[$h[0]])) { 202 | $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); 203 | } 204 | else { 205 | $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); 206 | } 207 | $key = $h[0]; 208 | } 209 | else { 210 | if (substr($h[0], 0, 1) == "\t") { 211 | $headers[$key] .= "\r\n\t".trim($h[0]); 212 | } 213 | elseif (!$key) { 214 | $headers[0] = trim($h[0]);trim($h[0]); 215 | } 216 | } 217 | } 218 | return $headers; 219 | } 220 | 221 | } 222 | -------------------------------------------------------------------------------- /includes/getRemoteFileInfoExample.php: -------------------------------------------------------------------------------- 1 | getType()); 13 | var_dump($file_info->getName()); 14 | -------------------------------------------------------------------------------- /js/dataset.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | 3 | Drupal.behaviors.dkanDataset = { 4 | attach: function (context, settings) { 5 | var height = 150; 6 | var dif = 30; 7 | var offset = height - dif; 8 | var id = '.field-group-format.group_additional > tbody > tr'; 9 | dkanDatasetRowHide(id, height, dif, offset); 10 | } 11 | } 12 | 13 | // Adds "Show more" to rows longer than height. 14 | function dkanDatasetRowHide(id, height, dif, offset) { 15 | $(id).each(function() { 16 | if ($(this).height() > height) { 17 | height = height + "px"; 18 | offset = offset + "px"; 19 | $(this).find('.field-item').append('
' + Drupal.t("Show more") + '
'); 20 | $(this).find('.field-item').eq(0).css({"height": height, "overflow":"hidden", "position":"relative", "padding-bottom" : dif}); 21 | } 22 | $("#click-full").off().on('click', function(e) { 23 | if ($(this).hasClass("clicked")) { 24 | $(this).parent().css({"height": height, "overflow":"hidden"}); 25 | $(this).css({"bottom": "inherit", "top" : offset, "padding" : "0 0 20px 0"}); 26 | $(this).find("a").text(Drupal.t("Show more")); 27 | $(this).removeClass("clicked"); 28 | } 29 | else { 30 | $(this).parent().css({"height": "inherit"}); 31 | $(this).css({"bottom": "0", "top" : "inherit", "padding" : "0 0 20px 0"}); 32 | $(this).find("a").text(Drupal.t("hide")); 33 | $(this).addClass("clicked"); 34 | } 35 | return false; 36 | }); 37 | }); 38 | } 39 | 40 | })(jQuery); 41 | -------------------------------------------------------------------------------- /js/dkan_forms.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * JS for DKAN forms. 4 | */ 5 | (function ($) { 6 | 7 | /** 8 | * Shows and hides a description for Drupal form elements. 9 | */ 10 | $.fn.dkanFormsHide = function () { 11 | this.each(function () { 12 | $(this).addClass('compact-form-wrapper'); 13 | var desc = $(this).find('.description').addClass('compact-form-description'); 14 | var input = $(this).find('input'); 15 | desc.click(function () { 16 | input.focus(); 17 | }); 18 | if ($(input).html() == '') { 19 | var input = $(this).find('textarea'); 20 | } 21 | if ($(input).html() == null) { 22 | var input = $(this).find('input'); 23 | } 24 | input.addClass('compact-form-input') 25 | input.blur(function () { 26 | if (input.val() === '') { 27 | desc.fadeIn('fast'); 28 | } 29 | }); 30 | input.keyup(function () { 31 | if (input.val() != '') { 32 | desc.hide(); 33 | } 34 | }); 35 | if (input.val() != '') { 36 | desc.css('display', 'none'); 37 | } 38 | }); 39 | } 40 | 41 | /** 42 | * Shows and hides a description for Autocomplete Deluxe form elements. 43 | */ 44 | $.fn.dkanFormsAutoDeluxeHide = function () { 45 | this.each(function () { 46 | $(this).addClass('compact-form-wrapper'); 47 | var desc = $(this).find('.description').addClass('compact-form-description'); 48 | var input = $(this).find('#autocomplete-deluxe-input'); 49 | desc.click(function () { 50 | input.focus(); 51 | }); 52 | input.focus(function () { 53 | desc.hide(); 54 | }); 55 | if ($('#autocomplete-deluxe-item').html() != null) { 56 | desc.css('display', 'none'); 57 | } 58 | if ($(this).find('input').val() != '') { 59 | desc.css('display', 'none'); 60 | } 61 | }); 62 | } 63 | Drupal.behaviors.dkanAddtional = { 64 | attach: function (context, settings) { 65 | if (settings.dkanAdditional && context.context) { 66 | var pos = $('#page').offset(); 67 | $('html, body').animate({ scrollTop: pos.top}, 'fast'); 68 | window.history.pushState("", "", '/node/' + settings.dkanAdditional.nid + '/edit?additional=1'); 69 | delete settings.dkanAdditional; 70 | } 71 | $("#edit-addtional").click(function(e) { 72 | var params = $.deparam.querystring(); 73 | document.location.href='/node/' + params.dataset + '/edit?additional=1'; 74 | }); 75 | } 76 | } 77 | Drupal.behaviors.dkanPush = { 78 | attach: function (context, settings) { 79 | if (settings.dkanPush && context.context) { 80 | var pos = $('#page').offset(); 81 | $('html, body').animate({ scrollTop: pos.top}, 'fast'); 82 | if (settings.dkanPush.lang) { 83 | window.history.pushState("", "", '/' + settings.dkanPush.lang + '/node/add/resource?dataset=' + settings.dkanPush.nid); 84 | } 85 | else { 86 | window.history.pushState("", "", '/node/add/resource?dataset=' + settings.dkanPush.nid); 87 | } 88 | // Make sure this doesn't fire again. 89 | delete settings.dkanPush; 90 | } 91 | } 92 | } 93 | 94 | Drupal.behaviors.dkanFieldGroup = { 95 | attach: function (context, settings) { 96 | 97 | $('fieldset.horizontal-tabs-pane', context).once('fieldgroup-effects', function(i) { 98 | // Make tab with any value in it focus. 99 | if ($(this).find('input').val()) { 100 | $(this).data('horizontalTab').focus(); 101 | } 102 | }); 103 | } 104 | } 105 | 106 | Drupal.behaviors.dkanForms = { 107 | attach: function (context, settings) { 108 | // Causes file to be uploaded automatically. 109 | $('input.form-file').change(function() { 110 | $(this).next('input[type="submit"]').mousedown(); 111 | }); 112 | 113 | // Autohide selected elements. 114 | var elements = "#views-exposed-form-dataset-page,#block-dkan-dataset-dkan-dataset-search-bar"; 115 | $(elements, context).dkanFormsHide(); 116 | var autoDeluxeElements = ".field-name-field-tags"; 117 | $(autoDeluxeElements, context).dkanFormsAutoDeluxeHide(); 118 | 119 | // Date module borks if you add a date without a time. This adds a default 120 | // time if someone picks a date and time has been added yet. 121 | if ($('#edit-field-temporal-coverage').length) { 122 | var tempInputDate1 = $('#edit-field-temporal-coverage input:eq(1)'); 123 | var tempInputTime1 = $('#edit-field-temporal-coverage input:eq(2)'); 124 | var tempInputDate2 = $('#edit-field-temporal-coverage input:eq(3)'); 125 | var tempInputTime2 = $('#edit-field-temporal-coverage input:eq(4)'); 126 | $(tempInputDate1).click(function() { 127 | if ($(tempInputTime1).val() == '') { 128 | $(tempInputTime1).val('00:00:00'); 129 | } 130 | }); 131 | $(tempInputDate2).click(function() { 132 | if ($(tempInputTime2).val() == '') { 133 | $(tempInputTime2).val('00:00:00'); 134 | } 135 | }); 136 | } 137 | $("#node_dataset_form_group_additional .description").each(function() { 138 | dkanFormsBeautyTipPrepare(this, 'label'); 139 | }); 140 | $(".field-widget-leaflet-widget-widget .fieldset-description").appendTo($(".field-widget-leaflet-widget-widget fieldset")); 141 | $(".field-widget-leaflet-widget-widget .fieldset-description").each(function() { 142 | dkanFormsBeautyTipPrepare(this, 'legend'); 143 | }); 144 | $(".field-type-datetime.field-name-field-temporal-coverage .fieldset-description").appendTo($(".field-type-datetime.field-name-field-temporal-coverage fieldset")); 145 | $(".field-type-datetime.field-name-field-temporal-coverage .fieldset-description").each(function() { 146 | dkanFormsBeautyTipPrepare(this, 'legend'); 147 | }); 148 | } 149 | } 150 | 151 | function dkanFormsBeautyTipPrepare(that, label) { 152 | var desc = $(that).html(); 153 | var link = $(that).find('a').attr('href'); 154 | if (link) { 155 | $(that).html(''); 156 | $(that).prevAll(label).append(''); 157 | $(that).prevAll(label).find("a.bt-pop").bt(desc, { 158 | spikeLength: 20, 159 | spikeGirth: 20, 160 | cornerRadius: 5, 161 | shrinkToFit: true, 162 | padding: 10, 163 | width: '400px', 164 | fill: '#EAEAEA', 165 | strokeWidth: 1, 166 | strokeStyle: '#CCC', 167 | cssStyles: {color: '#666', width: 'auto'}}); 168 | } 169 | } 170 | 171 | 172 | })(jQuery); 173 | -------------------------------------------------------------------------------- /js/dkan_forms.slugify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * JS for DKAN forms. 4 | */ 5 | (function ($) { 6 | 7 | $.fn.dkanFormsSlugifyTitle = function (source) { 8 | var $target = this; 9 | var $source = $(source); 10 | 11 | $source.keyup(function () { 12 | $target.text($(this).val()); 13 | }); 14 | 15 | return this; 16 | }; 17 | 18 | Drupal.behaviors.dkanFormsSlugify = { 19 | attach: function (context, settings) { 20 | // Slugify! 21 | if ($('#edit-path-alias').val() != '') { 22 | $('#url-edit-preview').hide(); 23 | } 24 | else { 25 | // Initially hide the path until clicked. 26 | $('.node-dataset-form .group-primary .path-form').hide(); 27 | // Hidden by default in case js is disabled. 28 | $('#url-edit-preview').show(); 29 | // Force URLs to be url friendly. 30 | $('#edit-path-alias').slugify('#edit-path-alias'); 31 | // Only edit path alias if alias has not been edited. 32 | $('.form-item-title input').click(function(e) { 33 | $('#edit-path-alias').slugify($(this)); 34 | $('#url-slug').slugify($(this)); 35 | }); 36 | $('#url-edit-preview button.btn').click(function(e) { 37 | e.preventDefault(); 38 | $('#url-edit-preview').hide(); 39 | $('.node-dataset-form .group-primary .path-form').show(); 40 | $('#edit-path-alias').focus(); 41 | $('#edit-path-alias').addClass('processed'); 42 | }); 43 | } 44 | 45 | // Resource list. 46 | $('#block-dkan-forms-dkan-forms-resource-nodes ul li.last').dkanFormsSlugifyTitle('.form-item-title input'); 47 | 48 | } 49 | } 50 | 51 | })(jQuery); 52 | -------------------------------------------------------------------------------- /js/dkan_tooltip.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | $(document).ready(function(){ 3 | $('[data-toggle="tooltip"]').tooltip(); 4 | $(".tip-bottom").tooltip({placement : 'bottom'}); 5 | }); 6 | })(jQuery); 7 | -------------------------------------------------------------------------------- /modules/dkan_dataset_api/dkan_dataset_api.info: -------------------------------------------------------------------------------- 1 | name = DKAN Dataset API 2 | description = Adds package, group, and tag APIs based on the CKAN API. 3 | package = DKAN API 4 | core = 7.x 5 | php = 5.2.4 6 | version = 7.x-1.x-dev 7 | project = dkan_dataset_api 8 | dependencies[] = dkan_dataset 9 | dependencies[] = dkan_dataset_content_types 10 | files[] = tests/dkan_dataset_api.test 11 | -------------------------------------------------------------------------------- /modules/dkan_dataset_api/tests/dkan_dataset_api.test: -------------------------------------------------------------------------------- 1 | 'DKAN Dataset API Test', 22 | 'description' => 'Test DKAN Dataset API functions and endpoints', 23 | 'group' => 'DKAN Dataset API', 24 | ); 25 | } 26 | 27 | /** 28 | * Setup testcase. 29 | */ 30 | public function setUp() { 31 | $args = func_get_args(); 32 | 33 | // Build the list of required modules which can be altered by passing in an 34 | // array of module names to setUp(). 35 | if (isset($args[0])) { 36 | if (is_array($args[0])) { 37 | $modules = $args[0]; 38 | } 39 | else { 40 | $modules = $args; 41 | } 42 | } 43 | else { 44 | $modules = array(); 45 | } 46 | 47 | $modules[] = 'ctools'; 48 | $modules[] = 'context'; 49 | $modules[] = 'block'; 50 | $modules[] = 'file'; 51 | $modules[] = 'filter'; 52 | $modules[] = 'image'; 53 | $modules[] = 'list'; 54 | $modules[] = 'menu'; 55 | $modules[] = 'number'; 56 | $modules[] = 'options'; 57 | $modules[] = 'path'; 58 | $modules[] = 'taxonomy'; 59 | $modules[] = 'text'; 60 | $modules[] = 'user'; 61 | $modules[] = 'date'; 62 | $modules[] = 'date_api'; 63 | $modules[] = 'date_popup'; 64 | $modules[] = 'dkan_dataset'; 65 | $modules[] = 'dkan_dataset_groups'; 66 | $modules[] = 'dkan_dataset_content_types'; 67 | $modules[] = 'dkan_dataset_api'; 68 | $modules[] = 'features'; 69 | $modules[] = 'double_field'; 70 | $modules[] = 'entityreference'; 71 | $modules[] = 'field_group'; 72 | $modules[] = 'field_group_table'; 73 | $modules[] = 'filefield_sources'; 74 | $modules[] = 'geofield'; 75 | $modules[] = 'link'; 76 | $modules[] = 'link_iframe_formatter'; 77 | $modules[] = 'multistep'; 78 | $modules[] = 'ref_field_sync'; 79 | $modules[] = 'select_or_other'; 80 | $modules[] = 'og'; 81 | $modules[] = 'og_context'; 82 | $modules[] = 'og_extras'; 83 | $modules[] = 'og_ui'; 84 | $modules[] = 'chosen'; 85 | $modules[] = 'entity'; 86 | $modules[] = 'geophp'; 87 | $modules[] = 'gravatar'; 88 | $modules[] = 'leaflet_widget'; 89 | $modules[] = 'libraries'; 90 | $modules[] = 'recline'; 91 | $modules[] = 'remote_stream_wrapper'; 92 | $modules[] = 'strongarm'; 93 | $modules[] = 'token'; 94 | $modules[] = 'search_api'; 95 | $modules[] = 'search_api_db'; 96 | $modules[] = 'search_api_views'; 97 | $modules[] = 'facetapi'; 98 | $modules[] = 'autocomplete_deluxe'; 99 | $modules[] = 'beautytips'; 100 | $modules[] = 'jquery_update'; 101 | $modules[] = 'uuid'; 102 | $modules[] = 'views'; 103 | $modules[] = 'views_bulk_operations'; 104 | 105 | $modules = array_unique($modules); 106 | 107 | parent::setUp($modules); 108 | 109 | features_rebuild(); 110 | 111 | // Setup group. 112 | $this->group = $this->drupalCreateNode( 113 | array( 114 | 'type' => 'group', 115 | 'title' => $this->randomName(32), 116 | ) 117 | ); 118 | 119 | // Upload test csv file. 120 | $file_path = drupal_get_path('module', 'dkan_dataset_api'); 121 | $file_path = realpath($file_path . '/tests/files/test.csv'); 122 | $file = file_get_contents($file_path); 123 | $file = file_save_data($file, 'public://test.csv'); 124 | $file = (array) $file; 125 | $file['grid'] = 1; 126 | $file['map'] = 1; 127 | 128 | // Setup resources. 129 | $this->resource = $this->drupalCreateNode( 130 | array( 131 | 'title' => $this->randomName(32), 132 | 'type' => 'resource', 133 | 'body' => array( 134 | LANGUAGE_NONE => array( 135 | array( 136 | $this->randomName(256), 137 | ), 138 | ), 139 | ), 140 | 'field_upload' => array( 141 | LANGUAGE_NONE => array( 142 | $file, 143 | ), 144 | ), 145 | ) 146 | ); 147 | 148 | // Setup dataset. 149 | $this->dataset = $this->drupalCreateNode( 150 | array( 151 | 'type' => 'dataset', 152 | 'title' => $this->randomName(32), 153 | ) 154 | ); 155 | 156 | $this->resource->field_dataset_ref[LANGUAGE_NONE][] = array( 157 | 'target_id' => $this->dataset->nid, 158 | 'target_type' => $this->dataset->type, 159 | ); 160 | node_save($this->resource); 161 | 162 | // $this->dataset->og_group_ref[LANGUAGE_NONE][] = array( 163 | // 'target_id' => $this->group->nid, 164 | // 'target_type' => $this->group->type, 165 | // ); 166 | 167 | $this->dataset->field_resources[LANGUAGE_NONE][] = array( 168 | 'target_id' => $this->resource->nid, 169 | 'target_type' => $this->resource->type, 170 | ); 171 | node_save($this->dataset); 172 | } 173 | 174 | /** 175 | * Test all read api methods with access control. 176 | */ 177 | public function testDkanDatasetAPIRead() { 178 | // Get all data.json succesful responses. 179 | $responses = $this->runQuerys('data_json'); 180 | 181 | // Get all data.json sucessful responses. 182 | foreach ($responses as $r) { 183 | // There should be only one item. 184 | $this->assertTrue(count($r) === 1); 185 | foreach ($r as $dataset) { 186 | // Test if title is set. 187 | $this->assertTrue(isset($dataset->title)); 188 | } 189 | } 190 | 191 | // Get all site_read succesful responses. 192 | $responses = $this->runQuerys('site_read'); 193 | // Test specifics to site_read for every succesful response. 194 | foreach ($responses as $r) { 195 | $this->runCommonTest($r, 'Return'); 196 | } 197 | 198 | // Get all revision_list succesful responses. 199 | $responses = $this->runQuerys('revision_list'); 200 | // Test specifics to revision_list for every succesful response. 201 | foreach ($responses as $r) { 202 | $this->runCommonTest($r, 'Return a list of the IDs'); 203 | } 204 | 205 | // Get all package_list succesful responses. 206 | $responses = $this->runQuerys('package_list'); 207 | // Test specifics to package_list for every succesful response. 208 | foreach ($responses as $r) { 209 | $this->runCommonTest($r, 'Return a list of the names'); 210 | $uuids = $r->result; 211 | } 212 | foreach ($uuids as $uuid) { 213 | // Get all package_revision_list succesful responses. 214 | $responses = $this->runQuerys('package_revision_list', $uuid); 215 | foreach ($responses as $r) { 216 | $this->runCommonTest($r, 'Return a dataset (package)'); 217 | foreach ($r->result as $package) { 218 | $this->assertTrue($package->timestamp); 219 | $this->assertTrue($package->id); 220 | } 221 | } 222 | 223 | // Get all package_show succesful responses. 224 | $responses = $this->runQuerys('package_show', $uuid); 225 | foreach ($responses as $r) { 226 | $this->runCommonTest($r, 'Return the metadata of a dataset'); 227 | $this->runPackageTests($r->result); 228 | } 229 | } 230 | 231 | // Get all current_package_list_with_resources succesful responses. 232 | $responses = $this->runQuerys('current_package_list_with_resources'); 233 | foreach ($responses as $r) { 234 | $this->runCommonTest($r, 'Return a list of the site\'s datasets'); 235 | $this->runPackageTests($r->result); 236 | } 237 | 238 | // Get all group_list succesful responses. 239 | $responses = $this->runQuerys('group_list'); 240 | $uuids = array(); 241 | foreach ($responses as $r) { 242 | $this->runCommonTest($r, 'Return a list of the names of the site\'s groups'); 243 | $uuids = $r->result; 244 | } 245 | 246 | foreach ($uuids as $uuid) { 247 | // Get all group_package_show succesful responses. 248 | $responses = $this->runQuerys('group_package_show', $uuid); 249 | foreach ($responses as $r) { 250 | $this->runCommonTest($r, 'Return the datasets (packages) of a group'); 251 | $this->runPackageTests($r->result); 252 | } 253 | } 254 | } 255 | 256 | /** 257 | * Run common test to an array of package. 258 | * 259 | * @param object $result 260 | * A dkan_dataset_api result object. 261 | * @param string $text 262 | * A string to match against the returned help string. 263 | */ 264 | protected function runCommonTest($result, $text) { 265 | if (count($result->result)) { 266 | $this->assertTrue($result->result); 267 | $this->assertTrue($result->success); 268 | } 269 | $this->assertTrue(strpos($result->help, $text) !== FALSE); 270 | } 271 | 272 | /** 273 | * Run common test to an array of package. 274 | * 275 | * @param array $packages 276 | * An array of json datasets. 277 | */ 278 | protected function runPackageTests($packages) { 279 | // Loop every dataset. 280 | foreach ($packages as $package) { 281 | $this->assertTrue($package->metadata_created); 282 | $this->assertTrue($package->metadata_modified); 283 | $this->assertTrue($package->id); 284 | $this->assertTrue($package->resources); 285 | $this->assertTrue($package->num_resources === count($package->resources)); 286 | // Loop every resource. 287 | foreach ($package->resources as $resource) { 288 | $this->assertTrue($resource->title); 289 | $this->assertTrue($resource->id); 290 | $this->assertTrue($resource->revision_id); 291 | $this->assertTrue($resource->created); 292 | $this->assertTrue($resource->active); 293 | } 294 | } 295 | } 296 | 297 | /** 298 | * Runs querys for every hook_menu_item related to $slug. 299 | * 300 | * @param string $slug 301 | * identifier for a specific api endpoint 302 | * @param string $uuid 303 | * unique identifier for a specific group, resource or dataset query 304 | * @param string $prefix 305 | * for access control variable_set 306 | */ 307 | protected function runQuerys($slug, $uuid = FALSE, $prefix = 'dkan_dataset_api_') { 308 | $uris = $this->getHookMenuItems($slug); 309 | foreach ($uris as $key => $uri) { 310 | $uris[$key] = array('uri' => $uri, 'options' => array()); 311 | if ($uuid) { 312 | if (strpos($uri, '%') !== FALSE) { 313 | $uris[$key]['uri'] = str_replace('%', $uuid, $uri); 314 | } 315 | else { 316 | $uris[$key]['options'] = array('query' => array('id' => $uuid), 'absolute' => TRUE); 317 | } 318 | } 319 | } 320 | $succesful = array(); 321 | // Assert Successful Header and store succesful responses. 322 | variable_set($prefix . $slug, 1); 323 | foreach ($uris as $uri) { 324 | $r = json_decode($this->drupalGet($uri['uri'], $uri['options'])); 325 | $h = $this->drupalGetHeaders(); 326 | $this->assertTrue(strpos($h[':status'], '200') !== FALSE); 327 | $succesful[] = $r; 328 | } 329 | // Assert Forbbiden Header. 330 | variable_set($prefix . $slug, 0); 331 | foreach ($uris as $uri) { 332 | $f = $this->drupalGet($uri['uri'], $uri['options']); 333 | $h = $this->drupalGetHeaders(); 334 | $this->assertTrue(strpos($h[':status'], '403') !== FALSE); 335 | } 336 | // Return succesful querys for further assertions. 337 | return $succesful; 338 | } 339 | 340 | /** 341 | * Helper that gets defined hook_menu items related to a specific callback. 342 | * 343 | * @param string $callback 344 | * a string representing a drupal callback. 345 | * @param string $prefix 346 | * prefix to remove from the callback. 347 | * 348 | * @return array 349 | * an array of related callbacks. 350 | */ 351 | protected function getHookMenuItems($callback, $prefix = 'dkan_dataset_api_') { 352 | $items = dkan_dataset_api_menu(); 353 | $r = array(); 354 | // Match callback variable against $item['page_callback'], 355 | foreach ($items as $key => $item) { 356 | $item_callback = $item['page callback']; 357 | $item_callback = str_replace($prefix, '', $item_callback); 358 | // If match push key to test endpoint. 359 | if ($item_callback === $callback) { 360 | $r[] = $key; 361 | } 362 | } 363 | return $r; 364 | } 365 | } 366 | -------------------------------------------------------------------------------- /modules/dkan_dataset_content_types/dkan_dataset_content_types.api.php: -------------------------------------------------------------------------------- 1 | array( 15 | 'label' => 'license label (pretty representation for license key)', 16 | 'uri' => '(Optional) uri to license page', 17 | ), 18 | ); 19 | } 20 | 21 | /** 22 | * Removes a set of license options for the dkan dataset license field. 23 | * 24 | */ 25 | function hook_license_subscribe() { 26 | return array( 27 | 'license-key', 28 | ); 29 | } -------------------------------------------------------------------------------- /modules/dkan_dataset_content_types/dkan_dataset_content_types.features.inc: -------------------------------------------------------------------------------- 1 | "1"); 13 | } 14 | if ($module == "strongarm" && $api == "strongarm") { 15 | return array("version" => "1"); 16 | } 17 | } 18 | 19 | /** 20 | * Implements hook_node_info(). 21 | */ 22 | function dkan_dataset_content_types_node_info() { 23 | $items = array( 24 | 'dataset' => array( 25 | 'name' => t('Dataset'), 26 | 'base' => 'node_content', 27 | 'description' => t('Datasets are simply used to group related pieces of data. These can then be found under a single url with a description and licensing information.'), 28 | 'has_title' => '1', 29 | 'title_label' => t('Title'), 30 | 'help' => '', 31 | ), 32 | 'resource' => array( 33 | 'name' => t('Resource'), 34 | 'base' => 'node_content', 35 | 'description' => t('Data can be any file or link to a file containing useful data.'), 36 | 'has_title' => '1', 37 | 'title_label' => t('Title'), 38 | 'help' => '', 39 | ), 40 | ); 41 | drupal_alter('node_info', $items); 42 | return $items; 43 | } 44 | -------------------------------------------------------------------------------- /modules/dkan_dataset_content_types/dkan_dataset_content_types.features.taxonomy.inc: -------------------------------------------------------------------------------- 1 | array( 13 | 'name' => 'Format', 14 | 'machine_name' => 'format', 15 | 'description' => 'This is generated automatically, you can edit it if you wish', 16 | 'hierarchy' => 0, 17 | 'module' => 'taxonomy', 18 | 'weight' => 0, 19 | 'rdf_mapping' => array( 20 | 'rdftype' => array( 21 | 0 => 'skos:ConceptScheme', 22 | ), 23 | 'name' => array( 24 | 'predicates' => array( 25 | 0 => 'dc:title', 26 | ), 27 | ), 28 | 'description' => array( 29 | 'predicates' => array( 30 | 0 => 'rdfs:comment', 31 | ), 32 | ), 33 | ), 34 | ), 35 | 'tags' => array( 36 | 'name' => 'Tags', 37 | 'machine_name' => 'tags', 38 | 'description' => 'eg. economy, mental health, government', 39 | 'hierarchy' => 0, 40 | 'module' => 'taxonomy', 41 | 'weight' => 0, 42 | 'rdf_mapping' => array( 43 | 'rdftype' => array( 44 | 0 => 'skos:ConceptScheme', 45 | ), 46 | 'name' => array( 47 | 'predicates' => array( 48 | 0 => 'dc:title', 49 | ), 50 | ), 51 | 'description' => array( 52 | 'predicates' => array( 53 | 0 => 'rdfs:comment', 54 | ), 55 | ), 56 | ), 57 | ), 58 | ); 59 | } 60 | -------------------------------------------------------------------------------- /modules/dkan_dataset_content_types/dkan_dataset_content_types.field_group.inc: -------------------------------------------------------------------------------- 1 | disabled = FALSE; /* Edit this to true to make a default field_group disabled initially */ 15 | $field_group->api_version = 1; 16 | $field_group->identifier = 'group_additional|node|dataset|default'; 17 | $field_group->group_name = 'group_additional'; 18 | $field_group->entity_type = 'node'; 19 | $field_group->bundle = 'dataset'; 20 | $field_group->mode = 'default'; 21 | $field_group->parent_name = ''; 22 | $field_group->data = array( 23 | 'label' => 'Dataset Info', 24 | 'weight' => '4', 25 | 'children' => array( 26 | 0 => 'field_author', 27 | 1 => 'field_contact_email', 28 | 2 => 'field_contact_name', 29 | 3 => 'field_data_dictionary', 30 | 4 => 'field_frequency', 31 | 5 => 'field_granularity', 32 | 6 => 'field_license', 33 | 7 => 'field_public_access_level', 34 | 8 => 'field_spatial', 35 | 9 => 'field_spatial_geographical_cover', 36 | 10 => 'field_temporal_coverage', 37 | 11 => 'og_group_ref', 38 | 12 => 'release_date', 39 | 13 => 'modified_date', 40 | 14 => 'identifier', 41 | 15 => 'field_is_part_of', 42 | 16 => 'field_data_dictionary_type', 43 | 17 => 'field_landing_page', 44 | 18 => 'field_pod_theme', 45 | 19 => 'field_conforms_to', 46 | 20 => 'field_rights', 47 | 21 => 'field_language', 48 | ), 49 | 'format_type' => 'table', 50 | 'format_settings' => array( 51 | 'label' => 'Dataset Info', 52 | 'instance_settings' => array( 53 | 'label' => 'hide', 54 | 'desc' => '
These fields are compatible with DCAT, an RDF vocabulary designed to facilitate interoperability between data catalogs published on the Web.
', 55 | 'first_column' => 'Field', 56 | 'second_column' => 'Value', 57 | 'cells' => 'empty', 58 | 'classes' => ' group-additional field-group-table', 59 | ), 60 | ), 61 | ); 62 | $field_groups['group_additional|node|dataset|default'] = $field_group; 63 | 64 | $field_group = new stdClass(); 65 | $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially */ 66 | $field_group->api_version = 1; 67 | $field_group->identifier = 'group_additional|node|dataset|form'; 68 | $field_group->group_name = 'group_additional'; 69 | $field_group->entity_type = 'node'; 70 | $field_group->bundle = 'dataset'; 71 | $field_group->mode = 'form'; 72 | $field_group->parent_name = ''; 73 | $field_group->data = array( 74 | 'label' => 'Dataset Information', 75 | 'weight' => '1', 76 | 'children' => array( 77 | 0 => 'field_additional_info', 78 | 1 => 'field_author', 79 | 2 => 'field_conforms_to', 80 | 3 => 'field_contact_email', 81 | 4 => 'field_contact_name', 82 | 5 => 'field_data_dictionary', 83 | 6 => 'field_data_dictionary_type', 84 | 7 => 'field_frequency', 85 | 8 => 'field_granularity', 86 | 9 => 'field_is_part_of', 87 | 10 => 'field_landing_page', 88 | 11 => 'field_language', 89 | 12 => 'field_modified_source_date', 90 | 13 => 'field_pod_theme', 91 | 14 => 'field_public_access_level', 92 | 15 => 'field_related_content', 93 | 16 => 'field_resources', 94 | 17 => 'field_rights', 95 | 18 => 'field_spatial', 96 | 19 => 'field_spatial_geographical_cover', 97 | 20 => 'field_temporal_coverage', 98 | ), 99 | 'format_type' => 'fieldset', 100 | 'format_settings' => array( 101 | 'label' => 'Dataset Information', 102 | 'instance_settings' => array( 103 | 'required_fields' => 1, 104 | 'classes' => ' group-additional field-group-fieldset', 105 | 'description' => 'These fields are compatible with DCAT, an RDF vocabulary designed to facilitate interoperability between data catalogs published on the Web. These fields are also compatible with the Common Core metadata schema from Project Open Data.', 106 | ), 107 | 'formatter' => 'open', 108 | ), 109 | ); 110 | $field_groups['group_additional|node|dataset|form'] = $field_group; 111 | 112 | $field_group = new stdClass(); 113 | $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially */ 114 | $field_group->api_version = 1; 115 | $field_group->identifier = 'group_data|node|resource|form'; 116 | $field_group->group_name = 'group_data'; 117 | $field_group->entity_type = 'node'; 118 | $field_group->bundle = 'resource'; 119 | $field_group->mode = 'form'; 120 | $field_group->parent_name = ''; 121 | $field_group->data = array( 122 | 'label' => 'Resource', 123 | 'weight' => '2', 124 | 'children' => array( 125 | 0 => 'group_link_api', 126 | 1 => 'group_link_file', 127 | 2 => 'group_upload', 128 | ), 129 | 'format_type' => 'htabs', 130 | 'format_settings' => array( 131 | 'label' => 'Resource', 132 | 'instance_settings' => array( 133 | 'classes' => ' group-data field-group-htabs', 134 | ), 135 | ), 136 | ); 137 | $field_groups['group_data|node|resource|form'] = $field_group; 138 | 139 | $field_group = new stdClass(); 140 | $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially */ 141 | $field_group->api_version = 1; 142 | $field_group->identifier = 'group_link_api|node|resource|form'; 143 | $field_group->group_name = 'group_link_api'; 144 | $field_group->entity_type = 'node'; 145 | $field_group->bundle = 'resource'; 146 | $field_group->mode = 'form'; 147 | $field_group->parent_name = 'group_data'; 148 | $field_group->data = array( 149 | 'label' => 'API or Website URL', 150 | 'weight' => '11', 151 | 'children' => array( 152 | 0 => 'field_link_api', 153 | ), 154 | 'format_type' => 'htab', 155 | 'format_settings' => array( 156 | 'label' => 'API or Website URL', 157 | 'instance_settings' => array( 158 | 'required_fields' => 1, 159 | 'classes' => 'htab_link_api group-link-api field-group-htab', 160 | 'description' => '', 161 | ), 162 | 'formatter' => 'closed', 163 | ), 164 | ); 165 | $field_groups['group_link_api|node|resource|form'] = $field_group; 166 | 167 | $field_group = new stdClass(); 168 | $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially */ 169 | $field_group->api_version = 1; 170 | $field_group->identifier = 'group_link_file|node|resource|form'; 171 | $field_group->group_name = 'group_link_file'; 172 | $field_group->entity_type = 'node'; 173 | $field_group->bundle = 'resource'; 174 | $field_group->mode = 'form'; 175 | $field_group->parent_name = 'group_data'; 176 | $field_group->data = array( 177 | 'label' => 'Remote file', 178 | 'weight' => '12', 179 | 'children' => array( 180 | 0 => 'field_link_remote_file', 181 | ), 182 | 'format_type' => 'htab', 183 | 'format_settings' => array( 184 | 'label' => 'Remote file', 185 | 'instance_settings' => array( 186 | 'required_fields' => 1, 187 | 'classes' => 'htab_link_file group-link-file field-group-htab', 188 | 'description' => '', 189 | ), 190 | 'formatter' => 'closed', 191 | ), 192 | ); 193 | $field_groups['group_link_file|node|resource|form'] = $field_group; 194 | 195 | $field_group = new stdClass(); 196 | $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially */ 197 | $field_group->api_version = 1; 198 | $field_group->identifier = 'group_primary|node|dataset|form'; 199 | $field_group->group_name = 'group_primary'; 200 | $field_group->entity_type = 'node'; 201 | $field_group->bundle = 'dataset'; 202 | $field_group->mode = 'form'; 203 | $field_group->parent_name = ''; 204 | $field_group->data = array( 205 | 'label' => 'Primary', 206 | 'weight' => '0', 207 | 'children' => array( 208 | 0 => 'body', 209 | 1 => 'field_license', 210 | 2 => 'field_tags', 211 | 3 => 'og_group_ref', 212 | 4 => 'field_topic', 213 | 5 => 'title', 214 | ), 215 | 'format_type' => 'fieldset', 216 | 'format_settings' => array( 217 | 'label' => 'Primary', 218 | 'instance_settings' => array( 219 | 'required_fields' => 1, 220 | 'classes' => ' group-primary field-group-fieldset', 221 | 'description' => '', 222 | ), 223 | 'formatter' => 'open', 224 | ), 225 | ); 226 | $field_groups['group_primary|node|dataset|form'] = $field_group; 227 | 228 | $field_group = new stdClass(); 229 | $field_group->disabled = FALSE; /* Edit this to true to make a default field_group disabled initially */ 230 | $field_group->api_version = 1; 231 | $field_group->identifier = 'group_upload|node|resource|form'; 232 | $field_group->group_name = 'group_upload'; 233 | $field_group->entity_type = 'node'; 234 | $field_group->bundle = 'resource'; 235 | $field_group->mode = 'form'; 236 | $field_group->parent_name = 'group_data'; 237 | $field_group->data = array( 238 | 'label' => 'Upload', 239 | 'weight' => '9', 240 | 'children' => array( 241 | 0 => 'field_upload', 242 | ), 243 | 'format_type' => 'htab', 244 | 'format_settings' => array( 245 | 'label' => 'Upload', 246 | 'instance_settings' => array( 247 | 'required_fields' => 1, 248 | 'classes' => 'htab_link_upload group-upload field-group-htab', 249 | 'description' => '', 250 | ), 251 | 'formatter' => 'closed', 252 | ), 253 | ); 254 | $field_groups['group_upload|node|resource|form'] = $field_group; 255 | 256 | // Translatables 257 | // Included for use with string extractors like potx. 258 | t('API or Website URL'); 259 | t('Dataset Info'); 260 | t('Dataset Information'); 261 | t('Primary'); 262 | t('Remote file'); 263 | t('Resource'); 264 | t('Upload'); 265 | 266 | return $field_groups; 267 | } 268 | -------------------------------------------------------------------------------- /modules/dkan_dataset_content_types/dkan_dataset_content_types.info: -------------------------------------------------------------------------------- 1 | name = DKAN Dataset Content Types 2 | description = Custom elements for Datasets. 3 | core = 7.x 4 | package = DKAN 5 | version = 7.x-1.x-dev 6 | project = dkan_dataset_content_types 7 | dependencies[] = autocomplete_deluxe 8 | dependencies[] = ctools 9 | dependencies[] = date 10 | dependencies[] = dkan_dataset 11 | dependencies[] = dkan_datastore 12 | dependencies[] = double_field 13 | dependencies[] = entityreference 14 | dependencies[] = features 15 | dependencies[] = field_group 16 | dependencies[] = file 17 | dependencies[] = file_resup 18 | dependencies[] = geofield 19 | dependencies[] = image 20 | dependencies[] = leaflet_widget 21 | dependencies[] = link 22 | dependencies[] = link_iframe_formatter 23 | dependencies[] = list 24 | dependencies[] = options 25 | dependencies[] = recline 26 | dependencies[] = select_or_other 27 | dependencies[] = strongarm 28 | dependencies[] = taxonomy 29 | dependencies[] = text 30 | features[ctools][] = field_group:field_group:1 31 | features[ctools][] = strongarm:strongarm:1 32 | features[features_api][] = api:2 33 | features[field_base][] = body 34 | features[field_base][] = field_additional_info 35 | features[field_base][] = field_author 36 | features[field_base][] = field_conforms_to 37 | features[field_base][] = field_contact_email 38 | features[field_base][] = field_contact_name 39 | features[field_base][] = field_data_dictionary 40 | features[field_base][] = field_data_dictionary_type 41 | features[field_base][] = field_dataset_ref 42 | features[field_base][] = field_format 43 | features[field_base][] = field_frequency 44 | features[field_base][] = field_granularity 45 | features[field_base][] = field_harvest_source_ref 46 | features[field_base][] = field_is_part_of 47 | features[field_base][] = field_landing_page 48 | features[field_base][] = field_language 49 | features[field_base][] = field_license 50 | features[field_base][] = field_link_api 51 | features[field_base][] = field_link_remote_file 52 | features[field_base][] = field_modified_source_date 53 | features[field_base][] = field_pod_theme 54 | features[field_base][] = field_public_access_level 55 | features[field_base][] = field_related_content 56 | features[field_base][] = field_resources 57 | features[field_base][] = field_rights 58 | features[field_base][] = field_spatial 59 | features[field_base][] = field_spatial_geographical_cover 60 | features[field_base][] = field_tags 61 | features[field_base][] = field_temporal_coverage 62 | features[field_base][] = field_upload 63 | features[field_group][] = group_additional|node|dataset|default 64 | features[field_group][] = group_additional|node|dataset|form 65 | features[field_group][] = group_data|node|resource|form 66 | features[field_group][] = group_link_api|node|resource|form 67 | features[field_group][] = group_link_file|node|resource|form 68 | features[field_group][] = group_primary|node|dataset|form 69 | features[field_group][] = group_upload|node|resource|form 70 | features[field_instance][] = node-dataset-body 71 | features[field_instance][] = node-dataset-field_additional_info 72 | features[field_instance][] = node-dataset-field_author 73 | features[field_instance][] = node-dataset-field_conforms_to 74 | features[field_instance][] = node-dataset-field_contact_email 75 | features[field_instance][] = node-dataset-field_contact_name 76 | features[field_instance][] = node-dataset-field_data_dictionary 77 | features[field_instance][] = node-dataset-field_data_dictionary_type 78 | features[field_instance][] = node-dataset-field_frequency 79 | features[field_instance][] = node-dataset-field_granularity 80 | features[field_instance][] = node-dataset-field_harvest_source_ref 81 | features[field_instance][] = node-dataset-field_is_part_of 82 | features[field_instance][] = node-dataset-field_landing_page 83 | features[field_instance][] = node-dataset-field_language 84 | features[field_instance][] = node-dataset-field_license 85 | features[field_instance][] = node-dataset-field_modified_source_date 86 | features[field_instance][] = node-dataset-field_pod_theme 87 | features[field_instance][] = node-dataset-field_public_access_level 88 | features[field_instance][] = node-dataset-field_related_content 89 | features[field_instance][] = node-dataset-field_resources 90 | features[field_instance][] = node-dataset-field_rights 91 | features[field_instance][] = node-dataset-field_spatial 92 | features[field_instance][] = node-dataset-field_spatial_geographical_cover 93 | features[field_instance][] = node-dataset-field_tags 94 | features[field_instance][] = node-dataset-field_temporal_coverage 95 | features[field_instance][] = node-resource-body 96 | features[field_instance][] = node-resource-field_dataset_ref 97 | features[field_instance][] = node-resource-field_format 98 | features[field_instance][] = node-resource-field_link_api 99 | features[field_instance][] = node-resource-field_link_remote_file 100 | features[field_instance][] = node-resource-field_upload 101 | features[field_instance][] = node-resource-og_group_ref 102 | features[node][] = dataset 103 | features[node][] = resource 104 | features[taxonomy][] = format 105 | features[taxonomy][] = tags 106 | features[variable][] = chosen_jquery_selector 107 | features[variable][] = chosen_minimum 108 | features[variable][] = chosen_minimum_multiple 109 | features[variable][] = chosen_minimum_single 110 | features[variable][] = field_bundle_settings_node__dataset 111 | features[variable][] = field_bundle_settings_node__resource 112 | features[variable][] = jquery_update_jquery_version 113 | features[variable][] = menu_options_dataset 114 | features[variable][] = menu_options_resource 115 | features[variable][] = menu_parent_dataset 116 | features[variable][] = menu_parent_resource 117 | features[variable][] = node_options_dataset 118 | features[variable][] = node_options_resource 119 | features[variable][] = node_preview_dataset 120 | features[variable][] = node_preview_resource 121 | features[variable][] = node_submitted_dataset 122 | features[variable][] = node_submitted_resource 123 | features_exclude[dependencies][og] = og 124 | features_exclude[dependencies][dkan_featured_topics] = dkan_featured_topics 125 | features_exclude[field_base][og_group_ref] = og_group_ref 126 | features_exclude[field_instance][node-dataset-og_group_ref] = node-dataset-og_group_ref 127 | -------------------------------------------------------------------------------- /modules/dkan_dataset_content_types/dkan_dataset_content_types.license_field.inc: -------------------------------------------------------------------------------- 1 | $value) { 14 | $allowed_values[$key] = $value['label']; 15 | } 16 | return $allowed_values; 17 | } 18 | 19 | /** 20 | * Retrieves a list of subscribed values for license field. 21 | */ 22 | function dkan_dataset_content_types_license_subscribed_values() { 23 | $modules = module_implements('license_subscribe'); 24 | $subscribed_values = array(); 25 | // Get a list of licenses to display. 26 | foreach ($modules as $module) { 27 | $function = $module . '_license_subscribe'; 28 | $values = $function(); 29 | foreach ($values as $key => $value) { 30 | // Make sure other module didn't provide the same license. 31 | if (!isset($subscribed_values[$key]) && isset($value['label'])) { 32 | $subscribed_values[$key] = $value; 33 | } 34 | } 35 | } 36 | // Get a list of licenses to remove from display. 37 | $modules = module_implements('license_unsubscribe'); 38 | foreach ($modules as $module) { 39 | $function = $module . '_license_unsubscribe'; 40 | $values = $function(); 41 | foreach ($values as $key) { 42 | // Unsubscribe item if present in subscribed values. 43 | if (isset($subscribed_values[$key])) { 44 | unset($subscribed_values[$key]); 45 | } 46 | } 47 | } 48 | 49 | // Remove licenses with empty URIs if strict POD validation is enabled. 50 | foreach ($subscribed_values as $key => $value) { 51 | // Skip licenses with empty URIs if strict POD validation is enabled. 52 | if (variable_get('dkan_dataset_form_pod_validation') && !isset($value['uri'])) { 53 | unset($subscribed_values[$key]); 54 | } 55 | } 56 | 57 | return $subscribed_values; 58 | } 59 | 60 | /** 61 | * Implements hook_license_subscribe(). 62 | */ 63 | function dkan_dataset_content_types_license_subscribe() { 64 | return array( 65 | "cc-by" => array( 66 | "label" => "Creative Commons Attribution", 67 | "uri" => "http://opendefinition.org/licenses/cc-by/", 68 | ), 69 | "cc-by-sa" => array( 70 | "label" => "Creative Commons Attribution Share-Alike", 71 | "uri" => "http://opendefinition.org/licenses/cc-by-sa/", 72 | ), 73 | "cc-zero" => array( 74 | "label" => "Creative Commons CCZero", 75 | "uri" => "http://opendefinition.org/licenses/cc-zero/", 76 | ), 77 | "cc-nc" => array( 78 | "label" => "Creative Commons Non-Commercial (Any)", 79 | "uri" => "http://opendefinition.org/licenses/cc-nc/", 80 | ), 81 | "cc-by-nc-nd" => array( 82 | "label" => "Attribution NonCommercial NoDerivatives 4.0 International", 83 | "uri" => "https://creativecommons.org/licenses/by-nc-nd/4.0/", 84 | ), 85 | "gfdl" => array( 86 | "label" => "GNU Free Documentation License", 87 | "uri" => "http://opendefinition.org/licenses/gfdl/", 88 | ), 89 | "odc-by" => array( 90 | "label" => "Open Data Commons Attribution License", 91 | "uri" => "http://opendefinition.org/licenses/odc-by/", 92 | ), 93 | "odc-odbl" => array( 94 | "label" => "Open Data Commons Open Database License (ODbL)", 95 | "uri" => "http://opendefinition.org/licenses/odc-odbl/", 96 | ), 97 | "odc-pddl" => array( 98 | "label" => "Open Data Commons Public Domain Dedication and Licence (PDDL)", 99 | "uri" => "http://opendefinition.org/licenses/odc-pddl/", 100 | ), 101 | "uk-ogl" => array( 102 | "label" => "UK Open Government Licence (OGL)", 103 | "url" => 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/2/' 104 | ), 105 | "other-at" => array( 106 | "label" => "Other (Attribution)" 107 | ), 108 | "other-nc" => array( 109 | "label" => "Other (Non-Commercial)" 110 | ), 111 | "other-closed" => array( 112 | "label" => "Other (Not Open)" 113 | ), 114 | "other-open" => array( 115 | "label" => "Other (Open)" 116 | ), 117 | "other-pd" => array( 118 | "label" => "Other (Public Domain)" 119 | ), 120 | "notspecified" => array( 121 | "label" => "License Not Specified", 122 | ), 123 | ); 124 | } -------------------------------------------------------------------------------- /modules/dkan_dataset_content_types/dkan_dataset_content_types.module: -------------------------------------------------------------------------------- 1 | t('- Select a value -')); 17 | $allowed_values = array_merge( 18 | $allowed_values, 19 | dkan_dataset_content_types_license_allowed_values() 20 | ); 21 | $form['field_license'][LANGUAGE_NONE]['#options'] = $allowed_values; 22 | 23 | // Hide fields. 24 | $form['field_modified_source_date']['#access'] = FALSE; 25 | $form['field_is_part_of']['#access'] = FALSE; 26 | $form['field_pod_theme']['#access'] = FALSE; 27 | 28 | $form['field_data_dictionary'][LANGUAGE_NONE]['#after_build'][] = 'data_dictionary_after_build'; 29 | } 30 | } 31 | /** 32 | * After build for data dictionary field. Removes format selector and guidelines. 33 | */ 34 | function data_dictionary_after_build(&$form) { 35 | unset($form[0]['format']); 36 | return $form; 37 | } 38 | /** 39 | * Implements hook_field_formatter_info(). 40 | */ 41 | function dkan_dataset_content_types_field_formatter_info() { 42 | return array( 43 | 'render_license' => array( 44 | 'label' => t('Render license as a link'), 45 | 'field types' => array('text'), 46 | ), 47 | ); 48 | } 49 | 50 | /** 51 | * Implements hook_field_formatter_view(). 52 | */ 53 | function dkan_dataset_content_types_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { 54 | $element = array(); 55 | switch ($display['type']) { 56 | case 'render_license': 57 | foreach ($items as $delta => $item) { 58 | $output = $item['value']; 59 | $subscribed_values = dkan_dataset_content_types_license_subscribed_values(); 60 | if (isset($subscribed_values[$output])) { 61 | $license = $subscribed_values[$output]; 62 | if (isset($license['uri'])) { 63 | $output = l($license['label'], $license['uri']); 64 | } 65 | else { 66 | $output = $license['label']; 67 | } 68 | } 69 | $element[$delta] = array('#markup' => $output); 70 | } 71 | break; 72 | } 73 | return $element; 74 | } 75 | 76 | /** 77 | * Implements hook_facet_items_alter(). 78 | */ 79 | function dkan_dataset_content_types_facet_items_alter(&$build, &$settings) { 80 | if ($settings->facet == 'field_license') { 81 | $allowed_values = dkan_dataset_content_types_license_allowed_values(); 82 | foreach ($build as $key => $item) { 83 | if (isset($allowed_values[$key])) { 84 | $build[$key]['#markup'] = $allowed_values[$key]; 85 | } 86 | } 87 | } 88 | } 89 | 90 | /** 91 | * Implements hook_open_data_schema_map_results_alter(). 92 | */ 93 | function dkan_dataset_content_types_open_data_schema_map_results_alter(&$result, $machine_name, $api_schema) { 94 | switch ($api_schema) { 95 | case 'pod_v1_1': 96 | $dataset_row = array(); 97 | foreach ($result as $key => $dataset) { 98 | dkan_dataset_content_types_alter_dataset_license($dataset, 'license'); 99 | $dataset_row[] = $dataset; 100 | unset($result[$key]); 101 | } 102 | $result = $dataset_row; 103 | break; 104 | case 'ckan_dataset': 105 | $dataset_row = array(); 106 | foreach ($result as $key => $dataset) { 107 | dkan_dataset_content_types_alter_dataset_license($dataset, 'license_title'); 108 | array_push($dataset_row, $dataset); 109 | unset($result[$key]); 110 | } 111 | $result[0] = $dataset_row; 112 | break; 113 | } 114 | } 115 | 116 | function dkan_dataset_content_types_alter_dataset_license(&$dataset, $key) { 117 | if (isset($dataset[$key])) { 118 | $subscribed_values = dkan_dataset_content_types_license_subscribed_values(); 119 | if (isset($subscribed_values[$dataset[$key]])) { 120 | $license = $subscribed_values[$dataset[$key]]; 121 | if (isset($license['uri'])) { 122 | $dataset[$key] = $license['uri']; 123 | } 124 | else { 125 | unset($dataset[$key]); 126 | } 127 | } 128 | else { 129 | unset($dataset[$key]); 130 | } 131 | } 132 | } 133 | 134 | /** 135 | * Add links to metadata fields. 136 | */ 137 | function dkan_dataset_content_types_preprocess_field(&$vars) { 138 | switch ($vars['element']['#field_name']) { 139 | case 'field_contact_email': 140 | $e = $vars['element']['#items'][0]['value']; 141 | $vars['items']['0']['#markup'] = '' . $e . ''; 142 | break; 143 | 144 | } 145 | return; 146 | 147 | } 148 | 149 | /** 150 | * Map of iso frequency ranges to field frequency allowed values. 151 | */ 152 | function dkan_dataset_content_types_iso_frecuency_map() { 153 | return array( 154 | 'R/P10Y' => 6, 155 | 'R/P4Y' => 7, 156 | 'R/P1Y' => 3, 157 | 'R/P2M' => 8, 158 | 'R/P0.5M' => 8, 159 | 'R/P3.5D' => 9, 160 | 'R/P1D' => 0, 161 | 'R/P2W' => 10, 162 | 'R/P0.5W' => 10, 163 | 'R/P6M' => 11, 164 | 'R/P2Y' => 12, 165 | 'R/P3Y' => 13, 166 | 'R/P0.33W' => 14, 167 | 'R/P0.33M' => 15, 168 | 'R/PT1S' => 4, 169 | 'R/P1M' => 2, 170 | 'R/P3M' => 16, 171 | 'R/P0.5M' => 18, 172 | 'R/P4M' => 17, 173 | 'R/P1W' => 1, 174 | ); 175 | } 176 | 177 | /** 178 | * Convert a frequency from iso to the field value representation. 179 | */ 180 | function dkan_dataset_content_types_iso2frequency($accrualPeriodicity) { 181 | $map = dkan_dataset_content_types_iso_frecuency_map(); 182 | return $map[$accrualPeriodicity]; 183 | } 184 | 185 | /** 186 | * Convert a frequency from a field value to the iso representation. 187 | */ 188 | function dkan_dataset_content_types_frequency2iso($frecuencyIndex) { 189 | $map = array_flip(dkan_dataset_content_types_iso_frecuency_map()); 190 | return $map[$accrualPeriodicity]; 191 | } 192 | 193 | /** 194 | * Implements allowed_values_function for field_language. 195 | */ 196 | function dkan_dataset_content_types_allowed_language_values() { 197 | module_load_include('php', 'dkan_dataset_content_types', 'includes/language_code_list'); 198 | return dkan_dataset_content_types_get_language_codes(); 199 | } 200 | -------------------------------------------------------------------------------- /modules/dkan_dataset_content_types/dkan_dataset_content_types.strongarm.inc: -------------------------------------------------------------------------------- 1 | disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 15 | $strongarm->api_version = 1; 16 | $strongarm->name = 'chosen_jquery_selector'; 17 | $strongarm->value = '.node-form select, .field-name-field-format select, .field-name-field-dataset-ref select'; 18 | $export['chosen_jquery_selector'] = $strongarm; 19 | 20 | $strongarm = new stdClass(); 21 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 22 | $strongarm->api_version = 1; 23 | $strongarm->name = 'chosen_minimum'; 24 | $strongarm->value = '0'; 25 | $export['chosen_minimum'] = $strongarm; 26 | 27 | $strongarm = new stdClass(); 28 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 29 | $strongarm->api_version = 1; 30 | $strongarm->name = 'chosen_minimum_multiple'; 31 | $strongarm->value = '0'; 32 | $export['chosen_minimum_multiple'] = $strongarm; 33 | 34 | $strongarm = new stdClass(); 35 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 36 | $strongarm->api_version = 1; 37 | $strongarm->name = 'chosen_minimum_single'; 38 | $strongarm->value = '0'; 39 | $export['chosen_minimum_single'] = $strongarm; 40 | 41 | $strongarm = new stdClass(); 42 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 43 | $strongarm->api_version = 1; 44 | $strongarm->name = 'field_bundle_settings_node__dataset'; 45 | $strongarm->value = array( 46 | 'view_modes' => array( 47 | 'teaser' => array( 48 | 'custom_settings' => TRUE, 49 | ), 50 | 'full' => array( 51 | 'custom_settings' => FALSE, 52 | ), 53 | 'rss' => array( 54 | 'custom_settings' => FALSE, 55 | ), 56 | 'print' => array( 57 | 'custom_settings' => FALSE, 58 | ), 59 | 'token' => array( 60 | 'custom_settings' => FALSE, 61 | ), 62 | 'search_index' => array( 63 | 'custom_settings' => FALSE, 64 | ), 65 | 'search_result' => array( 66 | 'custom_settings' => TRUE, 67 | ), 68 | 'diff_standard' => array( 69 | 'custom_settings' => FALSE, 70 | ), 71 | ), 72 | 'extra_fields' => array( 73 | 'form' => array( 74 | 'title' => array( 75 | 'weight' => '1', 76 | ), 77 | 'resources' => array( 78 | 'weight' => '6', 79 | ), 80 | 'path' => array( 81 | 'weight' => '7', 82 | ), 83 | 'release_date' => array( 84 | 'weight' => '5', 85 | ), 86 | 'modified_date' => array( 87 | 'weight' => '4', 88 | ), 89 | 'identifier' => array( 90 | 'weight' => '3', 91 | ), 92 | ), 93 | 'display' => array( 94 | 'resources' => array( 95 | 'default' => array( 96 | 'weight' => '2', 97 | 'visible' => TRUE, 98 | ), 99 | 'teaser' => array( 100 | 'weight' => '6', 101 | 'visible' => TRUE, 102 | ), 103 | 'search_result' => array( 104 | 'weight' => '1', 105 | 'visible' => TRUE, 106 | ), 107 | ), 108 | 'release_date' => array( 109 | 'default' => array( 110 | 'weight' => '7', 111 | 'visible' => TRUE, 112 | ), 113 | 'teaser' => array( 114 | 'weight' => '2', 115 | 'visible' => TRUE, 116 | ), 117 | 'search_result' => array( 118 | 'weight' => '7', 119 | 'visible' => TRUE, 120 | ), 121 | ), 122 | 'identifier' => array( 123 | 'default' => array( 124 | 'weight' => '9', 125 | 'visible' => TRUE, 126 | ), 127 | 'teaser' => array( 128 | 'weight' => '0', 129 | 'visible' => TRUE, 130 | ), 131 | 'search_result' => array( 132 | 'weight' => '9', 133 | 'visible' => TRUE, 134 | ), 135 | ), 136 | 'modified_date' => array( 137 | 'default' => array( 138 | 'weight' => '6', 139 | 'visible' => TRUE, 140 | ), 141 | 'teaser' => array( 142 | 'weight' => '1', 143 | 'visible' => TRUE, 144 | ), 145 | 'search_result' => array( 146 | 'weight' => '6', 147 | 'visible' => TRUE, 148 | ), 149 | ), 150 | ), 151 | ), 152 | ); 153 | $export['field_bundle_settings_node__dataset'] = $strongarm; 154 | 155 | $strongarm = new stdClass(); 156 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 157 | $strongarm->api_version = 1; 158 | $strongarm->name = 'field_bundle_settings_node__resource'; 159 | $strongarm->value = array( 160 | 'view_modes' => array( 161 | 'teaser' => array( 162 | 'custom_settings' => TRUE, 163 | ), 164 | 'full' => array( 165 | 'custom_settings' => FALSE, 166 | ), 167 | 'rss' => array( 168 | 'custom_settings' => FALSE, 169 | ), 170 | 'print' => array( 171 | 'custom_settings' => FALSE, 172 | ), 173 | 'diff_standard' => array( 174 | 'custom_settings' => FALSE, 175 | ), 176 | 'token' => array( 177 | 'custom_settings' => FALSE, 178 | ), 179 | ), 180 | 'extra_fields' => array( 181 | 'form' => array( 182 | 'title' => array( 183 | 'weight' => '3', 184 | ), 185 | 'feeds' => array( 186 | 'weight' => '0', 187 | ), 188 | 'path' => array( 189 | 'weight' => '9', 190 | ), 191 | ), 192 | 'display' => array(), 193 | ), 194 | ); 195 | $export['field_bundle_settings_node__resource'] = $strongarm; 196 | 197 | $strongarm = new stdClass(); 198 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 199 | $strongarm->api_version = 1; 200 | $strongarm->name = 'jquery_update_jquery_version'; 201 | $strongarm->value = '1.7'; 202 | $export['jquery_update_jquery_version'] = $strongarm; 203 | 204 | $strongarm = new stdClass(); 205 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 206 | $strongarm->api_version = 1; 207 | $strongarm->name = 'menu_options_dataset'; 208 | $strongarm->value = array(); 209 | $export['menu_options_dataset'] = $strongarm; 210 | 211 | $strongarm = new stdClass(); 212 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 213 | $strongarm->api_version = 1; 214 | $strongarm->name = 'menu_options_resource'; 215 | $strongarm->value = array(); 216 | $export['menu_options_resource'] = $strongarm; 217 | 218 | $strongarm = new stdClass(); 219 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 220 | $strongarm->api_version = 1; 221 | $strongarm->name = 'menu_parent_dataset'; 222 | $strongarm->value = 'main-menu:318'; 223 | $export['menu_parent_dataset'] = $strongarm; 224 | 225 | $strongarm = new stdClass(); 226 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 227 | $strongarm->api_version = 1; 228 | $strongarm->name = 'menu_parent_resource'; 229 | $strongarm->value = 'main-menu:0'; 230 | $export['menu_parent_resource'] = $strongarm; 231 | 232 | $strongarm = new stdClass(); 233 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 234 | $strongarm->api_version = 1; 235 | $strongarm->name = 'node_options_dataset'; 236 | $strongarm->value = array( 237 | 0 => 'status', 238 | 1 => 'revision', 239 | ); 240 | $export['node_options_dataset'] = $strongarm; 241 | 242 | $strongarm = new stdClass(); 243 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 244 | $strongarm->api_version = 1; 245 | $strongarm->name = 'node_options_resource'; 246 | $strongarm->value = array( 247 | 0 => 'status', 248 | 1 => 'revision', 249 | ); 250 | $export['node_options_resource'] = $strongarm; 251 | 252 | $strongarm = new stdClass(); 253 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 254 | $strongarm->api_version = 1; 255 | $strongarm->name = 'node_preview_dataset'; 256 | $strongarm->value = '0'; 257 | $export['node_preview_dataset'] = $strongarm; 258 | 259 | $strongarm = new stdClass(); 260 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 261 | $strongarm->api_version = 1; 262 | $strongarm->name = 'node_preview_resource'; 263 | $strongarm->value = '0'; 264 | $export['node_preview_resource'] = $strongarm; 265 | 266 | $strongarm = new stdClass(); 267 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 268 | $strongarm->api_version = 1; 269 | $strongarm->name = 'node_submitted_dataset'; 270 | $strongarm->value = 0; 271 | $export['node_submitted_dataset'] = $strongarm; 272 | 273 | $strongarm = new stdClass(); 274 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 275 | $strongarm->api_version = 1; 276 | $strongarm->name = 'node_submitted_resource'; 277 | $strongarm->value = 0; 278 | $export['node_submitted_resource'] = $strongarm; 279 | 280 | return $export; 281 | } 282 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/default_images/group.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetDKAN/dkan_dataset/75dffacfd5ca47862e4caa587991939a665ae8f2/modules/dkan_dataset_groups/default_images/group.png -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/dkan_dataset_groups.context.inc: -------------------------------------------------------------------------------- 1 | disabled = FALSE; /* Edit this to true to make a default context disabled initially */ 15 | $context->api_version = 3; 16 | $context->name = 'group_dataset'; 17 | $context->description = ''; 18 | $context->tag = 'Group'; 19 | $context->conditions = array( 20 | 'node' => array( 21 | 'values' => array( 22 | 'group' => 'group', 23 | ), 24 | 'options' => array( 25 | 'node_form' => '0', 26 | ), 27 | ), 28 | ); 29 | $context->reactions = array( 30 | 'block' => array( 31 | 'blocks' => array( 32 | 'views-group_block-block' => array( 33 | 'module' => 'views', 34 | 'delta' => 'group_block-block', 35 | 'region' => 'sidebar_first', 36 | 'weight' => '-10', 37 | ), 38 | 'facetapi-GZUUj6TgVjA9Nwt0HvjnjSO2uDxLxfy7' => array( 39 | 'module' => 'facetapi', 40 | 'delta' => 'GZUUj6TgVjA9Nwt0HvjnjSO2uDxLxfy7', 41 | 'region' => 'sidebar_first', 42 | 'weight' => '-9', 43 | ), 44 | 'facetapi-lzvCI5xSUC94irLWjBH4WoOTqXVxs8FR' => array( 45 | 'module' => 'facetapi', 46 | 'delta' => 'lzvCI5xSUC94irLWjBH4WoOTqXVxs8FR', 47 | 'region' => 'sidebar_first', 48 | 'weight' => '-8', 49 | ), 50 | 'facetapi-xNAidW9x2foW6UGpYpK8MzTaBT8ebK4D' => array( 51 | 'module' => 'facetapi', 52 | 'delta' => 'xNAidW9x2foW6UGpYpK8MzTaBT8ebK4D', 53 | 'region' => 'sidebar_first', 54 | 'weight' => '-7', 55 | ), 56 | 'facetapi-n9S7gglvd3lMrVMu760QrIyeZAKByKsX' => array( 57 | 'module' => 'facetapi', 58 | 'delta' => 'n9S7gglvd3lMrVMu760QrIyeZAKByKsX', 59 | 'region' => 'sidebar_first', 60 | 'weight' => '-6', 61 | ), 62 | ), 63 | ), 64 | ); 65 | $context->condition_mode = 0; 66 | 67 | // Translatables 68 | // Included for use with string extractors like potx. 69 | t('Group'); 70 | $export['group_dataset'] = $context; 71 | 72 | return $export; 73 | } 74 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/dkan_dataset_groups.features.field_base.inc: -------------------------------------------------------------------------------- 1 | 1, 16 | 'cardinality' => 1, 17 | 'deleted' => 0, 18 | 'entity_types' => array(), 19 | 'field_name' => 'field_image', 20 | 'indexes' => array( 21 | 'fid' => array( 22 | 0 => 'fid', 23 | ), 24 | ), 25 | 'locked' => 0, 26 | 'module' => 'image', 27 | 'settings' => array( 28 | 'default_image' => 0, 29 | 'uri_scheme' => 'public', 30 | ), 31 | 'translatable' => 0, 32 | 'type' => 'image', 33 | ); 34 | 35 | // Exported field_base: 'group_group'. 36 | $field_bases['group_group'] = array( 37 | 'active' => 1, 38 | 'cardinality' => 1, 39 | 'deleted' => 0, 40 | 'entity_types' => array(), 41 | 'field_name' => 'group_group', 42 | 'indexes' => array( 43 | 'value' => array( 44 | 0 => 'value', 45 | ), 46 | ), 47 | 'locked' => 0, 48 | 'module' => 'list', 49 | 'no_ui' => TRUE, 50 | 'settings' => array( 51 | 'allowed_values' => array( 52 | 0 => 'Not a group', 53 | 1 => 'Group', 54 | ), 55 | 'allowed_values_function' => '', 56 | ), 57 | 'translatable' => 0, 58 | 'type' => 'list_boolean', 59 | ); 60 | 61 | // Exported field_base: 'og_group_ref'. 62 | $field_bases['og_group_ref'] = array( 63 | 'active' => 1, 64 | 'cardinality' => -1, 65 | 'deleted' => 0, 66 | 'entity_types' => array(), 67 | 'field_name' => 'og_group_ref', 68 | 'indexes' => array( 69 | 'target_id' => array( 70 | 0 => 'target_id', 71 | ), 72 | ), 73 | 'locked' => 0, 74 | 'module' => 'entityreference', 75 | 'settings' => array( 76 | 'handler' => 'og', 77 | 'handler_settings' => array( 78 | 'behaviors' => array( 79 | 'og_behavior' => array( 80 | 'status' => TRUE, 81 | ), 82 | 'views-select-list' => array( 83 | 'status' => 0, 84 | ), 85 | ), 86 | 'membership_type' => 'og_membership_type_default', 87 | 'sort' => array( 88 | 'type' => 'none', 89 | ), 90 | 'target_bundles' => array( 91 | 'group' => 'group', 92 | ), 93 | ), 94 | 'handler_submit' => 'Change handler', 95 | 'sync' => '', 96 | 'target_type' => 'node', 97 | ), 98 | 'target_type' => 'node', 99 | 'translatable' => 0, 100 | 'type' => 'entityreference', 101 | ); 102 | 103 | return $field_bases; 104 | } 105 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/dkan_dataset_groups.features.field_instance.inc: -------------------------------------------------------------------------------- 1 | 'dataset', 16 | 'default_value' => NULL, 17 | 'deleted' => 0, 18 | 'description' => '', 19 | 'display' => array( 20 | 'default' => array( 21 | 'label' => 'hidden', 22 | 'module' => 'entityreference', 23 | 'settings' => array( 24 | 'link' => 1, 25 | ), 26 | 'type' => 'entityreference_label', 27 | 'weight' => 5, 28 | ), 29 | 'search_result' => array( 30 | 'label' => 'above', 31 | 'settings' => array(), 32 | 'type' => 'hidden', 33 | 'weight' => 0, 34 | ), 35 | 'teaser' => array( 36 | 'label' => 'above', 37 | 'settings' => array(), 38 | 'type' => 'hidden', 39 | 'weight' => 3, 40 | ), 41 | ), 42 | 'entity_type' => 'node', 43 | 'field_name' => 'og_group_ref', 44 | 'label' => 'Publisher', 45 | 'required' => 0, 46 | 'settings' => array( 47 | 'behaviors' => array( 48 | 'og_widget' => array( 49 | 'admin' => array( 50 | 'widget_type' => 'options_buttons', 51 | ), 52 | 'default' => array( 53 | 'widget_type' => 'options_select', 54 | ), 55 | 'status' => TRUE, 56 | ), 57 | ), 58 | 'user_register_form' => FALSE, 59 | ), 60 | 'view modes' => array( 61 | 'full' => array( 62 | 'custom settings' => FALSE, 63 | 'label' => 'Full', 64 | 'type' => 'og_list_default', 65 | ), 66 | 'teaser' => array( 67 | 'custom settings' => FALSE, 68 | 'label' => 'Teaser', 69 | 'type' => 'og_list_default', 70 | ), 71 | ), 72 | 'widget' => array( 73 | 'active' => 0, 74 | 'module' => 'options', 75 | 'settings' => array( 76 | 'apply_chosen' => '', 77 | ), 78 | 'type' => 'options_select', 79 | 'weight' => 3, 80 | ), 81 | ); 82 | 83 | // Exported field_instance: 'node-group-body'. 84 | $field_instances['node-group-body'] = array( 85 | 'bueditor_profile' => -1, 86 | 'bundle' => 'group', 87 | 'default_value' => NULL, 88 | 'deleted' => 0, 89 | 'description' => '', 90 | 'display' => array( 91 | 'default' => array( 92 | 'label' => 'hidden', 93 | 'settings' => array(), 94 | 'type' => 'hidden', 95 | 'weight' => 1, 96 | ), 97 | 'teaser' => array( 98 | 'label' => 'hidden', 99 | 'module' => 'text', 100 | 'settings' => array( 101 | 'trim_length' => 200, 102 | ), 103 | 'type' => 'text_summary_or_trimmed', 104 | 'weight' => 1, 105 | ), 106 | ), 107 | 'entity_type' => 'node', 108 | 'field_name' => 'body', 109 | 'label' => 'Description', 110 | 'required' => 0, 111 | 'settings' => array( 112 | 'display_summary' => 0, 113 | 'text_processing' => 1, 114 | 'user_register_form' => FALSE, 115 | ), 116 | 'widget' => array( 117 | 'active' => 1, 118 | 'module' => 'text', 119 | 'settings' => array( 120 | 'rows' => 20, 121 | 'summary_rows' => 5, 122 | ), 123 | 'type' => 'text_textarea_with_summary', 124 | 'weight' => 2, 125 | ), 126 | ); 127 | 128 | // Exported field_instance: 'node-group-field_image'. 129 | $field_instances['node-group-field_image'] = array( 130 | 'bundle' => 'group', 131 | 'deleted' => 0, 132 | 'description' => '', 133 | 'display' => array( 134 | 'default' => array( 135 | 'label' => 'hidden', 136 | 'settings' => array(), 137 | 'type' => 'hidden', 138 | 'weight' => 2, 139 | ), 140 | 'teaser' => array( 141 | 'label' => 'hidden', 142 | 'module' => 'image', 143 | 'settings' => array( 144 | 'image_link' => 'content', 145 | 'image_style' => 'group_medium', 146 | ), 147 | 'type' => 'image', 148 | 'weight' => 0, 149 | ), 150 | ), 151 | 'entity_type' => 'node', 152 | 'field_name' => 'field_image', 153 | 'label' => 'Image', 154 | 'required' => 0, 155 | 'settings' => array( 156 | 'alt_field' => 1, 157 | 'default_image' => 0, 158 | 'file_directory' => '', 159 | 'file_extensions' => 'png gif jpg jpeg', 160 | 'max_filesize' => '', 161 | 'max_resolution' => '', 162 | 'min_resolution' => '', 163 | 'resup' => 0, 164 | 'resup_autostart' => 0, 165 | 'resup_max_filesize' => '', 166 | 'title_field' => 0, 167 | 'user_register_form' => FALSE, 168 | ), 169 | 'widget' => array( 170 | 'active' => 1, 171 | 'module' => 'image', 172 | 'settings' => array( 173 | 'filefield_sources' => array( 174 | 'filefield_sources' => array( 175 | 'attach' => 0, 176 | 'clipboard' => 0, 177 | 'reference' => 0, 178 | 'remote' => 0, 179 | 'remotefile' => 0, 180 | 'upload' => 'upload', 181 | ), 182 | 'source_attach' => array( 183 | 'absolute' => 0, 184 | 'attach_mode' => 'move', 185 | 'path' => 'file_attach', 186 | ), 187 | 'source_imce' => array( 188 | 'imce_mode' => 0, 189 | ), 190 | 'source_reference' => array( 191 | 'autocomplete' => 0, 192 | 'search_all_fields' => 0, 193 | ), 194 | ), 195 | 'manualcrop_crop_info' => 1, 196 | 'manualcrop_default_crop_area' => 1, 197 | 'manualcrop_enable' => 0, 198 | 'manualcrop_inline_crop' => 0, 199 | 'manualcrop_instant_crop' => 0, 200 | 'manualcrop_instant_preview' => 1, 201 | 'manualcrop_keyboard' => 1, 202 | 'manualcrop_maximize_default_crop_area' => 0, 203 | 'manualcrop_require_cropping' => array(), 204 | 'manualcrop_styles_list' => array(), 205 | 'manualcrop_styles_mode' => 'include', 206 | 'manualcrop_thumblist' => 0, 207 | 'preview_image_style' => 'thumbnail', 208 | 'progress_indicator' => 'throbber', 209 | ), 210 | 'type' => 'image_image', 211 | 'weight' => 1, 212 | ), 213 | ); 214 | 215 | // Exported field_instance: 'node-group-group_group'. 216 | $field_instances['node-group-group_group'] = array( 217 | 'bundle' => 'group', 218 | 'default_value' => array( 219 | 0 => array( 220 | 'value' => 1, 221 | ), 222 | ), 223 | 'deleted' => 0, 224 | 'description' => 'Determine if this is an OG group.', 225 | 'display' => array( 226 | 'default' => array( 227 | 'label' => 'above', 228 | 'settings' => array(), 229 | 'type' => 'hidden', 230 | 'weight' => 3, 231 | ), 232 | 'teaser' => array( 233 | 'label' => 'above', 234 | 'settings' => array(), 235 | 'type' => 'hidden', 236 | 'weight' => 3, 237 | ), 238 | ), 239 | 'display_label' => 1, 240 | 'entity_type' => 'node', 241 | 'field_name' => 'group_group', 242 | 'label' => 'Group', 243 | 'required' => FALSE, 244 | 'settings' => array( 245 | 'user_register_form' => FALSE, 246 | ), 247 | 'view modes' => array( 248 | 'full' => array( 249 | 'custom settings' => FALSE, 250 | 'label' => 'Full', 251 | 'type' => 'og_group_subscribe', 252 | ), 253 | 'teaser' => array( 254 | 'custom settings' => FALSE, 255 | 'label' => 'Teaser', 256 | 'type' => 'og_group_subscribe', 257 | ), 258 | ), 259 | 'widget' => array( 260 | 'module' => 'options', 261 | 'settings' => array( 262 | 'display_label' => 0, 263 | ), 264 | 'type' => 'options_onoff', 265 | 'weight' => 4, 266 | ), 267 | ); 268 | 269 | // Translatables 270 | // Included for use with string extractors like potx. 271 | t('Description'); 272 | t('Determine if this is an OG group.'); 273 | t('Group'); 274 | t('Image'); 275 | t('Publisher'); 276 | 277 | return $field_instances; 278 | } 279 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/dkan_dataset_groups.features.inc: -------------------------------------------------------------------------------- 1 | "1"); 13 | } 14 | if ($module == "field_group" && $api == "field_group") { 15 | return array("version" => "1"); 16 | } 17 | if ($module == "strongarm" && $api == "strongarm") { 18 | return array("version" => "1"); 19 | } 20 | } 21 | 22 | /** 23 | * Implements hook_views_api(). 24 | */ 25 | function dkan_dataset_groups_views_api($module = NULL, $api = NULL) { 26 | return array("api" => "3.0"); 27 | } 28 | 29 | /** 30 | * Implements hook_image_default_styles(). 31 | */ 32 | function dkan_dataset_groups_image_default_styles() { 33 | $styles = array(); 34 | 35 | // Exported image style: group_medium. 36 | $styles['group_medium'] = array( 37 | 'label' => 'Group Medium', 38 | 'effects' => array( 39 | 2 => array( 40 | 'name' => 'image_scale', 41 | 'data' => array( 42 | 'width' => 200, 43 | 'height' => '', 44 | 'upscale' => 0, 45 | ), 46 | 'weight' => 2, 47 | ), 48 | 3 => array( 49 | 'name' => 'canvasactions_definecanvas', 50 | 'data' => array( 51 | 'RGB' => array( 52 | 'HEX' => '#ffffff', 53 | ), 54 | 'under' => 1, 55 | 'exact' => array( 56 | 'width' => 200, 57 | 'height' => 200, 58 | 'xpos' => 'center', 59 | 'ypos' => 'center', 60 | ), 61 | 'relative' => array( 62 | 'leftdiff' => '', 63 | 'rightdiff' => '', 64 | 'topdiff' => '', 65 | 'bottomdiff' => '', 66 | ), 67 | ), 68 | 'weight' => 2, 69 | ), 70 | 4 => array( 71 | 'name' => 'image_crop', 72 | 'data' => array( 73 | 'width' => 200, 74 | 'height' => 200, 75 | 'anchor' => 'center-center', 76 | ), 77 | 'weight' => 3, 78 | ), 79 | ), 80 | ); 81 | 82 | // Exported image style: group_thumbnail. 83 | $styles['group_thumbnail'] = array( 84 | 'label' => 'Group Thumbnail', 85 | 'effects' => array( 86 | 6 => array( 87 | 'name' => 'image_scale', 88 | 'data' => array( 89 | 'width' => 100, 90 | 'height' => '', 91 | 'upscale' => 0, 92 | ), 93 | 'weight' => 2, 94 | ), 95 | 7 => array( 96 | 'name' => 'canvasactions_definecanvas', 97 | 'data' => array( 98 | 'RGB' => array( 99 | 'HEX' => '#ffffff', 100 | ), 101 | 'under' => 1, 102 | 'exact' => array( 103 | 'width' => 100, 104 | 'height' => 100, 105 | 'xpos' => 'center', 106 | 'ypos' => 'center', 107 | ), 108 | 'relative' => array( 109 | 'leftdiff' => '', 110 | 'rightdiff' => '', 111 | 'topdiff' => '', 112 | 'bottomdiff' => '', 113 | ), 114 | ), 115 | 'weight' => 2, 116 | ), 117 | 8 => array( 118 | 'name' => 'image_crop', 119 | 'data' => array( 120 | 'width' => 100, 121 | 'height' => 100, 122 | 'anchor' => 'center-center', 123 | ), 124 | 'weight' => 3, 125 | ), 126 | ), 127 | ); 128 | 129 | return $styles; 130 | } 131 | 132 | /** 133 | * Implements hook_node_info(). 134 | */ 135 | function dkan_dataset_groups_node_info() { 136 | $items = array( 137 | 'group' => array( 138 | 'name' => t('Group'), 139 | 'base' => 'node_content', 140 | 'description' => t('Groups allow you to group together datasets under a organisation (for example, the Department of Health) or topic (e.g. Transport, Health) so make it easier for users to browse datasets by theme. 141 | 142 | Groups also enable you to assign roles and authorisation to members of the group - i.e. individuals can be given the right to publish datasets from a particular organisation.'), 143 | 'has_title' => '1', 144 | 'title_label' => t('Title'), 145 | 'help' => '', 146 | ), 147 | ); 148 | drupal_alter('node_info', $items); 149 | return $items; 150 | } 151 | 152 | /** 153 | * Implements hook_default_search_api_index(). 154 | */ 155 | function dkan_dataset_groups_default_search_api_index() { 156 | $items = array(); 157 | $items['groups_di'] = entity_import('search_api_index', '{ 158 | "name" : "Groups Dataset Index", 159 | "machine_name" : "groups_di", 160 | "description" : "An index for datasets in groups. Identical to the dataset index in the dkan_sitewide module.", 161 | "server" : "groups_server", 162 | "item_type" : "node", 163 | "options" : { 164 | "datasource" : { "bundles" : [ "dataset" ] }, 165 | "index_directly" : 1, 166 | "cron_limit" : "50", 167 | "fields" : { 168 | "author" : { "type" : "integer", "entity_type" : "user" }, 169 | "changed" : { "type" : "date" }, 170 | "field_resources:body:value" : { "type" : "list\\u003Ctext\\u003E" }, 171 | "field_resources:field_format" : { "type" : "list\\u003Cinteger\\u003E", "entity_type" : "taxonomy_term" }, 172 | "field_tags" : { "type" : "list\\u003Cinteger\\u003E", "entity_type" : "taxonomy_term" }, 173 | "og_group_ref" : { "type" : "list\\u003Cinteger\\u003E", "entity_type" : "node" }, 174 | "search_api_access_node" : { "type" : "list\\u003Cstring\\u003E" }, 175 | "search_api_language" : { "type" : "string" }, 176 | "search_api_viewed" : { "type" : "text" }, 177 | "status" : { "type" : "boolean" }, 178 | "title" : { "type" : "string" }, 179 | "type" : { "type" : "string" } 180 | }, 181 | "data_alter_callbacks" : { 182 | "search_api_alter_bundle_filter" : { 183 | "status" : 1, 184 | "weight" : "-10", 185 | "settings" : { "default" : "0", "bundles" : { "dataset" : "dataset" } } 186 | }, 187 | "search_api_alter_node_access" : { "status" : 1, "weight" : "0", "settings" : [] }, 188 | "search_api_alter_node_status" : { "status" : 0, "weight" : "0", "settings" : [] }, 189 | "search_api_alter_add_hierarchy" : { "status" : 0, "weight" : "0", "settings" : { "fields" : [] } }, 190 | "search_api_alter_add_viewed_entity" : { "status" : 1, "weight" : "0", "settings" : { "mode" : "full" } }, 191 | "search_api_alter_add_url" : { "status" : 0, "weight" : "0", "settings" : [] }, 192 | "search_api_alter_add_aggregation" : { "status" : 0, "weight" : "0", "settings" : [] } 193 | }, 194 | "processors" : { 195 | "search_api_case_ignore" : { "status" : 0, "weight" : "0", "settings" : { "fields" : [] } }, 196 | "search_api_html_filter" : { 197 | "status" : 0, 198 | "weight" : "10", 199 | "settings" : { 200 | "fields" : [], 201 | "title" : 0, 202 | "alt" : 1, 203 | "tags" : "h1 = 5\\r\\nh2 = 3\\r\\nh3 = 2\\r\\nstrong = 2\\r\\nb = 2\\r\\nem = 1.5\\r\\nu = 1.5" 204 | } 205 | }, 206 | "search_api_tokenizer" : { 207 | "status" : 0, 208 | "weight" : "20", 209 | "settings" : { "fields" : [], "spaces" : "[^[:alnum:]]", "ignorable" : "[\\u0027]" } 210 | }, 211 | "search_api_stopwords" : { 212 | "status" : 0, 213 | "weight" : "30", 214 | "settings" : { 215 | "fields" : [], 216 | "file" : "", 217 | "stopwords" : "but\\r\\ndid\\r\\nthe this that those\\r\\netc" 218 | } 219 | }, 220 | "search_api_highlighting" : { 221 | "status" : 0, 222 | "weight" : "35", 223 | "settings" : { 224 | "prefix" : "\\u003Cstrong\\u003E", 225 | "suffix" : "\\u003C\\/strong\\u003E", 226 | "excerpt" : 1, 227 | "excerpt_length" : "256", 228 | "highlight" : "always" 229 | } 230 | } 231 | } 232 | }, 233 | "enabled" : "1", 234 | "read_only" : "0" 235 | }'); 236 | return $items; 237 | } 238 | 239 | /** 240 | * Implements hook_default_search_api_server(). 241 | */ 242 | function dkan_dataset_groups_default_search_api_server() { 243 | $items = array(); 244 | $items['groups_server'] = entity_import('search_api_server', '{ 245 | "name" : "Groups Server", 246 | "machine_name" : "groups_server", 247 | "description" : "This is separate from the dataset server so it can be packaged with DKAN Dataset.", 248 | "class" : "search_api_db_service", 249 | "options" : { 250 | "database" : "default:default", 251 | "min_chars" : "1", 252 | "indexes" : { "groups_di" : { 253 | "type" : { 254 | "table" : "search_api_db_groups_di", 255 | "column" : "type", 256 | "type" : "string", 257 | "boost" : "1.0" 258 | }, 259 | "title" : { 260 | "table" : "search_api_db_groups_di", 261 | "column" : "title", 262 | "type" : "string", 263 | "boost" : "1.0" 264 | }, 265 | "status" : { 266 | "table" : "search_api_db_groups_di", 267 | "column" : "status", 268 | "type" : "boolean", 269 | "boost" : "1.0" 270 | }, 271 | "changed" : { 272 | "table" : "search_api_db_groups_di", 273 | "column" : "changed", 274 | "type" : "date", 275 | "boost" : "1.0" 276 | }, 277 | "author" : { 278 | "table" : "search_api_db_groups_di", 279 | "column" : "author", 280 | "type" : "integer", 281 | "boost" : "1.0" 282 | }, 283 | "search_api_language" : { 284 | "table" : "search_api_db_groups_di", 285 | "column" : "search_api_language", 286 | "type" : "string", 287 | "boost" : "1.0" 288 | }, 289 | "search_api_viewed" : { 290 | "table" : "search_api_db_groups_di_text", 291 | "type" : "text", 292 | "boost" : "1.0" 293 | }, 294 | "search_api_access_node" : { 295 | "table" : "search_api_db_groups_di_search_api_access_node", 296 | "column" : "value", 297 | "type" : "list\\u003Cstring\\u003E", 298 | "boost" : "1.0" 299 | }, 300 | "field_tags" : { 301 | "table" : "search_api_db_groups_di_field_tags", 302 | "column" : "value", 303 | "type" : "list\\u003Cinteger\\u003E", 304 | "boost" : "1.0" 305 | }, 306 | "field_resources:field_format" : { 307 | "table" : "search_api_db_groups_di_field_resources_field_format", 308 | "column" : "value", 309 | "type" : "list\\u003Cinteger\\u003E", 310 | "boost" : "1.0" 311 | }, 312 | "field_resources:body:value" : { 313 | "table" : "search_api_db_groups_di_text", 314 | "type" : "list\\u003Ctext\\u003E", 315 | "boost" : "1.0" 316 | }, 317 | "og_group_ref" : { 318 | "table" : "search_api_db_groups_di_og_group_ref", 319 | "column" : "value", 320 | "type" : "list\\u003Cinteger\\u003E", 321 | "boost" : "1.0" 322 | } 323 | } 324 | } 325 | }, 326 | "enabled" : "1" 327 | }'); 328 | return $items; 329 | } 330 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/dkan_dataset_groups.info: -------------------------------------------------------------------------------- 1 | name = DKAN Dataset Groups 2 | description = Custom elements for groups. 3 | core = 7.x 4 | package = DKAN 5 | version = 7.x-1.x-dev 6 | project = dkan_dataset_groups 7 | dependencies[] = ctools 8 | dependencies[] = dkan_dataset_content_types 9 | dependencies[] = draggableviews 10 | dependencies[] = entity 11 | dependencies[] = entityreference 12 | dependencies[] = facetapi 13 | dependencies[] = features 14 | dependencies[] = field_group 15 | dependencies[] = gravatar 16 | dependencies[] = image 17 | dependencies[] = imagecache_actions 18 | dependencies[] = imagecache_canvasactions 19 | dependencies[] = list 20 | dependencies[] = og 21 | dependencies[] = og_ui 22 | dependencies[] = options 23 | dependencies[] = search_api 24 | dependencies[] = search_api_db 25 | dependencies[] = search_api_views 26 | dependencies[] = strongarm 27 | dependencies[] = text 28 | dependencies[] = views 29 | dependencies[] = views_content 30 | dependencies[] = views_responsive_grid 31 | features[ctools][] = facetapi:facetapi_defaults:1 32 | features[ctools][] = field_group:field_group:1 33 | features[ctools][] = strongarm:strongarm:1 34 | features[ctools][] = views:views_default:3.0 35 | features[facetapi][] = search_api@groups_di::changed 36 | features[facetapi][] = search_api@groups_di:block:author 37 | features[facetapi][] = search_api@groups_di:block:changed 38 | features[facetapi][] = search_api@groups_di:block:field_license 39 | features[facetapi][] = search_api@groups_di:block:field_resources:body:value 40 | features[facetapi][] = search_api@groups_di:block:field_resources:field_format 41 | features[facetapi][] = search_api@groups_di:block:field_tags 42 | features[facetapi][] = search_api@groups_di:block:og_group_ref 43 | features[facetapi][] = search_api@groups_di:block:search_api_access_node 44 | features[facetapi][] = search_api@groups_di:block:search_api_language 45 | features[facetapi][] = search_api@groups_di:block:search_api_viewed 46 | features[facetapi][] = search_api@groups_di:block:status 47 | features[facetapi][] = search_api@groups_di:block:title 48 | features[facetapi][] = search_api@groups_di:block:type 49 | features[features_api][] = api:2 50 | features[field_base][] = field_image 51 | features[field_base][] = group_group 52 | features[field_base][] = og_group_ref 53 | features[field_instance][] = node-dataset-og_group_ref 54 | features[field_instance][] = node-group-body 55 | features[field_instance][] = node-group-field_image 56 | features[field_instance][] = node-group-group_group 57 | features[image][] = group_medium 58 | features[image][] = group_thumbnail 59 | features[node][] = group 60 | features[search_api_index][] = groups_di 61 | features[search_api_server][] = groups_server 62 | features[variable][] = field_bundle_settings_node__group 63 | features[variable][] = menu_options_group 64 | features[variable][] = menu_parent_group 65 | features[variable][] = node_options_group 66 | features[variable][] = node_preview_group 67 | features[variable][] = node_submitted_group 68 | features[variable][] = og_context_negotiation_group_context 69 | features[variable][] = og_context_providers_weight_group_context 70 | features[variable][] = pathauto_node_group_pattern 71 | features[views_view][] = dkan_group_search 72 | features[views_view][] = dkan_groups_featured 73 | features[views_view][] = dkan_og_extras_group_members 74 | features[views_view][] = front_page_group_grid 75 | features[views_view][] = front_page_group_list 76 | features[views_view][] = group_block 77 | features[views_view][] = groups_page 78 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/dkan_dataset_groups.install: -------------------------------------------------------------------------------- 1 | TRUE, 15 | ); 16 | variable_set('views_defaults', $views_disable); 17 | } 18 | 19 | /** 20 | * Implements hook_disable(). 21 | */ 22 | function dkan_dataset_groups_disable() { 23 | //Remove field groups from the index. 24 | features_revert(array('dkan_sitewide_search_db' => array('search_api_index', 'search_api_server'))); 25 | } 26 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/dkan_dataset_groups.module: -------------------------------------------------------------------------------- 1 | $item['title'])); 20 | $data['actions']['output'][] = array( 21 | '#theme' => 'menu_local_action', 22 | '#link' => $item, 23 | ); 24 | } 25 | } 26 | } 27 | 28 | /** 29 | * Get dataset that belongs to a group 30 | */ 31 | function dkan_dataset_groups_datasets($node) { 32 | $query = new EntityFieldQuery(); 33 | $query->entityCondition('entity_type', 'node') 34 | ->propertyCondition('status', 1) 35 | ->fieldCondition('og_group_ref', 'target_id', $node->nid) 36 | ->propertyCondition('type', 'dataset'); 37 | $result = $query->execute(); 38 | return isset($result['node']) ? $result['node'] : array(); 39 | } 40 | 41 | /** 42 | * Get group members 43 | */ 44 | function dkan_dataset_groups_node_members($node) { 45 | // Remove admin user from group 46 | return array_filter(og_get_group_members_properties($node, array(), 'members', 'node'), function($uid){ 47 | return $uid != 1; 48 | }); 49 | } 50 | 51 | /** 52 | * Implements hook_block_view_alter(). 53 | */ 54 | function dkan_dataset_groups_block_view_alter(&$data, $block) { 55 | if ($block->module == 'views' && $block->delta == 'group_block-block') { 56 | $node = menu_get_object(); 57 | if (isset($node->type) && $node->type == 'group') { 58 | global $user; 59 | $subscribe_link = dkan_dataset_groups_extras_subscribe('node', $node); 60 | // Give appropriate pending notice. 61 | if (og_is_member('node', $node->nid, 'user', $user, array(OG_STATE_PENDING))) { 62 | $subscribe_link = t('Your membership is pending approval.') . ' ' . l(t('Remove pending membership request'), 'group/node/' . $node->nid . '/unsubscribe'); 63 | } 64 | 65 | // Get the group from the context. 66 | $group = og_context(); 67 | 68 | $members = dkan_dataset_groups_node_members($node); 69 | 70 | $data['content']['#markup'] .= '
' . $subscribe_link . '
'; 71 | 72 | // Hide member count if group is empty. 73 | if (count($members)) { 74 | $data['content']['#markup'] .= '
Members (' . count($members) . ')
'; 75 | } 76 | 77 | } 78 | } 79 | } 80 | 81 | /** 82 | * Create a formatted 'Subscribe' link for this group. 83 | * @TODO 84 | * Replace with helper function if http://drupal.org/node/1568858 gets in. 85 | */ 86 | function dkan_dataset_groups_extras_subscribe($entity_type, $entity) { 87 | $display['type'] = 'og_group_subscribe'; 88 | $group_type = 'node'; 89 | $group = entity_load_single($group_type, $entity->nid); 90 | list(,, $group_bundle) = entity_extract_ids($group_type, $group); 91 | $display['settings']['field_name'] = og_get_best_group_audience_field($entity_type, $entity, $group_type, $group_bundle); 92 | $elements = og_ui_field_formatter_view($entity_type, $entity, NULL, NULL, NULL, array(), $display); 93 | return drupal_render($elements); 94 | } 95 | 96 | 97 | /** 98 | * Implements hook_default_search_api_index_alter(). 99 | * 100 | * Add og group ref when is enable dataset groups. In other case we don't need this field on the index. 101 | */ 102 | function dkan_dataset_groups_default_search_api_index_alter(array &$defaults) { 103 | foreach ($defaults as &$index) { 104 | if ($index->machine_name == 'datasets') { 105 | $index->options['fields']['og_group_ref'] = array('type' => 'list', 'entity_type' => 'node'); 106 | } 107 | } 108 | } 109 | 110 | /** 111 | * Implements hook_default_search_api_server_alter(). 112 | * 113 | * Add og group ref when is enable dataset groups. In other case we don't need this field on the index. 114 | */ 115 | function dkan_dataset_groups_default_search_api_server_alter(array &$defaults) { 116 | foreach ($defaults as &$server) { 117 | if ($server->machine_name == 'datasets') { 118 | $server->options['indexes']['datasets']['og_group_ref'] = array('boost' => '1.0', 'column' => 'value', 'table' => 'search_api_db_datasets_og_group_ref_2', 'type' => 'list'); 119 | } 120 | } 121 | } 122 | 123 | /** 124 | * Implements hook_og_context_negotiation_info(). 125 | */ 126 | function dkan_dataset_groups_og_context_negotiation_info() { 127 | $providers = array(); 128 | 129 | $providers['dataset_members_page'] = array( 130 | 'name' => t('Members page for datasets'), 131 | 'description' => t('Determine context from the path.'), 132 | 'callback' => 'dkan_dataset_groups_context_callback', 133 | 'menu path' => array('node/%/members'), 134 | ); 135 | 136 | return $providers; 137 | } 138 | 139 | /** 140 | * Group context callback. Helps determine the group context. 141 | */ 142 | function dkan_dataset_groups_context_callback() { 143 | $context = array(); 144 | 145 | // We are at node/%/members 146 | $node = node_load(arg(1)); 147 | 148 | if ($node->type == 'group') { 149 | //Is a node group then use it. 150 | $group_node = $node; 151 | } 152 | else { 153 | $group_node = node_load($node->og_group_ref[LANGUAGE_NONE][0]['target_id']); 154 | } 155 | 156 | if (!og_is_group('node', $group_node)) { 157 | return; 158 | } 159 | 160 | $context['node'][] = $group_node->nid; 161 | 162 | return $context; 163 | } 164 | 165 | /** 166 | * Implements hook_views_post_build(). 167 | */ 168 | function dkan_dataset_groups_views_post_build(&$view) { 169 | if ($view->name == 'dkan_og_extras_group_members' && $view->current_display == 'page') { 170 | $group = node_load($view->args[0]); 171 | $view->build_info['title'] = t('!group Members', array('!group' => $group->title)); 172 | $view->build_info['breadcrumb'] = array(); 173 | } 174 | } 175 | 176 | /** 177 | * Implements hook_menu_breadcrumb_alter(). 178 | */ 179 | function dkan_dataset_groups_menu_breadcrumb_alter(&$active_trail, $item) { 180 | if($item['path'] === 'node/%/members') { 181 | 182 | // We need to add the groups link to keep navigation consistent. 183 | $groups_link = array( 184 | 'title' => 'Groups', 185 | 'href' => 'groups', 186 | 'link_path' => '', 187 | 'localized_options' => array(), 188 | 'type' => 0, 189 | ); 190 | 191 | // Since no array_insert function is present in PHP 192 | // and array_splice doesn't accept an array as argument 193 | // then we need to handle this manually. 194 | $part1 = array_slice($active_trail, 0, 1, true); 195 | $part2 = array_slice($active_trail, 1, null, true); 196 | $active_trail = array_merge($part1, array( 1 => $groups_link), $part2); 197 | } 198 | } 199 | 200 | /** 201 | * Implements hook_node_update(). 202 | */ 203 | function dkan_dataset_groups_node_update($node) { 204 | path_breadcrumbs_object_cache_clear("group"); 205 | cache_clear_all('*', PATH_BREADCRUMBS_CACHE_STORAGE, TRUE); 206 | } 207 | 208 | /** 209 | * Implements hook_form_alter(). 210 | */ 211 | function dkan_dataset_groups_form_alter(&$form, $form_state, $form_id) { 212 | switch ($form_id) { 213 | case 'views_exposed_form': 214 | // Fixes pager bug. 215 | if (isset($form['sort_order']) && isset($form['sort_by']['#options']['changed'])) { 216 | $sort_by = 'changed'; 217 | if(isset($_GET['sort_by'])){ 218 | $sort_by = $_GET['sort_by']; 219 | } 220 | else { 221 | $_GET['sort_by'] = $sort_by; 222 | } 223 | $form_state['view']->set_exposed_input($_GET); 224 | $form_state['input']['sort_by'] = $sort_by; 225 | 226 | $form['sort_order']['#options']['ASC'] = t('Ascending'); 227 | $form['sort_order']['#options']['DESC'] = t('Descending'); 228 | } 229 | break; 230 | } 231 | } 232 | 233 | /** 234 | * Implements hook_node_presave 235 | * Add a default group image if the group image field is empty. 236 | */ 237 | function dkan_dataset_groups_node_presave($node) { 238 | if(is_object($node) && $node->type == "group") { 239 | $wrap = entity_metadata_wrapper('node', $node); 240 | $fid = $wrap->field_image->value(); 241 | if(!isset($fid)) { 242 | $source = drupal_get_path('module', 'dkan_dataset_groups') . '/default_images/group.png'; 243 | if (file_exists($source)) { 244 | $file = new stdClass; 245 | $file->filename = 'group.png'; 246 | $file->timestamp = REQUEST_TIME; 247 | $file->uri = $source; 248 | $file->filemime = file_get_mimetype($source); 249 | $file->uid = 1; 250 | $file->status = 1; 251 | $file = file_copy($file, 'public://', FILE_EXISTS_REPLACE); 252 | $fid = $file->fid; 253 | 254 | // Set group image fid. 255 | $node->field_image[$node->language][0]['fid'] = (string) $fid; 256 | $node->field_image[$node->language][0]['alt'] = t('Default group image'); 257 | } 258 | } 259 | } 260 | } 261 | 262 | /** 263 | * Implements hook_node_validate(). 264 | * 265 | * Check if we have some group with same title. 266 | */ 267 | function dkan_dataset_groups_node_validate($node, $form, &$form_state) { 268 | if ($node->type == 'group') { 269 | $nid = isset($node->nid) ? $node->nid : 0; 270 | $duplicate = db_query("SELECT nid FROM {node} WHERE LOWER(title)=LOWER(:title) AND nid != :nid AND type='group'", array(':title' => $node->title, ':nid' => $nid))->fetchField(); 271 | 272 | if ($duplicate) { 273 | form_set_error('title', t('A group with title %title exists on the site. Please use another title.', array('%title' => $node->title))); 274 | } 275 | } 276 | } 277 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/dkan_dataset_groups.strongarm.inc: -------------------------------------------------------------------------------- 1 | disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 15 | $strongarm->api_version = 1; 16 | $strongarm->name = 'field_bundle_settings_node__group'; 17 | $strongarm->value = array( 18 | 'view_modes' => array( 19 | 'teaser' => array( 20 | 'custom_settings' => TRUE, 21 | ), 22 | 'full' => array( 23 | 'custom_settings' => FALSE, 24 | ), 25 | 'rss' => array( 26 | 'custom_settings' => FALSE, 27 | ), 28 | 'print' => array( 29 | 'custom_settings' => FALSE, 30 | ), 31 | 'token' => array( 32 | 'custom_settings' => FALSE, 33 | ), 34 | 'search_index' => array( 35 | 'custom_settings' => FALSE, 36 | ), 37 | 'search_result' => array( 38 | 'custom_settings' => FALSE, 39 | ), 40 | 'diff_standard' => array( 41 | 'custom_settings' => FALSE, 42 | ), 43 | ), 44 | 'extra_fields' => array( 45 | 'form' => array( 46 | 'title' => array( 47 | 'weight' => '0', 48 | ), 49 | 'path' => array( 50 | 'weight' => '5', 51 | ), 52 | ), 53 | 'display' => array(), 54 | ), 55 | ); 56 | $export['field_bundle_settings_node__group'] = $strongarm; 57 | 58 | $strongarm = new stdClass(); 59 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 60 | $strongarm->api_version = 1; 61 | $strongarm->name = 'menu_options_group'; 62 | $strongarm->value = array(); 63 | $export['menu_options_group'] = $strongarm; 64 | 65 | $strongarm = new stdClass(); 66 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 67 | $strongarm->api_version = 1; 68 | $strongarm->name = 'menu_parent_group'; 69 | $strongarm->value = 'main-menu:0'; 70 | $export['menu_parent_group'] = $strongarm; 71 | 72 | $strongarm = new stdClass(); 73 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 74 | $strongarm->api_version = 1; 75 | $strongarm->name = 'node_options_group'; 76 | $strongarm->value = array( 77 | 0 => 'status', 78 | 1 => 'revision', 79 | ); 80 | $export['node_options_group'] = $strongarm; 81 | 82 | $strongarm = new stdClass(); 83 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 84 | $strongarm->api_version = 1; 85 | $strongarm->name = 'node_preview_group'; 86 | $strongarm->value = '0'; 87 | $export['node_preview_group'] = $strongarm; 88 | 89 | $strongarm = new stdClass(); 90 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 91 | $strongarm->api_version = 1; 92 | $strongarm->name = 'node_submitted_group'; 93 | $strongarm->value = 0; 94 | $export['node_submitted_group'] = $strongarm; 95 | 96 | $strongarm = new stdClass(); 97 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 98 | $strongarm->api_version = 1; 99 | $strongarm->name = 'og_context_negotiation_group_context'; 100 | $strongarm->value = array( 101 | 'url' => array(), 102 | 'node' => array(), 103 | 'dataset_members_page' => array(), 104 | ); 105 | $export['og_context_negotiation_group_context'] = $strongarm; 106 | 107 | $strongarm = new stdClass(); 108 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 109 | $strongarm->api_version = 1; 110 | $strongarm->name = 'og_context_providers_weight_group_context'; 111 | $strongarm->value = array( 112 | 'url' => '-5', 113 | 'node' => '-4', 114 | 'comment' => '0', 115 | 'og_extras' => '0', 116 | 'user-view' => '0', 117 | 'dataset_members_page' => '0', 118 | 'user-edit' => '0', 119 | ); 120 | $export['og_context_providers_weight_group_context'] = $strongarm; 121 | 122 | $strongarm = new stdClass(); 123 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 124 | $strongarm->api_version = 1; 125 | $strongarm->name = 'pathauto_node_group_pattern'; 126 | $strongarm->value = 'group/[node:title]'; 127 | $export['pathauto_node_group_pattern'] = $strongarm; 128 | 129 | return $export; 130 | } 131 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/modules/dkan_dataset_groups_perms/dkan_dataset_groups_perms.features.inc: -------------------------------------------------------------------------------- 1 | array( 16 | 'administrator member' => 'administrator member', 17 | 'member' => 'member', 18 | ), 19 | ); 20 | 21 | // Exported og permission: 'node:group:access authoring options of resource content' 22 | $permissions['node:group:access authoring options of resource content'] = array( 23 | 'roles' => array( 24 | 'administrator member' => 'administrator member', 25 | 'member' => 'member', 26 | ), 27 | ); 28 | 29 | // Exported og permission: 'node:group:access publishing options of dataset content' 30 | $permissions['node:group:access publishing options of dataset content'] = array( 31 | 'roles' => array( 32 | 'administrator member' => 'administrator member', 33 | 'member' => 'member', 34 | ), 35 | ); 36 | 37 | // Exported og permission: 'node:group:access publishing options of resource content' 38 | $permissions['node:group:access publishing options of resource content'] = array( 39 | 'roles' => array( 40 | 'administrator member' => 'administrator member', 41 | 'member' => 'member', 42 | ), 43 | ); 44 | 45 | // Exported og permission: 'node:group:access revisions options of dataset content' 46 | $permissions['node:group:access revisions options of dataset content'] = array( 47 | 'roles' => array( 48 | 'administrator member' => 'administrator member', 49 | 'member' => 'member', 50 | ), 51 | ); 52 | 53 | // Exported og permission: 'node:group:access revisions options of resource content' 54 | $permissions['node:group:access revisions options of resource content'] = array( 55 | 'roles' => array( 56 | 'administrator member' => 'administrator member', 57 | 'member' => 'member', 58 | ), 59 | ); 60 | 61 | // Exported og permission: 'node:group:add user' 62 | $permissions['node:group:add user'] = array( 63 | 'roles' => array( 64 | 'administrator member' => 'administrator member', 65 | ), 66 | ); 67 | 68 | // Exported og permission: 'node:group:administer group' 69 | $permissions['node:group:administer group'] = array( 70 | 'roles' => array( 71 | 'administrator member' => 'administrator member', 72 | ), 73 | ); 74 | 75 | // Exported og permission: 'node:group:approve and deny subscription' 76 | $permissions['node:group:approve and deny subscription'] = array( 77 | 'roles' => array( 78 | 'administrator member' => 'administrator member', 79 | ), 80 | ); 81 | 82 | // Exported og permission: 'node:group:create dataset content' 83 | $permissions['node:group:create dataset content'] = array( 84 | 'roles' => array( 85 | 'administrator member' => 'administrator member', 86 | 'member' => 'member', 87 | ), 88 | ); 89 | 90 | // Exported og permission: 'node:group:create resource content' 91 | $permissions['node:group:create resource content'] = array( 92 | 'roles' => array( 93 | 'administrator member' => 'administrator member', 94 | 'member' => 'member', 95 | ), 96 | ); 97 | 98 | // Exported og permission: 'node:group:delete any dataset content' 99 | $permissions['node:group:delete any dataset content'] = array( 100 | 'roles' => array( 101 | 'administrator member' => 'administrator member', 102 | ), 103 | ); 104 | 105 | // Exported og permission: 'node:group:delete any resource content' 106 | $permissions['node:group:delete any resource content'] = array( 107 | 'roles' => array( 108 | 'administrator member' => 'administrator member', 109 | ), 110 | ); 111 | 112 | // Exported og permission: 'node:group:delete own dataset content' 113 | $permissions['node:group:delete own dataset content'] = array( 114 | 'roles' => array( 115 | 'administrator member' => 'administrator member', 116 | 'member' => 'member', 117 | ), 118 | ); 119 | 120 | // Exported og permission: 'node:group:delete own resource content' 121 | $permissions['node:group:delete own resource content'] = array( 122 | 'roles' => array( 123 | 'administrator member' => 'administrator member', 124 | 'member' => 'member', 125 | ), 126 | ); 127 | 128 | // Exported og permission: 'node:group:manage members' 129 | $permissions['node:group:manage members'] = array( 130 | 'roles' => array( 131 | 'administrator member' => 'administrator member', 132 | ), 133 | ); 134 | 135 | // Exported og permission: 'node:group:manage permissions' 136 | $permissions['node:group:manage permissions'] = array( 137 | 'roles' => array( 138 | 'administrator member' => 'administrator member', 139 | ), 140 | ); 141 | 142 | // Exported og permission: 'node:group:manage roles' 143 | $permissions['node:group:manage roles'] = array( 144 | 'roles' => array( 145 | 'administrator member' => 'administrator member', 146 | ), 147 | ); 148 | 149 | // Exported og permission: 'node:group:subscribe' 150 | $permissions['node:group:subscribe'] = array( 151 | 'roles' => array( 152 | 'non-member' => 'non-member', 153 | ), 154 | ); 155 | 156 | // Exported og permission: 'node:group:subscribe without approval' 157 | $permissions['node:group:subscribe without approval'] = array( 158 | 'roles' => array(), 159 | ); 160 | 161 | // Exported og permission: 'node:group:unsubscribe' 162 | $permissions['node:group:unsubscribe'] = array( 163 | 'roles' => array( 164 | 'administrator member' => 'administrator member', 165 | 'member' => 'member', 166 | ), 167 | ); 168 | 169 | // Exported og permission: 'node:group:update any dataset content' 170 | $permissions['node:group:update any dataset content'] = array( 171 | 'roles' => array( 172 | 'administrator member' => 'administrator member', 173 | ), 174 | ); 175 | 176 | // Exported og permission: 'node:group:update any resource content' 177 | $permissions['node:group:update any resource content'] = array( 178 | 'roles' => array( 179 | 'administrator member' => 'administrator member', 180 | ), 181 | ); 182 | 183 | // Exported og permission: 'node:group:update group' 184 | $permissions['node:group:update group'] = array( 185 | 'roles' => array( 186 | 'administrator member' => 'administrator member', 187 | ), 188 | ); 189 | 190 | // Exported og permission: 'node:group:update own dataset content' 191 | $permissions['node:group:update own dataset content'] = array( 192 | 'roles' => array( 193 | 'administrator member' => 'administrator member', 194 | 'member' => 'member', 195 | ), 196 | ); 197 | 198 | // Exported og permission: 'node:group:update own resource content' 199 | $permissions['node:group:update own resource content'] = array( 200 | 'roles' => array( 201 | 'administrator member' => 'administrator member', 202 | 'member' => 'member', 203 | ), 204 | ); 205 | 206 | // Exported og permission: 'node:group:view any unpublished dataset content' 207 | $permissions['node:group:view any unpublished dataset content'] = array( 208 | 'roles' => array( 209 | 'administrator member' => 'administrator member', 210 | 'member' => 'member', 211 | ), 212 | ); 213 | 214 | // Exported og permission: 'node:group:view any unpublished resource content' 215 | $permissions['node:group:view any unpublished resource content'] = array( 216 | 'roles' => array( 217 | 'administrator member' => 'administrator member', 218 | 'member' => 'member', 219 | ), 220 | ); 221 | 222 | return $permissions; 223 | } 224 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/modules/dkan_dataset_groups_perms/dkan_dataset_groups_perms.info: -------------------------------------------------------------------------------- 1 | name = DKAN Dataset Groups Permissions 2 | description = Defines permissions for groups. 3 | core = 7.x 4 | package = DKAN Deprecated 5 | project = dkan 6 | dependencies[] = dkan_dataset_groups 7 | features[features_api][] = api:2 8 | features[og_features_permission][] = node:group:access authoring options of dataset content 9 | features[og_features_permission][] = node:group:access authoring options of resource content 10 | features[og_features_permission][] = node:group:access publishing options of dataset content 11 | features[og_features_permission][] = node:group:access publishing options of resource content 12 | features[og_features_permission][] = node:group:access revisions options of dataset content 13 | features[og_features_permission][] = node:group:access revisions options of resource content 14 | features[og_features_permission][] = node:group:add user 15 | features[og_features_permission][] = node:group:administer group 16 | features[og_features_permission][] = node:group:approve and deny subscription 17 | features[og_features_permission][] = node:group:create dataset content 18 | features[og_features_permission][] = node:group:create resource content 19 | features[og_features_permission][] = node:group:delete any dataset content 20 | features[og_features_permission][] = node:group:delete any resource content 21 | features[og_features_permission][] = node:group:delete own dataset content 22 | features[og_features_permission][] = node:group:delete own resource content 23 | features[og_features_permission][] = node:group:manage members 24 | features[og_features_permission][] = node:group:manage permissions 25 | features[og_features_permission][] = node:group:manage roles 26 | features[og_features_permission][] = node:group:subscribe 27 | features[og_features_permission][] = node:group:subscribe without approval 28 | features[og_features_permission][] = node:group:unsubscribe 29 | features[og_features_permission][] = node:group:update any dataset content 30 | features[og_features_permission][] = node:group:update any resource content 31 | features[og_features_permission][] = node:group:update group 32 | features[og_features_permission][] = node:group:update own dataset content 33 | features[og_features_permission][] = node:group:update own resource content 34 | features[og_features_permission][] = node:group:view any unpublished dataset content 35 | features[og_features_permission][] = node:group:view any unpublished resource content 36 | -------------------------------------------------------------------------------- /modules/dkan_dataset_groups/modules/dkan_dataset_groups_perms/dkan_dataset_groups_perms.module: -------------------------------------------------------------------------------- 1 | Services module to create CRUD endpoint at ``api/dataset/node``. By default, this endpoint provides full CRUD access to a website's content nodes, and limited access to users (to allow authentication). The endpoint can be customized at ``/admin/structure/services/list/dkan_dataset_api/resources``. 4 | 5 | ### Documentation 6 | The DKAN Dataset API module is only a light wrapper around the Services module, which has extensive documentation. Here are some entries of interest: 7 | 8 | * Testing Resources 9 | * Identifying field names 10 | * Using REST Server with 2-Legged OAuth Authentication (Example with Java Servlet) 11 | * Services CSRF Token with FireFox Poster 12 | 13 | The Sessions module also [has a thriving community on the Drupal Stack Exchange](http://drupal.stackexchange.com/questions/tagged/services). 14 | 15 | ### Server Types 16 | DKAN Dataset REST API comes with a REST Server. Other server types are also incldued in the Services module but not turned on. Those include: 17 | 18 | * OAUTH 19 | * XML-RPC 20 | 21 | ### Repsonse Formats 22 | 23 | * bencode 24 | * json 25 | * jsonp 26 | * php 27 | * xml 28 | * yaml 29 | 30 | ### Request Parser Types 31 | * application/json 32 | * application/vnd.php.serialized 33 | * application/x-www-form-urlencoded 34 | * application/x-yaml 35 | * application/xml 36 | * multipart/form-data 37 | * text/xml 38 | 39 | ### Authentication Modes 40 | 41 | #### Session Authentication 42 | Session authentication is enabled by default. With session authentication an inital request is made to the user login to requet a session cookie. That session cookie is then stored locally and sent with a request in the X-CSRF-Token header to authenticate the request. 43 | 44 | #### Token Authentication 45 | Token authenticaion is not currently available out of the box. However, it can be enabled by adding the Services Token Access module to your site. This is less secure but is easier for community members to use, and may be added to the DKAN distribution in a future release. 46 | 47 | #### Authentication Permissions 48 | The permissions with which a user is granted depend on the user role. User roles and permissions are easily configured in the user administration screen at ``admin/people``, and DKAN comes with a number of pre-configured default roles via the [DKAN Permissions](https://github.com/NuCivic/dkan/tree/7.x-1.x/modules/dkan/dkan_permissions) module. 49 | 50 | ### Examples 51 | 52 | Below you can find examples in PHP for the most common use cases, using session authentication. 53 | 54 | For an example of a fully-functional python-based client to the DKAN REST API, see the [pydkan](https://github.com/NuCivic/pydkan) project. 55 | 56 | #### How to Log In and get the Session Cookie 57 | 58 | ``` 59 | // Setup request URL. 60 | $request_url = 'http://example.com/api/dataset/user/login'; 61 | 62 | // Prepare user data. 63 | $user_data = array( 64 | 'username' => 'theusername', 65 | 'password' => 'theuserpassword', 66 | ); 67 | $user_data = http_build_query($user_data); 68 | 69 | // Setup request. 70 | $curl = curl_init($request_url); 71 | curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json')); // Accept JSON response. 72 | curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST. 73 | curl_setopt($curl, CURLOPT_POSTFIELDS, $user_data); // Set POST data. 74 | curl_setopt($curl, CURLOPT_HEADER, FALSE); 75 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 76 | curl_setopt($curl, CURLOPT_FAILONERROR, TRUE); 77 | 78 | // Execute request and get response. 79 | $response = curl_exec($curl); 80 | 81 | // Process response. 82 | $logged_user = json_decode($response); 83 | 84 | // Save cookie session to be used on future requests. 85 | $cookie_session = $logged_user->session_name . '=' . $logged_user->sessid; 86 | ``` 87 | 88 | #### How to get the CSRF Token 89 | 90 | ``` 91 | // Setup request URL. 92 | $request_url = 'http://example.com/services/session/token'; 93 | 94 | // Setup request. 95 | $curl = curl_init($request_url); 96 | curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json')); // Accept JSON response. 97 | curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST. 98 | curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); // Send the cookie session that we got after login. 99 | curl_setopt($curl, CURLOPT_HEADER, FALSE); 100 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 101 | curl_setopt($curl, CURLOPT_FAILONERROR, TRUE); 102 | 103 | // Execute request and save CSRF Token. 104 | $csrf_token = curl_exec($curl); 105 | ``` 106 | 107 | #### How to create a Resource 108 | 109 | ``` 110 | // Setup request URL. 111 | $request_url = 'http://example.com/api/dataset/node'; 112 | 113 | // Setup resource data. 114 | // A great explanation on how to target each node field can be found on the 'Identifying field names' article linked on the 'Documentation' section. 115 | $resource_data = array( 116 | 'type' => 'resource', 117 | 'title' => 'Example resource', 118 | 'status' => 1, 119 | 'body[und][0][value]' => 'The description' 120 | ); 121 | $resource_data = http_build_query($resource_data); 122 | 123 | // Setup request. 124 | $curl = curl_init($request_url); 125 | curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-CSRF-Token: ' . $csrf_token)); 126 | curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST. 127 | curl_setopt($curl, CURLOPT_POSTFIELDS, $resource_data); // Set POST data. 128 | curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); 129 | curl_setopt($curl, CURLOPT_HEADER, FALSE); 130 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 131 | curl_setopt($curl, CURLOPT_FAILONERROR, TRUE); 132 | 133 | // Execute request and get response. 134 | $response = curl_exec($curl); 135 | ``` 136 | 137 | #### How to attach a file to a resource 138 | 139 | ``` 140 | // Setup request URL. 141 | $request_url = 'http://example.com/api/dataset/node/' . $resource_id . '/attach_file'; 142 | 143 | // Setup file data. 144 | $file_data = array( 145 | 'files[1]' => curl_file_create($file), 146 | 'field_name' => 'field_upload', 147 | 'attach' => 1 148 | ); 149 | 150 | // Setup request. 151 | $curl = curl_init($request_url); 152 | curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data','Accept: application/json', 'X-CSRF-Token: ' . $csrf_token)); 153 | curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST. 154 | curl_setopt($curl, CURLOPT_POSTFIELDS, $file_data); // Set POST data. 155 | curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); 156 | curl_setopt($curl, CURLOPT_HEADER, FALSE); 157 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 158 | curl_setopt($curl, CURLOPT_FAILONERROR, TRUE); 159 | 160 | // Execute request and get response. 161 | $response = curl_exec($curl); 162 | ``` 163 | 164 | #### How to create a Dataset 165 | 166 | ``` 167 | // Setup request URL. 168 | $request_url = 'http://example.com/api/dataset/node'; 169 | 170 | // Setup dataset data. 171 | // A great explanation on how to target each node field can be found on the 'Identifying field names' article linked on the 'Documentation' section. 172 | $dataset_data = array( 173 | 'type' => 'dataset', 174 | 'title' => 'Example dataset', 175 | 'status' => 1, 176 | 'body[und][0][value]' => 'The description', 177 | 'field_resources[und][0][target_id]' => 'Madison Polling Places (5)' // Resource title plus node id 178 | 'field_author[und][0][value]' => 'Bob Lafollette' 179 | ); 180 | $dataset_data = http_build_query($dataset_data); 181 | 182 | // Setup request. 183 | $curl = curl_init($request_url); 184 | curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-CSRF-Token: ' . $csrf_token)); 185 | curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST. 186 | curl_setopt($curl, CURLOPT_POSTFIELDS, $dataset_data); // Set POST data. 187 | curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); 188 | curl_setopt($curl, CURLOPT_HEADER, FALSE); 189 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); 190 | curl_setopt($curl, CURLOPT_FAILONERROR, TRUE); 191 | 192 | // Execute request and get response. 193 | $response = curl_exec($curl); 194 | ``` 195 | -------------------------------------------------------------------------------- /modules/dkan_dataset_rest_api/dkan_dataset_rest_api.features.inc: -------------------------------------------------------------------------------- 1 | "3"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /modules/dkan_dataset_rest_api/dkan_dataset_rest_api.info: -------------------------------------------------------------------------------- 1 | name = DKAN Dataset REST API 2 | core = 7.x 3 | package = DKAN 4 | dependencies[] = ctools 5 | dependencies[] = dkan_dataset 6 | dependencies[] = rest_server 7 | dependencies[] = services 8 | features[ctools][] = services:services:3 9 | features[features_api][] = api:2 10 | features[services_endpoint][] = dkan_dataset_api 11 | mtime = 1417998121 12 | -------------------------------------------------------------------------------- /modules/dkan_dataset_rest_api/dkan_dataset_rest_api.module: -------------------------------------------------------------------------------- 1 | @results', array('@results' => print_r($gids, TRUE)), WATCHDOG_DEBUG); 22 | $wrapper = entity_metadata_wrapper('node', $entity); 23 | $wrapper->og_group_ref->set(array($gids)); 24 | $wrapper->save(); 25 | } 26 | 27 | //Alter service attach file for add automatically the resource to datastore 28 | if ($controller['callback'] == '_node_resource_attach_file') { 29 | if (isset($result[0]['uri'])) { 30 | $nid = $args[0]; 31 | $uuid = current(entity_get_uuid_by_id('node', array($nid))); 32 | $fid = $result[0]['fid']; 33 | 34 | dkan_datastore_queue_import($uuid, $fid); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /modules/dkan_dataset_rest_api/dkan_dataset_rest_api.services.inc: -------------------------------------------------------------------------------- 1 | disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */ 15 | $endpoint->api_version = 3; 16 | $endpoint->name = 'dkan_dataset_api'; 17 | $endpoint->server = 'rest_server'; 18 | $endpoint->path = 'api/dataset'; 19 | $endpoint->authentication = array( 20 | 'services' => 'services', 21 | ); 22 | $endpoint->server_settings = array( 23 | 'formatters' => array( 24 | 'bencode' => TRUE, 25 | 'json' => TRUE, 26 | 'jsonp' => TRUE, 27 | 'php' => TRUE, 28 | 'xml' => TRUE, 29 | 'yaml' => TRUE, 30 | ), 31 | 'parsers' => array( 32 | 'application/json' => TRUE, 33 | 'application/vnd.php.serialized' => TRUE, 34 | 'application/x-www-form-urlencoded' => TRUE, 35 | 'application/x-yaml' => TRUE, 36 | 'application/xml' => TRUE, 37 | 'multipart/form-data' => TRUE, 38 | 'text/xml' => TRUE, 39 | ), 40 | ); 41 | $endpoint->resources = array( 42 | 'node' => array( 43 | 'alias' => 'node', 44 | 'operations' => array( 45 | 'retrieve' => array( 46 | 'enabled' => '1', 47 | ), 48 | 'create' => array( 49 | 'enabled' => '1', 50 | ), 51 | 'update' => array( 52 | 'enabled' => '1', 53 | ), 54 | 'delete' => array( 55 | 'enabled' => '1', 56 | ), 57 | 'index' => array( 58 | 'enabled' => '1', 59 | ), 60 | ), 61 | 'relationships' => array( 62 | 'files' => array( 63 | 'enabled' => '1', 64 | ), 65 | ), 66 | 'targeted_actions' => array( 67 | 'attach_file' => array( 68 | 'enabled' => '1', 69 | ), 70 | ), 71 | ), 72 | 'user' => array( 73 | 'operations' => array( 74 | 'retrieve' => array( 75 | 'enabled' => '1', 76 | ), 77 | ), 78 | 'actions' => array( 79 | 'login' => array( 80 | 'enabled' => '1', 81 | ), 82 | 'logout' => array( 83 | 'enabled' => '1', 84 | ), 85 | 'token' => array( 86 | 'enabled' => '1', 87 | ), 88 | ), 89 | ), 90 | ); 91 | $endpoint->debug = 0; 92 | $export['dkan_dataset_api'] = $endpoint; 93 | 94 | return $export; 95 | } 96 | -------------------------------------------------------------------------------- /modules/dkan_dataset_voting/dkan_dataset_voting.features.field_base.inc: -------------------------------------------------------------------------------- 1 | 1, 16 | 'cardinality' => 1, 17 | 'deleted' => 0, 18 | 'entity_types' => array(), 19 | 'field_name' => 'field_rating', 20 | 'foreign keys' => array(), 21 | 'indexes' => array(), 22 | 'locked' => 0, 23 | 'module' => 'fivestar', 24 | 'settings' => array( 25 | 'axis' => 'vote', 26 | ), 27 | 'translatable' => 0, 28 | 'type' => 'fivestar', 29 | ); 30 | 31 | return $field_bases; 32 | } 33 | -------------------------------------------------------------------------------- /modules/dkan_dataset_voting/dkan_dataset_voting.features.field_instance.inc: -------------------------------------------------------------------------------- 1 | 'comment_node_dataset', 16 | 'default_value' => NULL, 17 | 'deleted' => 0, 18 | 'description' => 'Multiple comments can be added per dataset, but only the most recent vote will be added to the dataset score.', 19 | 'display' => array( 20 | 'default' => array( 21 | 'label' => 'above', 22 | 'module' => 'fivestar', 23 | 'settings' => array( 24 | 'expose' => TRUE, 25 | 'style' => 'user', 26 | 'text' => 'user', 27 | 'widget' => array( 28 | 'fivestar_widget' => 'default', 29 | ), 30 | ), 31 | 'type' => 'fivestar_formatter_default', 32 | 'weight' => 1, 33 | ), 34 | ), 35 | 'entity_type' => 'comment', 36 | 'field_name' => 'field_rating', 37 | 'label' => 'Rating', 38 | 'required' => 0, 39 | 'settings' => array( 40 | 'allow_clear' => 0, 41 | 'stars' => 5, 42 | 'target' => 'parent_node', 43 | 'user_register_form' => FALSE, 44 | ), 45 | 'widget' => array( 46 | 'active' => 1, 47 | 'module' => 'fivestar', 48 | 'settings' => array( 49 | 'widget' => array( 50 | 'fivestar_widget' => 'default', 51 | ), 52 | ), 53 | 'type' => 'stars', 54 | 'weight' => 1, 55 | ), 56 | ); 57 | 58 | // Exported field_instance: 'node-dataset-field_rating' 59 | $field_instances['node-dataset-field_rating'] = array( 60 | 'bundle' => 'dataset', 61 | 'default_value' => NULL, 62 | 'deleted' => 0, 63 | 'description' => '', 64 | 'display' => array( 65 | 'default' => array( 66 | 'label' => 'inline', 67 | 'module' => 'fivestar', 68 | 'settings' => array( 69 | 'expose' => TRUE, 70 | 'style' => 'average', 71 | 'text' => 'average', 72 | 'widget' => array( 73 | 'fivestar_widget' => 'default', 74 | ), 75 | ), 76 | 'type' => 'fivestar_formatter_default', 77 | 'weight' => 17, 78 | ), 79 | 'teaser' => array( 80 | 'label' => 'above', 81 | 'settings' => array(), 82 | 'type' => 'hidden', 83 | 'weight' => 0, 84 | ), 85 | ), 86 | 'entity_type' => 'node', 87 | 'field_name' => 'field_rating', 88 | 'label' => 'Rating', 89 | 'required' => 0, 90 | 'settings' => array( 91 | 'allow_clear' => 0, 92 | 'stars' => 5, 93 | 'target' => 'none', 94 | 'user_register_form' => FALSE, 95 | ), 96 | 'widget' => array( 97 | 'active' => 1, 98 | 'module' => 'fivestar', 99 | 'settings' => array( 100 | 'widget' => array( 101 | 'fivestar_widget' => 'default', 102 | ), 103 | ), 104 | 'type' => 'exposed', 105 | 'weight' => 19, 106 | ), 107 | ); 108 | 109 | // Translatables 110 | // Included for use with string extractors like potx. 111 | t('Rating'); 112 | 113 | return $field_instances; 114 | } 115 | -------------------------------------------------------------------------------- /modules/dkan_dataset_voting/dkan_dataset_voting.features.inc: -------------------------------------------------------------------------------- 1 | "1"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /modules/dkan_dataset_voting/dkan_dataset_voting.info: -------------------------------------------------------------------------------- 1 | name = DKAN Dataset Voting 2 | description = Adds voting to datasets. 3 | core = 7.x 4 | package = DKAN Features 5 | version = 7.x-1.x-dev 6 | php = 5.2.4 7 | project = dkan_dataset_voting 8 | dependencies[] = ajax_comments 9 | dependencies[] = comment 10 | dependencies[] = ctools 11 | dependencies[] = dkan_dataset 12 | dependencies[] = features 13 | dependencies[] = fivestar 14 | dependencies[] = strongarm 15 | features[ctools][] = strongarm:strongarm:1 16 | features[features_api][] = api:2 17 | features[field_base][] = field_rating 18 | features[field_instance][] = comment-comment_node_dataset-field_rating 19 | features[field_instance][] = node-dataset-field_rating 20 | features[variable][] = ajax_comments_node_types 21 | features[variable][] = ajax_comments_notify 22 | -------------------------------------------------------------------------------- /modules/dkan_dataset_voting/dkan_dataset_voting.module: -------------------------------------------------------------------------------- 1 | disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 15 | $strongarm->api_version = 1; 16 | $strongarm->name = 'ajax_comments_node_types'; 17 | $strongarm->value = array( 18 | 'dataset' => 'dataset', 19 | 'group' => 0, 20 | 'page' => 0, 21 | 'resource' => 0, 22 | ); 23 | $export['ajax_comments_node_types'] = $strongarm; 24 | 25 | $strongarm = new stdClass(); 26 | $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ 27 | $strongarm->api_version = 1; 28 | $strongarm->name = 'ajax_comments_notify'; 29 | $strongarm->value = 1; 30 | $export['ajax_comments_notify'] = $strongarm; 31 | 32 | return $export; 33 | } 34 | -------------------------------------------------------------------------------- /tests/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require-dev": { 3 | "phpunit/phpunit": "4.6.*", 4 | "myplanetdigital/function_mock": "dev-master", 5 | "drupal/drupal-driver": "~1.0" 6 | }, 7 | "config": { 8 | "bin-dir": "bin" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/dkan_dataset_class.test: -------------------------------------------------------------------------------- 1 | 'DKAN Dataset Class Test', 19 | 'description' => 'Test DKAN Dataset Class functionality', 20 | 'group' => 'DKAN Dataset', 21 | ); 22 | } 23 | 24 | /** 25 | * Setup testcase. 26 | */ 27 | public function setUp() { 28 | $args = func_get_args(); 29 | 30 | // Build the list of required modules. 31 | if (isset($args[0])) { 32 | if (is_array($args[0])) { 33 | $modules = $args[0]; 34 | } 35 | else { 36 | $modules = $args; 37 | } 38 | } 39 | else { 40 | $modules = array(); 41 | } 42 | 43 | $modules[] = 'ctools'; 44 | $modules[] = 'context'; 45 | $modules[] = 'block'; 46 | $modules[] = 'file'; 47 | $modules[] = 'filter'; 48 | $modules[] = 'image'; 49 | $modules[] = 'list'; 50 | $modules[] = 'menu'; 51 | $modules[] = 'number'; 52 | $modules[] = 'options'; 53 | $modules[] = 'path'; 54 | $modules[] = 'taxonomy'; 55 | $modules[] = 'text'; 56 | $modules[] = 'user'; 57 | $modules[] = 'date'; 58 | $modules[] = 'date_api'; 59 | $modules[] = 'date_popup'; 60 | $modules[] = 'dkan_dataset'; 61 | $modules[] = 'dkan_dataset_groups'; 62 | $modules[] = 'dkan_dataset_content_types'; 63 | $modules[] = 'dkan_default_content'; 64 | $modules[] = 'features'; 65 | $modules[] = 'double_field'; 66 | $modules[] = 'entityreference'; 67 | $modules[] = 'field_group'; 68 | $modules[] = 'field_group_table'; 69 | $modules[] = 'filefield_sources'; 70 | $modules[] = 'geofield'; 71 | $modules[] = 'link'; 72 | $modules[] = 'link_iframe_formatter'; 73 | $modules[] = 'multistep'; 74 | $modules[] = 'ref_field_sync'; 75 | $modules[] = 'select_or_other'; 76 | $modules[] = 'og'; 77 | $modules[] = 'og_context'; 78 | $modules[] = 'og_extras'; 79 | $modules[] = 'og_ui'; 80 | $modules[] = 'chosen'; 81 | $modules[] = 'entity'; 82 | $modules[] = 'geophp'; 83 | $modules[] = 'gravatar'; 84 | $modules[] = 'leaflet_widget'; 85 | $modules[] = 'libraries'; 86 | $modules[] = 'recline'; 87 | $modules[] = 'remote_stream_wrapper'; 88 | $modules[] = 'strongarm'; 89 | $modules[] = 'token'; 90 | $modules[] = 'search_api'; 91 | $modules[] = 'search_api_db'; 92 | $modules[] = 'search_api_views'; 93 | $modules[] = 'facetapi'; 94 | $modules[] = 'autocomplete_deluxe'; 95 | $modules[] = 'beautytips'; 96 | $modules[] = 'jquery_update'; 97 | $modules[] = 'uuid'; 98 | $modules[] = 'views'; 99 | $modules[] = 'views_bulk_operations'; 100 | 101 | $modules = array_unique($modules); 102 | parent::setUp($modules); 103 | 104 | // Run a features rebuild to ensure our feature is fully installed. 105 | features_rebuild(); 106 | } 107 | 108 | /** 109 | * Test Suite for DKAN Dataset Class. 110 | */ 111 | public function testDkanDatasetClass() { 112 | // Getting dkan_default_content data for Dataset Class. 113 | ctools_include('groups', 'dkan_default_content'); 114 | ctools_include('datasets', 'dkan_default_content'); 115 | ctools_include('Dataset', 'dkan_dataset'); 116 | 117 | // Create taxonomies 118 | dkan_default_content_taxonomy_create(); 119 | 120 | // Create default content groups for datasets. 121 | $groups = dkan_default_content_available_groups(); 122 | foreach ($groups as $key => $loadable) { 123 | $group = call_user_func('dkan_default_content_' . $loadable . '_group'); 124 | unset($group['field_image']); 125 | $group = (object) $group; 126 | node_save($group); 127 | // Test appropiate node creation for every group. 128 | $this->assertTrue(isset($group->nid)); 129 | $groups[$key] = $group; 130 | } 131 | 132 | // Save Datasets and Resources 133 | $datasets = dkan_default_content_available_datasets(); 134 | foreach ($datasets as $key => $loadable){ 135 | $dataset = call_user_func('dkan_default_content_' . $loadable . '_dataset'); 136 | $resources = call_user_func('dkan_default_content_' . $loadable . '_resources'); 137 | // Instantiate Dataset 138 | $instance = Dataset::instance($dataset['title']); 139 | $instance->attachFields($dataset); 140 | foreach($resources as $resource){ 141 | $instance->attachResource($resource); 142 | } 143 | $instance->save(); 144 | $datasets[$key] = $instance; 145 | } 146 | 147 | // Run tests for dataset and resources. 148 | foreach ($datasets as $dataset) { 149 | // Test appropiate node creation for every dataset. 150 | $this->assertTrue(isset($dataset->dataset->nid)); 151 | $resources_ref = array(); 152 | // Get node page and test properties through assertText. 153 | $this->drupalGet('node/' . $dataset->dataset->nid); 154 | $this->assertText($dataset->dataset->title); 155 | // Collecting resources to cross reference with $dataset->dataset->resources. 156 | foreach ($dataset->dataset->field_resources[LANGUAGE_NONE] as $resource) { 157 | $resources_ref[] = $resource['target_id']; 158 | } 159 | foreach ($dataset->resources as $resource) { 160 | // Test appropiate node creation for every dataset resource. 161 | $this->assertTrue($resource->nid); 162 | // Test if resource nid is present at dataset->field_resources. 163 | $this->assertTrue(in_array($resource->nid, $resources_ref)); 164 | // Test if the dataset reference is set properly. 165 | $this->assertTrue($resource->field_dataset_ref[LANGUAGE_NONE][0]['target_id'] === $dataset->dataset->nid); 166 | // Get node page and test properties through assertText. 167 | $this->drupalGet('node/' . $resource->nid); 168 | $this->assertText($resource->title); 169 | } 170 | // Test revision increment. 171 | $old_vid = $dataset->dataset->vid; 172 | $dataset->incrementRevision('Testing increments'); 173 | $dataset->save(); 174 | $this->assertTrue($old_vid !== $dataset->dataset->vid); 175 | // Test dataset and resources deletion. 176 | $this->assertTrue($dataset->delete(TRUE)); 177 | } 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /tests/getRemoteFileInfoTest.php: -------------------------------------------------------------------------------- 1 | getHeaders($url); 32 | $info['header'] = $fileInfo->httpParseHeaders($headers); 33 | $fileInfo->info = $info; 34 | $type = $fileInfo->getType(); 35 | $name = $fileInfo->getName(); 36 | $this->assertEquals($type, 'text/csv'); 37 | $this->assertEquals($name, 'Hospital_Inpatient_Discharges_by_DRG__Northwest__FY2011.csv'); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /tests/getUrlTest.php: -------------------------------------------------------------------------------- 1 | httpParseHeaders($headers); 22 | //var_dump($info); 23 | $fileInfo->info = $info; 24 | $type = $fileInfo->getType(); 25 | $name = $fileInfo->getName(); 26 | 27 | --------------------------------------------------------------------------------