Ejemplo n.º 1
0
 public static function updateServer($uri, $username, $password, $remember, $userId = -1)
 {
     $servers = BIMsie::getServers(false, $userId);
     $found = false;
     foreach ($servers as $key => $server) {
         if ($server['uri'] == $uri) {
             if ($remember == 1) {
                 $servers[$key] = array('uri' => $uri, 'remember' => 1, 'username' => $username, 'password' => $password);
             } else {
                 $servers[$key] = array('uri' => $uri, 'remember' => 0);
             }
             $found = true;
             $serverId = $key;
             break;
         }
     }
     $userId = $userId == -1 ? get_current_user_id() : $userId;
     if (!$found) {
         $serverId = count($servers);
         if ($remember == 1) {
             $server = array('uri' => $uri, 'remember' => 1, 'username' => $username, 'password' => $password);
         } else {
             $server = array('uri' => $uri, 'remember' => 0);
         }
         add_user_meta($userId, 'bimsie-servers', $server);
         $servers[$serverId] = $server;
     } else {
         delete_user_meta($userId, 'bimsie-servers');
         foreach ($servers as $server) {
             add_user_meta($userId, 'bimsie-servers', $server);
         }
     }
     return $servers[$serverId];
 }
    public static function showAddIssueForm()
    {
        global $wpdb;
        if (is_user_logged_in()) {
            $options = BIMBCFManagement::getOptions();
            $bimsieServers = BIMsie::getServers();
            $topicStatuses = explode(',', $options['topic_statuses']);
            $topicTypes = explode(',', $options['topic_types']);
            $topicLabels = explode(',', $options['topic_labels']);
            $snippetTypes = explode(',', $options['snippet_types']);
            $priorities = explode(',', $options['priorities']);
            $userIdTypes = BIMBCFManagement::getUserIdTypes();
            if (isset($_POST['submit'])) {
                $jsonIssue = array('markup' => array('Header' => array('File' => array()), 'Topic' => array(), 'Comment' => array(), 'Viewpoints' => array()), 'visualizationinfo' => array('Components' => array(), 'OrthogonalCamera' => array(), 'PerspectiveCamera' => array(), 'Lines' => array(), 'ClippingPlanes' => array(), 'Bitmap' => array()));
                $server = isset($_POST['bimsie_server_uri']) ? $_POST['bimsie_server_uri'] : '';
                if (is_numeric($server)) {
                    if (isset($bimsieServers[$server])) {
                        $server = $bimsieServers[$server]['uri'];
                    } else {
                        $server = '';
                    }
                }
                if (isset($_POST['file_project']) && is_array($_POST['file_project'])) {
                    foreach ($_POST['file_project'] as $key => $project) {
                        if ($project != '') {
                            $jsonIssue['markup']['Header']['File'][] = array('bimserver' => $server, 'poid' => $project, 'roid' => isset($_POST['file_revision'][$key]) ? $_POST['file_revision'][$key] : '', 'Filename' => isset($_POST['file_reference'][$key]) ? $_POST['file_reference'][$key] : '', 'Date' => isset($_POST['file_date'][$key]) ? $_POST['file_date'][$key] : date('Y-m-d\\TH:i:sP'), 'Reference' => isset($_POST['file_reference'][$key]) ? $_POST['file_reference'][$key] : '', '@attributes' => array('isExternal' => true, 'IfcProject' => isset($_POST['file_ifcproject'][$key]) ? $_POST['file_ifcproject'][$key] : '', 'IfcSpatialStructureElement' => isset($_POST['file_spatial'][$key]) ? $_POST['file_spatial'][$key] : ''));
                        }
                    }
                }
                $jsonIssue['markup']['Topic']['@attributes'] = array('Guid' => $_POST['topic_guid'], 'TopicType' => $_POST['topic_type'], 'TopicStatus' => $_POST['topic_status']);
                $jsonIssue['markup']['Topic']['ReferenceLink'] = $_POST['topic_referencelink'];
                $jsonIssue['markup']['Topic']['Title'] = $_POST['topic_title'];
                $jsonIssue['markup']['Topic']['Index'] = $_POST['topic_index'];
                $jsonIssue['markup']['Topic']['Label'] = $_POST['topic_label'];
                $jsonIssue['markup']['Topic']['CreationDate'] = date('Y-m-d\\TH:i:sP');
                $jsonIssue['markup']['Topic']['ModifiedDate'] = date('Y-m-d\\TH:i:sP');
                $jsonIssue['markup']['Topic']['AssignedTo'] = $_POST['assigned_to'];
                $jsonIssue['markup']['Topic']['BimSnippet']['Reference'] = $_POST['bim_snippet_reference'];
                $jsonIssue['markup']['Topic']['BimSnippet']['ReferenceSchema'] = $_POST['bim_snippet_reference_schema'];
                $jsonIssue['markup']['Topic']['BimSnippet']['@atributes'] = array('SnippetType' => $_POST['bim_snippet_type'], 'isExternal' => isset($_POST['bim_snippet_isexternal']) && $_POST['bim_snippet_isexternal'] == 'true' ? true : false);
                $jsonIssue['markup']['Topic']['DocumentReference'] = array();
                if (is_array($_POST['referenced_document'])) {
                    foreach ($_POST['referenced_document'] as $key => $referencedDocument) {
                        if ($referencedDocument != '') {
                            $jsonIssue['markup']['Topic']['DocumentReference'][] = array('ReferencedDocument' => $referencedDocument, 'Description' => isset($_POST['document_reference_description'][$key]) ? $_POST['document_reference_description'][$key] : '', '@attributes' => array('isExternal' => isset($_POST['document_reference_isexternal'][$key]) && $_POST['document_reference_isexternal'][$key] == 'true' ? true : false, 'Guid' => isset($_POST['document_reference_guid'][$key]) ? $_POST['document_reference_guid'][$key] : ''));
                        }
                    }
                }
                $jsonIssue['markup']['Topic']['RelatedTopics'] = array();
                if (is_array($_POST['related_topic'])) {
                    foreach ($_POST['related_topic'] as $key => $relatedTopic) {
                        if ($relatedTopic != '') {
                            $jsonIssue['markup']['Topic']['RelatedTopics'][] = array('@attributes' => array('Guid' => $relatedTopic));
                        }
                    }
                }
                $uploadInfo = wp_upload_dir();
                $attachments = array();
                if (is_array($_POST['viewpoint'])) {
                    foreach ($_POST['viewpoint'] as $key => $viewpoint) {
                        if ($viewpoint != '') {
                            $snapshot = '';
                            if (isset($_FILES['snapshot']) && is_array($_FILES['snapshot']['tmp_name']) && isset($_FILES['snapshot']['tmp_name'][$key]) && $_FILES['snapshot']['tmp_name'][$key] != '') {
                                if (!isset($_FILES['snapshot']['error'][$key]) || $_FILES['snapshot']['error'][$key] == 0) {
                                    $index = 1;
                                    $basename = substr($_FILES['snapshot']['name'][$key], 0, strrpos($_FILES['snapshot']['name'][$key], '.'));
                                    $extension = substr($_FILES['snapshot']['name'][$key], strrpos($_FILES['snapshot']['name'][$key], '.') + 1);
                                    $filename = $_FILES['snapshot']['name'][$key];
                                    // Find the first available filename
                                    while (file_exists($uploadInfo['path'] . '/' . $filename)) {
                                        $index++;
                                        $filename = $basename . '-' . $index . '.' . $extension;
                                    }
                                    if (move_uploaded_file($_FILES['snapshot']['tmp_name'][$key], $uploadInfo['path'] . '/' . $filename) !== false) {
                                        // Add the snapshot as an attachment to the project
                                        $wpFiletype = wp_check_filetype(basename($filename), null);
                                        $attachment = array('guid' => $uploadInfo['url'] . '/' . basename($filename), 'post_mime_type' => $wpFiletype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($filename)), 'post_content' => '', 'post_status' => 'inherit');
                                        $attachId = wp_insert_attachment($attachment, $uploadInfo['path'] . '/' . $filename);
                                        // you must first include the image.php file
                                        // for the function wp_generate_attachment_metadata() to work
                                        require_once ABSPATH . 'wp-admin/includes/image.php';
                                        $attachData = wp_generate_attachment_metadata($attachId, $uploadInfo['path'] . '/' . $filename);
                                        wp_update_attachment_metadata($attachId, $attachData);
                                        $attachments[] = $attachId;
                                        $snapshot = wp_get_attachment_url($attachId);
                                    }
                                }
                            }
                            $viewpointObject = array('Viewpoint' => $viewpoint, 'Snapshot' => $snapshot, 'Comments' => array(), '@attributes' => array('Guid' => isset($_POST['viewpoint_guid'][$key]) ? $_POST['viewpoint_guid'][$key] : ''));
                            if (is_array($_POST['viewpoint_comment']) && is_array($_POST['viewpoint_comment'][$key])) {
                                foreach ($_POST['viewpoint_comment'][$key] as $viewpointComment) {
                                    if ($viewpointComment != '') {
                                        $viewpointObject['Comments'][] = $viewpointComment;
                                    }
                                }
                            }
                            $jsonIssue['markup']['Viewpoints'][] = $viewpointObject;
                        }
                    }
                }
                if (is_array($_POST['component_orginatingsystem'])) {
                    foreach ($_POST['component_orginatingsystem'] as $key => $componentOrginatingSystem) {
                        if ($componentOrginatingSystem != '') {
                            $jsonIssue['visualizationinfo']['Components'][] = array('OriginatingSystem' => $componentOrginatingSystem, 'AuthoringToolId' => isset($_POST['component_authoring_tool_id'][$key]) ? $_POST['component_authoring_tool_id'][$key] : '', '@attributes' => array('IfcGuid' => isset($_POST['component_ifcguid'][$key]) ? $_POST['component_ifcguid'][$key] : '', 'Selected' => isset($_POST['component_selected'][$key]) && $_POST['component_selected'][$key] == 'true' ? true : false, 'Visible' => isset($_POST['component_visible'][$key]) && $_POST['component_visible'][$key] == 'true' ? true : false, 'Color' => isset($_POST['component_colour'][$key]) ? $_POST['component_colour'][$key] : ''));
                        }
                    }
                }
                if (is_array($_POST['view_to_world_scale'])) {
                    foreach ($_POST['view_to_world_scale'] as $key => $viewToWorldScale) {
                        if ($viewToWorldScale != '') {
                            $jsonIssue['visualizationinfo']['OrthogonalCamera'][] = array('CameraViewPoint' => array('X' => isset($_POST['camera_viewpoint_x'][$key]) ? $_POST['camera_viewpoint_x'][$key] : '', 'Y' => isset($_POST['camera_viewpoint_y'][$key]) ? $_POST['camera_viewpoint_y'][$key] : '', 'Z' => isset($_POST['camera_viewpoint_z'][$key]) ? $_POST['camera_viewpoint_z'][$key] : ''), 'CameraDirection' => array('X' => isset($_POST['camera_direction_x'][$key]) ? $_POST['camera_direction_x'][$key] : '', 'Y' => isset($_POST['camera_direction_y'][$key]) ? $_POST['camera_direction_y'][$key] : '', 'Z' => isset($_POST['camera_direction_z'][$key]) ? $_POST['camera_direction_z'][$key] : ''), 'CameraUpVector' => array('X' => isset($_POST['camera_vector_up_x'][$key]) ? $_POST['camera_vector_up_x'][$key] : '', 'Y' => isset($_POST['camera_vector_up_y'][$key]) ? $_POST['camera_vector_up_y'][$key] : '', 'Z' => isset($_POST['camera_vector_up_z'][$key]) ? $_POST['camera_vector_up_z'][$key] : ''), 'ViewToWorldScale' => $viewToWorldScale);
                        }
                    }
                }
                if (is_array($_POST['field_of_view'])) {
                    foreach ($_POST['field_of_view'] as $key => $fieldOfView) {
                        if ($fieldOfView != '') {
                            $jsonIssue['visualizationinfo']['PerspectiveCamera'][] = array('CameraViewPoint' => array('X' => isset($_POST['perspective_camera_viewpoint_x'][$key]) ? $_POST['perspective_camera_viewpoint_x'][$key] : '', 'Y' => isset($_POST['perspective_camera_viewpoint_y'][$key]) ? $_POST['perspective_camera_viewpoint_y'][$key] : '', 'Z' => isset($_POST['perspective_camera_viewpoint_z'][$key]) ? $_POST['perspective_camera_viewpoint_z'][$key] : ''), 'CameraDirection' => array('X' => isset($_POST['perspective_camera_direction_x'][$key]) ? $_POST['perspective_camera_direction_x'][$key] : '', 'Y' => isset($_POST['perspective_camera_direction_y'][$key]) ? $_POST['perspective_camera_direction_y'][$key] : '', 'Z' => isset($_POST['perspective_camera_direction_z'][$key]) ? $_POST['perspective_camera_direction_z'][$key] : ''), 'CameraUpVector' => array('X' => isset($_POST['perspective_camera_vector_up_x'][$key]) ? $_POST['perspective_camera_vector_up_x'][$key] : '', 'Y' => isset($_POST['perspective_camera_vector_up_y'][$key]) ? $_POST['perspective_camera_vector_up_y'][$key] : '', 'Z' => isset($_POST['perspective_camera_vector_up_z'][$key]) ? $_POST['perspective_camera_vector_up_z'][$key] : ''), 'FieldOfView' => $fieldOfView);
                        }
                    }
                }
                if (is_array($_POST['line_start_x'])) {
                    foreach ($_POST['line_start_x'] as $key => $lineStartX) {
                        if ($lineStartX != '') {
                            $jsonIssue['visualizationinfo']['Lines'][] = array('StartPoint' => array('X' => $lineStartX, 'Y' => isset($_POST['line_start_y'][$key]) ? $_POST['line_start_y'][$key] : '', 'Z' => isset($_POST['line_start_z'][$key]) ? $_POST['line_start_z'][$key] : ''), 'EndPoint' => array('X' => isset($_POST['line_end_x'][$key]) ? $_POST['line_end_x'][$key] : '', 'Y' => isset($_POST['line_end_y'][$key]) ? $_POST['line_end_y'][$key] : '', 'Z' => isset($_POST['line_end_z'][$key]) ? $_POST['line_end_z'][$key] : ''));
                        }
                    }
                }
                if (is_array($_POST['clipping_plane_location_x'])) {
                    foreach ($_POST['clipping_plane_location_x'] as $key => $clippingPlaneLocationX) {
                        if ($clippingPlaneLocationX != '') {
                            $jsonIssue['visualizationinfo']['ClippingPlanes'][] = array('Location' => array('X' => $clippingPlaneLocationX, 'Y' => isset($_POST['clipping_plane_location_y'][$key]) ? $_POST['clipping_plane_location_y'][$key] : '', 'Z' => isset($_POST['clipping_plane_location_z'][$key]) ? $_POST['clipping_plane_location_z'][$key] : ''), 'Direction' => array('X' => isset($_POST['clipping_plane_direction_x'][$key]) ? $_POST['clipping_plane_direction_x'][$key] : '', 'Y' => isset($_POST['clipping_plane_direction_y'][$key]) ? $_POST['clipping_plane_direction_y'][$key] : '', 'Z' => isset($_POST['clipping_plane_direction_z'][$key]) ? $_POST['clipping_plane_direction_z'][$key] : ''));
                        }
                    }
                }
                if (is_array($_POST['bitmap'])) {
                    foreach ($_POST['bitmap'] as $key => $bitmap) {
                        if ($bitmap != '') {
                            $jsonIssue['visualizationinfo']['Bitmap'][] = array('Bitmap' => $bitmap, 'Reference' => isset($_POST['reference'][$key]) ? $_POST['reference'][$key] : '', 'Location' => array('X' => isset($_POST['bitmap_location_x'][$key]) ? $_POST['bitmap_location_x'][$key] : '', 'Y' => isset($_POST['bitmap_location_y'][$key]) ? $_POST['bitmap_location_y'][$key] : '', 'Z' => isset($_POST['bitmap_location_z'][$key]) ? $_POST['bitmap_location_z'][$key] : ''), 'Normal' => array('X' => isset($_POST['bitmap_normal_x'][$key]) ? $_POST['bitmap_normal_x'][$key] : '', 'Y' => isset($_POST['bitmap_normal_y'][$key]) ? $_POST['bitmap_normal_y'][$key] : '', 'Z' => isset($_POST['bitmap_normal_z'][$key]) ? $_POST['bitmap_normal_z'][$key] : ''), 'Up' => array('X' => isset($_POST['bitmap_up_x'][$key]) ? $_POST['bitmap_up_x'][$key] : '', 'Y' => isset($_POST['bitmap_up_y'][$key]) ? $_POST['bitmap_up_y'][$key] : '', 'Z' => isset($_POST['bitmap_up_z'][$key]) ? $_POST['bitmap_up_z'][$key] : ''), 'Height' => isset($_POST['height'][$key]) ? $_POST['height'][$key] : '');
                        }
                    }
                }
                $postId = BIMBCFManagement::addIssue($jsonIssue);
                if ($postId !== false) {
                    // add images to this post and set first as featured
                    $first = true;
                    foreach ($attachments as $attachmentId) {
                        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts}" . "\n                     SET post_parent = %d\n                     WHERE ID = %d", $postId, $attachmentId));
                        if ($first) {
                            set_post_thumbnail($postId, $attachmentId);
                            $first = false;
                        }
                    }
                    ?>
               <h3><?php 
                    _e('Issue added', 'bim-bcf-management');
                    ?>
</h3>
               <a href="<?php 
                    print get_bloginfo('wpurl') . $options['issue_details_uri'] . '?id=' . $postId;
                    ?>
"><?php 
                    _e('view issue', 'bim-bcf-management');
                    ?>
</a><br />
               <?php 
                    _e('or', 'bim-bcf-management');
                    ?>
<br />
               <a href="<?php 
                    the_permalink();
                    ?>
"><?php 
                    _e('add new issue', 'bim-bcf-management');
                    ?>
</a><br />
<?php 
                    return '';
                } else {
                    // TODO: issue could not be imported tell the user!
                }
            }
            ?>
         <form method="post" action="" id="add-issue-form" enctype="multipart/form-data">
            <h3><?php 
            _e('Bimsie server', 'bim-bcf-management');
            ?>
