本文整理汇总了PHP中entity类的典型用法代码示例。如果您正苦于以下问题:PHP entity类的具体用法?PHP entity怎么用?PHP entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
function init($args = array())
{
parent::init($args);
$site = new entity($this->site_id);
if (!empty($this->params['sites'])) {
$this->child_sites = array();
foreach ($this->params['sites'] as $unique_name) {
if ($id = id_of($unique_name)) {
$e = new entity($id);
if ($e->get_value('type') == id_of('site') && ($site->get_value('site_state') != 'Live' || $e->get_value('site_state') == 'Live')) {
$this->child_sites[$id] = $e;
}
}
}
} else {
$es = new entity_selector();
$es->description = 'Getting child sites of this site';
$es->add_type(id_of('site'));
$es->add_left_relationship($this->site_id, relationship_id_of('parent_site'));
$es->set_order('entity.name');
if ($site->get_value('site_state') == 'Live') {
$es->add_relation('site_state="Live"');
}
$this->child_sites = $es->run_one();
}
}
示例2: show_feed_link
function show_feed_link()
{
$type = new entity(id_of('event_type'));
if ($type->get_value('feed_url_string')) {
echo '<div class="feedInfo"><a href="/' . REASON_GLOBAL_FEEDS_PATH . '/' . $type->get_value('feed_url_string') . '" title="RSS feed for this site\'s events">xml</a></div>';
}
}
示例3: get_plasmature_element_parameters
/**
* Get the appropriate parameters to pass to the plasmature element
* @param integer $site_id The Reason id of the site in which this editor is being invoked
* @param integer $user_id The Reason id of the current user (0 if user is anonymous or not in the Reason user store)
* @return array plasmature parameters
*/
function get_plasmature_element_parameters($site_id, $user_id = 0)
{
$params = array();
// site id
$params['site_id'] = $site_id;
// paths
$params['paths'] = $this->_get_paths($site_id);
// default widgets
$site = new entity($site_id);
if ($site->get_value('loki_default')) {
$map = $this->_get_options_map();
if (array_key_exists($site->get_value('loki_default'), $map)) {
$params['widgets'] = $map[$site->get_value('loki_default')]['maps_to'];
} else {
$params['widgets'] = $site->get_value('loki_default');
}
} else {
$params['widgets'] = 'default';
}
// user is admin
if (!empty($user_id) && (user_is_a($user_id, id_of('admin_role')) || user_is_a($user_id, id_of('power_user_role')))) {
$params['widgets'] .= ' +source +debug';
} else {
$params['widgets'] .= ' -source -debug';
}
if (defined('REASON_DEFAULT_ALLOWED_TAGS')) {
$params['allowable_tags'] = explode(',', str_replace(array('><', '<', '>'), array(',', '', ''), REASON_DEFAULT_ALLOWED_TAGS));
}
if (defined('REASON_LOKI_CRASH_REPORT_URI') && REASON_LOKI_CRASH_REPORT_URI != '') {
$params['crash_report_uri'] = REASON_LOKI_CRASH_REPORT_URI;
}
return $params;
}
示例4: thor_build_display_values
function thor_build_display_values()
{
$form = new entity($this->form_id);
$form->get_values();
if ($form->get_value('type') != id_of('form'))
{
trigger_error('the thor viewer was passed an invalid id ('.$form_id.') - it must be passed the ID of a reason form entity');
}
else
{
$form_xml_obj = new XMLParser($form->get_value('thor_content'));
$form_xml_obj->Parse();
$display_values = array();
foreach ($form_xml_obj->document->tagChildren as $k=>$v)
{
$tagname = is_object($v) ? $v->tagName : '';
if (method_exists($this, '_build_display_'.$tagname))
{
$build_function = '_build_display_'.$tagname;
$display_values = array_merge($display_values, $this->$build_function($v));
}
}
}
foreach ($this->extra_fields as $field_name)
{
$display_values[$field_name]['label'] = prettify_string($field_name);
$display_values[$field_name]['type'] = 'text';
}
$this->_display_values = (isset($display_values)) ? $display_values : array();
}
示例5: transform
/**
* Transforms an object (usuario) to a string (id).
*
* @param entity|null $entity
* @return string
*/
public function transform($entity)
{
if (null === $entity) {
return $this->id;
}
return $entity->getId();
}
示例6: init
function init($args = array())
{
parent::init($args);
$root_id = $this->parent->pages->root_node();
$this_page_id = $this->cur_page->id();
// check to see if this is a home page -- don't even query for siblings
if ($root_id != $this_page_id) {
$parent_id = $this->parent->pages->parent($this->cur_page->id());
if (!empty($parent_id)) {
$sibling_ids = $this->parent->pages->children($parent_id);
if (!empty($sibling_ids)) {
foreach ($sibling_ids as $sibling_id) {
if ($sibling_id != $root_id) {
$page = new entity($sibling_id);
if ($this->params['show_only_pages_in_nav'] && $page->get_value('nav_display') != 'Yes') {
continue;
}
if (isset($this->params['show_external_links']) && !$this->params['show_external_links'] && $page->get_value('url')) {
continue;
}
$this->siblings[$sibling_id] = $page;
}
}
}
$this->parent_page = new entity($parent_id);
}
}
}
示例7: get_pages_needing_change
function get_pages_needing_change()
{
if (!isset($this->pages_needing_change)) {
$es = new entity_selector();
$es->add_type(id_of('minisite_page'));
$es->enable_multivalue_results();
$es->limit_tables('page_node');
$es->limit_fields('custom_page');
$es->add_relation('page_node.custom_page = "blurb"');
$es->add_left_relationship_field('minisite_page_to_text_blurb', 'entity', 'id', 'blurb_id');
$result = $es->run_one();
foreach ($result as $k => $page) {
$blurbs = is_array($page->get_value('blurb_id')) ? $page->get_value('blurb_id') : array($page->get_value('blurb_id'));
foreach ($blurbs as $blurb_id) {
$blurb = new entity($blurb_id);
$content = $blurb->get_value('content');
$demoted_content = demote_headings($content, 1);
if ($content == $demoted_content) {
$pages_needing_page_type_change[$k] = $k;
}
}
}
$this->pages_needing_change = isset($pages_needing_page_type_change) ? array_keys($pages_needing_page_type_change) : false;
}
return $this->pages_needing_change;
}
示例8: set_audience_id
function set_audience_id($aud_id)
{
$aud = new entity($aud_id);
if ($aud->get_values()) {
$this->audiences[$aud_id] = $aud;
}
}
示例9: init
function init()
{
if (!empty($this->admin_page->id)) {
$temp = new entity($this->admin_page->id, false);
if ($temp->get_value('new') && $temp->get_value('state') == 'Pending' && !$temp->get_value('name') && reason_user_has_privs($this->admin_page->user_id, 'delete_pending')) {
reason_expunge_entity($this->admin_page->id, $this->admin_page->user_id);
}
}
if (!empty($this->admin_page->request[CM_VAR_PREFIX . 'type_id'])) {
$old_vars = array();
foreach ($this->admin_page->request as $key => $val) {
if (substr($key, 0, strlen(CM_VAR_PREFIX)) == CM_VAR_PREFIX) {
$old_vars[substr($key, strlen(CM_VAR_PREFIX))] = $val;
$old_vars[$key] = '';
}
}
foreach ($this->admin_page->default_args as $arg) {
if (!isset($old_vars[$arg])) {
$old_vars[$arg] = '';
}
}
$link = $this->admin_page->make_link($old_vars);
} else {
$link = $this->admin_page->make_link(array('id' => '', 'site_id' => $this->admin_page->site_id, 'type_id' => $this->admin_page->type_id, 'cur_module' => 'Lister'));
}
header('Location: ' . unhtmlentities($link));
die;
}
示例10: run
/**
* Run the upgrader
*
* @return string HTML report
*/
public function run()
{
$ret = '';
$e = new entity(id_of('css'));
if (!$e->get_value('custom_content_handler')) {
reason_update_entity($e->id(), $this->user_id(), array('custom_content_handler' => 'css.php'));
$ret .= '<p>The CSS type has been assigned a content manager.</p>' . "\n";
}
$tables = get_entity_tables_by_type(id_of('css'), false);
$has_meta = in_array('meta', $tables);
$has_url = in_array('url', $tables);
if ($has_meta || $has_url) {
set_time_limit(3600);
if ($has_meta) {
$ret .= $this->_move_table_fields('meta');
}
if ($has_url) {
$ret .= $this->_move_table_fields('url');
}
}
if (empty($ret)) {
$ret .= '<p>This upgrade has already been run. There is nothing to do.</p>';
}
return $ret;
}
示例11: get_feed_as_text
function get_feed_as_text($params)
{
if (!empty($params['type_id'])) {
$type = new entity($params['type_id']);
if (!empty($params['feed'])) {
$feed_file = $params['feed'];
} elseif ($type->get_value('custom_feed')) {
$feed_file = str_replace('.php', '', $type->get_value('custom_feed'));
} else {
$feed_file = 'default';
// otherwise use default feed script
}
reason_include_once('feeds/' . $feed_file . '.php');
$feed_class = $GLOBALS['_feed_class_names'][$feed_file];
if (!empty($params['site_id'])) {
$site = new entity($params['site_id']);
$feed = new $feed_class($type, $site);
} else {
$feed = new $feed_class($type);
}
$feed->set_request_vars($params);
ob_start();
$feed->run(false);
$feed_text = ob_get_contents();
ob_end_clean();
if (!empty($feed_text)) {
return $feed_text;
}
}
}
示例12: checkPermissions
function checkPermissions()
{
// first, make sure user is logged in
$username = reason_check_authentication();
if (!$username) {
$this->error("this page requires authentication");
} else {
// next, figure out the form id
$matches = array();
$res = preg_match("/form_(\\d*)/", $this->table, $matches);
if (count($matches) != 2) {
$this->error("invalid table name");
} else {
$formId = $matches[1];
// now that we've got the form id, find out what site it belongs to
$form = new entity($formId);
$site = $form->get_owner();
// and finally, make sure the logged in user has access to the site, and is an admin
$hasSiteAccess = reason_username_has_access_to_site($username, $site->id());
// $isAdmin = user_is_a(get_user_id($username), id_of("admin_role"));
// return $hasSiteAccess && $isAdmin;
return $hasSiteAccess;
}
}
return false;
}
示例13: show_entity_data
function show_entity_data($entity)
{
//echo '<h4>Entity data:</h4>';
$entity_type = new entity($entity->get_value('type'));
echo '<p><strong>Type</strong>: ' . $entity_type->get_value('name') . '</p>';
$owner = $entity->get_owner();
if (is_object($owner)) {
echo '<p><strong>Owner site</strong>: ' . $owner->get_value('name') . ' (ID: ' . $this->get_id_markup($owner->id()) . ')</p>' . "\n";
} else {
echo '<p>No owner site (orphan entity)</p>' . "\n";
}
echo '<table class="entityInfoDataTable">' . "\n";
echo '<tr>' . "\n";
echo '<th>Attribute</th>' . "\n";
echo '<th>Value</th>' . "\n";
echo '</tr>' . "\n";
$id_markup_keys = array('type', 'last_edited_by', 'created_by');
foreach ($entity->get_values() as $key => $value) {
echo '<tr>' . "\n";
echo '<td>' . $key . '</td>' . "\n";
if (in_array($key, $id_markup_keys)) {
echo '<td>' . $this->get_id_markup($value) . '</td>' . "\n";
} else {
echo '<td>' . $value . '</td>' . "\n";
}
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
}
示例14: make_link
function make_link($id)
{
$asset = $this->items[$id];
$owner_id = $asset->get_value('owner_id');
$owner_site = new entity($owner_id);
return 'http://' . REASON_HOST . $owner_site->get_value('base_url') . MINISITE_ASSETS_DIRECTORY_NAME . '/' . $asset->get_value('file_name');
}
示例15: init
function init()
{
parent::init();
if (!empty($this->admin_page->request['event_id'])) {
$event = new entity($this->admin_page->request['event_id']);
$this->admin_page->title = 'Sorting Registration Slots of "' . $event->get_value('name') . '"';
}
}