本文整理汇总了PHP中entity_selector::set_env方法的典型用法代码示例。如果您正苦于以下问题:PHP entity_selector::set_env方法的具体用法?PHP entity_selector::set_env怎么用?PHP entity_selector::set_env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity_selector
的用法示例。
在下文中一共展示了entity_selector::set_env方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addslashes
function image_may_be_shown($id)
{
if ($this->params['alternate_source_page_id']) {
$page_id = $this->params['alternate_source_page_id'];
if (!($site_id = get_owner_site_id($page_id))) {
$site_id = $this->site_id;
}
} else {
$page_id = $this->cur_page->id();
$site_id = $this->site_id;
}
$es = new entity_selector();
$es->add_type(id_of('image'));
$es->set_env('site', $site_id);
$es->add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));
$es->add_relation('entity.id = ' . addslashes($id));
$result = $es->run_one();
//echo 'given id='.$id;
if (!empty($result)) {
//echo 'returning true';
return true;
} else {
//echo 'returning false';
return false;
}
}
示例2: init
/**
* Initialize the module
* grabs all the blurbs associated with the current site
* @param $args array
*/
function init($args = array())
{
parent::init($args);
$master_admin_id = id_of('master_admin');
$es = new entity_selector($master_admin_id);
$es->limit_tables();
$es->limit_fields();
$es->add_type(id_of('text_blurb'));
$es->add_right_relationship($this->site_id, relationship_id_of('site_to_announcement_blurb'));
$es->set_env('site', $master_admin_id);
$this->blurbs = $es->run_one();
}
示例3: array
function get_filter_entities()
{
if(is_null($this->filter_entities))
{
$this->filter_entities = array();
foreach($this->filter_types as $filter_name=>$filter_type)
{
$r_id = false;
if(empty($filter_type['relationship'])) trigger_error($filter_type['type'].' does not have a relationship name specified');
else
{
$r_id = relationship_id_of($filter_type['relationship']);
if (!$r_id) trigger_error($filter_type['relationship'] . ' is not a valid allowable relationship');
}
$es = new entity_selector($this->parent->site_id);
$es->add_type(id_of($filter_type['type']));
$es->set_order('entity.name ASC');
$filter_entities = $es->run_one();
if(!empty($filter_entities))
{
// check to make sure the relationship filtering makes sense for each item
if($this->params['limit_to_current_site'])
{
$setup_es = new entity_selector($this->parent->site_id);
}
else
{
$setup_es = new entity_selector();
}
$setup_es->add_type( $this->type );
$setup_es->set_env('site_id',$this->parent->site_id);
$setup_es = $this->alter_relationship_checker_es($setup_es);
$setup_es->set_num(1);
foreach($filter_entities as $key=>$filter)
{
$es = carl_clone($setup_es);
$es->add_left_relationship( $filter->id(), $r_id );
$results = $es->run_one();
if(empty($results))
{
unset($filter_entities[$key]);
}
$results = array();
}
if(!empty($filter_entities))
{
$this->filter_entities[$filter_name] = $filter_entities;
}
}
}
ksort($this->filter_entities);
}
return $this->filter_entities;
}
示例4: elseif
/**
* Identify the images that should be displayed
*/
function select_images()
{
// Initialize the images with appropriate entity selector properties
$page_id = $this->page_id;
if (!empty($this->params['alternate_source_page_id'])) {
$page_id = $this->params['alternate_source_page_id'];
if (!($site_id = get_owner_site_id($page_id))) {
$site_id = $this->site_id;
}
} else {
$page_id = $this->cur_page->id();
$site_id = $this->site_id;
}
$es = new entity_selector();
$es->add_type(id_of('image'));
$es->set_env('site', $site_id);
$es->add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));
if ($this->params['rand_flag']) {
$es->set_order('rand()');
} elseif (!empty($this->params['order_by'])) {
$es->set_order($this->params['order_by']);
} else {
$es->add_rel_sort_field($page_id, relationship_id_of('minisite_page_to_image'));
$es->set_order('rel_sort_order');
}
if (!empty($this->params['num_to_display'])) {
$es->set_num($this->params['num_to_display']);
}
$this->images = $es->run_one();
}
示例5: IN
function init_from_categories(&$already_selected)
{
if ($this->page_category_mode) {
$cat_es = new entity_selector($this->site_id);
$cat_es->add_type(id_of('category_type'));
$cat_es->limit_tables();
$cat_es->limit_fields();
$cat_es->add_right_relationship($this->page_id, relationship_id_of('page_to_category'));
$cat_result = $cat_es->run_one();
if (!empty($cat_result)) {
$es = new entity_selector($this->site_id);
$es->add_type(id_of('quote_type'));
$es->set_env('site', $this->site_id);
$es->add_left_relationship_field('quote_to_category', 'entity', 'id', 'cat_id', array_keys($cat_result));
if (!empty($already_selected)) {
$es->add_relation('entity.id NOT IN (' . implode(array_keys($already_selected)) . ')');
}
$result = $es->run_one();
}
}
return !empty($result) ? $result : array();
}
示例6: array
function add_relationship_element($name, $type_id, $rel_id, $direction = 'right', $element_type = 'checkbox', $limit_to_site = true, $sort = 'entity.name ASC')
{
static $directions = array('right', 'left');
static $element_types = array('checkbox' => array('plasmature_type' => 'checkboxgroup_no_sort'), 'radio' => array('plasmature_type' => 'radio_no_sort'), 'select' => array('plasmature_type' => 'select_no_sort', 'args' => array('add_empty_value_to_top' => true)), 'multiple_select' => array('plasmature_type' => 'select_no_sort', 'args' => array('size' => 7, 'multiple' => true), 'comment' => 'Control-click (PC) or Command-click (Mac) to choose multiple items'));
static $single_item_element_types = array('radio', 'select');
if (!array_key_exists($element_type, $element_types)) {
trigger_error($element_type . ' is not an acceptable parameter for add_relationship_element(). Try one of the following: ' . implode(', ', $element_types));
return;
}
if (!in_array($direction, $directions)) {
trigger_error($direction . ' is not an acceptable parameter for add_relationship_element(). Try one of the following: ' . implode(', ', $directions));
return;
}
$rel_info = $this->get_relationship_info($rel_id);
if ($direction == 'right' && $rel_info['connections'] == 'one_to_many' || $direction == 'left' && $rel_info['connections'] == 'many_to_one') {
$can_relate_multiple_items = false;
} else {
$can_relate_multiple_items = true;
}
if (!empty($rel_info)) {
if (!in_array($element_type, $single_item_element_types)) {
if (!$can_relate_multiple_items) {
trigger_error('Rel type mismatch -- only these element types can be used with a one_to_many relationship: ' . implode(', ', $single_item_element_types));
return;
}
}
} else {
trigger_error($rel_id . ' does not appear to be an allowable relationship ID');
return;
}
if ($limit_to_site) {
$es = new entity_selector($this->get_value('site_id'));
} else {
$es = new entity_selector();
}
$es->add_type($type_id);
if ($this->get_value('site_id')) {
$es->set_env('site', $this->get_value('site_id'));
}
$rel_es = carl_clone($es);
if ($direction == 'right') {
$rel_es->add_right_relationship($this->get_value('id'), $rel_id);
} else {
$rel_es->add_left_relationship($this->get_value('id'), $rel_id);
$rel_es->add_right_relationship_field('owns', 'entity', 'id', 'owner_id');
}
if (in_array($element_type, $single_item_element_types)) {
$rel_es->set_num(1);
}
//$rel_es->add_field('relationship','id','rel_id');
$rel_es->set_order($sort);
$rel_es->add_field('relationship', 'site', 'rel_site_id');
$related_entities = $rel_es->run_one();
$related_keys = array();
$untouchables = array();
foreach ($related_entities as $entity) {
if ($direction == 'right' || $entity->get_value('owner_id') == $this->get_value('site_id') || $entity->get_value('rel_site_id') == $this->get_value('site_id')) {
$related_keys[] = $entity->id();
} else {
$untouchables[$entity->id()] = strip_tags($entity->get_display_name());
}
}
if (!empty($untouchables)) {
$es->add_relation('entity.id NOT IN (' . implode(',', array_keys($untouchables)) . ')');
}
$es->set_order($sort);
$entities = $es->run_one();
$values = array();
foreach ($entities as $entity) {
$values[$entity->id()] = strip_tags($entity->get_display_name());
}
$args = array();
if (!empty($element_types[$element_type]['args'])) {
$args = $element_types[$element_type]['args'];
}
$args['options'] = $values;
$this->add_element($name, $element_types[$element_type]['plasmature_type'], $args);
if (!empty($related_keys)) {
if (in_array($element_type, $single_item_element_types)) {
$this->set_value($name, current($related_keys));
} else {
$this->set_value($name, $related_keys);
}
}
if ($direction == 'right' && $rel_info['required'] == 'yes') {
if (!empty($entities)) {
$this->add_required($name);
} else {
$this->add_comments($name, '<em>None available</em>');
}
}
if (!empty($untouchables)) {
$this->add_comments($name, '<div class="otherSiteRelation"><strong>Attached to this item by another site:</strong><ul class="smallText"><li>' . implode('</li><li>', $untouchables) . '</li></ul></div>', 'before');
}
if (!empty($element_types[$element_type]['comment'])) {
$this->add_comments($name, form_comment($element_types[$element_type]['comment']));
}
$this->_relationship_elements[$name] = array('type_id' => $type_id, 'rel_id' => $rel_id, 'direction' => $direction, 'options' => array_keys($entities), 'related_at_prep' => $related_keys);
if (!in_array($name, $this->_no_tidy)) {
$this->_no_tidy[] = $name;
//.........这里部分代码省略.........
示例7: array
function display_right_relationships()
{
$rels = $this->get_right_relationships();
if (!empty($rels)) {
$associated_items = array();
foreach ($rels as $key => $v) {
$es = new entity_selector();
$es->add_type($v['relationship_a']);
$es->set_env('site', $this->admin_page->site_id);
$es->add_left_relationship($this->admin_page->id, $v['id']);
$es->set_env('restrict_site', false);
$es->add_right_relationship_field('owns', 'entity', 'name', 'owner_name');
$es->add_right_relationship_field('owns', 'entity', 'id', 'owner_id');
$ass_items = $es->run_one();
if (!empty($ass_items)) {
$associated_items[$key] = $ass_items;
}
}
if (!empty($associated_items)) {
echo '<h3>Usage</h3>' . "\n";
echo '<ul>' . "\n";
foreach ($rels as $key => $v) {
if (!empty($associated_items[$key])) {
$is_borrows_rel = !reason_relationship_names_are_unique() ? $v['name'] == 'borrows' : $v['type'] == 'borrows';
if ($is_borrows_rel) {
$type = new entity($this->_entity->get_value('type'));
$title = 'Sites That Are Borrowing This ' . $type->get_value('name');
$show_owner_site = false;
} else {
$show_owner_site = true;
$row = $this->get_rel_info($v['name']);
if ($row) {
$title = !empty($row['description_reverse_direction']) ? $row['description_reverse_direction'] : $row['entity_name'];
} else {
$title = !empty($v['description_reverse_direction']) ? $v['description_reverse_direction'] : $v['name'];
}
}
echo '<li><h4>';
if (!$this->_entity->user_can_edit_relationship($v['id'], $this->_user, 'left')) {
echo '<img class="lockIndicator" src="' . REASON_HTTP_BASE_PATH . 'ui_images/lock_12px.png" alt="Locked" width="12" height="12" />';
} elseif ($this->_entity->relationship_has_lock($v['id'], 'left') && reason_user_has_privs($this->_user->id(), 'manage_locks')) {
echo '<img class="lockIndicator" src="' . REASON_HTTP_BASE_PATH . 'ui_images/lock_12px_grey_trans.png" alt="Locked for some users" title="Locked for some users" width="12" height="12" />';
}
echo $title . ':</h4>' . "\n";
echo '<ul>' . "\n";
foreach ($associated_items[$key] as $ent) {
echo '<li>' . $this->_get_rel_list_display_name($ent, $v['name'], 'right');
if ($show_owner_site && $ent->get_value('owner_id') != $this->admin_page->site_id) {
//echo ' <em>(<a href="http://'.REASON_HOST.$ent->get_value('owner_base_url').'">'.$ent->get_value('owner_name').'</a>)</em>';
echo ' <em>(' . $ent->get_value('owner_name') . ')</em>';
}
echo '</li>' . "\n";
}
echo '</ul>' . "\n";
echo '</li>' . "\n";
}
}
echo '</ul>' . "\n";
}
}
}
示例8:
function get_item_comments($item)
{
$es = new entity_selector();
$es->description = 'Selecting comments for news item';
$es->add_type( id_of('comment_type') );
$es->set_env( 'site' , $this->site_id );
$es->add_relation('show_hide.show_hide = "show"');
$es->add_right_relationship( $item->id(), relationship_id_of('news_to_comment') );
$es->set_order( 'dated.datetime ASC' );
return $es->run_one();
}
示例9: current
function get_page_image($page_id)
{
$es = new entity_selector();
$es->set_env( 'site' , $this->site_id );
$es->add_type(id_of('image'));
$es->add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));
$es->set_num(1);
$es->limit_tables();
$es->limit_fields();
if($this->params['randomize_images']) $es->set_order('rand()');
else $es->set_order('relationship.rel_sort_order ASC');
$images = $es->run_one();
if(!empty($images))
{
return current($images);
}
return false;
}
示例10: _get_es
protected function _get_es()
{
$es = new entity_selector( $this->site_id );
$es->add_type( id_of( 'policy_type' ) );
//$es->set_order( 'sortable.sort_order ASC' );
$es->set_order( 'entity.name ASC' );
$es->set_env( 'site' , $this->site_id );
$es->add_relation( table_of('show_hide', id_of( 'policy_type' )) .' != "hide"' );
$es->add_left_relationship_field( 'policy_parent' , 'entity' , 'id' , 'parent_id' );
if($audience = $this->_get_current_audience())
{
$es->add_left_relationship($audience->id(),relationship_id_of('policy_to_relevant_audience'));
}
return $es;
}
示例11: array
/**
* Set up an initalization array for a reason calendar object
*
* @param string $start_date mysql date
* @param string $end_date mysql date
* @param string $view
* @return array
*/
function make_reason_calendar_init_array($start_date, $end_date = '', $view = '')
{
$init_array = array();
$init_array['context_site'] = $this->parent->site_info;
$init_array['site'] = $this->_get_sites();
$init_array['sharing_mode'] = $this->_get_sharing_mode();
if(!empty($start_date))
$init_array['start_date'] = $start_date;
if(!empty($end_date))
{
$init_array['end_date'] = $end_date;
}
elseif(!empty($view))
{
$init_array['view'] = $view;
}
if(!empty($this->pass_vars['audience']))
{
$audience = new entity($this->pass_vars['audience']);
$init_array['audiences'] = array( $audience->id()=>$audience );
}
if(!empty($this->pass_vars['category']))
{
$category = new entity($this->pass_vars['category']);
$init_array['categories'] = array( $category->id()=>$category );
}
if($this->params['limit_to_page_categories'])
{
$es = new entity_selector( $this->parent->site_id );
$es->description = 'Selecting categories for this page';
$es->add_type( id_of('category_type') );
$es->set_env('site',$this->parent->site_id);
$es->add_right_relationship( $this->parent->cur_page->id(), relationship_id_of('page_to_category') );
$es->set_cache_lifespan($this->get_cache_lifespan_meta());
$cats = $es->run_one();
if(!empty($cats))
{
$init_array['or_categories'] = $cats;
}
}
if($this->params['ideal_count'])
$init_array['ideal_count'] = $this->params['ideal_count'];
elseif(!empty($this->ideal_count))
$init_array['ideal_count'] = $this->ideal_count;
if($this->params['default_view_min_days'])
$init_array['default_view_min_days'] = $this->params['default_view_min_days'];
$init_array['automagic_window_snap_to_nearest_view'] = $this->snap_to_nearest_view;
if($markup = $this->get_markup_object('list'))
$display_type = $markup->get_ongoing_display_type();
else
$display_type = 'above';
if('inline' == $display_type)
{
$init_array['ongoing_count_all_occurrences'] = true;
}
elseif('above' == $display_type)
{
$init_array['ongoing_count_all_occurrences'] = false;
$init_array['ongoing_count_pre_start_dates'] = true;
$init_array['ongoing_count_ends'] = $this->params['ongoing_show_ends'];
}
elseif('below' == $display_type)
{
$init_array['ongoing_count_all_occurrences'] = false;
$init_array['ongoing_count_pre_start_dates'] = false;
$init_array['ongoing_count_ends'] = $this->params['ongoing_show_ends'];
}
if(!empty($this->request['search']))
{
$init_array['simple_search'] = $this->request['search'];
}
$init_array['es_callback'] = array($this, 'reason_calendar_master_callback');
$init_array['cache_lifespan'] = $this->get_cache_lifespan();
$init_array['cache_lifespan_meta'] = $this->get_cache_lifespan_meta();
return $init_array;
}
示例12: array
/**
* Determine if a given user has access to all of a set of assets
*
* @param array $access
* @param string $username
* @return boolean
*/
function _has_access($assets, $username)
{
if (!is_array($assets)) {
$assets = array($assets->id() => $assets);
}
if (!empty($assets)) {
$es = new entity_selector();
$es->add_right_relationship(array_keys($assets), relationship_id_of('asset_access_permissions_to_group'));
$es->add_type(id_of('group_type'));
$es->set_env('site', $this->site_id);
$groups = $es->run_one();
//pray($groups);
//die();
foreach ($groups as $group_id => $group) {
$gh = new group_helper();
$gh->set_group_by_entity($group);
if (!$gh->has_authorization($username)) {
return false;
}
}
}
return true;
}