/** * * Function that returns the xml object as a string * * @return string The XML as text WSDL if exists, else FALSE if not exists. */ private function getWSDL() { if (is_object($this->objWSDL)) { return $this->objWSDL->asXML(); } else { $this->errorMSG = "WSDL has not been generated."; return false; } }
/** * Save changes from XML object. * * @param array $attributes Attributes for child that you are added. * @return Salvaon * @throws Exception */ public function save($attributes = array()) { if (!empty($this->new)) { $this->addChildWithAttributes($attributes); } $result = static::$xmlObject->asXML(static::$path); if ($result === false) { throw new Exception('Cannot save values into "' . static::$path . '".'); } return $this; }
/** * Delete row * @return string * @throws Exception row ID not specified */ public function delete() { if (isset($this->_row_id)) { $row = $this->xml->xpath('/table/row[@id="' . $this->_row_id . '"]'); unset($row[0][0]); return $this->xml->asXML($this->file); } else { $this->_where(); foreach (array_reverse($this->_datas) as $obj) { $xml = $this->xml; $row = $xml->xpath('/table/row[@id="' . $obj->id . '"]'); unset($row[0][0]); } return $xml->asXML($this->file); } throw new Exception('Error with deleting'); }
/** * Writes a combined config file for runtime * * The master config and optional local config are output as a combined xml * file that is used by the runtime system * * @param string &$config config * @param string $config_filename path to xml config file * * @return null */ public static function writeConfig(&$config, $config_filename) { $canonical_filename = Nexista_Config::get('./path/compile') . $config_filename; $config_compile_error = "Can't open {$canonical_filename}.\n Check permissions of parent directories,\n or simply refresh to try and rebuild it.\n chmod 0777 {$canonical_filename} ?"; $tdir = dirname($canonical_filename); if (!is_dir($tdir)) { mkdir($tdir, 0777, true); } if ($tmp = fopen($canonical_filename, "w+")) { if (flock($tmp, LOCK_EX)) { fwrite($tmp, self::$xml->asXML()); flock($tmp, LOCK_UN); } else { Nexista_Error::Init($config_compile_error, NX_ERROR_FATAL); return false; } fclose($tmp); } return true; }
/** * Send order xml to Pacsoft * * @param object $orderXml * @return mixed */ public function sendOrder($orderXml) { $user = Mage::getStoreConfig('pdpacsoft_options/settings/pdpacsoft_user'); $password = Mage::getStoreConfig('pdpacsoft_options/settings/pdpacsoft_pass'); $developerId = '000000000'; $url = 'https://www.pacsoftonline.com/ufoweb/order?session=po_DK&user='******'&pin=' . $password . '&developerid=' . $developerId . '&type=xml'; $xml = $orderXml->asXML(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml', 'Content-length: ' . strlen($xml))); $response = curl_exec($ch); curl_close($ch); $xmlResponse = new SimpleXMLElement($response); $status = (string) $xmlResponse->val[1]; if ($status && isset($this->_statuses[$status])) { return $this->_statuses[$status]; } else { return $this->_statuses['exception']; } }
/** * Export User data as xml * * @return string|null */ public static function toXml() { if (!class_exists('SimpleXMLElement')) { throw new \Exception('SimpleXMLElement class not found'); } if (!is_object(static::$simpleXML)) { static::$simpleXML = new \SimpleXMLElement('<root/>'); } $data = static::getData(); if (is_array($data)) { foreach ($data as $field => $value) { static::$simpleXML->addChild($field, $value); } return static::$simpleXML->asXML(); } }
/** * evalResponsePromptSuccess( ) : * * @param array $xmlRequest : * @param object $xmlResponse : * @param object $xmlAction : * @param boolean $dontPrompt : do not prompt to the backend form (optional) * @return string $status : isNotOnEbay, isOnEbayEnabled, isOnEbayDisabled, isWoStatus * @access private * @version 0.0.3 * @since 0.0.3 */ private function evalResponsePromptSuccess($xmlRequest, $xmlResponse, $xmlAction, $dontPrompt = false) { $status = 'undefined (by ' . __METHOD__ . ' #' . __LINE__ . ')'; $prompt = 'Environment: ' . $this->ebayEnvironment; $this->log($prompt, -1); $prompt = 'Request: ' . $xmlAction; $this->log($prompt, -1); $xml = 'xmlRequest (success): ' . str_replace('><', '>' . PHP_EOL . '<', $xmlRequest); $this->log($xml, -1); $xml = 'xmlResponse (success): ' . $xmlResponse->asXML(); $xml = str_replace('><', '>' . PHP_EOL . '<', $xml); $this->log($xml, -1); //var_dump(__METHOD__, __LINE__, $xmlAction); switch (true) { // case( $action == 'setEbayItemStatus'): // $status = $this->evalResponseSetFieldEbayItemStatus($xmlResponse); // break; case $xmlAction == 'AddFixedPriceItem': case $xmlAction == 'RelistFixedPriceItem': case $xmlAction == 'ReviseFixedPriceItem': $status = $this->evalResponsePromptSuccessAddFixedPriceItem($xmlResponse); break; case $xmlAction == 'EndFixedPriceItem': $status = $this->evalResponsePromptSuccessEndFixedPriceItem($xmlResponse); break; case $xmlAction == 'GetItem': $status = $this->evalResponsePromptSuccessGetItem($xmlResponse, $dontPrompt); break; case $xmlAction == 'VerifyAddFixedPriceItem': // follow the workflow break; default: $prompt = __METHOD__ . ' (#' . __LINE__ . '): xmlAction is undefined "' . $xmlAction . '"'; die($prompt); } return $status; }
/** * XML Save * * @param object $xml * @param string $file Filename that it will be saved as * @return bool */ function XMLsave($xml, $file) { $success = $xml->asXML($file) === TRUE; return $success && chmod($file, 0755); }
/** * Method getXML() * * Returns the XML that is generated. Useful for debugging. * * @return string * @access public */ public function getXML() { $this->xml->InstrucaoUnica->addChild('IdProprio', $this->uniqueID); $this->xml->InstrucaoUnica->addChild('Razao', $this->reason); if (empty($this->value)) { throw new InvalidArgumentException('Erro: o valor da transação deve ser especificado'); } $this->xml->InstrucaoUnica->addChild('Valores')->addChild('Valor', $this->value)->addAttribute('moeda', 'BRL'); if (isset($this->deduction)) { $this->xml->InstrucaoUnica->Valores->addChild('Desconto', $this->deduction)->addAttribute('moeda', 'BRL'); } if (isset($this->adds)) { $this->xml->InstrucaoUnica->Valores->addChild('Acrescimo', $this->adds)->addAttribute('moeda', 'BRL'); } if (!empty($this->payment_way)) { $instrucao = $this->xml->InstrucaoUnica; $formas = $instrucao->addChild('FormasPagamento'); foreach ($this->payment_way as $way) { $formas->addChild('FormaPagamento', $this->payment_ways[$way]); if ($way == 'boleto' and !empty($this->payment_way_args)) { $instrucao->addChild('Boleto')->addChild('DiasExpiracao', $this->payment_way_args['dias_expiracao']['dias'])->addAttribute('Tipo', $this->payment_way_args['dias_expiracao']['tipo']); if (isset($this->payment_way_args['instrucoes'])) { $numeroInstrucoes = 1; foreach ($this->payment_way_args['instrucoes'] as $instrucaostr) { $instrucao->Boleto->addChild('Instrucao' . $numeroInstrucoes, $instrucaostr); $numeroInstrucoes++; } } } } } if (!empty($this->payer)) { $p = $this->payer; $this->xml->InstrucaoUnica->addChild('Pagador'); isset($p['nome']) ? $this->xml->InstrucaoUnica->Pagador->addChild('Nome', $this->payer['nome']) : null; isset($p['login_moip']) ? $this->xml->InstrucaoUnica->Pagador->addChild('LoginMoIP', $this->payer['login_moip']) : null; isset($p['email']) ? $this->xml->InstrucaoUnica->Pagador->addChild('Email', $this->payer['email']) : null; isset($p['celular']) ? $this->xml->InstrucaoUnica->Pagador->addChild('TelefoneCelular', $this->payer['celular']) : null; isset($p['apelido']) ? $this->xml->InstrucaoUnica->Pagador->addChild('Apelido', $this->payer['apelido']) : null; isset($p['identidade']) ? $this->xml->InstrucaoUnica->Pagador->addChild('Identidade', $this->payer['identidade']) : null; $p = $this->payer['endereco']; $this->xml->InstrucaoUnica->Pagador->addChild('EnderecoCobranca'); isset($p['logradouro']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('Logradouro', $this->payer['endereco']['logradouro']) : null; isset($p['numero']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('Numero', $this->payer['endereco']['numero']) : null; isset($p['complemento']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('Complemento', $this->payer['endereco']['complemento']) : null; isset($p['bairro']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('Bairro', $this->payer['endereco']['bairro']) : null; isset($p['cidade']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('Cidade', $this->payer['endereco']['cidade']) : null; isset($p['estado']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('Estado', $this->payer['endereco']['estado']) : null; isset($p['pais']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('Pais', $this->payer['endereco']['pais']) : null; isset($p['cep']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('CEP', $this->payer['endereco']['cep']) : null; isset($p['telefone']) ? $this->xml->InstrucaoUnica->Pagador->EnderecoCobranca->addChild('TelefoneFixo', $this->payer['endereco']['telefone']) : null; } $return = $this->xml->asXML(); $this->initXMLObject(); return str_ireplace("\n", "", $return); }
/** * XML Save * * @since 2.0 * @todo create and chmod file before ->asXML call (if it doesnt exist already, if so, then just chmod it.) * * @param object $xml * @param string $file Filename that it will be saved as * @return bool */ function XMLsave($xml, $file) { get_execution_time(true); $success = $xml->asXML($file) === TRUE; debugLog('XMLsave: ' . $file . ' ' . get_execution_time()); if (defined('GSCHMOD')) { return $success && chmod($file, GSCHMOD); } else { return $success && chmod($file, 0755); } }
/** * Return XHTML string based on SimpleXML element. * * @param object $element * @return string */ public final function dumpElement($element) { return str_replace('&', '&', $element->asXML()); }
/** * Setup form elements. * * @param object $xml Parsed XML declaration. * * @return object Initialized JForm object. */ protected function setupForm($xml) { // Add field renderer paths if (!defined('JSN_CONFIG_FIELD_PATH_ADDED')) { JForm::addFieldPath(JSN_PATH_LIBRARIES . '/joomlashine/form/fields'); JForm::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/fields'); define('JSN_CONFIG_FIELD_PATH_ADDED', 1); } // Prepare form declaration $formXML = '<config>' . preg_replace(array('/<(group|tab)\\s/i', '#</(group|tab)>#i'), array('<fieldset ', '</fieldset>'), $xml->asXML()) . '</config>'; // Load form object from XML $form = $xml['name'] ? (string) $xml['name'] : (string) $xml['label']; $form = $this->loadForm($form, $formXML, array('control' => 'jsnconfig', 'load_data' => true), false, '/config'); // Store declared form actions foreach ($xml->xpath('action') as $node) { $action = new stdClass(); $action->label = (string) $node['label']; $action->task = (string) $node['task']; $action->ajax = isset($node['ajax']) ? (int) $node['ajax'] : 1; $action->track = isset($node['track']) ? (int) $node['track'] : 1; $form->actions[] = $action; } return $form; }
/** * XML Save * * @since 2.0 * @todo create and chmod file before ->asXML call (if it doesnt exist already, if so, then just chmod it.) * * @param object $xml * @param string $file Filename that it will be saved as * @return bool */ function XMLsave($xml, $file) { $success = $xml->asXML($file) === TRUE; if (defined('GSCHMOD')) { return $success && chmod($file, GSCHMOD); } else { return $success && chmod($file, 0755); } }
/** * Сохранение XML-файла, соответствующего создаваемой пользователем кампании * */ public function save_data() { $this->campaign->asXML($this->xml_filepath); }