</h3>
            <div id="bimsie-server-selection">
               <div class="status"></div>
<?php 
            if (count($bimsieServers) > 0) {
                ?>
               <label for="server-selection"><?php 
                _e('Select BIMSie server', 'bim-bcf-management');
                ?>
</label> <select id="server-selection" onchange="BIMBCFManagement.frontEndServerSelected();">
                  <option value=""><?php 
                _e('Add BIMSie server URI', 'bim-bcf-management');
                ?>
</option>
<?php 
                foreach ($bimsieServers as $key => $server) {
                    ?>
                  <option value="<?php 
                    print $key;
                    ?>
"><?php 
                    print $server['uri'] . (isset($server['username']) ? ' - ' . $server['username'] : '');
                    ?>
</option>
<?php 
                }
                ?>
               </select><br />
               <div class="new-server-container">
                  <label for="new-bimsie-server"><?php 
                _e('Add BIMSie server URI', 'bim-bcf-management');
                ?>
</label>
                  <input id="new-bimsie-server" type="text" />
               </div><br />
               <div class="toggle-server-info hidden">
                  <input type="checkbox" id="server-remember-user" /> <label for="server-remember-user"><?php 
                _e('Remember user', 'bim-bcf-management');
                ?>
</label>
                  <div class="clear"></div><br />
                  <label for="bimsie-username"><?php 
                _e('Username', 'bim-bcf-management');
                ?>
</label> <input id="bimsie-username" type="text" /><br />
                  <label for="bimsie-password"><?php 
                _e('Password', 'bim-bcf-management');
                ?>
</label> <input id="bimsie-password" type="password" /><br />
               </div>
               <input type="button" value="<?php 
                _e('Connect', 'bim-bcf-management');
                ?>
" onclick="BIMBCFManagement.frontEndSubmitServerSelection();" />
            </div>
            <input type="hidden" id="bimsie-server-uri" name="bimsie_server_uri" />
<?php 
            }
            ?>
            <h3><?php 
            _e('Markup', 'bim-bcf-management');
            ?>
