Beispiel #1
0
 public static function exportUser($uids)
 {
     $users = User::model()->fetchAllByUids($uids);
     $xmlContents = XmlUtil::arrayToXml($users);
     $xmlName = date("Y-m-d") . "-user";
     if (ob_get_length()) {
         ob_end_clean();
     }
     header("Cache-control: private");
     header("Content-type: text/xml");
     header("Content-Disposition: attachment; filename= {$xmlName}.xml");
     exit($xmlContents);
 }
Beispiel #2
0
 public static function checkUpgrade()
 {
     $return = false;
     $ibosRelease = VERSION_DATE;
     $upgradeFile = self::UPGRADE_URL . self::getVersionPath() . "/" . $ibosRelease . "/upgrade.xml";
     $remoteResponse = FileUtil::fileSockOpen($upgradeFile);
     $response = XmlUtil::xmlToArray($remoteResponse);
     if (isset($response["cross"]) || isset($response["patch"])) {
         Setting::model()->updateSettingValueByKey("upgrade", $response);
         CacheUtil::update("setting");
         $return = true;
     } else {
         Setting::model()->updateSettingValueByKey("upgrade", "");
         $return = false;
     }
     return $return;
 }
 public function configure($basePath)
 {
     /*Document*/
     $configDoc = new DomDocument();
     //        try
     //        {
     //	         SAXBuilder builder = new SAXBuilder();
     //
     //       	 byte[] configBytes = ClassLoaders.loadResourceBytes( basePath + File.separator + getConfigFileName() );
     //       	 configDoc = builder.build( new ByteArrayInputStream( configBytes ));
     //        }
     //        catch( Throwable exception )
     //        {
     //            if( Log.isLogging( LoggingConstants.ERROR ) )
     //                Log.log( LoggingConstants.ERROR, "Unable to parse " + getConfigFileName(), exception );
     //
     //            return;
     //        }
     $configDoc->load($basePath . "/" . $this->getConfigFileName());
     /*Element*/
     $root = $configDoc->documentElement;
     /*List*/
     $channelDefinitions = XmlUtil::getChild($root, self::CHANNELS)->getElementsByTagName(self::CHANNEL_DEFINITION);
     for ($i = 0, $max = $channelDefinitions->length; $i < $max; $i++) {
         /*Element*/
         $channelDefinition = $channelDefinitions->item($i);
         /*Element*/
         $endpointElement = XmlUtil::getChild($channelDefinition, self::ENDPOINT);
         /*String*/
         $id = $channelDefinition->getAttribute("id");
         /*String*/
         $endpoint = $endpointElement->getAttribute("uri");
         /*Channel*/
         $channel = new Channel($id, $endpoint);
         $channel->setChannelClass($channelDefinition->getAttribute("class"));
         $channel->setEndpointClass($endpointElement->getAttribute("class"));
         $channel->setProperties($this->parseProperties(XmlUtil::getChild($channelDefinition, "properties")));
         $this->serviceChannels[] = $channel;
     }
 }
Beispiel #4
0
 public static function import($id, $file, $importUser = false)
 {
     $content = FileUtil::readFile($file);
     $xml = XmlUtil::xmlToArray($content);
     unset($xml["base"]["flowid"]);
     unset($xml["base"]["name"]);
     unset($xml["base"]["formid"]);
     unset($xml["base"]["sort"]);
     $user = array("newuser", "deptid", "uid", "positionid", "autouserop", "autouser", "mailto");
     $data = array();
     foreach ($xml["base"] as $key => $value) {
         $key = strtolower($key);
         if (!$importUser && in_array($key, $user)) {
             continue;
         }
         $data[$key] = $value;
     }
     FlowType::model()->modify($id, $data);
     unset($xml["base"]);
     unset($data);
     FlowProcess::model()->deleteAllByAttributes(array("flowid" => $id));
     if (!empty($xml)) {
         foreach ($xml as $process) {
             unset($process["id"]);
             $data = array();
             $process["flowid"] = $id;
             foreach ($process as $k => $v) {
                 if (!$importUser && in_array($k, $user)) {
                     continue;
                 }
                 $data[$k] = $v;
             }
             FlowProcess::model()->add($data);
         }
     }
     FileUtil::deleteFile($file);
 }
Beispiel #5
0
 /**
  * @covers ByJG\Util\XmlUtil::xml2Array
  */
 public function testXml2Array2()
 {
     $xml = XmlUtil::createXmlDocumentFromStr('<root><node param="pval">value</node></root>');
     $array = XmlUtil::xml2Array($xml);
     $this->assertEquals(["node" => "value"], $array);
 }
