Example #1
0
	/**
	 * Term constructor
	 * Creates a Term instance
	 *
	 * @param array $paramarray an associative array of initial term values
	 */
	public function __construct( $paramarray = array() )
	{
		// Defaults
		$this->fields = array_merge(
			self::default_fields(),
			$this->fields
		);

		if ( is_string( $paramarray ) ) {
			$paramarray = array(
				'term_display' => $paramarray,
				'term' => Utils::slugify( $paramarray ),
			);
		}

		parent::__construct( $paramarray );

		// TODO does term need to be a slug ?
		// TODO How should we handle neither being present ?
		// A Vocabulary may be used for organization, display, or both.
		// Therefore, a Term can be constructed with a term, term_display, or both
		if ( $this->term == '' ) {
			$this->fields[ 'term' ] = Utils::slugify( $this->fields[ 'term_display' ] );
		}

		$this->exclude_fields( 'id' );
	}
Example #2
0
 /**
  * Constructor for the Tag class.
  * @param array $paramarray an associative array of initial Tag field values.
  **/
 public function __construct($paramarray = array())
 {
     // Defaults
     $this->fields = array_merge(self::default_fields(), $this->fields, $this->newfields);
     parent::__construct($paramarray);
     $this->exclude_fields('id');
 }
Example #3
0
 /**
  * Constructor for the UserGroup class
  * @param array $paramarray an associative array of UserGroup fields
  */
 public function __construct($paramarray = array())
 {
     $this->fields = array_merge(self::default_fields(), $this->fields);
     parent::__construct($paramarray);
     // exclude field keys from the $this->fields array that should not be updated in the database on insert/update
     $this->exclude_fields(array('id'));
 }
Example #4
0
 /**
  * constructor __construct
  * Constructor for the Post class.
  * @param array an associative array of initial Post field values.
  */
 public function __construct($paramarray = array())
 {
     // Defaults
     $this->fields = array_merge(self::default_fields(), $this->fields);
     parent::__construct($paramarray);
     $this->exclude_fields('id');
     /* $this->fields['id'] could be null in case of a new comment. If so, the info object is _not_ safe to use till after set_key has been called. Info records can be set immediately in any other case. */
 }
Example #5
0
 /**
  * constructer
  *
  * @access public
  */
 public function __construct($paramarray = array())
 {
     if (isset($paramarray['ip'])) {
         $paramarray['ip'] = sprintf('%u', ip2long($paramarray['ip']));
     }
     // Defaults
     $this->fields = array_merge(self::default_fields(), $this->fields);
     parent::__construct($paramarray);
     $this->exclude_fields('id');
 }
Example #6
0
 /**
  * Vocabulary constructor
  * Creates a Vocabulary instance
  *
  * @param array $paramarray an associative array of initial vocabulary values
  **/
 public function __construct($paramarray = array())
 {
     // Defaults
     $this->fields = array_merge(self::default_fields(), $this->fields);
     parent::__construct($paramarray);
     $this->exclude_fields('id');
     if (is_string($this->features)) {
         $this->features = unserialize($this->features);
     }
 }
Example #7
0
 /**
  * Constructor for the CronJob class.
  *
  * @see QueryRecord::__construct()
  * @param array $paramarray an associative array or querystring of initial field values
  */
 public function __construct($paramarray = array())
 {
     $this->now = HabariDateTime::date_create();
     // Defaults
     $this->fields = array_merge(self::default_fields(), $this->fields);
     // maybe serialize the callback
     $paramarray = Utils::get_params($paramarray);
     if (isset($paramarray['callback']) && (is_array($paramarray['callback']) || is_object($paramarray['callback']))) {
         $paramarray['callback'] = serialize($paramarray['callback']);
     }
     parent::__construct($paramarray);
     $this->exclude_fields('cron_id');
 }
Example #8
0
 /**
  * Constructor for the LogEntry class
  *
  * @param array $paramarray an associative array of initial LogEntry field values
  */
 public function __construct($paramarray = array())
 {
     // Defaults
     $this->fields = array_merge(self::default_fields(), $this->fields);
     parent::__construct($paramarray);
     if (!isset($this->fields['module'])) {
         $this->fields['module'] = 'habari';
     }
     if (!isset($this->fields['type'])) {
         $this->fields['type'] = 'default';
     }
     if (!isset($this->fields['severity'])) {
         $this->fields['severity'] = 'info';
     }
     if (isset($this->fields['timestamp'])) {
         $this->fields['timestamp'] = HabariDateTime::date_create($this->fields['timestamp']);
     }
     $this->exclude_fields('id');
 }
Example #9
0
	/**
	 * Constructor for the Post class.
	 * @param array $paramarray an associative array of initial Post field values.
	 */
	public function __construct( $paramarray = array() )
	{
		// Defaults
		$this->fields = array_merge(
			self::default_fields(),
			$this->fields
		);

		parent::__construct( $paramarray );
		if ( isset( $this->fields['tags'] ) ) {
			$this->tags_object = Terms::parse( $this->fields['tags'], 'Tag', Tags::vocabulary() );
			unset( $this->fields['tags'] );
		}

		$this->exclude_fields( 'id' );
		/* $this->fields['id'] could be null in case of a new post. If so, the info object is _not_ safe to use till after set_key has been called. Info records can be set immediately in any other case. */
	}