/**
	 * function __get
	 * Overrides QueryRecord __get to implement custom object properties
	 * @param $name string Name of property to return
	 * @return mixed The requested field value
	 */
	public function __get( $name )
	{
		switch ( $name ) {
			case 'vocabulary':
				$out = Vocabulary::get_by_id( $this->vocabulary_id );
				break;
			case 'tag_text_searchable':
				// if it's got spaces, then quote it.
				if ( strpos( $this->term_display, ' ' ) !== false ) {
					$out = '\'' . str_replace( "'", "\'", $this->term_display ) . '\'';
				}
				else {
					$out = $this->term_display;
				}
				break;
			case 'count':
				$out = (int)$this->count();
				break;
			case 'id':
				return (int)parent::__get( $name );
			case 'info':
				return $this->get_info();
			default:
				$out = parent::__get( $name );
				break;
		}
		return $out;
	}
Exemple #2
0
 public function term_form_save($form)
 {
     $menu_vocab = intval($form->menu->value);
     $menu = Vocabulary::get_by_id($menu_vocab);
     $menu_type_data = $this->get_menu_type_data();
     if (isset($form->term)) {
         $term = Term::get(intval((string) $form->term->value));
         // maybe we should check if term exists? Or put that in the conditional above?
         $object_types = $term->object_types();
         $type = $object_types[0]->type;
         // that's twice we've grabbed the $term->object_types()[0]. Maybe this is a job for a function?
         if (isset($menu_type_data[$type]['save'])) {
             $menu_type_data[$type]['save']($menu, $form);
         }
         $form->has_result = 'updated';
     } else {
         // if no term is set, create a new item.
         // create a term for the link, store the URL
         $type = $form->menu_type->value;
         if (isset($menu_type_data[$type]['save'])) {
             $menu_type_data[$type]['save']($menu, $form);
         }
         $form->has_result = 'added';
     }
 }
 public function term_form_save($form)
 {
     $menu_vocab = intval($form->menu->value);
     $menu = Vocabulary::get_by_id($menu_vocab);
     $menu_type_data = $this->get_menu_type_data();
     if (isset($form->term)) {
         $term = Term::get(intval((string) $form->term->value));
         // maybe we should check if term exists? Or put that in the conditional above?
         $object_types = $term->object_types();
         $type = $object_types[0]->type;
         // that's twice we've grabbed the $term->object_types()[0]. Maybe this is a job for a function?
         if (isset($menu_type_data[$type]['save'])) {
             $menu_type_data[$type]['save']($menu, $form);
         }
     } else {
         // if no term is set, create a new item.
         // create a term for the link, store the URL
         $type = $form->menu_type->value;
         if (isset($menu_type_data[$type]['save'])) {
             $menu_type_data[$type]['save']($menu, $form);
         }
         // if not for this redirect, this whole if/else could be simplified considerably.
         Utils::redirect(URL::get('admin', array('page' => 'menu_iframe', 'action' => $type, 'menu' => $menu_vocab, 'result' => 'added')));
     }
 }
Exemple #4
0
 /**
  * function __get
  * Overrides QueryRecord __get to implement custom object properties
  * @param $name string Name of property to return
  * @return mixed The requested field value
  **/
 public function __get($name)
 {
     switch ($name) {
         case 'vocabulary':
             return Vocabulary::get_by_id($this->vocabulary_id);
         default:
             return parent::__get($name);
     }
 }