本文整理汇总了PHP中entity::id方法的典型用法代码示例。如果您正苦于以下问题:PHP entity::id方法的具体用法?PHP entity::id怎么用?PHP entity::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity
的用法示例。
在下文中一共展示了entity::id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: foreach
/**
* Update the entity with each element's value
**/
function update_entity()
{
$entity_id = $this->entity->id();
if (!empty($this->entity) && !empty($this->mapping)) {
foreach ($this->mapping as $element => $array) {
$values_array[$array['field']] = $this->get_value($element);
}
return reason_update_entity($entity_id, $this->user_netid, $values_array);
} else {
return false;
}
}
示例3: entity
function change_news_custom_feed()
{
$news_type = new entity(id_of('news', false));
$custom_feed = $news_type->get_value('custom_feed');
if ($custom_feed == 'news.php') {
if ($this->mode == 'run') {
$values['custom_feed'] = 'sitewide_news.php';
reason_update_entity($news_type->id(), $this->reason_user_id, $values);
$link = REASON_HTTP_BASE_PATH . '/scripts/urls/update_urls.php';
echo '<p>Changed the news type custom_feed from news to sitewide news.</p>';
} else {
echo '<p>Would change the news type custom_feed from news to sitewide news.</p>';
}
} else {
echo '<p>The news type custom feed has been changed from news.php - this script has probably already been run.</p>';
}
}
示例4: init
function init()
{
$this->admin_page->set_show('leftbar', false);
if (empty($this->admin_page->id)) {
$this->_not_undeletable_reason = 'no_id_provided';
return false;
}
if (!reason_user_has_privs($this->admin_page->user_id, 'publish')) {
$this->_not_undeletable_reason = 'insufficient_privileges';
return false;
}
$item = new entity($this->admin_page->id);
$user = new entity($this->admin_page->user_id);
if (!$item->user_can_edit_field('state', $user)) {
$this->_not_undeletable_reason = 'state_field_locked';
return false;
}
if ($item->get_value('state') != 'Deleted') {
$this->_not_undeletable_reason = 'not_deleted_yet';
return false;
}
reason_update_entity($this->admin_page->id, $this->admin_page->user_id, array('state' => 'Live'), false);
if ($this->admin_page->type_id == id_of('minisite_page')) {
// zap nav cache so it reappears.
reason_include_once('classes/object_cache.php');
$cache = new ReasonObjectCache($this->admin_page->site_id . '_navigation_cache');
$cache->clear();
}
$manager_site_id = $this->admin_page->site_id;
if ($item->get_value('type') == id_of('site')) {
$manager_site_id = $item->id();
}
//Updates the rewrites to prevent infinite redirection loop.
reason_include_once('classes/url_manager.php');
$urlm = new url_manager($manager_site_id);
$urlm->update_rewrites();
$link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'Lister', 'id' => '', 'state' => 'deleted')));
header('Location: ' . $link);
die;
}
示例5: init
function init()
{
$this->head_items->add_stylesheet(REASON_ADMIN_CSS_DIRECTORY . 'sharing.css');
reason_include_once('classes/sharing_filter.php');
reason_include_once('content_listers/sharing.php');
$type = new entity($this->admin_page->type_id);
// save the type entity in an object scope
$this->rel_type = $type;
$this->get_views($type->id());
if (empty($this->views)) {
//add generic lister if not already present
$this->views = array();
} else {
reset($this->views);
$c = current($this->views);
if ($c) {
$lister = $c->id();
$this->admin_page->request['lister'] = $lister;
} else {
$lister = '';
}
}
$this->admin_page->title = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
if ($icon_url = reason_get_type_icon_url($type, false)) {
$this->admin_page->title = '<img src="' . $icon_url . '" alt="" /> ' . $this->admin_page->title;
}
if ($this->admin_page->is_second_level()) {
$this->admin_page->set_show('leftbar', false);
}
$this->viewer = new sharing_viewer();
$this->viewer->set_page($this->admin_page);
if (!isset($lister)) {
$lister = '';
}
$this->viewer->init($this->admin_page->site_id, $type->id(), $lister);
$this->filter = new sharing_filter();
$this->filter->set_page($this->admin_page);
$this->filter->grab_fields($this->viewer->filters);
}
示例6: entity
function _ok_to_run_module()
{
if ($this->_ok_to_run !== true && $this->_ok_to_run !== false) {
$this->_ok_to_run = false;
if (!$this->admin_page->id) {
return $this->_ok_to_run;
}
$owner_site = get_owner_site_id($this->admin_page->id);
$entity = new entity($this->admin_page->id);
if ($owner_site == $this->admin_page->site_id) {
$this->_ok_to_run = true;
return $this->_ok_to_run;
}
if (site_borrows_entity($this->admin_page->site_id, $entity->id())) {
$this->_ok_to_run = true;
return $this->_ok_to_run;
}
if (site_shares_type($owner_site, $entity->get_value('type')) && $entity->get_value('no_share') == 0) {
$this->_ok_to_run = true;
return $this->_ok_to_run;
}
}
return $this->_ok_to_run;
}
示例7: get_page_link
/**
* Get the URL of a page
*
* This function will provide the URL of a page of a particular type or types on a site
*
* @param entity $site The site to look in
* @param page_tree $tree the page tree object for the site; this must be already initialized
* @param mixed $page_types The array of page types or string indicating single page type that is/are acceptable
* @param boolean $as_uri Returns a fully qualified URI if true; otherwise returns a URL relative to web root
* @param boolean $secure Uses https if true. This parameter only has an effect if $as_uri is true.
*/
function get_page_link(&$site, &$tree, $page_types, $as_uri = false, $secure = false)
{
if (empty($site) || empty($page_types)) {
trigger_error('site and page types must all be passed to get_page_link', EMERGENCY);
} elseif (is_string($page_types)) {
$page_types = array($page_types);
} elseif (!is_array($page_types)) {
trigger_error('$page_types must be an array or string', EMERGENCY);
}
$relations = array();
$es = new entity_selector($site->id());
$es->add_type(id_of('minisite_page'));
foreach ($page_types as $page_type) {
$relations[] = 'page_node.custom_page = "' . $page_type . '"';
}
$es->add_relation('(' . implode(' or ', $relations) . ')');
$es->set_num(1);
$pages = $es->run_one();
if (!empty($pages)) {
$page = current($pages);
if (!empty($tree)) {
$ret = $tree->get_full_url($page->id(), $as_uri, $secure);
} else {
$ret = build_URL($page->id());
}
} else {
$ret = $site->get_value('base_url');
}
if ($as_uri && empty($pages)) {
if ($secure) {
$ret = securest_available_protocol() . '://' . REASON_HOST . $ret;
} else {
$ret = 'http://' . REASON_HOST . $ret;
}
}
return $ret;
}
示例8: entity
/**
* Automatically called each time the form loads.
*
* Checks the show_form variable to determine if the deletion page should be shown.
* Displays each entity that will be deleted with the site, in the format
* <h4>Type</h4> <ul> <li> Entity <a href = "Preview of entity"> Preview </a> </li> </ul>
*
* Contains javascript to display a confirmation window after delete is submitted.
**/
function show_form()
{
if ($this->show_form) {
$site = new entity($this->get_value('id'));
$action_word = 'Deleting';
if ('Deleted' == $site->get_value('state')) {
$action_word = 'Expunging';
}
echo $action_word . " a site will delete all entities it owns. For " . $site->get_value('name') . " this includes:<br>";
$borrowing_array = $this->get_borrowing_list();
foreach ($borrowing_array as $type_id => $entities) {
$type_entity = new entity($type_id);
$type_name = $type_entity->get_value('plural_name') ? $type_entity->get_value('plural_name') : $type_entity->get_value('name');
$temp_string = "\n<h4>" . $type_name . "</h4>\n<ul>";
foreach (array_keys($entities) as $entity_id) {
$link_address = '<a href="?site_id=' . $site->id() . '&type_id=' . $type_id . '&id=' . $entity_id . '&cur_module=Preview" target="_blank">Preview</a> (id: ' . $entity_id . ')';
$entity_object = new entity($entity_id);
$entity_name = $entity_object->get_display_name();
$temp_string .= "\n<li>" . $entity_name . " " . $link_address . "</li>";
}
$temp_string .= "\n</ul>";
echo $temp_string;
}
parent::show_form();
echo "<script>";
echo "\n\$(document).ready(function(){";
echo "\n\$('form#disco_form').submit(function(event){";
echo "\nif(window.confirm('" . $action_word . " this site will delete all entities listed. Are you sure you want to proceed?')){";
echo "\n}";
echo "\nelse{";
echo "\nevent.preventDefault();";
echo "\ncancelDisableSubmit();";
echo "\n}";
echo "\n});";
echo "\n});";
/*
echo "\ndocument.getElementById('disco_form')[0].onsubmit=function() {return displayWarning(this)}";
echo "\nfunction displayWarning(item)\n{\n\na = window.confirm('Deleting this site will delete all entities listed. Are you sure you want to proceed?')\nif(a!=true)\n{\nreturn false\n}\n}";
*/
echo "\n</script>";
} else {
echo $this->no_show_form();
}
}
示例9: array
if (!isset($_POST['verify'])) {
echo '<p>This script creates a number of fields in the user entity table, and sets the user type to use the user content previewer.';
echo 'Running this script changes the reason database so that the Reason user type can be used for authentication purposes.</p>';
}
if (isset($_POST['verify']) && $_POST['verify'] == 'Run the Script') {
// Use the field_to_entity_table_class to add needed fields to 'user' entity table
$fields = array('user_surname' => array('db_type' => 'tinytext'), 'user_given_name' => array('db_type' => 'tinytext'), 'user_email' => array('db_type' => 'tinytext'), 'user_phone' => array('db_type' => 'tinytext'), 'user_password_hash' => array('db_type' => 'tinytext'), 'user_authoritative_source' => array('db_type' => "enum('reason','external')"));
$updater = new FieldToEntityTable('user', $fields);
$updater->update_entity_table();
$updater->report();
// Set the custom_previewer value for the User type to User
$user_type_entity = new entity(id_of('user'));
$previewer = $user_type_entity->get_value('custom_previewer');
if ($previewer != "user.php") {
$update_array = array('type' => array('custom_previewer' => 'user.php'));
$update = update_entity($user_type_entity->id(), $user_id, $update_array, false);
if ($update) {
echo '<h2>Updated user content previewer to user.php</h2>';
}
} else {
echo '<h3>User content previewer already set to user.php</h3>';
}
$group_fields = array('ldap_group_filter' => array('db_type' => 'text'), 'ldap_group_member_fields' => array('db_type' => 'tinytext'), 'group_has_members' => array('db_type' => 'enum(\'true\',\'false\')'));
$updater = new FieldToEntityTable('user_group', $group_fields);
$updater->update_entity_table();
$updater->report();
// check to see if field is still in db
$results = db_query('DESCRIBE user_group');
$field_exists = false;
while ($row = mysql_fetch_array($results)) {
if ($row['Field'] == 'course_identifier_strings') {
示例10: die
force_secure_if_available();
$user_netID = reason_require_authentication();
$reason_user_id = get_user_id($user_netID);
if (empty($reason_user_id)) {
die('valid Reason user required');
}
if (!reason_user_has_privs($reason_user_id, 'upgrade')) {
die('You must have upgrade privileges to run this script');
}
$stt = new entity(id_of('site_type_type'));
if ($stt->get_value('custom_content_handler')) {
echo '<p>Site Types already have a content manager. There is no need to run this script!</p>';
} else {
echo '<p>This script will add the site type content manager to this Reason instance. This content manager makes creating site types easier by adding useful comments.</p>';
if (empty($_POST['run'])) {
echo '<form action="?" method="post"><input type="submit" name="run" value="Run It" /></form>';
} else {
$success = reason_update_entity($stt->id(), $reason_user_id, array('custom_content_handler' => 'site_type.php'));
if ($success) {
echo '<p>Successfully updated site types to use new content manager</p>';
} else {
echo '<p>Unable to update site type to use new content manager. Please see the errors triggered (or the Reason error log) to identify why it did not work. Alternately, you can manually update this Reason instance. Here\'s how:</p>';
echo '<ol><li>Log in to Reason</li><li>Go into the Master Admin</li><li>Choose "Types"</li><li>Find the type "Site Type" and click Edit</li><li>Choose "Site Type" on the Content Manager field</li><li>Save and finish</li></ol>';
}
}
}
echo '<p><a href="index.php">Back to 4.0b4 to 4.0b5 upgrades</a></p>';
?>
</body>
</html>
示例11: entity
function stats_link()
{
// if using google analytics don't show Stats
if (!$this->show['analytics']) {
if (defined('REASON_STATS_URI_BASE') && REASON_STATS_URI_BASE != '') {
$site = new entity($this->site_id);
if ($site->get_value('unique_name')) {
$show = false;
if ($site->get_value('site_state') == 'Live') {
$show = true;
} else {
$es = new entity_selector();
$es->add_right_relationship($site->id(), relationship_id_of('site_archive'));
$es->add_relation('site_state = "Live"');
$es->set_num(1);
$sites = $es->run_one(id_of('site'), 'Archived');
if (!empty($sites)) {
$show = true;
}
}
if ($show) {
$link = REASON_STATS_URI_BASE;
if (function_exists('posix_uname')) {
$uname = posix_uname();
$uname_host = $uname['nodename'];
} else {
$uname_host = php_uname('n');
}
$link .= strtolower($uname_host) . '/';
$link .= $_SERVER['HTTP_HOST'] . '/';
$link .= $site->get_value('unique_name') . '/';
return $link;
}
}
}
}
return false;
}
示例12: die
}
if ($pub->get_value('type') != id_of('publication_type')) {
die('The publication provided is not, in fact, a publication' . "\n");
}
$days = (int) $args['days'];
if (empty($days)) {
die('Please provide days as an integer (e.g. 1, 2, 3, or 73)' . "\n");
}
$time = strtotime('-' . $days . ' days');
if (empty($time)) {
die('Something appears to be amiss -- no time value was able to be resolved from the number of days provided' . "\n");
}
$datetime = date('Y-m-d H:i:s', $time);
$es = new entity_selector();
$es->add_type(id_of('news'));
$es->add_left_relationship($pub->id(), relationship_id_of('news_to_publication'));
$es->add_relation('`datetime` >= "' . $datetime . '"');
$es->set_num(1);
$posts = $es->run_one();
if (empty($posts)) {
echo 'No new posts on publication id ' . $pub->id() . ' (' . $pub->get_value('name') . ') since ' . $datetime . '.' . "\n";
if (!empty($args['emails'])) {
$message = 'FYI, there are currently no recent posts on the Reason publication "' . $pub->get_value('name') . '."' . "\n\n";
$message .= 'You are signed up to receive notices when this publication has not been updated in the last ' . $days . ' days.' . "\n\n";
$message .= 'It may be time to add a new post!' . "\n\n";
$message .= 'Click here to add posts to this publication: http://' . REASON_WEB_ADMIN_PATH . '?site_id=' . get_owner_site_id($pub->id()) . '&type_id=' . id_of('news') . "\n\n";
$message .= 'If you are no longer responsible for this publication, please contact a Reason administrator to have this email sent to someone else.' . "\n\n";
$message .= 'Thank you!' . "\n\n";
mail($args['emails'], 'Reason Publication Reminder', $message, 'From: <no-reply@carleton.edu>');
echo 'Message sent to ' . $args['emails'] . "\n";
}
示例13: current
/**
* Get a page on the site for a given category
*
* @param entity $category
* @return entity $page
*/
function _get_page_for_category($category)
{
$ps = new entity_selector($this->site_id);
$ps->add_type( id_of('minisite_page') );
$ps->add_left_relationship($category->id(), relationship_id_of('page_to_category'));
$ps->add_relation('entity.id != "'.addslashes($this->page_id).'"');
$ps->set_num(1);
$pages = $ps->run_one();
if(!empty($pages))
return current($pages);
else
return false;
}
示例14: array
/**
* Get the audiences for a given event entity
*
* Returned audience entities are sweetened with the value _link, containing an html-encoded URL
*
* @param object $e event entity
* @return array audience entities
*/
function get_event_audiences($e)
{
$audiences = array();
$es = new entity_selector();
$es->description = 'Selecting audiences for event';
$es->limit_tables();
$es->limit_fields();
$es->enable_multivalue_results();
$es->add_type( id_of('event_type'));
$es->add_relation('entity.id = ' . $e->id());
$es->add_left_relationship_field('event_to_audience', 'entity', 'id', 'aud_ids');
$with_audiences = $es->run_one();
if (!empty($with_audiences))
{
$audiences = array();
$event = reset($with_audiences);
$aud_ids = $event->get_value('aud_ids');
$aud_ids = is_array($aud_ids) ? $aud_ids : array($aud_ids);
foreach( $aud_ids AS $aud_id )
{
$aud = new entity($aud_id);
$aud->set_value('_link', $this->construct_link(array('audience'=>$aud->id(),'no_search'=>'1'), false));
$audiences[$aud_id] = $aud;
}
}
return $audiences;
}
示例15: run
function run()
{
echo '<div id="siteIntro">' . "\n";
$e = new entity($this->admin_page->site_id);
echo '<div id="siteNotices">' . "\n";
if ($e->get_value('site_state') == "Not Live" && $e->get_value('unique_name') != 'master_admin') {
echo '<div class="notLiveNotice"><h4>This site is not live.</h4><p>Among other things, that means that it\'s excluded from search engines (so people won\'t stumble upon a site that isn\'t ready for public consumption).</p>' . "\n";
if (user_can_edit_site($this->admin_page->user_id, id_of('master_admin'))) {
echo '<p><a href="' . $this->admin_page->make_link(array('site_id' => id_of('master_admin'), 'type_id' => id_of('site'), 'id' => $e->id(), 'cur_module' => 'Editor')) . '">Edit this site</a></p>' . "\n";
} else {
echo '<p>Please contact ' . REASON_CONTACT_INFO_FOR_CHANGING_USER_PERMISSIONS . ' when you are ready to make this site live.</p>' . "\n";
}
echo '</div>' . "\n";
}
if ($e->get_value('description')) {
echo '<div id="siteDesc">' . "\n";
if (strip_tags($e->get_value('description')) == $e->get_value('description')) {
echo nl2br($e->get_value('description'));
} else {
echo $e->get_value('description');
}
echo '</div>' . "\n";
}
$sites = $this->admin_page->get_sites();
if (count($sites) == 1) {
parent::run();
}
echo '</div>' . "\n";
echo '<div id="guide">' . "\n";
$es = new entity_selector();
$es->add_type(id_of('type'));
$es->add_right_relationship($e->id(), relationship_id_of('site_to_type'));
$es->limit_tables();
$es->limit_fields();
$non_editable_es = carl_clone($es);
$non_editable_es->add_right_relationship($e->id(), relationship_id_of('site_cannot_edit_type'));
$noneditable_types = $non_editable_es->run_one();
if (!empty($noneditable_types)) {
$es->add_relation('entity.id NOT IN (' . implode(',', array_keys($noneditable_types)) . ')');
}
$es->set_order('entity.name ASC');
$types = $es->run_one();
if (array_key_exists(id_of('minisite_page'), $types)) {
$page_type_array[id_of('minisite_page')] = $types[id_of('minisite_page')];
unset($types[id_of('minisite_page')]);
$types = array_merge($page_type_array, $types);
}
echo '<ul>' . "\n";
foreach ($types as $type) {
$es = new entity_selector($e->id());
$es->set_sharing('owns');
$es->add_type($type->id());
$es->limit_tables();
$es->limit_fields();
$es->set_order('entity.last_modified DESC');
if (reason_user_has_privs($this->admin_page->user_id, 'edit')) {
$state = 'Live';
$state_link_val = 'live';
} else {
$state = 'Pending';
$state_link_val = 'pending';
}
$ents = $es->run_one($type->id(), $state);
$ents_count = count($ents);
$name = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
echo '<li class="' . $type->get_value('unique_name') . '" style="list-style-image:url(' . reason_get_type_icon_url($type) . ')">';
echo '<h4><a href="' . $this->admin_page->make_link(array('type_id' => $type->id(), 'cur_module' => 'Lister', 'state' => $state_link_val)) . '">' . $name . '</a> <span class="count">(' . $ents_count . ')</span></h4>' . "\n";
if (!empty($ents)) {
echo '<div class="recent">' . "\n";
echo 'Recently edited:' . "\n";
echo '<ul>' . "\n";
$i = 1;
foreach ($ents as $ent_id => $ent) {
if ($i > 3) {
break;
}
$name = strip_tags($ent->get_display_name());
if (empty($name)) {
$name = '[unnamed]';
}
echo '<li class="item' . $i . '"><a href="' . $this->admin_page->make_link(array('type_id' => $type->id(), 'id' => $ent_id, 'cur_module' => 'Editor')) . '">' . $name . '</a></li>' . "\n";
$i++;
}
echo '</ul>' . "\n";
echo '</div>' . "\n";
}
echo '</li>' . "\n";
}
echo '</ul>' . "\n";
echo '</div>' . "\n";
echo '</div>' . "\n";
}