當前位置: 首頁>>代碼示例>>PHP>>正文


PHP entity_selector::add_field方法代碼示例

本文整理匯總了PHP中entity_selector::add_field方法的典型用法代碼示例。如果您正苦於以下問題:PHP entity_selector::add_field方法的具體用法?PHP entity_selector::add_field怎麽用?PHP entity_selector::add_field使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在entity_selector的用法示例。


在下文中一共展示了entity_selector::add_field方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: foreach

 function setup_associated_items()
 {
     // populate associated entity selector from scratch
     $ass_es = new entity_selector();
     $ass_es->add_type($this->type_id);
     if ($this->rel_direction == 'a_to_b') {
         $ass_es->add_right_relationship($this->admin_page->id, $this->admin_page->rel_id);
     } else {
         $ass_es->add_left_relationship($this->admin_page->id, $this->admin_page->rel_id);
     }
     $ass_es->add_right_relationship_field('owns', 'entity', 'id', 'site_owner_id');
     if ($this->rel_direction == 'a_to_b' && $this->check_is_rel_sortable()) {
         $this->columns['rel_sort_order'] = true;
         $ass_es->add_field('relationship', 'id', 'rel_id');
         $ass_es->add_rel_sort_field($this->admin_page->id);
         $ass_es->set_order('relationship.rel_sort_order ASC');
         if ($this->_cur_user_has_edit_privs() && !$this->get_relationship_lock_state()) {
             $this->alter_order_enable = true;
         }
     } else {
         $ass_es->add_field('relationship', 'site', 'rel_site_id');
     }
     if ($this->assoc_viewer_order_by($ass_es)) {
         $this->alter_order_enable = false;
     }
     $this->ass_vals = $ass_es->run_one();
     // check sharing on associated entities
     foreach ($this->ass_vals as $k => $val) {
         // setup sharing value
         if ($this->site_id == $val->get_value('site_owner_id')) {
             $this->ass_vals[$k]->set_value('sharing', 'owns');
         } else {
             $this->ass_vals[$k]->set_value('sharing', $this->check_borrow_status($k));
         }
     }
     // this verifies and updates the associated items rel_sort_order if this is an a to b relationship
     if ($this->rel_direction == 'a_to_b' && $this->check_is_rel_sortable()) {
         if (count($this->ass_vals) == 1 && isset($this->columns['rel_sort_order'])) {
             unset($this->columns['rel_sort_order']);
         }
         if ($ass_es->orderby == 'relationship.rel_sort_order ASC') {
             $rel_update_array = $this->validate_rel_sort_order($this->ass_vals, true);
         } else {
             $rel_update_array = $this->validate_rel_sort_order($this->ass_vals);
         }
         if (count($rel_update_array) > 0) {
             foreach ($rel_update_array as $k => $v) {
                 update_relationship($k, array('rel_sort_order' => $v));
             }
         }
     }
 }
開發者ID:hunter2814,項目名稱:reason_package,代碼行數:52,代碼來源:associate.php

示例2:

 function alter_values()
 {
     $parent = new entity_selector();
     $parent->add_field('entity2', 'id', 'parent_id');
     $parent->add_table('allowable_relationship2', 'allowable_relationship');
     $parent->add_table('relationship2', 'relationship');
     $parent->add_table('entity2', 'entity');
     $parent->add_relation('entity2.id =  relationship2.entity_b');
     $parent->add_relation('entity.id = relationship2.entity_a');
     $parent->add_relation('relationship2.type = allowable_relationship2.id');
     $parent->add_relation('allowable_relationship2.name LIKE "%parent%"');
     $parent->set_order('sortable.sort_order');
     $this->es->swallow($parent);
     $this->remove_column('id');
 }
開發者ID:hunter2814,項目名稱:reason_package,代碼行數:15,代碼來源:multiple_root_tree.php

示例3: current

 function _get_max_sort_order_value($page_id)
 {
     $es = new entity_selector();
     $es->add_type(id_of('image'));
     $es->add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));
     $es->add_field('relationship', 'id', 'rel_id');
     $es->add_rel_sort_field($page_id);
     $es->set_order('relationship.rel_sort_order DESC');
     $es->set_num(1);
     $images = $es->run_one();
     if (!empty($images)) {
         $image = current($images);
         if ($image->get_value('rel_sort_order')) {
             return $image->get_value('rel_sort_order');
         }
     }
     return 0;
 }
開發者ID:natepixel,項目名稱:reason_package,代碼行數:18,代碼來源:image_import.php

示例4: get_relationships_to_update

