API:EPrints/DataObj/Subject
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
- 1 NAME
- 2 DESCRIPTION
- 2.1 $thing = EPrints::DataObj::Subject->get_system_field_info
- 2.2 $subject = EPrints::DataObj::Subject->new( $session, $subjectid )
- 2.3 $subject = EPrints::DataObj::Subject->new_from_data( $session, $data )
- 2.4 $success = $subject->commit( [$force] )
- 2.5 $success = $subject->remove
- 2.6 $dataset = EPrints::DataObj::Subject->get_dataset_id
- 2.7 EPrints::DataObj::Subject::remove_all( $session )
- 2.8 $child_subject = $subject->create_child( $id, $name, $depositable )
- 2.9 @children = $subject->get_children
- 2.10 @parents = $subject->get_parents
- 2.11 $boolean = $subject->can_post( [$user] )
- 2.12 $xhtml = $subject->render_with_path( $session, $topsubjid )
- 2.13 @paths = $subject->get_paths( $session, $topsubjid )
- 2.14 $subject_pairs = $subject->get_subjects ( [$postable_only], [$show_top_level], [$nes_tids], [$no_nest_label] )
- 2.15 $label = EPrints::DataObj::Subject::subject_label( $session, $subject_id )
- 2.16 ( $subject_map, $reverse_map ) = EPrints::DataObj::Subject::get_all( $session )
- 2.17 $count = $subject->count_eprints( $dataset )
- 2.18 $boolean = EPrints::DataObj::Subject::valid_id( $id )
- 2.19 $subj->render()
NAME
EPrints::DataObj::Subject - Class and methods relating to the subejcts tree.
DESCRIPTION
This class represents a single node in the subejcts tree. It also contains a number of methods for handling the entire tree.
EPrints::DataObj::Subject is a subclass of EPrints::DataObj
$thing = EPrints::DataObj::Subject->get_system_field_info
Return an array describing the system metadata of the Subject dataset.
$subject = EPrints::DataObj::Subject->new( $session, $subjectid )
Create a new subject object given the id of the subject. The values for the subject are loaded from the database.
$subject = EPrints::DataObj::Subject->new_from_data( $session, $data )
Construct a new subject object from a hash reference containing the relevant fields. Generally this method is only used to construct new Subjects coming out of the database.
$success = $subject->commit( [$force] )
Commit this subject to the database, but only if any fields have changed since we loaded it.
If $force is set then always commit, even if there appear to be no changes.
$success = $subject->remove
Remove this subject from the database.
$dataset = EPrints::DataObj::Subject->get_dataset_id
Returns the id of the EPrints::DataSet object to which this record belongs.
EPrints::DataObj::Subject::remove_all( $session )
Static function.
Remove all subjects from the database. Use with care!
$child_subject = $subject->create_child( $id, $name, $depositable )
Similar to EPrints::DataObj::Subject::create, but this creates the new subject as a child of the current subject.
@children = $subject->get_children
Return a list of EPrints::DataObj::Subject objects which are direct children of the current subject.
@parents = $subject->get_parents
Return a list of EPrints::DataObj::Subject objects which are direct parents of the current subject.
$boolean = $subject->can_post( [$user] )
Determines whether the given user can post in this subject.
Currently there is no way to configure subjects for certain users, so this just returns the true or false depending on the "depositable" flag.
$xhtml = $subject->render_with_path( $session, $topsubjid )
Return the name of this subject including it's path from $topsubjid.
$topsubjid must be an ancestor of this subject.
eg.
Library of Congress > B Somthing > BC Somthing more Detailed
@paths = $subject->get_paths( $session, $topsubjid )
This function returns all the paths from this subject back up to the specified top subject.
@paths is an array of array references. Each of the inner arrays is a list of subject id's describing a path down the tree from $topsubjid to $session.
$subject_pairs = $subject->get_subjects ( [$postable_only], [$show_top_level], [$nes_tids], [$no_nest_label] )
Return a reference to an array. Each item in the array is a two element list.
The first element in the list is an indenifier string.
The second element is a utf-8 string describing the subject (in the current language), including all the items above it in the tree, but only as high as this subject.
The subjects which are returned are this item and all its children, and childrens children etc. The order is it returns this subject, then the first child of this subject, then children of that (recursively), then the second child of this subject etc.
If $postable_only is true then filter the results to only contain subjects which have the "depositable" flag set to true.
If $show_top_level is not true then the pair representing the current subject is not included at the start of the list.
If $nest_ids is true then each then the ids retured are nested so that the ids of the children of this subject are prefixed with this subjects id and a colon, and their children are prefixed by their nested id and a colon. eg. L:LC:LC003 rather than just "LC003"
if $no_nest_label is true then the subject label only contains the name of the subject, not the higher level ones.
A default result from this method would look something like this:
[ [ "D", "History" ], [ "D1", "History: History (General)" ], [ "D111", "History: History (General): Medieval History" ] ]
$label = EPrints::DataObj::Subject::subject_label( $session, $subject_id )
Return the full label of a subject, including parents. Returns undef if the subject id is invalid.
The returned string is encoded in utf8.
( $subject_map, $reverse_map ) = EPrints::DataObj::Subject::get_all( $session )
Get all the subjects for the current archvive of $session.
$subject_map is a reference to a hash. The keys of the hash are the id's of the subjects. The values of the hash are the EPrint::Subject object relating to that id.
$reverse_map is a reference to a hash. Each key is the id of a subject. Each value is a reference to an array. The array contains a EPrints::DataObj::Subject objects, one for each child of the subject with the id. The array is sorted by the labels for the subjects, in the current language.
$count = $subject->count_eprints( $dataset )
Return the number of eprints in the dataset which are in this subject or one of its decendants. Search all fields of type subject.
$boolean = EPrints::DataObj::Subject::valid_id( $id )
Return true if the string is an acceptable identifier for a subject.
This does not check all possible illegal values, yet.
$subj->render()
undocumented