Beispiel #6
0
 /**
  * Get a remote document and transform to DomXMLDocument
  * @param string $url
  * @return handle \DOMDocument
  */
 public static function GetRemoteXMLDocument($url)
 {
     // THIS FUNCTION IS A CRAP!!!!
     // I NEED REFACTORY THIS!
     $handle = FileUtil::OpenRemoteDocument($url);
     $xmlString = FileUtil::ReadRemoteDocument($handle);
     $search = array("'&(quot|#34);'i", "'&(amp|#38);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&aacute;'i", "'&eacute;'i", "'&iacute;'i", "'&oacute;'i", "'&uacute;'i", "'&atilde;'i", "'&ccedil;'i", "'&#(\\d+);'e");
     // evaluate as php
     $replace = array("\"", "&", " ", chr(161), chr(162), chr(163), chr(169), "á", "é", "í", "ó", "ú", "ã", "ç", "chr(\\1)");
     $xmlString = preg_replace($search, $replace, $xmlString);
     //$xmlString = tidy_parse_string($xmlString, array('output-xml' => TRUE), 'UTF8');
     $xmldoc = XmlUtil::CreateXmlDocumentFromStr($xmlString);
     return $xmldoc;
 }
Beispiel #7
0
 private static function parseLocalConfig($address)
 {
     $config = array();
     if (is_file($address)) {
         $fileContent = file_get_contents($address);
         $config = XmlUtil::xmlToArray($fileContent);
     }
     return $config;
 }
 public function saveServerConfiguration(ServerConfiguration $configuration)
 {
     $this->configuration = $configuration;
     /*Element*/
     $serverConfigurationElement = XmlUtil::getChild($this->configElement, ORBConstants::RBISERVERCONFIGURATION);
     //$this->configElement->getElementsByTagName( ORBConstants::RBISERVERCONFIGURATION );
     if ($serverConfigurationElement != null) {
         $this->configElement->removeChild($serverConfigurationElement);
     }
     $dom = $this->orbConfig->dom;
     $serverConfigurationElement = $dom->createElement(ORBConstants::RBISERVERCONFIGURATION);
     $serverAddressElement = $dom->createElement("serverAddress", $configuration->serverAddress);
     $serverConfigurationElement->appendChild($serverAddressElement);
     $reconnectionTimeoutElement = $dom->createElement("reconnectionTimeout", $configuration->reconnectionTimeout);
     $serverConfigurationElement->appendChild($reconnectionTimeoutElement);
     $this->configElement->appendChild($serverConfigurationElement);
     $this->orbConfig->Save();
 }
Beispiel #9
0
 private function getLicence()
 {
     $file = self::OFFICE_PATH . "licence.xml";
     if (file_exists($file)) {
         $content = file_get_contents($file);
         if (is_string($content)) {
             $licence = XmlUtil::xmlToArray($content);
             return $licence;
         }
     } else {
         return false;
     }
 }
