* @author Vasilis Georgoudis * @author Corentin Perrot */ class Pressbooks_Metadata_Article extends Pressbooks_Metadata_Type { /** * The variable that holds all parent required properties * * @since 0.13 * @access public */ static $required_parent_props = array( 'author', 'datePublished', 'headline', 'image', 'publisher' ); /** * The variable that holds the values for the settings for this schema type * * @since 0.13 * @access public */ static $type_setting = array('article_type' => array('Article Type','http://schema.org/Article')); /** * The variable that holds the parents for the type * * @since 0.13 * @access public */ static $type_parents = array( 'schemaTypes\Pressbooks_Metadata_Thing', 'schemaTypes\Pressbooks_Metadata_CreativeWork' ); /** * The variable that holds the properties of this schema type * * @since 0.13 * @access public */ static $type_properties = array( 'articleBody' => array(false,'Article Body','The actual body of the article.'), 'articleSection' => array(false,'Article Section','Articles may belong to one or more "sections" in a magazine or newspaper, such as Sports, Lifestyle, etc.'), 'pageEnd' => array(false,'Page End','The page on which the work ends; for example "138" or "xvi".'), 'pageStart' => array(false,'Page Start','The identifier for the Article used by the article provider (e.g. CS101 or 6.001).'), 'pagination' => array(false,'Pagination','Any description of pages that is not separated into pageStart and pageEnd; for example, "1-6, 9, 55" or "10-12, 46-49".'), 'speakable' => array(false,'Speakable','Indicates sections of a Web page that are particularly "speakable" in the sense of being highlighted as being especially appropriate for text-to-speech conversion. Other sections of a page may also be usefully spoken in particular circumstances; the "speakable" property serves to indicate the parts most likely to be generally useful for speech. The speakable property can be repeated an arbitrary number of times, with three kinds of possible "content-locator" values: 1.) id-value URL references - uses id-value of an element in the page being annotated. The simplest use of speakable has (potentially relative) URL values, referencing identified sections of the document concerned. 2.) CSS Selectors - addresses content in the annotated page, eg. via class attribute. Use the cssSelector property. 3.) XPaths - addresses content via XPaths (assuming an XML view of the content). Use the xpath property. For more sophisticated markup of speakable sections beyond simple ID references, either CSS selectors or XPath expressions to pick out document section(s) as speakable. For this we define a supporting type, SpeakableSpecification which is defined to be a possible value of the speakable property.'), 'wordCount' => array(false,'Word Count','The number of words in the text of the Article.') ); public function __construct($type_level_input) { parent::__construct($type_level_input); $this->type_fields = $this->get_all_properties(); $this->class_name = __CLASS__ .'_'. $this->type_level; $this->pmdt_populate_names(self::$type_setting); $this->pmdt_add_metabox($this->type_level); } /** * Function used for combining the current types properties with its parents fields * * @since 0.13 * @access public */ public function get_all_properties() { $properties = self::$type_properties; foreach(self::$type_parents as $parentType){ $properties = array_merge($properties,$parentType::type_properties); } return $properties; } /** * Function used for comparing the instances of the schema types * * @since 0.13 * @access public */ public function __toString() { return $this->class_name; } }