function start_xml_element($parser, $name, $attrs)
{
    global $App;
    global $obj;
    global $kinds;
    global $folders;
    switch ($name) {
        case 'CHANGE':
            include_once 'projects/obj/change.php';
            $obj = new CHANGE($App);
            $obj->title = $attrs['TITLE'];
            $kind = $kinds[strtolower($attrs['KIND'])];
            if (!$kind) {
                raise_xml("[{$attrs['KIND']}] is not a valid change type.");
            }
            $obj->kind = $kind->value;
            $t = $App->make_date_time($attrs['TIME'], Date_time_iso);
            if (!$t->is_valid()) {
                raise_xml("[{$attrs['TIME']}] is not a valid date/time.");
            } else {
                $obj->time_created = $t;
                $obj->time_modified = $t;
            }
            break;
        case 'CREATOR':
            raise_if_not_in_object($name);
            $orig_name = $attrs['TITLE'];
            $user_name = $orig_name;
            $at = strpos($user_name, '@');
            if ($at !== false) {
                $user_name = substr($user_name, 0, $at);
                raise_xml("Truncated name from [{$orig_name}] to [{$user_name}]", Msg_type_warning);
            }
            if (!$user_name) {
                raise_xml("Creator title cannot be empty.");
            }
            $user_query = $App->user_query();
            $user = $user_query->object_at_name($user_name);
            if (!$user) {
                raise_xml("User [{$user_name}] does not exist.");
            }
            $obj->creator_id = $user->id;
            $obj->modifier_id = $user->id;
            break;
        case 'FOLDER':
            raise_if_not_in_object($name);
            $id = $attrs['ID'];
            $folder = $folders[$id];
            if (!$folder) {
                raise_xml("Folder [{$id}] does not exist.");
            }
            $obj->set_parent_folder($folder);
            break;
        case 'DESCRIPTION':
            raise_if_not_in_object($name);
            break;
        case 'FILES':
            raise_if_not_in_object($name);
            break;
    }
}
Esempio n. 2
0
 /**
  * Draw extra description information for the entry.
  * @param CHANGE $obj
  */
 protected function _draw_description($obj)
 {
     if ($obj->files) {
         echo '<h4>' . $obj->num_files() . ' Files</h4>';
         echo $obj->files_as_html();
     }
 }
 /**
  * @param CHANGE $obj Retrieve the title from this change.
  * @return string
  * @access private
  */
 protected function _text_for_list($obj)
 {
     $props = $obj->kind_properties();
     return $this->context->get_icon_with_text($props->icon, Sixteen_px, parent::_text_for_list($obj));
 }
 /**
  * Record class-specific differences.
  * 'orig' is the same as {@link $_object}, but is passed here for convenience.
  * @param CHANGE $orig
  * @param CHANGE $new
  * @access private
  */
 protected function _record_differences($orig, $new)
 {
     $this->_record_text_difference('Files', $orig->files, $new->files);
     if ($orig->job_id != $new->job_id) {
         $this->_record_object_difference('Job', $orig->job(), $new->job(), '(no job)', '\'', '\'');
     }
     parent::_record_differences($orig, $new);
 }
 /**
  * Outputs the object as plain text.
  * @param CHANGE $entry
  * @access private
  */
 protected function _display_as_plain_text($entry)
 {
     echo $this->line('[Kind]: ' . $entry->kind_as_text());
     $job = $entry->job();
     if (isset($job)) {
         echo $this->line('[Job]: ' . $job->title_as_plain_text());
     }
     $this->_echo_plain_text_user_information($entry);
     $this->_echo_branches_as_plain_text($entry);
     $this->_echo_plain_text_description($entry);
     $this->_echo_plain_text_extra_description($entry);
 }