• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

modules/system.views.inc

Go to the documentation of this file.
00001 <?php
00018 function system_views_data() {
00019   $data = array();
00020 
00021   // ----------------------------------------------------------------------
00022   // file_managed table
00023 
00024   $data['files']['moved to'] = 'file_managed';
00025   $data['file_managed']['table']['group']  = t('File');
00026 
00027   // Advertise this table as a possible base table
00028   $data['file_managed']['table']['base'] = array(
00029     'field' => 'fid',
00030     'title' => t('File'),
00031     'help' => t("Files maintained by Drupal and various modules."),
00032     'defaults' => array(
00033       'field' => 'filename'
00034     ),
00035   );
00036   $data['file_managed']['table']['entity type'] = 'file';
00037 
00038 
00039   // The file table does not inherently join to the node table,
00040   // but may things (such as upload.module) can add relationships
00041   // that allow file fields to be used.
00042 
00043   // fid
00044   $data['file_managed']['fid'] = array(
00045     'title' => t('File ID'),
00046     'help' => t('The ID of the file.'),
00047     'field' => array(
00048       'handler' => 'views_handler_field_file',
00049       'click sortable' => TRUE,
00050     ),
00051     'argument' => array(
00052       'handler' => 'views_handler_argument_file_fid',
00053       'name field' => 'filename', // the field to display in the summary.
00054       'numeric' => TRUE,
00055     ),
00056     'filter' => array(
00057       'handler' => 'views_handler_filter_numeric',
00058     ),
00059     'sort' => array(
00060       'handler' => 'views_handler_sort',
00061     ),
00062   );
00063 
00064   // filename
00065   $data['file_managed']['filename'] = array(
00066     'title' => t('Name'),
00067     'help' => t('The name of the file.'),
00068     'field' => array(
00069       'handler' => 'views_handler_field_file',
00070       'click sortable' => TRUE,
00071      ),
00072     'sort' => array(
00073       'handler' => 'views_handler_sort',
00074     ),
00075     'filter' => array(
00076       'handler' => 'views_handler_filter_string',
00077     ),
00078     'argument' => array(
00079       'handler' => 'views_handler_argument_string',
00080     ),
00081   );
00082 
00083   // uri
00084   $data['file_managed']['uri'] = array(
00085     'title' => t('Path'),
00086     'help' => t('The path of the file.'),
00087     'field' => array(
00088       'handler' => 'views_handler_field_file_uri',
00089       'click sortable' => TRUE,
00090      ),
00091     'sort' => array(
00092       'handler' => 'views_handler_sort',
00093     ),
00094     'filter' => array(
00095       'handler' => 'views_handler_filter_string',
00096     ),
00097     'argument' => array(
00098       'handler' => 'views_handler_argument_string',
00099     ),
00100   );
00101 
00102   // filemime
00103   $data['file_managed']['filemime'] = array(
00104     'title' => t('Mime type'),
00105     'help' => t('The mime type of the file.'),
00106     'field' => array(
00107       'handler' => 'views_handler_field_file_filemime',
00108       'click sortable' => TRUE,
00109      ),
00110     'sort' => array(
00111       'handler' => 'views_handler_sort',
00112     ),
00113     'filter' => array(
00114       'handler' => 'views_handler_filter_string',
00115     ),
00116     'argument' => array(
00117       'handler' => 'views_handler_argument_string',
00118     ),
00119   );
00120 
00121   // extension
00122   $data['file_managed']['extension'] = array(
00123     'title' => t('Extension'),
00124     'help' => t('The extension of the file.'),
00125     'real field' => 'filename',
00126     'field' => array(
00127       'handler' => 'views_handler_field_file_extension',
00128       'click sortable' => FALSE,
00129      ),
00130   );
00131 
00132   // filesize
00133   $data['file_managed']['filesize'] = array(
00134     'title' => t('Size'),
00135     'help' => t('The size of the file.'),
00136     'field' => array(
00137       'handler' => 'views_handler_field_file_size',
00138       'click sortable' => TRUE,
00139      ),
00140     'sort' => array(
00141       'handler' => 'views_handler_sort',
00142     ),
00143     'filter' => array(
00144       'handler' => 'views_handler_filter_numeric',
00145     ),
00146   );
00147 
00148   // status
00149   $data['file_managed']['status'] = array(
00150     'title' => t('Status'),
00151     'help' => t('The status of the file.'),
00152     'field' => array(
00153       'handler' => 'views_handler_field_file_status',
00154       'click sortable' => TRUE,
00155      ),
00156     'sort' => array(
00157       'handler' => 'views_handler_sort',
00158     ),
00159     'filter' => array(
00160       'handler' => 'views_handler_filter_file_status',
00161     ),
00162   );
00163 
00164   // timestamp field
00165   $data['file_managed']['timestamp'] = array(
00166     'title' => t('Upload date'),
00167     'help' => t('The date the file was uploaded.'),
00168     'field' => array(
00169       'handler' => 'views_handler_field_date',
00170       'click sortable' => TRUE,
00171     ),
00172     'sort' => array(
00173       'handler' => 'views_handler_sort_date',
00174     ),
00175     'filter' => array(
00176       'handler' => 'views_handler_filter_date',
00177     ),
00178   );
00179 
00180   // uid
00181   $data['file_managed']['uid'] = array(
00182     'title' => t('User who uploaded'),
00183     'help' => t('The user that uploaded the file.'),
00184     'relationship' => array(
00185       'title' => t('User who uploaded'),
00186       'label' => t('User who uploaded'),
00187       'base' => 'users',
00188       'base field' => 'uid',
00189     ),
00190   );
00191 
00192   // ----------------------------------------------------------------------
00193   // file_usage table
00194 
00195   $data['file_usage']['table']['group']  = t('File Usage');
00196 
00197   // Provide field-type-things to several base tables; on the core files table ("file_managed") so
00198   // that we can create relationships from files to entities, and then on each core entity type base
00199   // table so that we can provide general relationships between entities and files.
00200   $data['file_usage']['table']['join'] = array(
00201     // Link ourself to the {file_managed} table so we can provide file->entity relationships.
00202     'file_managed' => array(
00203       'field' => 'fid',
00204       'left_field' => 'fid',
00205     ),
00206     // Link ourself to the {node} table so we can provide node->file relationships.
00207     'node' => array(
00208       'field' => 'id',
00209       'left_field' => 'nid',
00210       'extra' => array(array('field' => 'type', 'value' => 'node')),
00211     ),
00212     // Link ourself to the {users} table so we can provide user->file relationships.
00213     'users' => array(
00214       'field' => 'id',
00215       'left_field' => 'uid',
00216       'extra' => array(array('field' => 'type', 'value' => 'user')),
00217     ),
00218     // Link ourself to the {comment} table so we can provide comment->file relationships.
00219     'comment' => array(
00220       'field' => 'id',
00221       'left_field' => 'cid',
00222       'extra' => array(array('field' => 'type', 'value' => 'comment')),
00223     ),
00224     // Link ourself to the {taxonomy_term_data} table so we can provide taxonomy_term->file relationships.
00225     'taxonomy_term_data' => array(
00226       'field' => 'id',
00227       'left_field' => 'tid',
00228       'extra' => array(array('field' => 'type', 'value' => 'taxonomy_term')),
00229     ),
00230     // Link ourself to the {taxonomy_vocabulary} table so we can provide taxonomy_vocabulary->file relationships.
00231     'taxonomy_vocabulary' => array(
00232       'field' => 'id',
00233       'left_field' => 'vid',
00234       'extra' => array(array('field' => 'type', 'value' => 'taxonomy_vocabulary')),
00235     ),
00236   );
00237 
00238   // Provide a relationship between the files table and each entity type, and between each entity
00239   // type and the files table. Entity->file relationships are type-restricted in the joins
00240   // declared above, and file->entity relationships are type-restricted in the relationship
00241   // declarations below.
00242 
00243   // Relationships between files and nodes.
00244   $data['file_usage']['file_to_node'] = array(
00245     'title' => t('Content'),
00246     'help' => t('Content that is associated with this file, usually because this file is in a field on the content.'),
00247     // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
00248     'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
00249     'real field' => 'id',
00250     'relationship' => array(
00251       'title' => t('Content'),
00252       'label' => t('Content'),
00253       'base' => 'node',
00254       'base field' => 'nid',
00255       'relationship field' => 'id',
00256       'extra' => array(array('field' => 'type', 'value' => 'node')),
00257     ),
00258   );
00259   $data['file_usage']['node_to_file'] = array(
00260     'title' => t('File'),
00261     'help' => t('A file that is associated with this node, usually because it is in a field on the node.'),
00262     // Only provide this field/relationship/etc. when the 'node' base table is present.
00263     'skip base' => array('file_managed', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
00264     'real field' => 'fid',
00265     'relationship' => array(
00266       'title' => t('File'),
00267       'label' => t('File'),
00268       'base' => 'file_managed',
00269       'base field' => 'fid',
00270       'relationship field' => 'fid',
00271     ),
00272   );
00273 
00274   // Relationships between files and users.
00275   $data['file_usage']['file_to_user'] = array(
00276     'title' => t('User'),
00277     'help' => t('A user that is associated with this file, usually because this file is in a field on the user.'),
00278     // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
00279     'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
00280     'real field' => 'id',
00281     'relationship' => array(
00282       'title' => t('User'),
00283       'label' => t('User'),
00284       'base' => 'users',
00285       'base field' => 'uid',
00286       'relationship field' => 'id',
00287       'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'user')),
00288     ),
00289   );
00290   $data['file_usage']['user_to_file'] = array(
00291     'title' => t('File'),
00292     'help' => t('A file that is associated with this user, usually because it is in a field on the user.'),
00293     // Only provide this field/relationship/etc. when the 'users' base table is present.
00294     'skip base' => array('file_managed', 'node', 'node_revision', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
00295     'real field' => 'fid',
00296     'relationship' => array(
00297       'title' => t('File'),
00298       'label' => t('File'),
00299       'base' => 'file_managed',
00300       'base field' => 'fid',
00301       'relationship field' => 'fid',
00302     ),
00303   );
00304 
00305   // Relationships between files and comments.
00306   $data['file_usage']['file_to_comment'] = array(
00307     'title' => t('Comment'),
00308     'help' => t('A comment that is associated with this file, usually because this file is in a field on the comment.'),
00309     // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
00310     'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
00311     'real field' => 'id',
00312     'relationship' => array(
00313       'title' => t('Comment'),
00314       'label' => t('Comment'),
00315       'base' => 'comment',
00316       'base field' => 'cid',
00317       'relationship field' => 'id',
00318       'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'comment')),
00319     ),
00320   );
00321   $data['file_usage']['comment_to_file'] = array(
00322     'title' => t('File'),
00323     'help' => t('A file that is associated with this comment, usually because it is in a field on the comment.'),
00324     // Only provide this field/relationship/etc. when the 'comment' base table is present.
00325     'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'taxonomy_term_data', 'taxonomy_vocabulary'),
00326     'real field' => 'fid',
00327     'relationship' => array(
00328       'title' => t('File'),
00329       'label' => t('File'),
00330       'base' => 'file_managed',
00331       'base field' => 'fid',
00332       'relationship field' => 'fid',
00333     ),
00334   );
00335 
00336   // Relationships between files and taxonomy_terms.
00337   $data['file_usage']['file_to_taxonomy_term'] = array(
00338     'title' => t('Taxonomy Term'),
00339     'help' => t('A taxonomy term that is associated with this file, usually because this file is in a field on the taxonomy term.'),
00340     // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
00341     'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
00342     'real field' => 'id',
00343     'relationship' => array(
00344       'title' => t('Taxonomy Term'),
00345       'label' => t('Taxonomy Term'),
00346       'base' => 'taxonomy_term_data',
00347       'base field' => 'tid',
00348       'relationship field' => 'id',
00349       'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'taxonomy_term')),
00350     ),
00351   );
00352   $data['file_usage']['taxonomy_term_to_file'] = array(
00353     'title' => t('File'),
00354     'help' => t('A file that is associated with this taxonomy term, usually because it is in a field on the taxonomy term.'),
00355     // Only provide this field/relationship/etc. when the 'taxonomy_term_data' base table is present.
00356     'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'comment', 'taxonomy_vocabulary'),
00357     'real field' => 'fid',
00358     'relationship' => array(
00359       'title' => t('File'),
00360       'label' => t('File'),
00361       'base' => 'file_managed',
00362       'base field' => 'fid',
00363       'relationship field' => 'fid',
00364     ),
00365   );
00366 
00367   // Relationships between files and taxonomy_vocabulary items.
00368   $data['file_usage']['file_to_taxonomy_vocabulary'] = array(
00369     'title' => t('Taxonomy Vocabulary'),
00370     'help' => t('A taxonomy vocabulary that is associated with this file, usually because this file is in a field on the taxonomy vocabulary.'),
00371     // Only provide this field/relationship/etc. when the 'file_managed' base table is present.
00372     'skip base' => array('node', 'node_revision', 'users', 'comment', 'taxonomy_term_data', 'taxonomy_vocabulary'),
00373     'real field' => 'id',
00374     'relationship' => array(
00375       'title' => t('Taxonomy Vocabulary'),
00376       'label' => t('Taxonomy Vocabulary'),
00377       'base' => 'taxonomy_vocabulary',
00378       'base field' => 'vid',
00379       'relationship field' => 'id',
00380       'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'taxonomy_vocabulary')),
00381     ),
00382   );
00383   $data['file_usage']['taxonomy_vocabulary_to_file'] = array(
00384     'title' => t('File'),
00385     'help' => t('A file that is associated with this taxonomy vocabulary, usually because it is in a field on the taxonomy vocabulary.'),
00386     // Only provide this field/relationship/etc. when the 'taxonomy_vocabulary' base table is present.
00387     'skip base' => array('file_managed', 'node', 'node_revision', 'users', 'comment', 'taxonomy_term_data'),
00388     'real field' => 'fid',
00389     'relationship' => array(
00390       'title' => t('File'),
00391       'label' => t('File'),
00392       'base' => 'file_managed',
00393       'base field' => 'fid',
00394       'relationship field' => 'fid',
00395     ),
00396   );
00397 
00398   // Provide basic fields from the {file_usage} table to all of the base tables we've declared
00399   // joins to (because there is no 'skip base' property on these fields).
00400   $data['file_usage']['module'] = array(
00401     'title' => t('Module'),
00402     'help' => t('The module managing this file relationship.'),
00403     'field' => array(
00404       'handler' => 'views_handler_field',
00405       'click sortable' => TRUE,
00406      ),
00407     'filter' => array(
00408       'handler' => 'views_handler_filter_string',
00409     ),
00410     'argument' => array(
00411       'handler' => 'views_handler_argument_string',
00412     ),
00413     'sort' => array(
00414       'handler' => 'views_handler_sort',
00415     ),
00416   );
00417   $data['file_usage']['type'] = array(
00418     'title' => t('Entity type'),
00419     'help' => t('The type of entity that is related to the file.'),
00420     'field' => array(
00421       'handler' => 'views_handler_field',
00422       'click sortable' => TRUE,
00423      ),
00424     'filter' => array(
00425       'handler' => 'views_handler_filter_string',
00426     ),
00427     'argument' => array(
00428       'handler' => 'views_handler_argument_string',
00429     ),
00430     'sort' => array(
00431       'handler' => 'views_handler_sort',
00432     ),
00433   );
00434   $data['file_usage']['count'] = array(
00435     'title' => t('Use count'),
00436     'help' => t('The number of times the file is used by this entity.'),
00437     'field' => array(
00438       'handler' => 'views_handler_field_numeric',
00439       'click sortable' => TRUE,
00440      ),
00441     'filter' => array(
00442       'handler' => 'views_handler_filter_numeric',
00443     ),
00444     'sort' => array(
00445       'handler' => 'views_handler_sort',
00446     ),
00447   );
00448 
00449   // ----------------------------------------------------------------------
00450   // system table
00451   $data['system']['table']['group']  = t('System');
00452 
00453   // Advertise this table as a possible base table
00454   $data['system']['table']['base'] = array(
00455     'field' => 'filename',
00456     'title' => t('Module/Theme/Theme engine'),
00457     'help' => t('Modules/Themes/Theme engines in your codebase.'),
00458   );
00459 
00460   // fields
00461   // - filename
00462   $data['system']['filename'] = array(
00463     'title' => t('Module/Theme/Theme engine filename'),
00464     'help' => t('The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.'),
00465     'field' => array(
00466       'handler' => 'views_handler_field',
00467       'click sortable' => TRUE,
00468     ),
00469     'argument' => array(
00470       'handler' => 'views_handler_argument_string',
00471       'name field' => 'filename', // the field to display in the summary.
00472     ),
00473     'filter' => array(
00474       'handler' => 'views_handler_filter_string',
00475     ),
00476     'sort' => array(
00477       'handler' => 'views_handler_sort',
00478     ),
00479   );
00480   // - name
00481   $data['system']['name'] = array(
00482     'title' => t('Module/Theme/Theme engine name'),
00483     'help' => t('The name of the item; e.g. node.'),
00484     'field' => array(
00485       'handler' => 'views_handler_field',
00486       'click sortable' => TRUE,
00487     ),
00488     'argument' => array(
00489       'handler' => 'views_handler_argument_string',
00490       'name field' => 'name', // the field to display in the summary.
00491     ),
00492     'filter' => array(
00493       'handler' => 'views_handler_filter_string',
00494     ),
00495     'sort' => array(
00496       'handler' => 'views_handler_sort',
00497     ),
00498   );
00499   // - type
00500   $data['system']['type'] = array(
00501     'title' => t('Type'),
00502     'help' => t('The type of the item, either module, theme, or theme_engine.'),
00503     'field' => array(
00504       'handler' => 'views_handler_field',
00505       'click sortable' => TRUE,
00506     ),
00507     'argument' => array(
00508       'handler' => 'views_handler_argument_string',
00509       'name field' => 'type', // the field to display in the summary.
00510     ),
00511     'filter' => array(
00512       'handler' => 'views_handler_filter_system_type',
00513     ),
00514     'sort' => array(
00515       'handler' => 'views_handler_sort',
00516     ),
00517   );
00518   // - status
00519   $data['system']['status'] = array(
00520     'title' => t('Status'),
00521     'help' => t('Boolean indicating whether or not this item is enabled.'),
00522     'field' => array(
00523       'handler' => 'views_handler_field_boolean',
00524       'click sortable' => TRUE,
00525     ),
00526     'argument' => array(
00527       'handler' => 'views_handler_argument_numeric',
00528       'name field' => 'status', // the field to display in the summary.
00529     ),
00530     'filter' => array(
00531       'handler' => 'views_handler_filter_boolean_operator',
00532     ),
00533     'sort' => array(
00534       'handler' => 'views_handler_sort',
00535     ),
00536   );
00537   // - schema version
00538   $data['system']['schema_version'] = array(
00539     'title' => t('Schema version'),
00540     '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."),
00541     'field' => array(
00542       'handler' => 'views_handler_field_numeric',
00543       'click sortable' => TRUE,
00544     ),
00545     'argument' => array(
00546       'handler' => 'views_handler_argument_numeric',
00547       'name field' => 'schema_version', // the field to display in the summary.
00548     ),
00549     'filter' => array(
00550       'handler' => 'views_handler_filter_numeric',
00551     ),
00552     'sort' => array(
00553       'handler' => 'views_handler_sort',
00554     ),
00555   );
00556 
00557   return $data;
00558 }
00559 
00560 function _views_file_status($choice = NULL) {
00561   $status = array(
00562     0 => t('Temporary'),
00563     FILE_STATUS_PERMANENT => t('Permanent'),
00564   );
00565 
00566   if (isset($choice)) {
00567     return isset($status[$choice]) ? $status[$choice] : t('Unknown');
00568   }
00569 
00570   return $status;
00571 }
00572 

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1