当前位置: 首页>>代码示例>>PHP>>正文


PHP Term::get方法代码示例

本文整理汇总了PHP中Term::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Term::get方法的具体用法?PHP Term::get怎么用?PHP Term::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Term的用法示例。


在下文中一共展示了Term::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __get

 /**
  * 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)
 {
     $term = Term::get(Tags::vocabulary()->id, $this->id);
     switch ($name) {
         case 'tag':
         case 'tag_text':
             $out = $term->term_display;
             break;
         case 'tag_text_searchable':
             // if it's got spaces, then quote it.
             if (strpos($term->term_display, ' ') !== FALSE) {
                 $out = '\'' . str_replace("'", "\\'", $term->term_display) . '\'';
             } else {
                 $out = $term->term_display;
             }
             break;
         case 'slug':
         case 'tag_slug':
             $out = $term->term;
             break;
         case 'count':
             $out = $this->get_count();
             break;
         default:
             break;
     }
     return $out;
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:34,代码来源:tag.php

示例2: term_form_save

 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')));
     }
 }
开发者ID:habari-extras,项目名称:termmenus,代码行数:25,代码来源:termmenus.plugin.php

示例3: term_form_save

 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';
     }
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:25,代码来源:menus.plugin.php

示例4: get_term

 /**
  * Gets the term object by id. No parameter returns the root Term object.
  * @param integer $term_id The id of the term to fetch, or null for the root node
  * @return Term The Term object requested
  **/
 public function get_term($term_id = null)
 {
     return Term::get($this->id, $term_id);
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:9,代码来源:vocabulary.php

示例5: test_not_descendants

 public function test_not_descendants()
 {
     $v = Vocabulary::create(array('name' => 'animals', 'description' => 'Types of animals.', 'features' => array('hierarchical')));
     $root = $v->add_term('Animal Kingdom');
     $backbone = $v->add_term('Backbone', $root);
     $mammal = $v->add_term('Mammal', $backbone);
     $lungs = $v->add_term('Lungs', $backbone);
     $reptile = $v->add_term('Reptile', $backbone);
     $bird = $v->add_term('Bird', $backbone);
     $gills = $v->add_term('Gills', $backbone);
     $fish = $v->add_term('Fish', $gills);
     $amphibian = $v->add_term('Amphibian', $gills);
     $no_backbone = $v->add_term('No Backbone', $root);
     $starfish = $v->add_term('Starfish', $no_backbone);
     $mollusk = $v->add_term('Mollusk', $no_backbone);
     $legs = $v->add_term('Jointed Legs', $no_backbone);
     $snail = $v->add_term('Snail', $v->get_term($mollusk->id));
     $clam = $v->add_term('Clam', $v->get_term($mollusk->id));
     $insect = $v->add_term('Insect', $v->get_term($legs->id));
     $spider = $v->add_term('Spider', $v->get_term($legs->id));
     $crustacean = $v->add_term('Crustacean', $v->get_term($legs->id));
     $not_descendants = Term::get($v, $backbone->id)->not_descendants();
     $s = array();
     foreach ($not_descendants as $el) {
         $s[] = (string) $el;
     }
     $expected = array($root, $no_backbone, $starfish, $mollusk, $legs, $snail, $clam, $insect, $spider, $crustacean);
     $this->assertTrue(10 == count($not_descendants), sprintf('Found: %s', implode(', ', $s)));
     $e = array();
     foreach ($expected as $el) {
         $e[] = (string) $el;
     }
     $this->assertTrue(0 == count(array_diff($s, $e)));
     // clean up
     $v->delete();
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:36,代码来源:taxonomyTest.php


注:本文中的Term::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。