Exemplo n.º 1
0
 /**
  * function __get
  * Overrides QueryRecord __get to implement custom object properties
  * @param string Name of property to return
  * @return mixed The requested field value
  */
 public function __get($name)
 {
     $fieldnames = array_merge(array_keys($this->fields), array('permalink', 'tags', 'comments', 'comment_count', 'approved_comment_count', 'comment_feed_link', 'author', 'editlink'));
     if (!in_array($name, $fieldnames) && strpos($name, '_') !== false) {
         preg_match('/^(.*)_([^_]+)$/', $name, $matches);
         list($junk, $name, $filter) = $matches;
     } else {
         $filter = false;
     }
     switch ($name) {
         case 'statusname':
             $out = self::status_name($this->status);
             break;
         case 'typename':
             $out = self::type_name($this->content_type);
             break;
         case 'permalink':
             $out = $this->get_permalink();
             break;
         case 'editlink':
             $out = $this->get_editlink();
             break;
         case 'tags':
             $out = $this->get_tags();
             break;
         case 'comments':
             $out = $this->get_comments();
             break;
         case 'comment_count':
             $out = $this->get_comments()->count();
             break;
         case 'approved_comment_count':
             $out = Comments::count_by_id($this->id);
             break;
         case 'comment_feed_link':
             $out = $this->get_comment_feed_link();
             break;
         case 'author':
             $out = $this->get_author();
             break;
         case 'info':
             $out = $this->get_info();
             break;
         default:
             $out = parent::__get($name);
             break;
     }
     $out = Plugins::filter("post_get", $out, $name, $this);
     $out = Plugins::filter("post_{$name}", $out, $this);
     if ($filter) {
         $out = Plugins::filter("post_{$name}_{$filter}", $out, $this);
     }
     return $out;
 }
Exemplo n.º 2
0
	/**
	 * function __get
	 * Overrides QueryRecord __get to implement custom object properties
	 * @param string Name of property to return
	 * @return mixed The requested field value
	 */
	public function __get( $name )
	{
		// some properties are considered special and accidentally filtering them would be bad, so we exclude those
		$fieldnames = array_merge( array_keys( $this->fields ), array( 'permalink', 'tags', 'comments', 'comment_count', 'approved_comment_count', 'comment_feed_link', 'author', 'editlink', 'info' ) );
		$filter = false;
		if ( !in_array( $name, $fieldnames ) && strpos( $name, '_' ) !== false ) {
			$field_matches = implode('|', $fieldnames);
			if(preg_match( '/^(' . $field_matches . ')_(.+)$/', $name, $matches )) {
				list( $junk, $name, $filter )= $matches;
			}
		}

		switch ( $name ) {
			case 'statusname':
				$out = self::status_name( $this->status );
				break;
			case 'typename':
				$out = self::type_name( $this->content_type );
				break;
			case 'permalink':
				$out = $this->get_permalink();
				break;
			case 'editlink':
				$out = $this->get_editlink();
				break;
			case 'tags':
				$out = $this->get_tags();
				break;
			case 'comments':
				$out = $this->get_comments();
				break;
			case 'comment_count':
				$out = $this->get_comments()->count();
				break;
			case 'approved_comment_count':
				$out = Comments::count_by_id( $this->id );
				break;
			case 'comment_feed_link':
				$out = $this->get_comment_feed_link();
				break;
			case 'author':
				$out = $this->get_author();
				break;
			case 'info':
				$out = $this->get_info();
				break;
			default:
				$out = parent::__get( $name );
				break;
		}
		$out = Plugins::filter( "post_get", $out, $name, $this );
		$out = Plugins::filter( "post_{$name}", $out, $this );
		if ( $filter ) {
			$out = Plugins::filter( "post_{$name}_{$filter}", $out, $this );
		}
		return $out;
	}
Exemplo n.º 3
0
 /**
  * Overrides QueryRecord __get to implement custom object properties
  * @param string $name Name of property to return
  * @return mixed The requested field value
  */
 public function __get($name)
 {
     // some properties are considered special and accidentally filtering them would be bad, so we exclude those
     $fieldnames = array_merge(array_keys($this->fields), array('permalink', 'tags', 'comments', 'comment_count', 'approved_comment_count', 'comment_feed_link', 'author', 'editlink', 'info'));
     $filter = false;
     if (!in_array($name, $fieldnames) && strpos($name, '_') !== false) {
         $field_matches = implode('|', $fieldnames);
         if (preg_match('/^(' . $field_matches . ')_(.+)$/', $name, $matches)) {
             list($junk, $name, $filter) = $matches;
         }
     }
     switch ($name) {
         case 'content':
             if ($filter == 'internal') {
                 $out = parent::__get('content');
             } else {
                 $out = parent::__get('cached_content');
                 // Didn't bother to store a cached version? Run the prerender filter on the raw version.
                 if (empty($out)) {
                     $out = Plugins::filter("post_prerender_content", parent::__get('content'), $this);
                     // Queue rendered content for writing to cached_content field?
                 }
             }
             break;
         case 'statusname':
             $out = self::status_name($this->status);
             break;
         case 'typename':
             $out = self::type_name($this->content_type);
             break;
         case 'permalink':
             $out = $this->get_permalink();
             break;
         case 'editlink':
             $out = $this->get_editlink();
             break;
         case 'tags':
             $out = $this->get_tags();
             break;
         case 'comments':
             $out = $this->get_comments();
             break;
         case 'comment_count':
             $out = $this->get_comments()->count();
             break;
         case 'approved_comment_count':
             $out = Comments::count_by_id($this->id);
             break;
         case 'comment_feed_link':
             $out = $this->get_comment_feed_link();
             break;
         case 'author':
             $out = $this->get_author();
             break;
         case 'info':
             $out = $this->get_info();
             break;
         case 'excerpt':
             $field = 'content' . ($filter ? '_' . $filter : '_out');
             $out = $this->__get($field);
             if (!Plugins::implemented('post_excerpt', 'filter')) {
                 $out = Format::more($out, $this, Options::get('excerpt_settings', array('max_paragraphs' => 2)));
             }
             break;
         default:
             $out = parent::__get($name);
             break;
     }
     if ($filter != 'internal') {
         $out = Plugins::filter("post_get", $out, $name, $this);
         $out = Plugins::filter("post_{$name}", $out, $this);
     }
     if ($filter) {
         $out = Plugins::filter("post_{$name}_{$filter}", $out, $this);
     }
     return $out;
 }