</h3>
            <h4><?php 
            _e('Header', 'bim-bcf-management');
            ?>
</h4>
            <h5><?php 
            _e('File', 'bim-bcf-management');
            ?>
</h5>
            <div class="file sub-element">
               <label for="file-filename-0"><?php 
            _e('Filename', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="filename-0" name="file_filename[]" /><br />
               <label for="file-date-0"><?php 
            _e('Date', 'bim-bcf-management');
            ?>
</label>
               <input type="date" id="file-date-0" name="file_date[]" /><br />
               <label for="file-reference-0"><?php 
            _e('Reference', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="file-reference-0" name="file_reference[]" /><br />
               <label for="file-ifcproject-0"><?php 
            _e('Ifc Project', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="file-ifcproject-0" name="file_ifcproject[]" /><br />
               <label for="file-ifcspatial-0"><?php 
            _e('Ifc Spatial Structure Element', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="file-ifcspatial-0" name="file_spatial[]" /><br />
               <label for="file-project-0" class="project-place-holder"><?php 
            _e('Bimsie project', 'bim-bcf-management');
            ?>
</label>
               <span class="select-project"><?php 
            _e('Connect to a Bimsie server to get a project list', 'bim-bcf-management');
            ?>
</span>
               <br />
               <label for="file-revision-0" class="revision-place-holder"><?php 
            _e('Bimsie revision', 'bim-bcf-management');
            ?>
</label>
               <br />
            </div>
            <a href="#" class="more-items" id="more-file"><?php 
            _e('Add file', 'bim-bcf-management');
            ?>
</a><br />
            <h4><?php 
            _e('Topic', 'bim-bcf-management');
            ?>
</h4>
            <div class="topic sub-element">
               <label for="referencelink"><?php 
            _e('Referencelink', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="referencelink" name="topic_referencelink" /><br />
               <label for="topic-title"><?php 
            _e('Title', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="topic-title" name="topic_title" /><br />
               <label for="topic-index"><?php 
            _e('Index', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="topic-index" name="topic_index" /><br />
               <label for="topic-label"><?php 
            _e('Label', 'bim-bcf-management');
            ?>
</label>
               <select id="topic-label" name="topic_label">
<?php 
            foreach ($topicLabels as $topicLabel) {
                ?>
                  <option value="<?php 
                print trim($topicLabel);
                ?>
"><?php 
                print trim($topicLabel);
                ?>
</option>
<?php 
            }
            ?>
               </select><br />
               <label for="topic-type"><?php 
            _e('Type', 'bim-bcf-management');
            ?>
</label>
               <select id="topic-type" name="topic_type">
<?php 
            foreach ($topicTypes as $topicType) {
                ?>
                  <option value="<?php 
                print trim($topicType);
                ?>
"><?php 
                print trim($topicType);
                ?>
</option>
<?php 
            }
            ?>
               </select><br />
               <label for="topic-status"><?php 
            _e('Status', 'bim-bcf-management');
            ?>
</label>
               <select id="topic-status" name="topic_status">
<?php 
            foreach ($topicStatuses as $topicStatus) {
                ?>
                  <option value="<?php 
                print trim($topicStatus);
                ?>
"><?php 
                print trim($topicStatus);
                ?>
</option>
<?php 
            }
            ?>
               </select><br />
               <label for="topic-guid"><?php 
            _e('Guid', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="topic-guid" name="topic_guid" /><br />
               <!-- label for="topic-creation-date"><?php 
            _e('Creation date', 'bim-bcf-management');
            ?>
</label>
               <input type="date" id="topic-creation-date" name="topic_creation_date" /><br />
               <label for="topic-creation-time"><?php 
            _e('Creation time', 'bim-bcf-management');
            ?>
</label>
               <input type="time" id="topic-creation-time" name="topic_creation_time" /><br />
               <label for="topic-modified-date"><?php 
            _e('Creation date', 'bim-bcf-management');
            ?>
</label>
               <input type="date" id="topic-modified-date" name="topic_modified_date" /><br />
               <label for="topic-modified-time"><?php 
            _e('Modified time', 'bim-bcf-management');
            ?>
</label>
               <input type="time" id="topic-modified-time" name="topic_modified_time" /><br /-->
               <label for="assigned-to"><?php 
            _e('Assigned to', 'bim-bcf-management');
            ?>
</label>
               <select id="assigned-to" name="assigned_to">
<?php 
            foreach ($userIdTypes as $userIdType) {
                ?>
                  <option value="<?php 
                print trim($userIdType);
                ?>
"><?php 
                print trim($userIdType);
                ?>
</option>
<?php 
            }
            ?>
               </select><br />
               <h5><?php 
            _e('Bim Snippet', 'bim-bcf-management');
            ?>
</h5>
               <label for="bim-snippet-reference"><?php 
            _e('Reference', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="bim-snippet-reference" name="bim_snippet_reference" /><br />
               <label for="bim-snippet-reference-schema"><?php 
            _e('Reference schema', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="bim-snippet-reference-schema" name="bim_snippet_reference_schema" /><br />
               <label for="bim-snippet-type"><?php 
            _e('Bim Snippet Type', 'bim-bcf-management');
            ?>
</label>
               <select id="bim-snippet-type" name="bim_snippet_type">
<?php 
            foreach ($snippetTypes as $snippetType) {
                ?>
                  <option value="<?php 
                print trim($snippetType);
                ?>
"><?php 
                print trim($snippetType);
                ?>
</option>
<?php 
            }
            ?>
               </select><br />
               <input type="checkbox" id="bim-snippet-isexternal" name="bim_snippet_isexternal" value="true" />
               <label for="bim-snippet-isexternal"><?php 
            _e('Is external', 'bim-bcf-management');
            ?>
</label><br />
               <h5><?php 
            _e('Document Reference', 'bim-bcf-management');
            ?>
</h5>
               <div class="sub-element document-reference">
                  <label for="referenced-document-0"><?php 
            _e('Referenced document', 'bim-bcf-management');
            ?>
</label>
                  <input type="text" id="referenced-document-0" name="referenced_document[]" /><br />
                  <label for="document-reference-description-0"><?php 
            _e('Description', 'bim-bcf-management');
            ?>
</label>
                  <input type="text" id="document-reference-description-0" name="document_reference_description[]" /><br />
                  <label for="document-reference-guid-0"><?php 
            _e('Document reference guid', 'bim-bcf-management');
            ?>
</label>
                  <input type="text" id="document-reference-guid-0" name="document_reference_guid[]" /><br />
                  <input type="checkbox" id="document-reference-isexternal-0" name="document_reference_isexternal[]" value="true" />
                  <label for="document-reference-isexternal-0"><?php 
            _e('Is external', 'bim-bcf-management');
            ?>
</label><br />
               </div>
               <a href="#" class="more-items" id="more-document-reference"><?php 
            _e('Add document reference', 'bim-bcf-management');
            ?>
</a><br />
               <h5><?php 
            _e('Related topics', 'bim-bcf-management');
            ?>
</h5>
               <div class="sub-element related-topics">
                  <label for="related-topic-0"><?php 
            _e('Related topic', 'bim-bcf-management');
            ?>
</label>
                  <input type="text" id="related-topic-0" name="related_topic[]" /><br />
               </div>
               <a href="#" class="more-items" id="more-related-topics"><?php 
            _e('Add related topic', 'bim-bcf-management');
            ?>
</a><br />
            </div>
            <h4><?php 
            _e('Viewpoint', 'bim-bcf-management');
            ?>
</h4>
            <div class="viewpoint sub-element">
               <label for="viewpoint-0"><?php 
            _e('Viewpoint', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="viewpoint-0" name="viewpoint[]" /><br />
               <label for="viewpoint-guid-0"><?php 
            _e('Guid', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="viewpoint-guid-0" name="viewpoint_guid[]" /><br />
               <label for="snapshot-0"><?php 
            _e('Snapshot', 'bim-bcf-management');
            ?>
</label>
               <input type="file" id="snapshot-0" name="snapshot[]" /><br />
               <div class="viewpoint-comments-0 sub-sub-element">
                  <label for="viewpoint-comments-0-0"><?php 
            _e('Comment', 'bim-bcf-management');
            ?>
</label>
                  <input type="text" id="viewpoint-comments-0-0" name="viewpoint_comment[0][]" /><br />
               </div>
               <a href="#" class="more-items" id="more-viewpoint-comments-0"><?php 
            _e('Add viewpoint comment', 'bim-bcf-management');
            ?>
</a><br />
            </div>
            <a href="#" class="more-items" id="more-viewpoint"><?php 
            _e('Add viewpoint', 'bim-bcf-management');
            ?>
</a><br />
            <h3><?php 
            _e('Vizualization information', 'bim-bcf-management');
            ?>
</h3>
            <h4><?php 
            _e('Components', 'bim-bcf-management');
            ?>
</h4>
            <div class="component sub-element">
               <label for="component-ifcguid-0"><?php 
            _e('Ifc Guid', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="component-ifcguid-0" name="component_ifcguid[]" /><br />
               <input type="checkbox" id="component-selected-0" name="component_selected[]" value="true" />
               <label for="component-selected-0"><?php 
            _e('Selected', 'bim-bcf-management');
            ?>
</label><br />
               <input type="checkbox" id="component-visible-0" name="component_visible[]" value="true" />
               <label for="component-visible-0"><?php 
            _e('Visible', 'bim-bcf-management');
            ?>
</label><br />
               <label for="component-colour-0"><?php 
            _e('Colour', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="component-colour-0" name="component_colour[]" /><br />
               <label for="component-orginatingsystem-0"><?php 
            _e('Orginating system', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="component-orginatingsystem-0" name="component_orginatingsystem[]" /><br />
               <label for="component-authoring-tool-id-0"><?php 
            _e('Authoring tool id', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="component-authoring-tool-id-0" name="component_authoring_tool_id[]" /><br />
            </div>
            <a href="#" class="more-items" id="more-component"><?php 
            _e('Add component', 'bim-bcf-management');
            ?>
</a><br />
            <h4><?php 
            _e('Orthogonal Camera', 'bim-bcf-management');
            ?>
</h4>
            <div class="camera-direction sub-element">
               <h5><?php 
            _e('Camera View Point', 'bim-bcf-management');
            ?>
</h5>
               <label for="camera-viewpoint-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-viewpoint-x-0" name="camera_viewpoint_x[]" /><br />
               <label for="camera-viewpoint-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-viewpoint-y-0" name="camera_viewpoint_y[]" /><br />
               <label for="camera-viewpoint-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-viewpoint-z-0" name="camera_viewpoint_z[]" /><br />
               <h5><?php 
            _e('Camera Direction', 'bim-bcf-management');
            ?>
</h5>
               <label for="camera-direction-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-direction-x-0" name="camera_direction_x[]" /><br />
               <label for="camera-direction-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-direction-y-0" name="camera_direction_y[]" /><br />
               <label for="camera-direction-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-direction-z-0" name="camera_direction_z[]" /><br />
               <h5><?php 
            _e('Camera Up Vector', 'bim-bcf-management');
            ?>
</h5>
               <label for="camera-up-vector-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-up-vector-x-0" name="camera_up_vector_x[]" /><br />
               <label for="camera-up-vector-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-up-vector-y-0" name="camera_up_vector_y[]" /><br />
               <label for="camera-up-vector-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="camera-up-vector-z-0" name="camera_up_vector_z[]" /><br />
               <label for="view-to-world-scale-0"><?php 
            _e('View to world scale', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="view-to-world-scale-0" name="view_to_world_scale[]" /><br />
            </div>
            <a href="#" class="more-items" id="more-camera-direction"><?php 
            _e('Add camera direction', 'bim-bcf-management');
            ?>
</a><br />
            <h4><?php 
            _e('Perspective Camera', 'bim-bcf-management');
            ?>
</h4>
            <div class="camera-perspective sub-element">
               <h5><?php 
            _e('Camera View Point', 'bim-bcf-management');
            ?>
</h5>
               <label for="perspective-camera-viewpoint-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-viewpoint-x-0" name="perspective_camera_viewpoint_x[]" /><br />
               <label for="perspective-camera-viewpoint-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-viewpoint-y-0" name="perspective_camera_viewpoint_y[]" /><br />
               <label for="perspective-camera-viewpoint-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-viewpoint-z-0" name="perspective_camera_viewpoint_z[]" /><br />
               <h5><?php 
            _e('Camera Direction', 'bim-bcf-management');
            ?>
</h5>
               <label for="perspective-camera-direction-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-direction-x-0" name="perspective_camera_direction_x[]" /><br />
               <label for="perspective-camera-direction-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-direction-y-0" name="perspective_camera_direction_y[]" /><br />
               <label for="perspective-camera-direction-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-direction-z-0" name="perspective_camera_direction_z[]" /><br />
               <h5><?php 
            _e('Camera Up Vector', 'bim-bcf-management');
            ?>
</h5>
               <label for="perspective-camera-up-vector-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-up-vector-x-0" name="perspective_camera_up_vector_x[]" /><br />
               <label for="perspective-camera-up-vector-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-up-vector-y-0" name="perspective_camera_up_vector_y[]" /><br />
               <label for="perspective-camera-up-vector-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="perspective-camera-up-vector-z-0" name="perspective_camera_up_vector_z[]" /><br />
               <label for="field-of-view-0"><?php 
            _e('Field of view', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="field-of-view-0" name="field_of_view[]" /><br />
            </div>
            <a href="#" class="more-items" id="more-camera-perspective"><?php 
            _e('Add camera perspective', 'bim-bcf-management');
            ?>
</a><br />
            <h4><?php 
            _e('Lines', 'bim-bcf-management');
            ?>
</h4>
            <div class="line sub-element">
               <h5><?php 
            _e('Startpoint', 'bim-bcf-management');
            ?>
</h5>
               <label for="line-start-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="line-start-x-0" name="line_start_x[]" /><br />
               <label for="line-start-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="line-start-y-0" name="line_start_y[]" /><br />
               <label for="line-start-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="line-start-z-0" name="line_start_z[]" /><br />
               <h5><?php 
            _e('Endpoint', 'bim-bcf-management');
            ?>
</h5>
               <label for="line-end-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="line-end-x-0" name="line_end_x[]" /><br />
               <label for="line-end-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="line-end-y-0" name="line_end_y[]" /><br />
               <label for="line-end-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="line-end-z-0" name="line_end_z[]" /><br />
            </div>
            <a href="#" class="more-items" id="more-line"><?php 
            _e('Add line', 'bim-bcf-management');
            ?>
</a><br />
            <h4><?php 
            _e('Clipping planes', 'bim-bcf-management');
            ?>
</h4>
            <div class="clipping-plane sub-element">
               <h5><?php 
            _e('Location', 'bim-bcf-management');
            ?>
</h5>
               <label for="clipping-plane-location-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="clipping-plane-location-x-0" name="clipping_plane_location_x[]" /><br />
               <label for="clipping-plane-location-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="clipping-plane-location-y-0" name="clipping_plane_location_y[]" /><br />
               <label for="clipping-plane-location-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="clipping-plane-location-z-0" name="clipping_plane_location_z[]" /><br />
               <h5><?php 
            _e('Direction', 'bim-bcf-management');
            ?>
</h5>
               <label for="clipping-plane-direction-x-0"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="clipping-plane-direction-x-0" name="clipping_plane_direction_x[]" /><br />
               <label for="clipping-plane-direction-y-0"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="clipping-plane-direction-y-0" name="clipping_plane_direction_y[]" /><br />
               <label for="clipping-plane-direction-z-0"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
               <input type="text" id="clipping-plane-direction-z-0" name="clipping_plane_direction_z[]" /><br />
            </div>
            <a href="#" class="more-items" id="more-clipping-plane"><?php 
            _e('Add clipping plane', 'bim-bcf-management');
            ?>
</a><br />
            <h4><?php 
            _e('Bitmap', 'bim-bcf-management');
            ?>
</h4>
            <label for="bitmap"><?php 
            _e('Bitmap', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap" name="bitmap" /><br />
            <label for="reference"><?php 
            _e('Reference', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="reference" name="reference" /><br />
            <label for="height"><?php 
            _e('Height', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="height" name="height" /><br />
            <h5><?php 
            _e('Location', 'bim-bcf-management');
            ?>
</h5>
            <label for="bitmap-location-x"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-location-x" name="bitmap_location_x" /><br />
            <label for="bitmap-location-y"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-location-y" name="bitmap_location_y" /><br />
            <label for="bitmap-location-z"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-location-z" name="bitmap_location_z" /><br />
            <h5><?php 
            _e('Normal', 'bim-bcf-management');
            ?>
</h5>
            <label for="bitmap-normal-x"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-normal-x" name="bitmap_normal_x" /><br />
            <label for="bitmap-normal-y"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-normal-y" name="bitmap_normal_y" /><br />
            <label for="bitmap-normal-z"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-normal-z" name="bitmap_normal_z" /><br />
            <h5><?php 
            _e('Up', 'bim-bcf-management');
            ?>
</h5>
            <label for="bitmap-up-x"><?php 
            _e('X', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-up-x" name="bitmap_up_x" /><br />
            <label for="bitmap-up-y"><?php 
            _e('Y', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-up-y" name="bitmap_up_y" /><br />
            <label for="bitmap-up-z"><?php 
            _e('Z', 'bim-bcf-management');
            ?>
</label>
            <input type="text" id="bitmap-up-z" name="bitmap_up_z" /><br />
            <div class="submit-container">
               <input type="submit" name="submit" value="<?php 
            _e('Submit', 'bim-bcf-management');
            ?>
" />
            </div>
         </form>
         <script type="text/javascript">
            var bimBCFManagementSettings = {
               ajaxURI: "<?php 
            print plugins_url('ajax-handler.php', __FILE__);
            ?>
",
               loadingImage: "<img class=\"loading-image\" src=\"<?php 
            bloginfo('wpurl');
            ?>
/wp-admin/images/loading.gif\" alt=\"loading...\" />",
               bimsieServers: <?php 
            print json_encode($bimsieServers);
            ?>
,
               text: {
                  serverSubmitError: "<?php 
            _e('Supply a BIMSie server URI, username and password or select one from your list.', 'bim-bcf-management');
            ?>
",
                  noKnownRevisions: "<?php 
            _e('There are no revisions for this project.', 'bim-bcf-management');
            ?>
",
                  serverSelected: "<?php 
            _e('Connected to Bimsie Server', 'bim-bcf-management');
            ?>
",

                  selectServerTitle: "<?php 
            _e('Select a BIMsie server or enter a new one', 'bim-bcf-management');
            ?>
",
                  selectProjectTitle: "<?php 
            _e('Select the project for each file', 'bim-bcf-management');
            ?>
",
                  newServerLabel: "<?php 
            _e('Add BIMSie server URI', 'bim-bcf-management');
            ?>
",
                  submitServer: "<?php 
            _e('Retrieve information', 'bim-bcf-management');
            ?>
",
                  selectServerLabel: "<?php 
            _e('Select BIMSie server', 'bim-bcf-management');
            ?>
",
                  noServerOption: "--- <?php 
            _e('New server', 'bim-bcf-management');
            ?>
 ---",
                  rememberServerLabel: "<?php 
            _e('Remember user', 'bim-bcf-management');
            ?>
",
                  serverUserLabel: "<?php 
            _e('Username', 'bim-bcf-management');
            ?>
",
                  serverPasswordLabel: "<?php 
            _e('Password', 'bim-bcf-management');
            ?>
",
                  noProjectsFoundMessage: "<?php 
            _e('No projects could be found on this BIMSie server for this user.', 'bim-bcf-management');
            ?>
",
                  revision: "<?php 
            _e('Revision', 'bim-bcf-management');
            ?>
"
               }
            };
         </script>
<?php 
        } else {
            ?>
         <p><?php 
            _e('Please log in to access this page', 'bim-bcf-management');
            ?>
</p>
<?php 
        }
    }
Ejemplo n.º 3
0
 // New server added
 if ($serverId == -1 && isset($_POST['serverURI']) && $_POST['serverURI'] != '' && isset($_POST['username']) && isset($_POST['password'])) {
     $uri = $_POST['serverURI'];
     $username = $_POST['username'];
     $password = $_POST['password'];
     $remember = isset($_POST['remember']) && $_POST['remember'] == 'true' ? 1 : 0;
     Bimsie::updateServer($uri, $username, $password, $remember);
 }
 if ($serverId != -1) {
     $response['serverId'] = $serverId;
     // No token known or the token is expired
     if ($token === false) {
         $token = BIMsie::publicRequest($uri, 'Bimsie1AuthInterface', 'login', array('username' => $username, 'password' => $password));
         if (isset($token) && isset($token->response) && isset($token->response->result) && BIMsie::getErrorMessage($token) === false) {
             $token = $token->response->result;
             $servers = BIMsie::getServers(false);
             foreach ($servers as $server) {
                 if ($server['uri'] == $uri) {
                     $oldServer = $server;
                     $server['token'] = $token;
                     $server['tokenValid'] = time() + BIMsie::$tokenTimeout;
                     update_user_meta(get_current_user_id(), 'BIMsie-servers', $server, $oldServer);
                     break;
                 }
             }
         } elseif (isset($token)) {
             $response['error'] = BIMsie::getErrorMessage($token);
         } else {
             $response['error'] = __('Could not retrieve token from the server with your credentials', 'bim-bcf-management');
         }
     }