diff --git a/core/modules/profile2/lib/Drupal/profile2/Plugin/views/argument/Pid.php b/core/modules/profile2/lib/Drupal/profile2/Plugin/views/argument/Pid.php new file mode 100644 index 0000000..a09f6a4 --- /dev/null +++ b/core/modules/profile2/lib/Drupal/profile2/Plugin/views/argument/Pid.php @@ -0,0 +1,37 @@ +value); + foreach ($profiles as $profile) { + $titles[] = check_plain($profile->label()); + } + + return $titles; + } + +} diff --git a/core/modules/profile2/lib/Drupal/profile2/Plugin/views/filter/Type.php b/core/modules/profile2/lib/Drupal/profile2/Plugin/views/filter/Type.php new file mode 100644 index 0000000..47f68f5 --- /dev/null +++ b/core/modules/profile2/lib/Drupal/profile2/Plugin/views/filter/Type.php @@ -0,0 +1,49 @@ +value_options)) { + $this->value_title = t('Profile types'); + $types = entity_get_controller('profile2_type')->load(); + + $options = array(); + foreach ($types as $type => $entity) { + $options[$entity->get('id')] = $entity->get('label'); + } + + asort($options); + $this->value_options = $options; + } + } + + /** + * Overrides \Drupal\views\Plugin\views\filter\InOperator::query(). + */ + public function query() { + // Make sure that the entity base table is in the query. + $this->ensureMyTable(); + parent::query(); + } + +} diff --git a/core/modules/profile2/profile2.views.inc b/core/modules/profile2/profile2.views.inc new file mode 100644 index 0000000..aa815c9 --- /dev/null +++ b/core/modules/profile2/profile2.views.inc @@ -0,0 +1,169 @@ + t('Profile'), + 'base' => array( + 'field' => 'pid', + 'title' => t('Profile'), + 'weight' => -10, + 'access query tag' => 'profile2_access', + 'defaults' => array( + 'field' => 'pid', + ), + ), + 'entity type' => 'profile2', + // @todo wizard id/integration. + ); + + // pid + $data['profile']['pid'] = array( + 'title' => t('Pid'), + 'help' => t('The profile ID.'), + 'field' => array( + 'id' => 'numeric', + ), + 'argument' => array( + 'id' => 'profile2_pid', + 'name field' => 'label', + 'numeric' => TRUE, + 'validate type' => 'pid', + ), + 'filter' => array( + 'id' => 'numeric', + ), + 'sort' => array( + 'id' => 'standard', + ), + ); + + // type. + $data['profile']['type'] = array( + 'title' => t('Type'), + 'help' => t('The profle type.'), + 'field' => array( + 'id' => 'node_type', + ), + 'sort' => array( + 'id' => 'standard', + ), + 'filter' => array( + 'id' => 'profile2_type', + ), + 'argument' => array( + 'id' => 'string', + ), + ); + + // uid + $data['profile']['uid'] = array( + 'title' => t('Uid'), + 'help' => t('The user ID'), + 'field' => array( + 'id' => 'user', + ), + 'argument' => array( + 'id' => 'user_uid', + 'name field' => 'name', + ), + 'filter' => array( + 'title' => t('Name'), + 'id' => 'numeric', + ), + 'sort' => array( + 'id' => 'standard', + ), + 'relationship' => array( + 'title' => t('Profile author'), + 'help' => t('Relate a profile to the user who created it. This relationship will create one record for each profile created by the user.'), + 'id' => 'standard', + 'base' => 'users', + 'field' => 'uid', + 'label' => t('author'), + ), + ); + + // langcode. + if (module_exists('language')) { + $data['profile']['langcode'] = array( + 'title' => t('Language'), + 'help' => t('The langcode the profile is in.'), + 'field' => array( + 'id' => 'string', + ), + 'filter' => array( + 'id' => 'language', + ), + 'argument' => array( + 'id' => 'language', + ), + 'sort' => array( + 'id' => 'standard', + ), + ); + } + + // label. + $data['profile']['label'] = array( + 'title' => t('Label'), + 'help' => t('The profile label.'), + 'field' => array( + 'field' => 'label', + 'group' => t('Profile'), + 'id' => 'node', + ), + 'sort' => array( + 'id' => 'standard', + ), + 'filter' => array( + 'id' => 'string', + ), + 'argument' => array( + 'id' => 'string', + ), + ); + + // created field + $data['profile']['created'] = array( + 'title' => t('Post date'), + 'help' => t('The date the profile was created.'), + 'field' => array( + 'id' => 'date', + ), + 'sort' => array( + 'id' => 'date' + ), + 'filter' => array( + 'id' => 'date', + ), + ); + + // changed field + $data['profile']['changed'] = array( + 'title' => t('Updated date'), + 'help' => t('The date the profile was last updated.'), + 'field' => array( + 'id' => 'date', + ), + 'sort' => array( + 'id' => 'date' + ), + 'filter' => array( + 'id' => 'date', + ), + ); + + return $data; +}