本文整理汇总了PHP中entity::get_left_relationship方法的典型用法代码示例。如果您正苦于以下问题:PHP entity::get_left_relationship方法的具体用法?PHP entity::get_left_relationship怎么用?PHP entity::get_left_relationship使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity
的用法示例。
在下文中一共展示了entity::get_left_relationship方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: entity
/**
* Checks DB for all possible searchable_fields
* @return void
*/
function viewer_searchable_fields() // {{{
{
if($this->viewer_id)
{
$e = new entity( $this->viewer_id );
$fields = get_fields_by_type( $this->type_id );
$column_add = $e->get_left_relationship( 'view_searchable_fields' );
foreach( $column_add AS $value )
{
if(!empty($fields[ $value->get_value( 'name' ) ] ) )
$this->add_filter( $value->get_value( 'name' ) );
}
}
} // }}}
示例2: empty
/**
* Returns the HTML for displaying a given theme's primary image
*
* @param entity $theme the themes whose image we're selecting
* @return string HTML for image
*/
function get_theme_image($theme)
{
$image = $theme->get_left_relationship('theme_to_primary_image');
$image = empty($image[0]) ? '' : $image[0];
if (!empty($image)) {
ob_start();
show_image($image, true, true, false);
$ret = ob_get_contents();
ob_end_clean();
return $ret;
} else {
return '';
}
}
示例3: array
function _add_bedrich_theme()
{
$theme_id = id_of('bedrich_theme');
$created_theme = false;
$created_template = false;
$created_css = false;
if (empty($theme_id)) {
if ($this->_testmode) {
$this->_report[] = 'Would have created the Bedrich theme';
} else {
$theme_id = reason_create_entity(id_of('master_admin'), id_of('theme_type'), $this->_user_id, 'Bedrich', array('unique_name' => 'bedrich_theme'));
$this->_report[] = 'Created the Bedrich theme (id: ' . $theme_id . ')';
$created_theme = true;
}
} else {
$this->_report[] = 'Bedrich theme exists. No need to create it.';
}
$es = new entity_selector(id_of('master_admin'));
$es->add_type(id_of('minisite_template'));
$es->add_relation('entity.name = "bedrich"');
$es->set_num(1);
$templates = $es->run_one();
if (empty($templates)) {
if ($this->_testmode) {
$this->_report[] = 'Would have created the Bedrich template';
} else {
$template_id = reason_create_entity(id_of('master_admin'), id_of('minisite_template'), $this->_user_id, 'bedrich');
$this->_report[] = 'Created the Bedrich template (id: ' . $template_id . ')';
$created_template = true;
}
} else {
$template = current($templates);
$template_id = $template->id();
$this->_report[] = 'bedrich template exists. No need to create it.';
}
$es = new entity_selector(id_of('master_admin'));
$es->add_type(id_of('css'));
$es->add_relation('url = "css/bedrich/bedrich.css"');
$es->set_num(1);
$css = $es->run_one();
if (empty($css)) {
if ($this->_testmode) {
$this->_report[] = 'Would have created the Bedrich css';
} else {
$css_id = reason_create_entity(id_of('master_admin'), id_of('css'), $this->_user_id, 'bedrich', array('url' => 'css/bedrich/bedrich.css', 'css_relative_to_reason_http_base' => 'true'));
$this->_report[] = 'Created the Bedrich css (id: ' . $css_id . ')';
$created_css = true;
}
} else {
$c = current($css);
$css_id = $c->id();
$this->_report[] = 'bedrich css exists. No need to create it.';
}
if (!empty($theme_id)) {
$theme = new entity($theme_id);
if (!empty($css_id) && !$theme->get_left_relationship('theme_to_external_css_url')) {
create_relationship($theme_id, $css_id, relationship_id_of('theme_to_external_css_url'));
$this->_report[] = 'attached bedrich css to bedrich theme';
} else {
$this->_report[] = 'bedrich theme already attached to css. No need to attach css.';
}
if (!empty($template_id) && !$theme->get_left_relationship('theme_to_minisite_template')) {
create_relationship($theme_id, $template_id, relationship_id_of('theme_to_minisite_template'));
$this->_report[] = 'attached bedrich template to bedrich theme';
} else {
$this->_report[] = 'berich theme already attached to template. No need to attach template.';
}
}
}
示例4: process
function process($test = true)
{
$ret = '';
foreach ($this->get_entity_info() as $type_uname => $entities) {
foreach ($entities as $entity) {
if (!reason_unique_name_exists($entity['unique_name'])) {
if ($test) {
$ret .= '<p>Would create ' . $type_uname . ' ' . $entity['name'] . '</p>';
} elseif (reason_create_entity(id_of('master_admin'), id_of($type_uname), $this->user_id, $entity['name'], $entity)) {
$ret .= '<p>Created ' . $type_uname . ' ' . $entity['name'] . '</p>';
} else {
$ret .= '<p>ERROR: Unable to create ' . $type_uname . ' ' . $entity['name'] . '</p>';
}
}
}
}
foreach ($this->get_theme_rels() as $theme_uname => $rels) {
if (reason_unique_name_exists($theme_uname)) {
$theme = new entity(id_of($theme_uname));
foreach ($rels as $rel_name => $rel_unames) {
$rel_id = relationship_id_of($rel_name);
if (empty($rel_id)) {
$ret .= '<p>ERROR: unable to create relationships with name ' . $rel_name . ' -- not found</p>';
continue;
}
$rel_entities = $theme->get_left_relationship($rel_name);
$rel_unames_in_db = array();
foreach ($rel_entities as $rel_entity) {
if ($rel_entity->get_value('unique_name')) {
$rel_unames_in_db[] = $rel_entity->get_value('unique_name');
}
}
$unrelated = array_diff($rel_unames, $rel_unames_in_db);
foreach ($unrelated as $unrelated_uname) {
if (!$test) {
if (!reason_unique_name_exists($unrelated_uname)) {
$ret .= '<p>ERROR: unable to create relationships with unique name ' . $unrelated_uname . ' -- not found</p>';
continue;
} else {
$unrelated_id = id_of($unrelated_uname);
}
}
if ($test) {
$ret .= '<p>Would create relationship from ' . $theme_uname . ' to ' . $unrelated_uname . '</p>';
} elseif (create_relationship($theme->id(), $unrelated_id, $rel_id)) {
$ret .= '<p>Created relationship from ' . $theme_uname . ' to ' . $unrelated_uname . '</p>';
} else {
$ret .= '<p>ERROR: Unable to create relationship from ' . $theme_uname . ' to ' . $unrelated_uname . '</p>';
}
}
}
} elseif ($test) {
$ret .= '<p>Would create relationships from ' . $theme_uname . ' to css and templates.</p>';
} else {
trigger_error('Unable to create relationship with theme ' . $theme_uname . ' -- it doesn\'t appear to exist!');
$ret .= '<p>ERROR: Unable to create relationship with theme ' . $theme_uname . ' -- it doesn\'t appear to exist!. Please try running this script again.</p>';
}
}
if (empty($ret)) {
$ret .= '<p>Upgrade complete; nothing to do</p>';
}
return $ret;
}