Example #1
0
 public function getResponse()
 {
     $doc = new DOMDocument();
     $doc->loadXML('<nodeid>' . $this->context->queryToValue('//id') . '</nodeid>');
     $uiComposer = new \BaseXMS\UiComposer\UiComposer();
     $uiComposer->setServiceLocator($this->getServiceLocator());
     $uiComposer->setContextData($doc);
     $response = new ZendResponse();
     $response->setContent($uiComposer->run()->output());
     $response->setStatusCode(200);
     return $response;
 }
Example #2
0
 private static function getContextDescription($incElement, $data)
 {
     $attributes = $incElement->attributes;
     $context = '<context type="includetag">';
     for ($i = 0; $i < $attributes->length; ++$i) {
         $item = $attributes->item($i);
         $context .= '<' . $item->name . '>' . $item->value . '</' . $item->name . '>';
     }
     // Will break if we decide to store $data differently
     if ($data->firstChild) {
         $context .= $data->saveXML($data->firstChild);
     }
     $context .= '<created>' . time() . '</created>';
     $context .= '</context>';
     $doc = new DOMDocument();
     $doc->loadXML($context);
     //echo $doc->saveXML();
     return $doc;
 }
Example #3
0
    public function getRole()
    {
        // Build PermissionXML role
        $xml = <<<XML
<policy id="update_content">/node</policy>
XML;
        $doc = new DOMDocument();
        $doc->loadXML($xml);
        $roleA = new Role('PermissionXML');
        $roleA->doc = $doc;
        $roleA->addPermission('query');
        // Build search filter Role
        $roleSearchFilter = new Role('SearchPermissionFilter');
        $roleSearchFilter->filter = '/@id';
        // Group up Roles under the 'User' Role
        $userRole = new Role('User');
        $userRole->addChild($roleA);
        $userRole->addChild($roleSearchFilter);
        return $userRole;
    }
Example #4
0
 public function getRedirectResponse()
 {
     $return = false;
     // Check if it matches a redirect path
     $nodePath = '';
     foreach ($this->requestPath as $part) {
         $nodePath .= '/node[accessPaths//entry[ ( @type="alt" or @type="main" or @type="old" ) and @path="' . $part . '"]]';
     }
     $query = 'let $code := 000 return let $x := ' . $nodePath . 'return if( $x ) then ' . $this->returnFormat . ' else null';
     $orgRequest = $this->services->get('xmldb')->execute($query, 'xml');
     if ($orgRequest instanceof \DOMDocument) {
         // build an array with involved node ids - reverse order
         $idPathParts = array_reverse(explode('/', $orgRequest->queryToValue('/node/path')));
         // translate requestPath
         $newRequestPath = array();
         foreach (array_reverse($this->requestPath) as $index => $part) {
             $query = '//node[@id="' . $idPathParts[$index] . '"]/accessPaths//entry[@type="old" and @path="' . $part . '"]/string()';
             $newPath = $this->services->get('xmldb')->execute($query);
             if ($newPath) {
                 $newRequestPath[] = $newPath;
             } else {
                 $newRequestPath[] = $part;
             }
         }
         $return = new DOMDocument();
         $return->loadXML('<node><code>301</code><id></id><contentclass></contentclass><path>' . implode('/', array_reverse($newRequestPath)) . '</path></node>');
     }
     return $return;
 }
Example #5
0
 /**
  * @param unknown_type $resultText
  * @param unknown_type $returnFormat
  * @return string
  */
 public function transformToFormat($resultText, $returnFormat = 'text')
 {
     $return = '';
     if ($resultText) {
         switch ($returnFormat) {
             case 'xml':
                 $return = new DOMDocument();
                 $return->loadXML($resultText);
                 break;
             case 'simplexml':
                 $return = new SimpleXMLElement($resultText);
                 break;
             case 'json':
                 break;
                 // case text
             // case text
             default:
                 $return = $resultText;
         }
     }
     return $return;
 }