/**
  * Run the upgrader
  * @return string HTML report
  */
 public function run()
 {
     $run_message = '';
     if (!reason_relationship_name_exists('news_to_media_work')) {
         $news_to_media_work_definition = array('description' => 'News / Post shows Media Work', 'directionality' => 'bidirectional', 'connections' => 'many_to_many', 'required' => 'no', 'is_sortable' => 'yes', 'display_name' => 'Media', 'display_name_reverse_direction' => 'News / Posts');
         if (create_allowable_relationship(id_of('news'), id_of('av'), 'news_to_media_work', $news_to_media_work_definition)) {
             $run_message .= '<p>Added the news_to_media_work allowable relationship.</p>';
         } else {
             $run_message .= '<p>Failed to create the news_to_media_work allowable relationship. Try again. If you are not successful, you may wish to try to add this relationship type manually: In Master Admin, go to Allowable Relationship Manager, add a row, then create a relationship between News / Post and Media Work named news_to_media work. The other values are:</p>' . spray($news_to_media_work_definition);
         }
     }
     if (!reason_relationship_name_exists('event_to_media_work')) {
         $event_to_media_work_definition = array('description' => 'Event shows Media Work', 'directionality' => 'bidirectional', 'connections' => 'many_to_many', 'required' => 'no', 'is_sortable' => 'yes', 'display_name' => 'Media', 'display_name_reverse_direction' => 'Events');
         if (create_allowable_relationship(id_of('event_type'), id_of('av'), 'event_to_media_work', $event_to_media_work_definition)) {
             $run_message .= '<p>Added the event_to_media_work allowable relationship.</p>';
         } else {
             $run_message .= '<p>Failed to create the event_to_media_work allowable relationship. Try again. If you are not successful, you may wish to try to add this relationship type manually: In Master Admin, go to Allowable Relationship Manager, add a row, then create a relationship between Event and Media Work named event_to_media work. The other values are:</p>' . spray($event_to_media_work_definition);
         }
     }
     if (!empty($run_message)) {
         return $run_message;
     } else {
         return 'This update has already run.';
     }
 }
/** @access private */
function _carl_util_display_error($level, $message, $file, $line, $context)
{
    $s_level = error_level_name($level);
    list($escaped_message, $include_loc) = _process_message($message);
    $file = _clean_filename($file);
    $err = '<div style="border: 2px solid #E00; background-color: #EEE; ' . 'color: black; padding: 0.5em; margin: 0.5em; font-size: 90%;">';
    $err .= "<strong>{$s_level}:</strong> {$escaped_message}";
    if ($include_loc) {
        if (preg_match('/[\\.?!]$/', $message)) {
            // full sentence
            $err .= " (<code>{$file}:{$line}</code>)";
        } else {
            // fragment
            $err .= " at <code>{$file}:{$line}</code>";
        }
    }
    if (level_is_terminal($level) && error_handler_config('display_context')) {
        $escaped_context = spray($context);
        $err .= '<br />';
        $err .= '<b style="font-size: 90%; margin-top: 0.3em;">Context:</b>' . "\n\n<pre>{$escaped_context}</pre>";
        $err .= "<br /><br /><strong>Script execution halted.</strong>";
    }
    $err .= "</div>\n";
    if (php_sapi_name() == 'cli') {
        $err = strip_tags(preg_replace('=<br */?>=i', "\n", $err));
    }
    echo $err;
}