system.views.inc

  1. cis7 sites/all/modules/ulmus/views/modules/system.views.inc
  2. cle7 sites/all/modules/ulmus/views/modules/system.views.inc
  3. ecd7 sites/all/modules/ulmus/views/modules/system.views.inc
  4. elmsmedia7 sites/all/modules/ulmus/views/modules/system.views.inc
  5. harmony7 sites/all/modules/ulmus/views/modules/system.views.inc
  6. icor7 sites/all/modules/ulmus/views/modules/system.views.inc
  7. meedjum_blog7 sites/all/modules/ulmus/views/modules/system.views.inc
  8. mooc7 sites/all/modules/ulmus/views/modules/system.views.inc

Provide views data and handlers for system.module.

Functions

File

sites/all/modules/ulmus/views/modules/system.views.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provide views data and handlers for system.module.
  5. *
  6. * @ingroup views_module_handlers
  7. */
  8. /**
  9. * Implements hook_views_data().
  10. */
  11. function system_views_data() {
  12. $data = array();
  13. // ----------------------------------------------------------------------
  14. // file_managed table
  15. $data['files']['moved to'] = 'file_managed';
  16. $data['file_managed']['table']['group'] = t('File');
  17. // Advertise this table as a possible base table
  18. $data['file_managed']['table']['base'] = array(
  19. 'field' => 'fid',
  20. 'title' => t('File'),
  21. 'help' => t("Files maintained by Drupal and various modules."),
  22. 'defaults' => array(
  23. 'field' => 'filename'
  24. ),
  25. );
  26. $data['file_managed']['table']['entity type'] = 'file';
  27. // fid
  28. $data['file_managed']['fid'] = array(
  29. 'title' => t('File ID'),
  30. 'help' => t('The ID of the file.'),
  31. 'field' => array(
  32. 'handler' => 'views_handler_field_file',
  33. 'click sortable' => TRUE,
  34. ),
  35. 'argument' => array(
  36. 'handler' => 'views_handler_argument_file_fid',
  37. 'name field' => 'filename', // the field to display in the summary.
  38. 'numeric' => TRUE,
  39. ),
  40. 'filter' => array(
  41. 'handler' => 'views_handler_filter_numeric',
  42. ),
  43. 'sort' => array(
  44. 'handler' => 'views_handler_sort',
  45. ),
  46. );
  47. // filename
  48. $data['file_managed']['filename'] = array(
  49. 'title' => t('Name'),
  50. 'help' => t('The name of the file.'),
  51. 'field' => array(
  52. 'handler' => 'views_handler_field_file',
  53. 'click sortable' => TRUE,
  54. ),
  55. 'sort' => array(
  56. 'handler' => 'views_handler_sort',
  57. ),
  58. 'filter' => array(
  59. 'handler' => 'views_handler_filter_string',
  60. ),
  61. 'argument' => array(
  62. 'handler' => 'views_handler_argument_string',
  63. ),
  64. );
  65. // uri
  66. $data['file_managed']['uri'] = array(
  67. 'title' => t('Path'),
  68. 'help' => t('The path of the file.'),
  69. 'field' => array(
  70. 'handler' => 'views_handler_field_file_uri',
  71. 'click sortable' => TRUE,
  72. ),
  73. 'sort' => array(
  74. 'handler' => 'views_handler_sort',
  75. ),
  76. 'filter' => array(
  77. 'handler' => 'views_handler_filter_string',
  78. ),
  79. 'argument' => array(
  80. 'handler' => 'views_handler_argument_string',
  81. ),
  82. );
  83. // filemime
  84. $data['file_managed']['filemime'] = array(
  85. 'title' => t('Mime type'),
  86. 'help' => t('The mime type of the file.'),
  87. 'field' => array(
  88. 'handler' => 'views_handler_field_file_filemime',
  89. 'click sortable' => TRUE,
  90. ),
  91. 'sort' => array(
  92. 'handler' => 'views_handler_sort',
  93. ),
  94. 'filter' => array(
  95. 'handler' => 'views_handler_filter_string',
  96. ),
  97. 'argument' => array(
  98. 'handler' => 'views_handler_argument_string',
  99. ),
  100. );
  101. // extension
  102. $data['file_managed']['extension'] = array(
  103. 'title' => t('Extension'),
  104. 'help' => t('The extension of the file.'),
  105. 'real field' => 'filename',
  106. 'field' => array(
  107. 'handler' => 'views_handler_field_file_extension',
  108. 'click sortable' => FALSE,
  109. ),
  110. );
  111. // filesize
  112. $data['file_managed']['filesize'] = array(
  113. 'title' => t('Size'),
  114. 'help' => t('The size of the file.'),
  115. 'field' => array(
  116. 'handler' => 'views_handler_field_file_size',
  117. 'click sortable' => TRUE,
  118. ),
  119. 'sort' => array(
  120. 'handler' => 'views_handler_sort',
  121. ),
  122. 'filter' => array(
  123. 'handler' => 'views_handler_filter_numeric',
  124. ),
  125. );
  126. // status
  127. $data['file_managed']['status'] = array(
  128. 'title' => t('Status'),
  129. 'help' => t('The status of the file.'),
  130. 'field' => array(
  131. 'handler' => 'views_handler_field_file_status',
  132. 'click sortable' => TRUE,
  133. ),
  134. 'sort' => array(
  135. 'handler' => 'views_handler_sort',
  136. ),
  137. 'filter' => array(
  138. 'handler' => 'views_handler_filter_file_status',
  139. ),
  140. );
  141. // timestamp field
  142. $data['file_managed']['timestamp'] = array(
  143. 'title' => t('Upload date'),
  144. 'help' => t('The date the file was uploaded.'),
  145. 'field' => array(
  146. 'handler' => 'views_handler_field_date',
  147. 'click sortable' => TRUE,
  148. ),
  149. 'sort' => array(
  150. 'handler' => 'views_handler_sort_date',
  151. ),
  152. 'filter' => array(
  153. 'handler' => 'views_handler_filter_date',
  154. ),
  155. );
  156. // uid
  157. $data['file_managed']['uid'] = array(
  158. 'title' => t('User who uploaded'),
  159. 'help' => t('The user that uploaded the file.'),
  160. 'relationship' => array(
  161. 'title' => t('User who uploaded'),
  162. 'label' => t('User who uploaded'),
  163. 'base' => 'users',
  164. 'base field' => 'uid',
  165. ),
  166. );
  167. // ----------------------------------------------------------------------
  168. // file_usage table
  169. $data['file_usage']['table']['group'] = t('File Usage');
  170. // Provide field-type-things to several base tables; on the core files table ("file_managed") so
  171. // that we can create relationships from files to entities, and then on each core entity type base
  172. // table so that we can provide general relationships between entities and files.
  173. $data['file_usage']['table']['join'] = array(
  174. // Link ourself to the {file_managed} table so we can provide file->entity relationships.
  175. 'file_managed' => array(
  176. 'field' => 'fid',
  177. 'left_field' => 'fid',
  178. ),
  179. // Link ourself to the {node} table so we can provide node->file relationships.
  180. 'node' => array(
  181. 'field' => 'id',
  182. 'left_field' => 'nid',
  183. 'extra' => array(array('field' => 'type', 'value' => 'node')),
  184. ),
  185. // Link ourself to the {users} table so we can provide user->file relationships.
  186. 'users' => array(
  187. 'field' => 'id',
  188. 'left_field' => 'uid',
  189. 'extra' => array(array('field' => 'type', 'value' => 'user')),
  190. ),
  191. // Link ourself to the {comment} table so we can provide comment->file relationships.
  192. 'comment' => array(
  193. 'field' => 'id',
  194. 'left_field' => 'cid',
  195. 'extra' => array(array('field' => 'type', 'value' => 'comment')),
  196. ),
  197. // Link ourself to the {taxonomy_term_data} table so we can provide taxonomy_term->file relationships.
  198. 'taxonomy_term_data' => array(
  199. 'field' => 'id',
  200. 'left_field' => 'tid',
  201. 'extra' => array(array('field' => 'type', 'value' => 'taxonomy_term')),
  202. ),
  203. // Link ourself to the {taxonomy_vocabulary} table so we can provide taxonomy_vocabulary->file relationships.
  204. 'taxonomy_vocabulary' => array(
  205. 'field' => 'id',
  206. 'left_field' => 'vid',
  207. 'extra' => array(array('field' => 'type', 'value' => 'taxonomy_vocabulary')),
  208. ),
  209. );
  210. // Provide a relationship between the files table and each entity type, and between each entity
  211. // type and the files table. Entity->file relationships are type-restricted in the joins
  212. // declared above, and file->entity relationships are type-restricted in the relationship
  213. // declarations below.
  214. // Relationships between files and nodes.
  215. $data['file_usage']['file_to_node'] = array(
  216. 'title' => t('Content'),
  217. 'help' => t('Content that is associated with this file, usually because this file is in a field on the content.'),
  218. // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
  219. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
  220. 'real field' => 'id',
  221. 'relationship' => array(
  222. 'title' => t('Content'),
  223. 'label' => t('Content'),
  224. 'base' => 'node',
  225. 'base field' => 'nid',
  226. 'relationship field' => 'id',
  227. 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'node')),
  228. ),
  229. );
  230. $data['file_usage']['node_to_file'] = array(
  231. 'title' => t('File'),
  232. 'help' => t('A file that is associated with this node, usually because it is in a field on the node.'),
  233. // Only provide this field/relationship/etc. when the 'node' base table is present.
  234. 'skip base' => array('file_managed', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
  235. 'real field' => 'fid',
  236. 'relationship' => array(
  237. 'title' => t('File'),
  238. 'label' => t('File'),
  239. 'base' => 'file_managed',
  240. 'base field' => 'fid',
  241. 'relationship field' => 'fid',
  242. ),
  243. );
  244. // Relationships between files and users.
  245. $data['file_usage']['file_to_user'] = array(
  246. 'title' => t('User'),
  247. 'help' => t('A user that is associated with this file, usually because this file is in a field on the user.'),
  248. // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
  249. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
  250. 'real field' => 'id',
  251. 'relationship' => array(
  252. 'title' => t('User'),
  253. 'label' => t('User'),
  254. 'base' => 'users',
  255. 'base field' => 'uid',
  256. 'relationship field' => 'id',
  257. 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'user')),
  258. ),
  259. );
  260. $data['file_usage']['user_to_file'] = array(
  261. 'title' => t('File'),
  262. 'help' => t('A file that is associated with this user, usually because it is in a field on the user.'),
  263. // Only provide this field/relationship/etc. when the 'users' base table is present.
  264. 'skip base' => array('file_managed', 'node', 'node_revision', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
  265. 'real field' => 'fid',
  266. 'relationship' => array(
  267. 'title' => t('File'),
  268. 'label' => t('File'),
  269. 'base' => 'file_managed',
  270. 'base field' => 'fid',
  271. 'relationship field' => 'fid',
  272. ),
  273. );
  274. // Relationships between files and comments.
  275. $data['file_usage']['file_to_comment'] = array(
  276. 'title' => t('Comment'),
  277. 'help' => t('A comment that is associated with this file, usually because this file is in a field on the comment.'),
  278. // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
  279. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
  280. 'real field' => 'id',
  281. 'relationship' => array(
  282. 'title' => t('Comment'),
  283. 'label' => t('Comment'),
  284. 'base' => 'comment',
  285. 'base field' => 'cid',
  286. 'relationship field' => 'id',
  287. 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'comment')),
  288. ),
  289. );
  290. $data['file_usage']['comment_to_file'] = array(
  291. 'title' => t('File'),
  292. 'help' => t('A file that is associated with this comment, usually because it is in a field on the comment.'),
  293. // Only provide this field/relationship/etc. when the 'comment' base table is present.
  294. 'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'taxonomy_term_data', 'taxonomy_vocabulary'),
  295. 'real field' => 'fid',
  296. 'relationship' => array(
  297. 'title' => t('File'),
  298. 'label' => t('File'),
  299. 'base' => 'file_managed',
  300. 'base field' => 'fid',
  301. 'relationship field' => 'fid',
  302. ),
  303. );
  304. // Relationships between files and taxonomy_terms.
  305. $data['file_usage']['file_to_taxonomy_term'] = array(
  306. 'title' => t('Taxonomy Term'),
  307. 'help' => t('A taxonomy term that is associated with this file, usually because this file is in a field on the taxonomy term.'),
  308. // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
  309. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
  310. 'real field' => 'id',
  311. 'relationship' => array(
  312. 'title' => t('Taxonomy Term'),
  313. 'label' => t('Taxonomy Term'),
  314. 'base' => 'taxonomy_term_data',
  315. 'base field' => 'tid',
  316. 'relationship field' => 'id',
  317. 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'taxonomy_term')),
  318. ),
  319. );
  320. $data['file_usage']['taxonomy_term_to_file'] = array(
  321. 'title' => t('File'),
  322. 'help' => t('A file that is associated with this taxonomy term, usually because it is in a field on the taxonomy term.'),
  323. // Only provide this field/relationship/etc. when the 'taxonomy_term_data' base table is present.
  324. 'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'comment', 'taxonomy_vocabulary'),
  325. 'real field' => 'fid',
  326. 'relationship' => array(
  327. 'title' => t('File'),
  328. 'label' => t('File'),
  329. 'base' => 'file_managed',
  330. 'base field' => 'fid',
  331. 'relationship field' => 'fid',
  332. ),
  333. );
  334. // Relationships between files and taxonomy_vocabulary items.
  335. $data['file_usage']['file_to_taxonomy_vocabulary'] = array(
  336. 'title' => t('Taxonomy Vocabulary'),
  337. 'help' => t('A taxonomy vocabulary that is associated with this file, usually because this file is in a field on the taxonomy vocabulary.'),
  338. // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
  339. 'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
  340. 'real field' => 'id',
  341. 'relationship' => array(
  342. 'title' => t('Taxonomy Vocabulary'),
  343. 'label' => t('Taxonomy Vocabulary'),
  344. 'base' => 'taxonomy_vocabulary',
  345. 'base field' => 'vid',
  346. 'relationship field' => 'id',
  347. 'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'taxonomy_vocabulary')),
  348. ),
  349. );
  350. $data['file_usage']['taxonomy_vocabulary_to_file'] = array(
  351. 'title' => t('File'),
  352. 'help' => t('A file that is associated with this taxonomy vocabulary, usually because it is in a field on the taxonomy vocabulary.'),
  353. // Only provide this field/relationship/etc. when the 'taxonomy_vocabulary' base table is present.
  354. 'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'comment', 'taxonomy_term_data'),
  355. 'real field' => 'fid',
  356. 'relationship' => array(
  357. 'title' => t('File'),
  358. 'label' => t('File'),
  359. 'base' => 'file_managed',
  360. 'base field' => 'fid',
  361. 'relationship field' => 'fid',
  362. ),
  363. );
  364. // Provide basic fields from the {file_usage} table to all of the base tables we've declared
  365. // joins to (because there is no 'skip base' property on these fields).
  366. $data['file_usage']['module'] = array(
  367. 'title' => t('Module'),
  368. 'help' => t('The module managing this file relationship.'),
  369. 'field' => array(
  370. 'handler' => 'views_handler_field',
  371. 'click sortable' => TRUE,
  372. ),
  373. 'filter' => array(
  374. 'handler' => 'views_handler_filter_string',
  375. ),
  376. 'argument' => array(
  377. 'handler' => 'views_handler_argument_string',
  378. ),
  379. 'sort' => array(
  380. 'handler' => 'views_handler_sort',
  381. ),
  382. );
  383. $data['file_usage']['type'] = array(
  384. 'title' => t('Entity type'),
  385. 'help' => t('The type of entity that is related to the file.'),
  386. 'field' => array(
  387. 'handler' => 'views_handler_field',
  388. 'click sortable' => TRUE,
  389. ),
  390. 'filter' => array(
  391. 'handler' => 'views_handler_filter_string',
  392. ),
  393. 'argument' => array(
  394. 'handler' => 'views_handler_argument_string',
  395. ),
  396. 'sort' => array(
  397. 'handler' => 'views_handler_sort',
  398. ),
  399. );
  400. $data['file_usage']['id'] = array(
  401. 'title' => t('Entity ID'),
  402. 'help' => t('The ID of the entity that is related to the file.'),
  403. 'field' => array(
  404. 'handler' => 'views_handler_field_numeric',
  405. 'click sortable' => TRUE,
  406. ),
  407. 'argument' => array(
  408. 'handler' => 'views_handler_argument_numeric',
  409. ),
  410. 'filter' => array(
  411. 'handler' => 'views_handler_filter_numeric',
  412. ),
  413. 'sort' => array(
  414. 'handler' => 'views_handler_sort',
  415. ),
  416. );
  417. $data['file_usage']['count'] = array(
  418. 'title' => t('Use count'),
  419. 'help' => t('The number of times the file is used by this entity.'),
  420. 'field' => array(
  421. 'handler' => 'views_handler_field_numeric',
  422. 'click sortable' => TRUE,
  423. ),
  424. 'filter' => array(
  425. 'handler' => 'views_handler_filter_numeric',
  426. ),
  427. 'sort' => array(
  428. 'handler' => 'views_handler_sort',
  429. ),
  430. );
  431. // ----------------------------------------------------------------------
  432. // system table
  433. $data['system']['table']['group'] = t('System');
  434. // Advertise this table as a possible base table
  435. $data['system']['table']['base'] = array(
  436. 'field' => 'filename',
  437. 'title' => t('Module/Theme/Theme engine'),
  438. 'help' => t('Modules/Themes/Theme engines in your codebase.'),
  439. );
  440. // fields
  441. // - filename
  442. $data['system']['filename'] = array(
  443. 'title' => t('Module/Theme/Theme engine filename'),
  444. 'help' => t('The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.'),
  445. 'field' => array(
  446. 'handler' => 'views_handler_field',
  447. 'click sortable' => TRUE,
  448. ),
  449. 'argument' => array(
  450. 'handler' => 'views_handler_argument_string',
  451. 'name field' => 'filename', // the field to display in the summary.
  452. ),
  453. 'filter' => array(
  454. 'handler' => 'views_handler_filter_string',
  455. ),
  456. 'sort' => array(
  457. 'handler' => 'views_handler_sort',
  458. ),
  459. );
  460. // - name
  461. $data['system']['name'] = array(
  462. 'title' => t('Module/Theme/Theme engine name'),
  463. 'help' => t('The name of the item; e.g. node.'),
  464. 'field' => array(
  465. 'handler' => 'views_handler_field',
  466. 'click sortable' => TRUE,
  467. ),
  468. 'argument' => array(
  469. 'handler' => 'views_handler_argument_string',
  470. 'name field' => 'name', // the field to display in the summary.
  471. ),
  472. 'filter' => array(
  473. 'handler' => 'views_handler_filter_string',
  474. ),
  475. 'sort' => array(
  476. 'handler' => 'views_handler_sort',
  477. ),
  478. );
  479. // - type
  480. $data['system']['type'] = array(
  481. 'title' => t('Type'),
  482. 'help' => t('The type of the item, either module, theme, or theme_engine.'),
  483. 'field' => array(
  484. 'handler' => 'views_handler_field',
  485. 'click sortable' => TRUE,
  486. ),
  487. 'argument' => array(
  488. 'handler' => 'views_handler_argument_string',
  489. 'name field' => 'type', // the field to display in the summary.
  490. ),
  491. 'filter' => array(
  492. 'handler' => 'views_handler_filter_system_type',
  493. ),
  494. 'sort' => array(
  495. 'handler' => 'views_handler_sort',
  496. ),
  497. );
  498. // - status
  499. $data['system']['status'] = array(
  500. 'title' => t('Status'),
  501. 'help' => t('Boolean indicating whether or not this item is enabled.'),
  502. 'field' => array(
  503. 'handler' => 'views_handler_field_boolean',
  504. 'click sortable' => TRUE,
  505. ),
  506. 'argument' => array(
  507. 'handler' => 'views_handler_argument_numeric',
  508. 'name field' => 'status', // the field to display in the summary.
  509. ),
  510. 'filter' => array(
  511. 'handler' => 'views_handler_filter_boolean_operator',
  512. ),
  513. 'sort' => array(
  514. 'handler' => 'views_handler_sort',
  515. ),
  516. );
  517. // - schema version
  518. $data['system']['schema_version'] = array(
  519. 'title' => t('Schema version'),
  520. 'help' => t("The module's database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed."),
  521. 'field' => array(
  522. 'handler' => 'views_handler_field_numeric',
  523. 'click sortable' => TRUE,
  524. ),
  525. 'argument' => array(
  526. 'handler' => 'views_handler_argument_numeric',
  527. 'name field' => 'schema_version', // the field to display in the summary.
  528. ),
  529. 'filter' => array(
  530. 'handler' => 'views_handler_filter_numeric',
  531. ),
  532. 'sort' => array(
  533. 'handler' => 'views_handler_sort',
  534. ),
  535. );
  536. return $data;
  537. }
  538. function _views_file_status($choice = NULL) {
  539. $status = array(
  540. 0 => t('Temporary'),
  541. FILE_STATUS_PERMANENT => t('Permanent'),
  542. );
  543. if (isset($choice)) {
  544. return isset($status[$choice]) ? $status[$choice] : t('Unknown');
  545. }
  546. return $status;
  547. }

Related topics