Пример #1
0
 /**
  * Function to form to add new entity instance.
  * @param string $type The entitiy name.
  */
 public function displayAdd($type)
 {
     $pagingAllowed = null;
     if ($this->_enablePaging && isset($_REQUEST['pagingAllowed'])) {
         $pagingAllowed = "<input type=\"hidden\" name=\"pagingAllowed\" value=\"" . $_REQUEST['pagingAllowed'] . "\">";
     }
     $skip = null;
     if (isset($_REQUEST['skip'])) {
         $skip = "<input type=\"hidden\" name=\"skip\" value=\"" . $_REQUEST['skip'] . "\">";
     }
     $object = $this->getObject($type);
     echo "<table style=\"border: thin solid #C0C0C0;\" border=\"1\">";
     echo "<form action=\"" . $this->_containerScriptName . "?query=" . $this->_query . "&serviceUri=" . $this->_uri . "&Type=" . $type . "\" method=\"post\">";
     echo "<tr align=\"center\" style=\"font-family: Calibri; " . "background-color: #97CC00\">" . "<td Colspan =\"2\">" . get_class($object) . "</td></tr>";
     echo "<tr style=\"font-family: Calibri; background-color: #99CCFF\">" . "<td>Field</td><td>Value</td></tr>";
     $propertyArray = WCFDataServicesEntity::getProperties($object);
     foreach ($propertyArray as $property) {
         echo "<tr style=\"font-family: Calibri; " . "background-color: #CCFFFF\">";
         $prop = new ReflectionProperty($object, $property);
         if (Utility::ContainAttribute($prop->getDocComment(), 'NavigationProperty')) {
         } else {
             if (Utility::ContainAttribute($prop->getDocComment(), 'NotNullable')) {
                 echo "<td style=\"width=150pt\">" . $property . "*</td>";
             } else {
                 echo "<td style=\"width=150pt\">" . $property . "</td>";
             }
             echo "<td ><input size = \"150\" name=\"" . $property . "\" type=\"text\" /></td>";
         }
         echo "</tr>";
     }
     echo "<tr>";
     echo $pagingAllowed;
     echo $skip;
     echo "<td colspan=\"2\" style=\"width=70\">" . "<input id=\"btnSave\" type=\"submit\" " . "name=\"btnSave\" value=\"Save\"/></td>";
     echo "</tr>";
     echo "</form>";
     echo "</table>";
 }
Пример #2
0
    /**
     * This function displays the editor
     */
    public function show()
    {
        ?>
<html>
    <head>
    </head>
    <body>
        <table style="border: thin solid #C0C0C0; width:100%" align="left" >
            <form action="<?php 
        echo $this->_containerScriptName;
        ?>
" method="post">
                <tr>
                     <td style="font-family: calibri; font-size: medium;">
                        WCF Data Service : <a href="<?php 
        echo $this->_serviceUri;
        ?>
"><?php 
        echo $this->_serviceUri;
        ?>
</a>
                        <input type="hidden" name="txtUri" value="<?php 
        echo $this->_serviceUri;
        ?>
" />
                    </td>
                </tr>
                <tr>
                    <td style="font-family: calibri; font-size: medium;">
                        Query &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:
                        <input style="width:550pt;" id="txtQuery" type="text" name="txtQuery" value="<?php 
        if (isset($_POST['txtQuery']) == 1) {
            echo str_replace("\\'", "'", $_POST['txtQuery']);
        } elseif (isset($_GET['query']) == 1) {
            echo str_replace("\\'", "'", $_GET['query']);
        }
        ?>
"/>
                        <input id="btnResult" type="submit" name="btnResult" value="Submit Query" />
                    </td>
                </tr>
            </form>
            <tr>
                <td colspan="3" style="width: 100%;">
                    <div>
                    <?php 
        $serviceUri = '';
        $query = '';
        if (isset($_GET['serviceUri'])) {
            $serviceUri = $_GET['serviceUri'];
        }
        if (isset($_GET['query'])) {
            $query = $_GET['query'];
        }
        if (isset($_POST['btnResult']) == 1) {
            $serviceUri = $_POST['txtUri'];
            $query = $_POST['txtQuery'];
        }
        if ($serviceUri != '' || $query != '') {
            $getResult = new WCFDataServicesEntity($this->_containerScriptName, $this->_containerName, $this->_enablePaging, $this->_pageSize, $serviceUri, $query, $this->_proxy, $this->_port, $this->_userName, $this->_password);
            if (isset($_POST['btnDelete'])) {
                $getResult->Delete($_POST, $_GET['Type']);
            } else {
                if (isset($_POST['btnUpdate'])) {
                    $getResult->Update($_POST, $_GET['Type']);
                } else {
                    if (isset($_POST['btnSave'])) {
                        $getResult->Insert($_POST, $_GET['Type']);
                    } else {
                        if (isset($_POST['btnAddLink'])) {
                            $attachQuery = str_replace("\\'", "'", $_GET['AttachQuery']);
                            $getResult->AddLink($_POST, $_GET['Type'], $attachQuery);
                        }
                    }
                }
            }
            $getResult->display();
            if (isset($_POST['btnDetail'])) {
                if (isset($_GET['changeId'])) {
                    $changeId = str_replace("\\'", "'", $_GET['changeId']);
                    $getResult->displayDetails($changeId, $_GET['Type']);
                }
            } else {
                if (isset($_POST['btnAdd'])) {
                    $getResult->displayAdd($_GET['Type']);
                } else {
                    if (isset($_GET['AttachTo'])) {
                        $attachTo = str_replace("\\'", "'", $_GET['AttachTo']);
                        $getResult->displayAddLink($_GET['Type'], $attachTo);
                    }
                }
            }
        } else {
            $getResult = new WCFDataServicesEntity($this->_containerScriptName, $this->_containerName, $this->_enablePaging, $this->_pageSize, $this->_serviceUri, '', $this->_proxy, $this->_port, $this->_userName, $this->_password);
            $getResult->display();
        }
        ?>
                    </div>
                </td>
            </tr>
        </table>
    </body>
</html>
<?php 
    }