Beispiel #10
0
 public function checkUpgrade()
 {
     $return = false;
     $upgradeFile = $this->upgradeurl . $this->versionPath() . "/" . IBOS_RELEASE . "/upgrade.xml";
     $xmlContents = FileUtil::fileSockOpen($upgradeFile);
     $response = XmlUtil::xmlToArray($xmlContents);
     if (isset($response["cross"]) || isset($response["patch"])) {
         Setting::model()->updateByPk("upgrade", array("value" => serialize($response)));
         $return = true;
     } else {
         Setting::model()->updateByPk("upgrade", array("value" => ""));
         $return = false;
     }
     $setting = Yii::app()->setting->get("setting");
     $setting["upgrade"] = isset($response["cross"]) || isset($response["patch"]) ? $response : array();
     Yii::app()->setting->set("setting", $setting);
     return $return;
 }
 public function update(ServiceDestination $serviceDestination, ServiceDestination $newServiceDestination)
 {
     $dom = FlexRemotingServiceConfig::getConfigDoc();
     if ($this->isReadOnly($serviceDestination)) {
         throw new Exception("Destination can't be updated");
     }
     if (!$serviceDestination->DestinationId == $newServiceDestination->DestinationId) {
         $this->checkExistance($newServiceDestination);
     }
     $this->validate($newServiceDestination);
     /*Element*/
     $root = $dom->documentElement;
     /*List*/
     $children = $root->getElementsByTagName("destination");
     /*Element*/
     $serviceDestinationNode = null;
     for ($i = 0; $i < $children->length; $i++) {
         $serviceDestinationNode = $children->item($i);
         if ($serviceDestinationNode->getAttribute("id") == $serviceDestination->DestinationId) {
             break;
         }
     }
     if ($serviceDestinationNode == null) {
         throw new Exception("Destination " . $serviceDestination->DestinationId . " not found");
     }
     /*Element*/
     $serviceDestinationNode = $this->findService($serviceDestination);
     /*Element*/
     $source = XmlUtil::getChild(XmlUtil::getChild($serviceDestinationNode, "properties"), "source");
     XmlUtil::getChild($serviceDestinationNode, "properties")->removeChild($source);
     XmlUtil::getChild($serviceDestinationNode, "properties")->appendChild($dom->createElement("source", $newServiceDestination->ServiceId));
     $serviceDestinationNode->setAttribute("id", $newServiceDestination->DestinationId);
     /*Element*/
     $channelsElement = XmlUtil::getChild($serviceDestinationNode, "channels");
     if ($channelsElement != null) {
         if ($newServiceDestination->Channel == "default channel") {
             $serviceDestinationNode->removeChild($channelsElement);
         } else {
             /*Element*/
             $channelElement = XmlUtil::getChild(channelsElement, "channel");
             if ($channelElement != null) {
                 $channelElement->setAttribute("ref", $newServiceDestination->Channel);
             } else {
                 $channelsElement->appendChild($dom->createElement("channel")->setAttribute("ref", $newServiceDestination->Channel));
             }
         }
     } else {
         if (!$newServiceDestination->Channel == "default channel") {
             $channelsElement = $dom->createElement("channels");
             $channelsElement->appendChild($dom->createElement("channel")->setAttribute("ref", $newServiceDestination->Channel));
             $serviceDestinationNode->appendChild($channelsElement);
         }
     }
     /*Element*/
     $securityElement = XmlUtil::getChild($serviceDestinationNode, "security");
     /*Element*/
     $rolesElement = null;
     /*Element*/
     $constraintElement = null;
     if (count($newServiceDestination->Roles) > 0) {
         if ($securityElement != null) {
             $constraintElement = XmlUtil::getChild($securityElement, "security-constraint");
         } else {
             $securityElement = $dom->createElement("security");
             $constraintElement = $dom->createElement("security-constraint");
             $securityElement->appendChild($constraintElement);
             $serviceDestinationNode->appendChild($securityElement);
         }
         if ($constraintElement != null) {
             $rolesElement = XmlUtil::getChild($constraintElement, "roles");
         } else {
             $constraintElement = $dom->createElement("security-constraint");
             $rolesElement = $dom->createElement("roles");
             $constraintElement->appendChild($rolesElement);
             $securityElement->appendChild($constraintElement);
         }
         if ($rolesElement == null) {
             $rolesElement = $dom->createElement("roles");
             $constraintElement->appendChild($rolesElement);
         } else {
             /*Element*/
             $role = XmlUtil::getChild($rolesElement, "role");
             $rolesElement->removeChildren($role);
         }
         for ($j = 0; $j < count($newServiceDestination->Roles); $j++) {
             /*Element*/
             $role = $dom->createElement("role", $newServiceDestination->Roles[$j]);
             $rolesElement->appendChild($role);
         }
     } else {
         /*Element*/
         $role = XmlUtil::getChild(XmlUtil::getChild(XmlUtil::getChild($securityElement, "security-constraint"), "roles"), "role");
         if (XmlUtil::getChild(XmlUtil::getChild($securityElement, "security-constraint"), "roles") != null) {
             XmlUtil::getChild(XmlUtil::getChild($securityElement, "security-constraint"), "roles")->removeChild($role);
         }
     }
     $dom->save(OrbConfig::getInstance()->getFlexConfigPath() . FlexRemotingServiceConfig::REMOTINGSERVICE_FILE);
     /*IDestination*/
     $dest = new FlexRemotingServiceConfig();
     $dest->processDestination(ORBConfig::getInstance(), $serviceDestination->DestinationId, $serviceDestinationNode);
     ORBConfig::getInstance()->getDataServices()->getDestinationManager()->addDestination($serviceDestination->DestinationId, $dest);
 }
Beispiel #12
0
 /**
  * Remove a node specified by your tag name. You must pass a DOMDocument ($node->ownerDocument);
  *
  * @param DOMDocument $domdocument
  * @param string $tagname
  * @return bool
  */
 public static function removeTagName($domdocument, $tagname)
 {
     $nodeLista = $domdocument->getElementsByTagName($tagname);
     if ($nodeLista->length > 0) {
         $node = $nodeLista->item(0);
         XmlUtil::removeNode($node);
         return true;
     } else {
         return false;
     }
 }
 private function getTypes()
 {
     $schemas = null;
     for ($i = 0; $i < $this->definitions->length; $i++) {
         $item = $this->definitions->item($i);
         if (XmlUtil::cleearNS($item->nodeName) == "types") {
             $schemas = $item->childNodes;
             for ($j = 0; $j < $schemas->length; $j++) {
                 $schema = null;
                 if (XmlUtil::cleearNS($schemas->item($j)->nodeName) == "schema") {
                     $schema = $schemas->item($j)->childNodes;
                     for ($k = 0; $k < $schema->length; $k++) {
                         $this->types[] = XmlUtil::getDOMDocument($schema->item($k));
                     }
                 }
             }
             break;
         }
     }
 }