当前位置: 首页>>代码示例>>PHP>>正文


PHP reason_create_entity函数代码示例

本文整理汇总了PHP中reason_create_entity函数的典型用法代码示例。如果您正苦于以下问题:PHP reason_create_entity函数的具体用法?PHP reason_create_entity怎么用?PHP reason_create_entity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了reason_create_entity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 function process()
 {
     //prep site
     $this->helper->ensure_type_is_on_site(id_of('publication_type'));
     $this->helper->ensure_type_is_on_site(id_of('group_type'));
     $this->helper->ensure_nobody_group_is_on_site();
     // gather core information
     $pub_type_id = id_of('publication_type');
     $name = trim(strip_tags($this->get_value('pub_name')));
     // populate values array
     $values['new'] = 0;
     $values['description'] = trim(get_safer_html($this->get_value('pub_description')));
     $values['unique_name'] = trim(strip_tags($this->get_value('pub_unique_name')));
     $values['state'] = 'Live';
     $values['hold_comments_for_review'] = 'no';
     $values['posts_per_page'] = turn_into_int($this->get_value('pub_posts_per_page'));
     $values['blog_feed_string'] = trim(strip_tags($this->get_value('pub_rss_feed_url')));
     $values['publication_type'] = 'Newsletter';
     $values['has_issues'] = 'no';
     $values['has_sections'] = 'no';
     $values['date_format'] = $this->get_value('date_format');
     // create the publication
     $pub_id = reason_create_entity($this->site_id, $pub_type_id, $this->user_id, $name, $values);
     // associate with nobody posting and commenting groups
     create_relationship($pub_id, id_of('nobody_group'), relationship_id_of('publication_to_authorized_posting_group'));
     create_relationship($pub_id, id_of('nobody_group'), relationship_id_of('publication_to_authorized_commenting_group'));
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:27,代码来源:migrator_screen_3.php

示例2: create_type

function create_type($site, $type, $user, $name, $array)
{
    $ret = reason_create_entity($site, $type, $user, $name, $array);
    id_of('type', false);
    //clear cache
    create_default_rels_for_new_type($ret, $array['unique_name']);
    return $ret;
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:8,代码来源:classified.php

示例3: do_updates

 function do_updates($mode, $reason_user_id)
 {
     if ($mode != 'run' && $mode != 'test') {
         trigger_error('$mode most be either "run" or "test"');
         return;
     }
     $messages = array();
     $es = new entity_selector(id_of('master_admin'));
     $es->add_type(id_of('view_type'));
     $es->add_relation('url = "sections_and_issues.php"');
     $es->set_num(1);
     $view_types = $es->run_one();
     if (empty($view_types)) {
         if ('test' == $mode) {
             echo '<p>Would have added the view type sections_and_issues.php and the Sections and Issues view</p>' . "\n";
             return;
         } else {
             $view_type_id = reason_create_entity(id_of('master_admin'), id_of('view_type'), $reason_user_id, 'News Sections and Issues', array('url' => 'sections_and_issues.php'));
             $view_type = new entity($view_type_id);
             echo '<p>Added the view type sections_and_issues.php</p>' . "\n";
         }
     } else {
         echo '<p>sections_and_issues.php view type already added</p>' . "\n";
         $view_type = current($view_types);
     }
     $es = new entity_selector(id_of('master_admin'));
     $es->add_type(id_of('view'));
     $es->add_left_relationship($view_type->id(), relationship_id_of('view_to_view_type'));
     $es->set_num(1);
     $views = $es->run_one();
     if (empty($views)) {
         if ('test' == $mode) {
             echo '<p>Would have added the Sections and Issues view</p>' . "\n";
         } else {
             $es = new entity_selector(id_of('master_admin'));
             $es->add_type(id_of('field'));
             $es->add_relation('entity.name = "status"');
             $es->set_num(1);
             $fields = $es->run_one();
             $view_id = reason_create_entity(id_of('master_admin'), id_of('view'), $reason_user_id, 'News Sections and Issues', array('display_name' => 'Sections and Issues'));
             create_relationship($view_id, $view_type->id(), relationship_id_of('view_to_view_type'));
             create_relationship($view_id, id_of('news'), relationship_id_of('view_to_type'));
             if (!empty($fields)) {
                 $field = current($fields);
                 create_relationship($view_id, $field->id(), relationship_id_of('view_columns'));
                 create_relationship($view_id, $field->id(), relationship_id_of('view_searchable_fields'));
             }
             echo '<p>Added sections and issue view</p>';
         }
     } else {
         echo '<p>sections and issues view already added.</p>' . "\n";
     }
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:53,代码来源:minor_updates.php

示例4: run

 /**
  * Run the upgrader
  * @return string HTML report
  */
 public function run()
 {
     if ($this->_link_in_db()) {
         return 'This script has already run';
     } else {
         if ($id = reason_create_entity(id_of('master_admin'), id_of('admin_link'), $this->user_id(), 'Admin Tools', array('url' => '?cur_module=AdminTools', 'new' => 0))) {
             if (create_relationship(id_of('master_admin'), $id, relationship_id_of('site_to_admin_link'))) {
                 return 'Created the admin tools link and placed on Master Admin sidebar';
             } else {
                 return 'Created the admin tools link but error occurred placing in Master Admin sidebar. You may want to do this manually.';
             }
         } else {
             return 'Error creating the AdminTools link. You may want to add this link manually, by adding an Admin Link in Master Admin to the URL "?cur_module=AdminTools"';
         }
     }
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:20,代码来源:add_admin_tools.php

示例5: create_image_entity

function create_image_entity($media_work, $username)
{
    $name = $media_work->get_value('name') . ' (Generated Thumbnail)';
    $values = array();
    $values['new'] = '0';
    $values['description'] = 'A thumbnail image for Vimeo media work ' . $media_work->get_value('name');
    $values['no_share'] = '0';
    $e = new entity($media_work->get_value('id'));
    $site_id = $e->get_owner()->id();
    if ($username) {
        return reason_create_entity($site_id, id_of('image'), get_user_id($username), $name, $values);
    } else {
        echo date(DATE_RFC822) . ': Empty username. Could not create image entity for Media Work with id ' . $media_work->get_value('id') . '.' . "\n";
    }
    return false;
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:16,代码来源:update_script.php

示例6: create_google_map_type

 /**
  * Create the google map type.
  */
 protected function create_google_map_type()
 {
     // make sure the cache is clear
     reason_refresh_relationship_names();
     reason_refresh_unique_names();
     $str = '';
     $google_map_id = reason_create_entity(id_of('master_admin'), id_of('type'), $this->user_id(), 'Google Map', $this->google_map_type_details);
     create_default_rels_for_new_type($google_map_id);
     create_reason_table('google_map', $this->google_map_type_details['unique_name'], $this->user_id());
     $ftet = new FieldToEntityTable('google_map', $this->google_map_table_fields);
     $ftet->update_entity_table();
     ob_start();
     $ftet->report();
     $str .= ob_get_contents();
     ob_end_clean();
     // create all the necessary relationships for the google map type
     create_allowable_relationship(id_of('minisite_page'), id_of('google_map_type'), 'page_to_google_map', $this->page_to_google_map_details);
     create_allowable_relationship(id_of('event_type'), id_of('google_map_type'), 'event_to_google_map', $this->event_to_google_map_details);
     $str .= '<p>Created page_to_google_map and even_to_google_map allowable relationships</p>';
     return $str;
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:24,代码来源:add_google_map.php

示例7: add_quote_type

 function add_quote_type()
 {
     if (reason_unique_name_exists('quote_type', false)) {
         echo '<p>quote_type already exists. No need to create</p>' . "\n";
         return false;
     }
     if ($this->mode == 'run') {
         reason_create_entity(id_of('master_admin'), id_of('type'), $this->reason_user_id, 'Quote', $this->quote_type_details);
         if (reason_unique_name_exists($this->quote_type_details['unique_name'], false)) {
             $type_id = id_of('quote_type');
             create_default_rels_for_new_type($type_id, $this->quote_type_details['unique_name']);
             $this->add_entity_table_to_type('meta', 'quote_type');
             $this->add_entity_table_to_type('chunk', 'quote_type');
             // setup its relationship to entity tables
             echo '<p>quote_types successfully created</p>' . "\n";
         } else {
             echo '<p>Unable to create quote_type</p>';
         }
     } else {
         echo '<p>Would have created quote_type.</p>' . "\n";
     }
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:22,代码来源:quote_type.php

示例8: reason_import

 function reason_import($info, $user)
 {
     return reason_create_entity($this->admin_page->site_id, id_of('av'), $user->id(), $info['name'], $info);
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:4,代码来源:media_import.php

示例9: process

	function process()
	{	
		$description = trim(tidy($this->get_value('description')));
		$content = trim(get_safer_html(tidy($this->get_value('post_content'))));
		if(carl_empty_html($description))
		{
			$words = explode(' ', $content, 31);
			unset($words[count($words)-1]);
			$description = implode(' ', $words).'…';
			$description = trim(tidy($description)); // we're tidying it twice so that if we chop off a closing tag tidy will stitch it back up again
		}
		
		if(!empty($this->user_netID))
		{
			$user_id = make_sure_username_is_user($this->user_netID, $this->site_info->id());
		}
		else
		{
			$user_id = $this->site_info->id();
		}
		
		if($this->hold_posts_for_review)
		{
			$status = 'pending';
		}
		else
		{
			$status = 'published';
		}

		$values = array (
			'status' => $status,
			'release_title' => trim(strip_tags($this->get_value('title'))),
			'author' => trim(strip_tags($this->get_value('author'))),
			'content' => $content,
			'description' => $description,
			'datetime' => date('Y-m-d H:i:s', time()),
			'keywords' => implode(', ', array(strip_tags($this->get_value('title')), date('Y'), date('F'))),
			'show_hide' => 'show',
			'new' => 0
		);
				
		$this->new_post_id = reason_create_entity( 
			$this->site_info->id(), 
			id_of('news'), 
			$user_id, 
			$values['release_title'], 
			$values
		);
		
		create_relationship(
			$this->new_post_id,
			$this->publication->id(),
			relationship_id_of('news_to_publication')
		);

		if ($this->successfully_submitted())
		{
			
			if($this->hold_posts_for_review)
			{
				echo '<p>Posts are being held for review on this publication. Please check back later to see if your post has been published.</p>';
				echo '<a href="?">Back to main page</a>';
			
			}
			else
			{
				echo '<p>Your post has been published.</p>';
				echo '<a href="'.carl_construct_redirect(array('story_id'=>$this->new_post_id)).'">View it.</a>';
			}
		}
		
		if($this->get_value('issue'))
		{
			create_relationship($this->new_post_id, $this->get_value('issue'), relationship_id_of('news_to_issue'));
		}
		
		if($this->get_value('section'))
		{
			create_relationship($this->new_post_id, $this->get_value('section'), relationship_id_of('news_to_news_section'));
		}
		
		if($this->get_value('categories'))
		{
			foreach($this->get_value('categories') as $category_id)
			{
				// Check to make sure ids posted actually belong to categories in the site
				if(array_key_exists($category_id, $this->categories))
				{
					create_relationship(
						$this->new_post_id,
						$category_id,
						relationship_id_of('news_to_category')
					);
				}
			}
		}
		
		$this->show_form = false;

//.........这里部分代码省略.........
开发者ID:natepixel,项目名称:reason_package,代码行数:101,代码来源:submit_post.php

示例10: id_of

    echo '<li>Changes required to "no" for news_to_issue</li>';
    echo '<li>Changes required to "no" for news_to_news_section</li>';
    echo '</ul>';
}
if (isset($_POST['verify']) && $_POST['verify'] == 'Run') {
    //check if nobody group exists
    $e = id_of('nobody_group');
    if ($e) {
        echo '<p>nobody group already exists - not created</p>';
    } else {
        $user_id = get_user_id($user_netID);
        $site_id = id_of('master_admin');
        $type_id = id_of('group_type');
        $name = "Nobody Group";
        $values = array('unique_name' => 'nobody_group', 'group_has_members' => 'false');
        $new_e_id = reason_create_entity($site_id, $type_id, $user_id, $name, $values, $testmode = false);
        if (!empty($new_e_id)) {
            echo '<p>created nobody group entity</p>';
        }
    }
    //check if blog_type exists - if it does not this database has probably already been upgraded and converted
    //
    $test = id_of('blog_type');
    $blog_type_exists = empty($test) ? false : true;
    //echo '<p>There is no type with unique name blog_type, which means ';
    //echo 'the script cannot continue to run and this database has ';
    //echo 'probably already been upgraded.</p>';
    //die;
    //check if entity table date_format exists
    if ($blog_type_exists && create_entity_table("date_format", "blog_type", get_user_id($user_netID))) {
        echo '<p>created entity table date_format and added to blog type</p>';
开发者ID:hunter2814,项目名称:reason_package,代码行数:31,代码来源:upgrade_db.php

示例11: current

$es->set_num(1);
$theme_entities = $es->run_one(id_of('theme_type'));
if (!empty($theme_entities)) {
    $theme_entity = current($theme_entities);
    echo 'Updating ' . $theme_entity->get_value('name') . ' Theme<br />';
    reason_update_entity($theme_entity->id(), $user_id, array('name' => 'Simplicity Blue'));
}
$es = new entity_selector();
$es->add_relation('url = "css/simplicity/green.css"');
$es->set_num(1);
$css_entities = $es->run_one(id_of('css'));
if (empty($css_entities)) {
    $css_entity = current($css_entities);
    echo 'Adding simplicity green theme<br />', "\n";
    $css_id = reason_create_entity(id_of('master_admin'), id_of('css'), $user_id, 'Simplicity Green', array('url' => 'css/simplicity/green.css', 'css_relative_to_reason_http_base' => 'true'));
    $theme_id = reason_create_entity(id_of('master_admin'), id_of('theme_type'), $user_id, 'Simplicity Green', array('unique_name' => 'simplicity_green_theme'));
    create_relationship($theme_id, $css_id, relationship_id_of('theme_to_external_css_url'));
    $es = new entity_selector();
    $es->add_relation('name = "default"');
    $es->set_num(1);
    $def_temps = $es->run_one(id_of('minisite_template'));
    if (!empty($def_temps)) {
        $def_temp = current($def_temps);
        create_relationship($theme_id, $def_temp->id(), relationship_id_of('theme_to_minisite_template'));
    }
}
// Add the css selector to exisiting generic themes (except for core themes)
$core_templates = array('tables', 'default');
$core_themes = array('unbranded_theme', 'tableless_2_unbranded_theme', 'unbranded_basic_blue_theme', 'opensource_reason_theme', 'reason_promo', 'reason_promo_subsite', 'simplicity_green_theme');
$css_es = new entity_selector();
$css_es->add_type(id_of('css'));
开发者ID:hunter2814,项目名称:reason_package,代码行数:31,代码来源:template_fix.php

示例12: process

	function process()
	{
		if(!empty($this->username))
		{
			$user_id = make_sure_username_is_user($this->username, $this->site_id);
		}
		else
		{
			$user_id = $this->site_info->id();
		}

		if($this->hold_comments_for_review)
		{
			$show_hide = 'hide';
		}
		else
		{
			$show_hide = 'show';
		}
		$flat_values = array (
			'state' => 'Live',
			'author' => trim(get_safer_html(strip_tags($this->get_value('author')))),
			'content' => trim(get_safer_html(strip_tags(tidy($this->get_value('comment_content')), '<p><em><strong><a><ol><ul><li><blockquote><acronym><abbr><br><cite><code><pre>'))),
			'datetime' => date('Y-m-d H:i:s'),
			'show_hide' => $show_hide,
			'new'=>'0',
		);

		$this->comment_id = reason_create_entity( 
			$this->site_id, 
			id_of('comment_type'), 
			$user_id, 
			trim(substr(strip_tags($flat_values['content']),0,40)),
			$flat_values,
			$testmode = false
		);
		
		create_relationship(
			$this->news_item->_id,
			$this->comment_id,
			relationship_id_of('news_to_comment')
		);
		$this->do_notifications();
	}
开发者ID:natepixel,项目名称:reason_package,代码行数:44,代码来源:submit_comment.php

示例13: create_image_entity

/**
 * Creates an image entity for the video's thumbnail.
 *
 * @param $media_work entity
 * @param $username string
 * @return entity
 */
function create_image_entity($media_work, $username)
{
    $name = $media_work->get_value('name') . ' (Generated Thumbnail)';
    $values = array();
    $values['new'] = '0';
    $values['description'] = 'A placard image for media work ' . $media_work->get_value('name');
    $values['no_share'] = '0';
    return reason_create_entity($media_work->get_owner()->id(), id_of('image'), get_user_id($username), $name, $values);
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:16,代码来源:zencoder_notification_receiver.php

示例14: process

 function process()
 {
     $site_id = $this->site_id;
     $counts = array();
     for ($i = 1; $i <= $this->max_upload_number; $i++) {
         $element = $this->get_element('upload_' . $i);
         if (!empty($element->tmp_full_path) and file_exists($element->tmp_full_path)) {
             $filename = $this->get_value('upload_' . $i . '_filename');
             if ($this->verify_image($element->tmp_full_path)) {
                 if (empty($counts[$filename])) {
                     $this->files[$filename] = $element->tmp_full_path;
                     $counts[$filename] = 1;
                 } else {
                     $counts[$filename]++;
                     $this->files[$filename . '.' . $counts[$filename]] = $element->tmp_full_path;
                 }
             } else {
                 $this->invalid_files[$filename] = $element->tmp_full_path;
             }
         }
     }
     if (count($this->files)) {
         $page_id = (int) $this->get_value('attach_to_page');
         $max_sort_order_value = 0;
         if ($page_id) {
             $max_sort_order_value = $this->_get_max_sort_order_value($page_id);
         }
         $sort_order_value = $max_sort_order_value;
         $tables = get_entity_tables_by_type(id_of('image'));
         $valid_file_html = '<ul>' . "\n";
         foreach ($this->files as $entry => $cur_name) {
             $sort_order_value++;
             $valid_file_html .= '<li><strong>' . $entry . ':</strong> processing ';
             $date = '';
             // get suffix
             $type = strtolower(substr($cur_name, strrpos($cur_name, '.') + 1));
             $ok_types = array('jpg');
             // get exif data
             if ($this->get_value('exif_override') && in_array($type, $ok_types) && function_exists('read_exif_data')) {
                 // read_exif_data() does not obey error supression
                 $exif_data = @read_exif_data($cur_name);
                 if ($exif_data) {
                     // some photos may have different fields filled in for dates - look through these until one is found
                     $valid_dt_fields = array('DateTimeOriginal', 'DateTime', 'DateTimeDigitized');
                     foreach ($valid_dt_fields as $field) {
                         // once we've found a valid date field, store that and break out of the loop
                         if (!empty($exif_data[$field])) {
                             $date = $exif_data[$field];
                             break;
                         }
                     }
                 }
             } else {
                 $date = $this->get_value('datetime');
             }
             $keywords = $entry;
             if ($this->get_value('keywords')) {
                 $keywords .= ', ' . $this->get_value('keywords');
             }
             // insert entry into DB with proper info
             $values = array('datetime' => $date, 'image_type' => $type, 'author' => $this->get_value('author'), 'state' => 'Pending', 'keywords' => $keywords, 'description' => $this->get_value('description'), 'name' => $this->get_value('name') ? $this->get_value('name') : $entry, 'content' => $this->get_value('content'), 'original_image_format' => $this->get_value('original_image_format'), 'new' => 0, 'no_share' => $this->get_value('no_share'));
             //tidy values
             $no_tidy = array('state', 'new');
             foreach ($values as $key => $val) {
                 if (!in_array($key, $no_tidy) && !empty($val)) {
                     $values[$key] = trim(get_safer_html(tidy($val)));
                 }
             }
             $id = reason_create_entity($site_id, id_of('image'), $this->user_id, $entry, $values);
             if ($id) {
                 //assign to categories
                 $categories = $this->get_value('assign_to_categories');
                 if (!empty($categories)) {
                     foreach ($categories as $category_id) {
                         create_relationship($id, $category_id, relationship_id_of('image_to_category'));
                     }
                 }
                 //assign to	gallery page
                 if ($page_id) {
                     create_relationship($page_id, $id, relationship_id_of('minisite_page_to_image'), array('rel_sort_order' => $sort_order_value));
                 }
                 // resize and move photos
                 $new_name = PHOTOSTOCK . $id . '.' . $type;
                 $orig_name = PHOTOSTOCK . $id . '_orig.' . $type;
                 $tn_name = PHOTOSTOCK . $id . '_tn.' . $type;
                 // Support for new fields; they should be set null by default, but will be
                 // changed below if a thumbnail/original image is created. This is very messy...
                 $thumbnail_image_type = null;
                 $original_image_type = null;
                 // atomic move the file if possible, copy if necessary
                 if (is_writable($cur_name)) {
                     rename($cur_name, $new_name);
                 } else {
                     copy($cur_name, $new_name);
                 }
                 // create a thumbnail if need be
                 list($width, $height, $type, $attr) = getimagesize($new_name);
                 if ($width > REASON_STANDARD_MAX_IMAGE_WIDTH || $height > REASON_STANDARD_MAX_IMAGE_HEIGHT) {
                     copy($new_name, $orig_name);
                     resize_image($new_name, REASON_STANDARD_MAX_IMAGE_WIDTH, REASON_STANDARD_MAX_IMAGE_HEIGHT);
//.........这里部分代码省略.........
开发者ID:natepixel,项目名称:reason_package,代码行数:101,代码来源:image_import.php

示例15: build_course_section_entities

 protected function build_course_section_entities($data)
 {
     echo "Building section entities\n";
     foreach ($data as $key => $row) {
         //echo round(memory_get_usage()/1024,2)."K at point E\n";
         $es = new entity_selector();
         $es->add_type(id_of('course_section_type'));
         $name = sprintf('%s %s %s', $row['course_number'], $row['academic_session'], $row['title']);
         $es->relations = array();
         $es->add_relation('sourced_id = "' . $row['sourced_id'] . '"');
         if ($result = $es->run_one()) {
             $section = reset($result);
             // Find all the values that correspond to the data we're importing
             $values = array_intersect_key($section->get_values(), $row);
             if ($values != $row) {
                 echo 'Updating: ' . $name . "\n";
                 reason_update_entity($section->id(), get_user_id('causal_agent'), $row, false);
             } else {
                 echo 'Unchanged: ' . $name . "\n";
             }
         } else {
             if ($this->get_section_parent($row['parent_template_id'])) {
                 echo 'Adding: ' . $name . "\n";
                 $id = reason_create_entity(id_of('academic_catalog_site'), id_of('course_section_type'), get_user_id('causal_agent'), $name, $row);
                 $section = new entity($id);
             } else {
                 echo 'No course template found; skipping ' . $name . "\n";
                 continue;
             }
         }
         if (!empty($section)) {
             $this->link_section_to_parent($section);
         }
         //echo round(memory_get_usage()/1024,2)."K at point D\n";
     }
 }
开发者ID:hunter2814,项目名称:reason_package,代码行数:36,代码来源:course_import.php


注:本文中的reason_create_entity函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。