TSDBook Class Reference
[Textbook Hierarchy Objects]

Represents "Book" in the TSD textbook hierarchy. More...

Inheritance diagram for TSDBook:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 __construct ($id= '')
 Initializes new Book object.
 addChapter ($name)
 Creates a new chapter in this book.
 delete ()
 Delete this book.
 deleteChapterByName ($name)
 Deletes any child chapters with given name.
 getIdentifier ()
 Returns a string that identifies this book.
 getParent ()
 INSERT BRIEF DESCRIPTION HERE.
 isValid ()
 Determines whether book is valid to be in the database.
 listChildren ($constraints=array(), $limit=array(), $order=array(), $cnt=false)
 Returns a list of all chapters contained in this book, constrained by given criteria.
 listValidChildren ($constraints=array(), $limit=array(), $order=array(), $cnt=false)
 Returns list of chapters that have more than one section.
 setCoverImage ($snapPath)
 Sets or resets the cover image of this book.
 uploadCoverImage ($tmpFile, $fileName= '')
 Uploads a new cover image for this book.

Static Public Member Functions

static getList ($constraints=array(), $limit=array(), $order=array(), $cnt=false)
 Returns a list of all books, constrained by given criteria.


Detailed Description

Represents "Book" in the TSD textbook hierarchy.

A book contains zero or more chapters, which may contain zero or more sections. A book is the root of a tree in the textbook side of TSD. This class provides methods to query books, list books, create new books, delete books and align/unalign books with resources.

To change the cover image of the book, use setCoverImage() or uploadCoverImage().

Attributes:


Constructor & Destructor Documentation

TSDBook::__construct ( id = ''  ) 

Initializes new Book object.

If $id is provided, then an attempt is made to populate this object from the database using that ID. Otherwise, an empty object is created, which can be filled with new data to be committed later. You cannot populate after creating the object.

Parameters:
$id [int]: ID of book in database to populate from


Member Function Documentation

TSDBook::addChapter ( name  ) 

Creates a new chapter in this book.

You must have the edit permission to add new chapters.

Parameters:
$name [string]: name of chapter
Returns:
[TSDChapter]: new chapter object, or null if there was an error

TSDBook::delete (  ) 

Delete this book.

Deletion also takes care of removing the resource from Snap2 for the cover image as well.

Returns:
[boolean]: success or failure

TSDBook::deleteChapterByName ( name  ) 

Deletes any child chapters with given name.

This will only delete chapters that belong to this book and only if the name matches exactly (but case insensitive).

Parameters:
$name [string]: name of chapter(s) to delete
Returns:
[boolean]: success or failure

TSDBook::getIdentifier (  ) 

Returns a string that identifies this book.

The identifier string is not meant to uniquely identify the book, but rather for use for display purposes. For books, the identifier is a concatenation of the title with the gradeOrCourse field, separated by a space.

Returns:
[string]: identifier for book

static TSDBook::getList ( constraints = array(),
limit = array(),
order = array(),
cnt = false 
) [static]

Returns a list of all books, constrained by given criteria.

See Guide to Database Constraints for more about how to constraint the resultset. You can also request that the number of results be returned, rather than the results themselves.

Parameters:
$constraints [array]: additional constraints on the result set
$limit [array]: parameters for the LIMIT clause of the query
$order [array]: how to order the results
$cnt [boolean]: whether to return the number of results (if true) or the results themselves (if false, the default)
Returns:
[array]: array of TSDBook, if any, or an integer specifying the number of results that would have been returned (if $cnt == true), or null if there was an error

TSDBook::getParent (  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

TSDBook::isValid (  ) 

Determines whether book is valid to be in the database.

A book is valid if it has a non-empty title and an empty or string gradeOrCourse field, and a null or numeric coverImage field (which should be a snap ID, but this is not checked). The id of the book can either be empty, or a non-negative integer.

Returns:
[boolean]: whether book is valid.

TSDBook::listChildren ( constraints = array(),
limit = array(),
order = array(),
cnt = false 
)

Returns a list of all chapters contained in this book, constrained by given criteria.

See Guide to Database Constraints for more about how to constraint the resultset. You can also request that the number of results be returned, rather than the results themselves.

Only chapters that belong to this book will be returned, although it is theoretically possible to circumvent this with the constraints array. With no arguments, an array of TSDChapter objects is returned, all of which belong to this book object.

Parameters:
$constraints [array]: additional constraints on the result set
$limit [array]: parameters for the LIMIT clause of the query
$order [array]: how to order the results
$cnt [boolean]: whether to return the number of results (if true) or the results themselves (if false, the default)
Returns:
[array]: array of TSDChapter, if any, or an integer specifying the number of results that would have been returned (if $cnt == true), or null if there was an error

TSDBook::listValidChildren ( constraints = array(),
limit = array(),
order = array(),
cnt = false 
)

Returns list of chapters that have more than one section.

This method is the same as listChildren() except that it will only return chapters that have at least one section in them.

Parameters:
$constraints [array]: additional constraints on the result set
$limit [array]: parameters for the LIMIT clause of the query
$order [array]: how to order the results
$cnt [boolean]: whether to return the number of results (if true) or the results themselves (if false, the default)
Returns:
[array]: array of results, if any, or an integer specifying the number of results that would have been returned (if $cnt == true), or null if there was an error

TSDBook::setCoverImage ( snapPath  ) 

Sets or resets the cover image of this book.

This method requires that you have already uploaded the image into Snap2 somewhere. It will then store a link to that image in the database. You must have the edit permission in TSD to use this method.

Parameters:
$snapPath [string]: path to image in Snap2
Returns:
[boolean]: success or failure

TSDBook::uploadCoverImage ( tmpFile,
fileName = '' 
)

Uploads a new cover image for this book.

Unlike setCoverImage() this method allows you to directly upload an image for the cover of the book. It will be uploaded into a special directory in Snap2 and the ID of the image will be stored in the database. You must have the edit permission to use this method.

Parameters:
$tmpFile [string]: path to image file on server
$fileName [string]: original name of file (useful for browser file uploads); defaults to be basename($tmpFile).
Returns:
[boolean]: success or failure


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:04:53 2010 for Common by  doxygen 1.5.6