function get_relationships_to_update($left_side_entity_type, $right_side_entity_type, $relationship_type, $left_side_relation_limiter, $ordering)
{
    $es = new entity_selector();
    $es->add_type(id_of($left_side_entity_type));
    if (!empty($left_side_relation_limiter)) {
        $es->add_relation($left_side_relation_limiter);
    }
    $result = $es->run_one();
    foreach ($result as $entity) {
        if ($entity->has_left_relation_of_type(relationship_id_of($relationship_type))) {
            $owns_entity = $entity->get_owner();
            $site_id = !empty($owns_entity) ? $owns_entity->id() : '';
            $es2 = new entity_selector($site_id);
            $es2->add_type(id_of($right_side_entity_type));
            $es2->set_sharing('owns,borrows');
            $es2->add_right_relationship($entity->id(), relationship_id_of($relationship_type));
            if (!empty($site_id)) {
                $es2->add_field('ar', 'name', 'sharing');
            }
            $es2->add_field('relationship', 'id', 'rel_id');
            if (!empty($ordering)) {
                $es2->set_order($ordering);
            }
            //echo '<hr> '.$es2->get_one_query() . '<hr/>';
            $result2 = $es2->run_one();
            $sort_order = 1;
            if (is_array($result2)) {
                foreach ($result2 as $entity) {
                    $update_array[$entity->get_value('rel_id')] = $sort_order;
                    $sort_order++;
                }
            }
        }
    }
    if (isset($update_array) && count($update_array) > 0) {
        return $update_array;
    } else {
        trigger_error('Could not find anything to update - check to make sure you have entered a valid left and right side entity, and relationship type');
        die;
    }
}
開發者ID:hunter2814,項目名稱:reason_package,代碼行數:41,代碼來源:news_to_image_sorting.php

示例5:

 function get_images_in_new_order($page_id)
 {
     $es = new entity_selector();
     $es->add_type(id_of('image'));
     $es->add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));
     $es->add_rel_sort_field($page_id, relationship_id_of('minisite_page_to_image'), 'rel_sort_order');
     $es->add_field('relationship', 'id', 'rel_id');
     $es->set_order('rel_sort_order ASC, dated.datetime ASC, meta.description ASC, entity.id ASC');
     return $es->run_one();
 }
開發者ID:hunter2814,項目名稱:reason_package,代碼行數:10,代碼來源:image_ordering.php

示例6: entity

 /**
  * prep_for_run returns the array describing which relationships need to be updated, and also verifies that the entity that is
  * being moved is in the same row position it was prior to the request (gracefully handles double clicks and the like)
  *
  * @return mixed array describing new sort orders according to relationship id, or false
  */
 function prep_for_run()
 {
     $e = new entity($this->entity_id);
     $type_id = $e->get_value('type');
     // performs an appropriate entity selection - populates class variables with specifics for run method.
     $es = new entity_selector($this->site_id);
     $es->add_type($type_id);
     $es->set_sharing('owns,borrows');
     $es->add_field('relationship', 'id', 'relationship_id');
     $es->add_right_relationship($this->left_entity_id, $this->al_relationship_id);
     $es->add_rel_sort_field($this->left_entity_id);
     if ($this->direction == 'moveup') {
         $es->set_order('rel_sort_order DESC');
     } else {
         $es->set_order('rel_sort_order ASC');
     }
     $result = $es->run_one();
     $resultcount = count($result);
     $read_next = false;
     $rowcounter = 0;
     foreach ($result as $k => $v) {
         if ($read_next == true) {
             $new_rel_sort_order = $v->get_value('rel_sort_order');
             $relationship_id_2 = $v->get_value('relationship_id');
             break;
         } elseif ($k == $this->entity_id) {
             if ($this->direction == 'moveup' && $this->row_id == $resultcount - $rowcounter || $this->direction == 'movedown' && $this->row_id == $rowcounter + 1) {
                 $old_rel_sort_order = $v->get_value('rel_sort_order');
                 $relationship_id_1 = $v->get_value('relationship_id');
                 $read_next = true;
             } else {
                 trigger_error('There was a problem modifying the relationship sort order - the entity being moved does not have the same location as when the request was initiated. This can happen from multiple clicks or when multiple people are modifying the sort order.');
                 return false;
             }
         } else {
             unset($result[$k]);
             $rowcounter++;
         }
     }
     if (is_numeric($relationship_id_1) && is_numeric($relationship_id_2) && is_numeric($new_rel_sort_order) && is_numeric($old_rel_sort_order)) {
         return array($relationship_id_1 => $new_rel_sort_order, $relationship_id_2 => $old_rel_sort_order);
     } else {
         return false;
     }
 }
開發者ID:hunter2814,項目名稱:reason_package,代碼行數:51,代碼來源:rel_sort.php


注:本文中的entity_selector::add_field方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。