Example #1
0
 function setJob($name, $template, $replacements = array())
 {
     $job_xml = file_get_contents('templates/' . $template . '.xml', 'r');
     foreach ($replacements as $search => $replace) {
         $job_xml = str_replace('{{{' . $search . '}}}', $replace, $job_xml);
     }
     $job = new SimpleXMLElement($job_xml);
     $job->displayName = $name;
     // Existing job.
     if (isset($this->getJobs()[$name])) {
         return $this->conn->post('job/' . $name . '/config.xml', ['body' => $job->asXml(), 'headers' => ['Content-Type' => 'application/xml']]);
     }
     // New job.
     return $this->conn->post('createItem', ['body' => $job->asXml(), 'headers' => ['Content-Type' => 'application/xml'], 'query' => ['name' => $name]]);
 }
 public function act_packages()
 {
     $packages = Posts::get(array('content_type' => 'plugin', 'nolimit' => true));
     $xml = new SimpleXMLElement('<packages/>');
     foreach ($packages as $package) {
         if (!$package->info->guid) {
             continue;
         }
         $package_node = $xml->addChild('package');
         $package_node->addChild('description', utf8_encode(Format::summarize(strip_tags($package->content))));
         $package_node->addAttribute('guid', $package->info->guid);
         $package_node->addAttribute('name', $package->title);
         if ($package->info->author) {
             $package_node->addAttribute('author', $package->info->author);
         }
         if ($package->info->author_url) {
             $package_node->addAttribute('author_url', $package->info->author_url);
         }
         $package_node->addAttribute('type', 'plugin');
         $package_node->addAttribute('tags', implode(',', (array) $package->tags));
         $versions_node = $package_node->addChild('versions');
         foreach ($package->versions as $version) {
             if ($version->habari_version) {
                 $version_node = $versions_node->addChild('version', $version->description);
                 $version_node->addAttribute('version', $version->version);
                 $version_node->addAttribute('archive_md5', $version->md5);
                 $version_node->addAttribute('archive_url', $version->url);
                 $version_node->addAttribute('habari_version', $version->habari_version);
             }
         }
     }
     ob_clean();
     header('Content-Type: application/xml');
     echo $xml->asXml();
 }
 function toXml()
 {
     $baseStr = '<?xml version="1.0" standalone="yes"?><tree id="0"></tree>';
     $xml = new SimpleXMLElement($baseStr);
     $currentLevel = array($xml);
     $currentRgt = 0;
     foreach ($this->_tree as $key => $row) {
         if ($key == 0) {
             $currentLevel[0]->addAttribute('lft', $row['lft']);
             $currentLevel[0]->addAttribute('rgt', $row['rgt']);
             continue;
         } elseif ($row['lft'] > $currentLevel[count($currentLevel) - 1]->attributes()->rgt) {
             while ($row['lft'] > $currentLevel[count($currentLevel) - 1]->attributes()->rgt) {
                 array_pop($currentLevel);
             }
         }
         $node = $currentLevel[count($currentLevel) - 1]->addChild('item');
         $node->addAttribute('id', $row['enumerationId']);
         $node->addAttribute('text', $row['name']);
         $node->addAttribute('lft', $row['lft']);
         $node->addAttribute('rgt', $row['rgt']);
         if ($row['rgt'] > $row['lft'] + 1) {
             $node->addAttribute('child', 1);
             array_push($currentLevel, $node);
             $currentRgt = $row['rgt'];
         } elseif ($row['rgt'] + 1 == $currentRgt) {
             array_pop($currentLevel);
             $node->addAttribute('curRgt', $currentLevel[count($currentLevel) - 1]->attributes()->rgt);
         }
     }
     return $xml->asXml();
 }
 public function delextrafields(Request $request, $location_id, $item_type)
 {
     $type = Itemtype::find($item_type);
     $fields = $request->input();
     $rootXML = new \SimpleXMLElement($type['extra_fields']);
     //simplexml_load_string($type->extra_fields) or die("Error: Cannot create object");
     //$bla = json_decode($request->input('data'),true);
     //var_dump($request->input());
     foreach ($fields as $field) {
         $j = 0;
         for ($x = 0; $x < $type->count; $x++) {
             //$fields[] = strval($rootXML->field[$x]['name']);
             if (strval($rootXML->field[$j]['name']) === $field) {
                 unset($rootXML->field[$j]);
                 $type->count = $type->count - 1;
                 $j = $j - 1;
             }
             $j = $j + 1;
         }
     }
     // should also create a batch function to later remove all data from items_meta tables extra_values field
     $type->extra_fields = $rootXML->asXml();
     if ($type->count < 1) {
         $type->extra_fields = null;
     }
     if ($type->save() === true) {
         return response()->json(["Response" => "success"]);
     } else {
         return response()->json(["Response" => "fail"]);
     }
 }
 public function listXmlAction()
 {
     $baseStr = "<?xml version='1.0' standalone='yes'?><rows></rows>";
     $xml = new SimpleXMLElement($baseStr);
     $updateFile = new UpdateFile();
     $updateFileIterator = $updateFile->getIteratorActive();
     $alterTable = new AlterTable();
     $channel = null;
     $ctr = 1;
     foreach ($updateFileIterator as $item) {
         if ($channel === null || $channel != $item->channel) {
             $channel = $item->channel;
             $channelXml = $xml->addChild('row', $channel);
             $channelXml->addAttribute('id', $ctr++);
             $channelXml->addChild('cell', $channel);
         }
         $parent = $channelXml->addChild('row');
         $parent->addAttribute('id', $item->updateFileId);
         $parent->addChild('cell', $item->name . ' (v' . $item->version . ')');
         $parent->addChild('cell', $item->status);
         $parent->addChild('cell', '');
     }
     header('content-type: text/xml');
     $this->view->content = $xml->asXml();
     $this->render('list-xml');
 }
Example #6
0
 function __construct($src)
 {
     $this->xslt = new XSLTProcessor();
     $this->xslt->registerPHPFunctions();
     $this->xslt->importStylesheet($xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>
             <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl">
             <xsl:output method="text" encoding="UTF-8"/>
             <xsl:template match="/template-arguments">' . $this->compileFragment(strtr($src, array("<" => "&lt;", ">" => "&gt;", '"' => "&quot;", "'" => "&apos;", "&" => "&amp;"))) . '</xsl:template></xsl:stylesheet>'));
     print $xml->asXml();
 }
Example #7
0
 /**
  * Delete row with id_item how reference
  */
 function deleteItem()
 {
     $doc = new SimpleXMLElement('xml/blacklist.xml', null, true);
     foreach ($doc->ITEM as $ITEM) {
         if ($ITEM['ID'] == $this->id_item) {
             $dom = dom_import_simplexml($ITEM);
             $dom->parentNode->removeChild($dom);
         }
     }
     echo $doc->asXml('xml/blacklist.xml');
 }
Example #8
0
 public function actionIndex()
 {
     // 		$arrGoogle=array('google','Gmail','Chrome','Android');
     // //第一次使用each取得当前键值对,并且将指针移到下一个位置
     // $arrG=each($arrGoogle);
     // print_r($arrG);
     // $arrGmail=each($arrGoogle);
     // print_r($arrGmail);
     // $arrChrome=each($arrGoogle);
     // print_r($arrChrome);
     // $arrAndroid=each($arrGoogle);
     // print_r($arrAndroid);
     //当指针位于数组末尾再次执行函数each,如果是这样再次执行结果返回false
     // $empty=each($arrGoogle);die();
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="GBK"?><DOCUMENT />');
     header("Content-type: text/html; charset=utf-8");
     include "simple_html_dom.php";
     $html = file_get_html('http://www.ttpet.com/quanzhong/jinmao.html');
     $item = $xml->addchild("item");
     // Find all images
     foreach ($html->find('dl.qz_inft ') as $element) {
         /*echo $element;die();*/
         /*echo $element->children(2);echo $element->children(3);die()*/
         // $num1 = $item->addchild("name",$element->children(1)->plaintext);
         $num1 = $item->addchild("alias", $element->children(2)->plaintext);
     }
     $num1 = $item->addchild("ename", $element->children(3)->plaintext);
     // $num1 = $item->addchild("weight",$element->children(8)->plaintext);
     // $num1 = $item->addchild("years",$element->children(9)->plaintext);
     // $num1 = $item->addchild("place",$element->children(10)->plaintext);
     // $num1 = $item->addchild("shape",$element->children(4)->plaintext);
     // $num1 = $item->addchild("wool",$element->children(6)->plaintext);
     $num1 = $item->addchild("function", $element->children(5)->plaintext);
     // $num1 = $item->addchild("name",$element->plaintext);
     // unset($num1);continue;
     // $item->addchild("age",$element-next_sibling()->plaintext();
     header("Content-type: text/xml");
     echo $xml->asXml();
     $xml->asXml("student.xml");
     // die();
 }
Example #9
0
/**
 * 添加颜色到颜色库
 * @param $colorName
 */
function createColorLibrary($filename)
{
    if (file_exists($filename)) {
        $xml = simplexml_load_file($filename);
        return $xml;
    } else {
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><Colors />');
        $xml->asXml($filename);
        $colorXml = simplexml_load_file($filename);
        return $colorXml;
    }
}
 public function handle()
 {
     $result = $this->generateSoapXML($this->data);
     $result = new SimpleXMLElement($result);
     if ($this->wsdl_out == true) {
         //header("Content-Type: application/xml; charset=utf-8");
         //echo $result->asXml();
         $tmpfile = tempnam(sys_get_temp_dir(), "wsdl");
         $file = fopen($tmpfile, "w");
         fwrite($file, $result->asXml());
         fclose($file);
         $server = new SoapServer($tmpfile);
         foreach ($this->data as $value) {
             $server->addFunction($value->funcName);
         }
         $server->handle();
         unlink($tmpfile);
         return;
     } else {
         echo $this->echoXML($result->asXml());
     }
 }
Example #11
0
 /**
  * @param ProgrammeCondroid[] $programme
  */
 private function createXml(array $programme)
 {
     $annotations = new \SimpleXMLElement('<annotations></annotations>');
     foreach ($programme as $item) {
         $node = $annotations->addChild('programme');
         $node->addChild('pid', $item->pid);
         $node->addChild('author', '<![CDATA[' . $item->author . ']]>');
         $node->addChild('title', '<![CDATA[' . $item->title . ']]>');
         $node->addChild('type', $item->type);
         $node->addChild('program-line', '<![CDATA[' . $item->programLine . ']]>');
         $node->addChild('location', $item->location);
         $node->addChild('start-time', $item->startTime->format(DATE_ISO8601));
         $node->addChild('end-time', $item->endTime->format(DATE_ISO8601));
         $node->addChild('annotation', '<![CDATA[' . $item->annotation . ']]>');
     }
     return $annotations->asXml();
 }
 private static function deleteFromMasterConfig($strPluginName)
 {
     $oldContents = QFile::readFile(self::getMasterConfigFilePath());
     $doc = new SimpleXMLElement($oldContents);
     $found = false;
     foreach ($doc as $plugin) {
         if ($plugin->name == $strPluginName) {
             $dom = dom_import_simplexml($plugin);
             $dom->parentNode->removeChild($dom);
             $found = true;
             break;
         }
     }
     $newContents = $doc->asXml();
     $newContents = self::stripExtraNewlines($newContents);
     QFile::writeFile(self::getMasterConfigFilePath(), $newContents);
     return $found;
 }
Example #13
0
 /**
  * Clean up the xml file as google requires
  * @param string $feed
  */
 private function googlefixes($feed)
 {
     // Delete wrong attributes used by the Atom 1.0
     $feed = str_replace(" type=\"html\"", "", $feed);
     $feed = str_replace(" type=\"text\"", "", $feed);
     // Delete some xml childs from the xml
     $xmlfeed = new SimpleXMLElement($feed);
     foreach ($xmlfeed->entry as $child) {
         $target = $child->id;
         if ($target) {
             $dom = dom_import_simplexml($target);
             $dom->parentNode->removeChild($dom);
         }
     }
     $feed = $xmlfeed->asXml();
     // removeChild method leave a blank line after the deletion of the xml child
     $feed = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/", "\n", $feed);
     return $feed;
 }
Example #14
0
 function toXml()
 {
     $baseStr = '<?xml version="1.0" standalone="yes"?><tree id="0"></tree>';
     $xml = new SimpleXMLElement($baseStr);
     $currentLevel = $xml;
     $currentParent = 0;
     $currentNode = null;
     foreach ($this->_tree as $row) {
         if ($currentParent != $row['parentId']) {
             $currentLevel = $currentNode;
         }
         $node = $currentLevel->addChild('item');
         $node->addAttribute('id', $row['locationId']);
         $node->addAttribute('text', $row['name']);
         $currentParent = $row['parentId'];
         $currentNode = $node;
     }
     return $xml->asXml();
 }
Example #15
0
 /**
  * Get string with XML content.
  *
  * @return string
  */
 public function getPackageXml()
 {
     return $this->_packageXml->asXml();
 }
Example #16
0
<?php

$xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?>
<collection></collection>');
$xml->movie[]->characters->character[0]->name = 'Miss Coder';
echo $xml->asXml();
?>
===DONE===
Example #17
0
 public function download($id, $position, $product_id, $file = 'svg')
 {
     if ($id > 0) {
         $this->load->model('product_m');
         $design = $this->product_m->getProductDesign($product_id);
         if (count($design)) {
             $area = json_decode($design->area);
             if (isset($area->{$position}) && $area->{$position} != '') {
                 $view = json_decode(str_replace("'", '"', $area->{$position}));
                 $radius = str_replace('px', '', $view->radius);
                 $svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="' . $view->height . '" width="' . $view->width . '">';
                 $data = $this->order_m->getDesignDetail($id);
                 $vectors = json_decode($data->vectors);
                 $items = $vectors->{$position};
                 $items = json_decode(json_encode($items), true);
                 function cmp($a, $b)
                 {
                     return strcmp($a['zIndex'], $b['zIndex']);
                 }
                 usort($items, 'cmp');
                 $items = json_decode(json_encode($items));
                 foreach ($items as $item) {
                     $top = str_replace('px', '', $item->top);
                     $left = str_replace('px', '', $item->left);
                     if (isset($item->file) && isset($item->file->type) && $item->file->type == 'image') {
                         preg_match_all("/xlink:href=\"(.*)\">/i", $item->svg, $links);
                         if (isset($links[1][0])) {
                             $link = str_replace('_thumb', '', $links[1][0]);
                             $data = file_get_contents($link);
                             $base64 = 'data:image/PNG;base64,' . base64_encode($data);
                             $temp = explode($links[1][0], $item->svg);
                             if (isset($temp[1])) {
                                 $item->svg = $temp[0] . $base64 . $temp[1];
                             }
                         }
                     }
                     $doc = new SimpleXMLElement($item->svg);
                     unset($doc->attributes()['x']);
                     unset($doc->attributes()['y']);
                     $item->svg = $doc->asXml();
                     if ($item->rotate != 0) {
                         $width = str_replace('px', '', $item->width);
                         $height = str_replace('px', '', $item->height);
                         $width = (int) $width / 2;
                         $height = (int) $height / 2;
                         $strsvg = str_replace('<svg ', '<svg ', $item->svg);
                         $svg .= '<g transform="translate(' . $left . ', ' . $top . ')  rotate(' . $item->rotate . ' ' . $width . ' ' . $height . ')">' . $strsvg . '</g>';
                     } else {
                         $svg .= str_replace('<svg ', '<svg y="' . $top . '" x="' . $left . '" ', $item->svg);
                     }
                 }
                 if ($radius > 0) {
                     $svg .= '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="' . ($view->height + $radius) . '" width="' . ($view->width + $radius) . '"><rect x="-' . (int) ($radius / 2) . '" y="-' . (int) ($radius / 2) . '" rx="' . $radius . '" ry="' . $radius . '" height="' . ($view->height + $radius) . '" width="' . ($view->width + $radius) . '" style="fill:none;stroke:#FFFFFF;stroke-width:' . $radius . ';"/></svg>';
                 }
                 $svg .= '</svg>';
                 $svg = str_replace('<?xml version="1.0"?>', '', $svg);
                 header('Content-type:image/svg+xml');
                 if ($file == 'svg') {
                     header('Content-Disposition: attachment; filename="' . $position . '.svg"');
                 } else {
                     $dom = new DOMDocument();
                     $dom->loadXML($svg);
                     $books = $dom->getElementsByTagName('svg');
                     foreach ($books as $book) {
                         $width = $book->getAttribute('width') * 15;
                         $book->setAttribute('width', $width);
                         $height = $book->getAttribute('height') * 15;
                         $book->setAttribute('height', $height);
                         $x = $book->getAttribute('x') * 15;
                         $book->setAttribute('x', $x);
                         $y = $book->getAttribute('y') * 15;
                         $book->setAttribute('y', $y);
                     }
                     $images = $dom->getElementsByTagName('image');
                     if ($images->length > 0) {
                         foreach ($images as $image) {
                             $width = $image->getAttribute('width') * 15;
                             $image->setAttribute('width', $width);
                             $height = $image->getAttribute('height') * 15;
                             $image->setAttribute('height', $height);
                             $x = $image->getAttribute('x') * 15;
                             $image->setAttribute('x', $x);
                             $y = $image->getAttribute('y') * 15;
                             $image->setAttribute('y', $y);
                         }
                     }
                     echo $dom->saveXML();
                     exit;
                 }
                 echo $svg;
                 exit;
             }
         }
     }
 }
Example #18
0
<?php

$xml_path = "test.xml";
// SET SIMPLEXMLELEMENT
$conf = file_get_contents($xml_path);
$xml = new SimpleXMLElement($conf);
// GET XML VARS
$environment = (string) $xml->environment;
foreach ($xml as $key => $value) {
}
// ADD TO XML
$new = $xml->addChild('details');
$new->addChild('UsrInitials', $rs_login[0]["UsrInitials"]);
$new->addChild('Name', $rs_login[0]["Name"]);
$xml->asXml($xml_path);
Example #19
0
 /**
  * Return an XML representation of the record using the specified format.
  * Return false if the format is unsupported.
  *
  * @param string $format Name of format to use (corresponds with OAI-PMH
  * metadataPrefix parameter).
  *
  * @return mixed         XML, or false if format unsupported.
  */
 public function getXML($format)
 {
     // For OAI-PMH Dublin Core, produce the necessary XML:
     if ($format == 'oai_dc') {
         $dc = 'http://purl.org/dc/elements/1.1/';
         $xml = new \SimpleXMLElement('<oai_dc:dc ' . 'xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" ' . 'xmlns:dc="' . $dc . '" ' . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ ' . 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd" />');
         $xml->addChild('title', htmlspecialchars($this->getTitle()), $dc);
         $primary = $this->getPrimaryAuthor();
         if (!empty($primary)) {
             $xml->addChild('creator', htmlspecialchars($primary), $dc);
         }
         $corporate = $this->getCorporateAuthor();
         if (!empty($corporate)) {
             $xml->addChild('creator', htmlspecialchars($corporate), $dc);
         }
         foreach ($this->getSecondaryAuthors() as $current) {
             $xml->addChild('creator', htmlspecialchars($current), $dc);
         }
         foreach ($this->getLanguages() as $lang) {
             $xml->addChild('language', htmlspecialchars($lang), $dc);
         }
         foreach ($this->getPublishers() as $pub) {
             $xml->addChild('publisher', htmlspecialchars($pub), $dc);
         }
         foreach ($this->getPublicationDates() as $date) {
             $xml->addChild('date', htmlspecialchars($date), $dc);
         }
         foreach ($this->getAllSubjectHeadings() as $subj) {
             $xml->addChild('subject', htmlspecialchars(implode(' -- ', $subj)), $dc);
         }
         return $xml->asXml();
     }
     // Unsupported format:
     return false;
 }
Example #20
0
 /**
  * Add photo
  *
  * @param   string  $file     Path of file to upload
  * @param   string  $title    Title to give to file (defaults to filename)
  * @param   string  $summary  Description of the file
  *
  * @return  mixed  Data from Google
  *
  * @since   12.3
  * @throws  RuntimeException
  */
 public function upload($file, $title = '', $summary = '')
 {
     if ($this->isAuthenticated()) {
         jimport('joomla.filesystem.file');
         $title = $title != '' ? $title : JFile::getName($file);
         if (!($type = $this->getMime($file))) {
             throw new RuntimeException("Inappropriate file type.");
         }
         if (!($data = JFile::read($file))) {
             throw new RuntimeException("Cannot access file: `{$file}`");
         }
         $xml = new SimpleXMLElement('<entry></entry>');
         $xml->addAttribute('xmlns', 'http://www.w3.org/2005/Atom');
         $xml->addChild('title', $title);
         $xml->addChild('summary', $summary);
         $cat = $xml->addChild('category', '');
         $cat->addAttribute('scheme', 'http://schemas.google.com/g/2005#kind');
         $cat->addAttribute('term', 'http://schemas.google.com/photos/2007#photo');
         $post = "Media multipart posting\n";
         $post .= "--END_OF_PART\n";
         $post .= "Content-Type: application/atom+xml\n\n";
         $post .= $xml->asXml() . "\n";
         $post .= "--END_OF_PART\n";
         $post .= "Content-Type: {$type}\n\n";
         $post .= $data;
         $jdata = $this->query($this->getLink(), $post, array('GData-Version' => 2, 'Content-Type: multipart/related'), 'post');
         return new JGoogleDataPicasaPhoto($this->safeXml($jdata->body), $this->options, $this->auth);
     } else {
         return false;
     }
 }
Example #21
0
 /**
  *
  * @param string $xmlQuery
  */
 protected function _oapiAddMetadata(&$xmlQuery)
 {
     OSM_ZLog::debug(__METHOD__);
     $x = new SimpleXMLElement($xmlQuery);
     $xPrints = $x->xpath('//print');
     foreach ($xPrints as $xPrint) {
         if ($xPrint['mode'] == null) {
             $xPrint->addAttribute('mode', 'meta');
         }
     }
     $xmlQuery = $x->asXml();
 }
Example #22
0
 /**
  * Return informations about the system into a XML string.
  *
  * @return string XML
  */
 public static function getInformationsAboutSystem()
 {
     $config = Zend_Registry::get('config');
     $xml = new SimpleXMLElement("<informations></informations>");
     $os = $xml->addChild('host');
     $os->addChild('os', PHP_OS);
     $os->addChild('uname', php_uname());
     $subversion = $xml->addChild('subversion');
     $subversion->addChild('version', implode(".", USVN_SVNUtils::getSvnVersion()));
     $usvn = $xml->addChild('usvn');
     $usvn->addChild('version', $config->version);
     $usvn->addChild('translation', $config->translation->locale);
     $usvn->addChild('databaseadapter', $config->database->adapterName);
     $php = $xml->addChild('php');
     $php->addChild('version', phpversion());
     // $ini = $php->addChild('ini');
     // foreach(ini_get_all() as $var => $value)
     // 	$ini->addChild($var, htmlspecialchars((string)$value['local_value']));
     // foreach (get_loaded_extensions() as $ext)
     // 	$php->addChild('extension', $ext);
     // $apache = $xml->addChild('host');
     // if (function_exists("apache_get_modules"))
     // 	foreach (apache_get_modules() as $ext)
     // 		$apache->addChild("module", $ext);
     return $xml->asXml();
 }
Example #23
0
/**
 * 添加颜色到颜色库
 * @param $colorName
 */
function colorLibraryOperate($colorName)
{
    if (file_exists('test.xml')) {
        $xml = simplexml_load_file('test.xml');
        var_dump($xml);
    } else {
        $xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><Colors />');
        $filename = date('YmdHi', time()) . '-' . 'color.xml';
        $xml->asXml($filename);
    }
}
 function listItemsAction()
 {
     $eSignIterator = new ESignatureIterator();
     $objectId = (int) $this->_getParam('objectId');
     if ($objectId > 0) {
         $eSignIterator->setFilter($objectId, 'objectId');
     } else {
         $eSignIterator->setFilter((int) Zend_Auth::getInstance()->getIdentity()->personId, 'signList');
     }
     //var_dump($db->query($cnSelect)->fetchAll());exit;
     $baseStr = "<?xml version='1.0' standalone='yes'?><rows></rows>";
     $xml = new SimpleXMLElement($baseStr);
     $currentCat = null;
     $category = null;
     // override the include_path to include controllers path
     set_include_path(realpath(Zend_Registry::get('basePath') . '/application/controllers') . PATH_SEPARATOR . get_include_path());
     foreach ($eSignIterator as $row) {
         $row = $row->toArray();
         if ($currentCat != $row['objectClass']) {
             $currentCat = $row['objectClass'];
             $category = $xml->addChild("row");
             $category->addAttribute("id", $row['objectClass']);
             $cell = $category->addChild("cell", call_user_func($currentCat . "::" . "getPrettyName", array()));
             $cell = $category->addChild("cell", '');
             $controllerName = call_user_func($currentCat . "::" . "getControllerName");
             $jumpLink = call_user_func_array($controllerName . "::" . "buildJSJumpLink", array($row['objectId'], $row['signingUserId'], $row['objectClass']));
             //$jumpLink = $this->buildJSJumpLink($row['objectId'],$row['signingUserId'],$row['objectClass']);
             $js = "function jumpLink{$row['objectClass']}(objectId,patientId) {\n{$jumpLink}\n}";
             $cell = $category->addChild('cell', $js);
         }
         $leaf = $category->addChild("row");
         $leaf->addAttribute('id', $row['eSignatureId']);
         $leaf->addChild('cell', $row['dateTime'] . " " . $row['summary']);
         $leaf->addChild('cell', '');
         // hidden column that will load the correct tab
         $leaf->addChild('cell', $row['objectId']);
         // temporary set to objectId
         //$leaf->addChild('cell',$this->buildJSJumpLink($row['objectId'],$row['signingUserId']));
         // for patientId hidden column, not sure if this is the correct field.
         //$leaf->addChild('cell',$row['signingUserId']);
         $obj = new $row['objectClass']();
         foreach ($obj->_primaryKeys as $key) {
             $obj->{$key} = $row['objectId'];
         }
         $obj->populate();
         $patientId = $obj->personId;
         $leaf->addChild('cell', $patientId);
     }
     header('content-type: text/xml');
     $this->view->content = $xml->asXml();
     $this->render();
 }
Example #25
0
 /**
  * Prepare an xml file content holding
  * a standard record for returning result
  * of an ajax request
  *
  * @param JView $view the view handling the request
  */
 public static function prepareAjaxResponse($view)
 {
     // create a root node
     $base = '<?xml version="1.0" encoding="UTF-8" ?><item id="shajax-response"></item>';
     $xml = new SimpleXMLElement($base);
     $status = '_';
     $message = '_';
     $messagecode = '_';
     $taskexecuted = '_';
     // set their respective values
     $vErrors = array();
     $view = new stdClass();
     if (empty($vErrors)) {
         // retrieve messagecode and task
         if (empty($view->messagecode)) {
             $view->messagecode = 'COM_SH404SEF_OPERATION_COMPLETED';
         }
         if (empty($view->taskexecuted)) {
             $view->taskexecuted = $taskexecuted;
         }
         // either a success or a redirect
         if (empty($view->redirectTo)) {
             // no error
             $status = 'success';
             $msg = empty($view->message) ? JText::_('COM_SH404SEF_OPERATION_COMPLETED') : $view->message;
             $message = '<ul>' . $msg . '</ul>';
             $messagecode = 200;
         } else {
             $status = 'redirect';
             $glue = strpos($view->redirectTo, '?') === false ? '?' : '&';
             $message = $view->redirectTo . $glue . 'sh404sefMsg=' . $view->messagecode;
         }
         $taskexecuted = $view->taskexecuted;
     } else {
         $status = 'failure';
         $messageTxt = '';
         foreach ($vErrors as $error) {
             $messageTxt .= '<li>' . $error . '</li>';
         }
         $message = '<ul>' . $messageTxt . '</ul>';
     }
     // add children : status, message, message code, task
     $xml->addChild('status', $status);
     $xml->addChild('message', $message);
     $xml->addChild('messagecode', $messagecode);
     $xml->addChild('taskexecuted', $taskexecuted);
     // output resulting text, no need for a layout file I think
     $output = $xml->asXml();
     return $output;
 }
Example #26
0
 public function _getScoring($id_order, $id_lang)
 {
     $scoring = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'prestafraud_orders WHERE scoring IS NOT NULL AND id_order = ' . (int) $id_order);
     if (!$scoring) {
         $root = new SimpleXMLElement("<?xml version=\"1.0\"?><trust></trust>");
         $xml = $root->addChild('get_scoring');
         $xml->addChild('shop_id', Configuration::get('PS_TRUST_SHOP_ID'));
         $xml->addChild('shop_password', Configuration::get('PS_TRUST_SHOP_KEY'));
         $xml->addChild('id_order', (int) $id_order);
         $xml->addChild('lang', Language::getIsoById((int) $id_lang));
         $result = $this->_pushDatas($root->asXml());
         if (!$result) {
             return false;
         }
         $xml = simplexml_load_string($result);
         if ((int) $xml->check_scoring->status != -1) {
             Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'prestafraud_orders SET scoring = ' . (double) $xml->check_scoring->scoring . ', comment = \'' . pSQL($xml->check_scoring->comment) . '\' WHERE id_order=' . (int) $id_order);
         }
         $scoring = array('scoring' => (double) $xml->check_scoring->scoring, 'comment' => (string) $xml->check_scoring->comment);
     }
     return $scoring;
 }
Example #27
0
 function listItemsAction()
 {
     $eSignIterator = new ESignatureIterator();
     $objectId = (int) $this->_getParam('objectId');
     if ($objectId > 0) {
         $eSignIterator->setFilter($objectId, 'objectId');
     } else {
         $eSignIterator->setFilter((int) Zend_Auth::getInstance()->getIdentity()->personId, 'signList');
     }
     //var_dump($db->query($cnSelect)->fetchAll());exit;
     $baseStr = "<?xml version='1.0' standalone='yes'?><rows></rows>";
     $xml = new SimpleXMLElement($baseStr);
     $currentCat = null;
     $category = null;
     // override the include_path to include controllers path
     set_include_path(realpath(Zend_Registry::get('basePath') . '/application/controllers') . PATH_SEPARATOR . get_include_path());
     foreach ($eSignIterator as $row) {
         $row = $row->toArray();
         $obj = new $row['objectClass']();
         foreach ($obj->_primaryKeys as $key) {
             $obj->{$key} = $row['objectId'];
         }
         if (!$obj->populate()) {
             continue;
         }
         // signing but actual object does not exists
         if ($currentCat != $row['objectClass']) {
             $currentCat = $row['objectClass'];
             $category = $xml->addChild("row");
             $category->addAttribute("style", 'height:20px;');
             $category->addAttribute("id", $row['objectClass']);
             $cell = $category->addChild("cell", call_user_func($currentCat . "::" . "getPrettyName", array()));
             $cell = $category->addChild("cell", '');
             $controllerName = call_user_func($currentCat . "::" . "getControllerName");
             $jumpLink = call_user_func_array($controllerName . "::" . "buildJSJumpLink", array($row['objectId'], $row['signingUserId'], $row['objectClass']));
             //$jumpLink = $this->buildJSJumpLink($row['objectId'],$row['signingUserId'],$row['objectClass']);
             $js = "function jumpLink{$row['objectClass']}(objectId,patientId) {\n{$jumpLink}\n}";
             //				$cell = $category->addChild('cell',$js);
             $userdata = $category->addChild('userdata', $js);
             $userdata->addAttribute('name', 'js');
         }
         $leaf = $category->addChild("row");
         $leaf->addAttribute('id', $row['eSignatureId']);
         $leaf->addChild('cell', $row['dateTime'] . " " . preg_replace('/[<>]/', '', $row['summary']));
         $leaf->addChild('cell', '');
         $userdata = $leaf->addChild('userdata', $row['objectId']);
         $userdata->addAttribute('name', 'objectId');
         // hidden column that will load the correct tab
         //			$leaf->addChild('cell',$row['objectId']); // temporary set to objectId
         //$leaf->addChild('cell',$this->buildJSJumpLink($row['objectId'],$row['signingUserId']));
         // for patientId hidden column, not sure if this is the correct field.
         //$leaf->addChild('cell',$row['signingUserId']);
         $patientId = $obj->personId;
         $userdata = $leaf->addChild('userdata', $patientId);
         $userdata->addAttribute('name', 'patientId');
         //$leaf->addChild('cell',$patientId);
         // add a subrow for other info
         if ($row['objectClass'] == 'Medication') {
             $pharmacyInfo = array();
             // $obj refers to Medication ORM
             if ($obj->isScheduled()) {
                 $pharmacyInfo[] = 'Medication is a controlled substance, it cannot be sent electronically. The Rx will be printed and needs a wet signature before it can be faxed to the pharmacy or handed to the patient.';
             } else {
                 $pharmacy = $obj->pharmacy;
                 if (strlen($pharmacy->StoreName) > 0) {
                     $pharmacyInfo[] = $pharmacy->StoreName;
                     $address = $pharmacy->AddressLine1;
                     if (strlen($pharmacy->AddressLine2) > 0) {
                         $address .= ' ' . $pharmacy->AddressLine2;
                     }
                     $address .= ', ' . $pharmacy->City;
                     $address .= ', ' . $pharmacy->State;
                     $address .= ', ' . $pharmacy->Zip;
                     $pharmacyInfo[] = $address;
                     $phones = array();
                     $phones[] = $pharmacy->PhonePrimary;
                     if (strlen($pharmacy->Fax) > 0) {
                         $phones[] = $pharmacy->Fax;
                     }
                     if (strlen($pharmacy->PhoneAlt1) > 0) {
                         $phones[] = $pharmacy->PhoneAlt1;
                     }
                     if (strlen($pharmacy->PhoneAlt2) > 0) {
                         $phones[] = $pharmacy->PhoneAlt2;
                     }
                     if (strlen($pharmacy->PhoneAlt3) > 0) {
                         $phones[] = $pharmacy->PhoneAlt3;
                     }
                     if (strlen($pharmacy->PhoneAlt4) > 0) {
                         $phones[] = $pharmacy->PhoneAlt4;
                     }
                     if (strlen($pharmacy->PhoneAlt5) > 0) {
                         $phones[] = $pharmacy->PhoneAlt5;
                     }
                     $pharmacyInfo[] = implode(', ', $phones);
                 } else {
                     $pharmacyInfo[] = 'No pharmacy selected';
                 }
             }
             $pharmacyInfo = implode(" <br /> ", $pharmacyInfo);
             $patient = new Patient();
             $patient->personId = $obj->personId;
             $patient->populate();
             $patientInfo = $patient->lastName . ", " . $patient->firstName . " " . strtoupper(substr($patient->middleName, 0, 1)) . " #" . $patient->recordNumber;
             $qualifiers = Medication::listQuantityQualifiersMapping();
             $medicationInfo = array();
             $rxn = $obj->rxReferenceNumber;
             if (strlen($rxn) > 0) {
                 $medicationInfo[] = 'Rx Reference Number: ' . $rxn;
             }
             $medicationInfo[] = 'Description: ' . htmlspecialchars($obj->description);
             $medicationInfo[] = 'Directions: ' . htmlspecialchars($obj->directions);
             $medicationInfo[] = 'Quantity: ' . $obj->quantity . ' ' . $qualifiers[$obj->quantityQualifier];
             //$medicationInfo[] = 'Quantity: '.$obj->quantity.' '.$obj->quantityQualifier;
             $medicationInfo[] = 'Strength: ' . $obj->dose . ' ' . $qualifiers[$obj->quantityQualifier];
             //$medicationInfo[] = 'Strength: '.$obj->dose.' '.$obj->quantityQualifier;
             $medicationInfo[] = 'Days Supply: ' . $obj->daysSupply;
             $refills = $obj->refills;
             if ($obj->prn) {
                 $refills = 'PRN';
             }
             $medicationInfo[] = 'Refills: ' . $refills;
             $substitution = 'Permitted';
             if ($obj->substitution == 0) {
                 $substitution = 'Not Permitted';
             }
             $medicationInfo[] = 'Substitutions: ' . $substitution;
             $medicationInfo[] = 'Date Prescribed: ' . date('Y-m-d', strtotime($obj->datePrescribed));
             //$medicationInfo[] = 'NDC: '.$obj->hipaaNDC;
             //$medicationInfo[] = 'Dosage Form: '.DataTables::getDosageForm($obj->chmedDose);
             //$medicationInfo[] = 'DB Code: '.$obj->pkey;
             $medicationInfo[] = 'Note: ' . htmlspecialchars($obj->comment);
             $medicationInfo = implode(' <br /> ', $medicationInfo);
             $info = '<div style="margin-left:75px;margin-top:-18px;margin-bottom:5px;">
		<fieldset>
			<legend title="' . htmlspecialchars($patientInfo) . '">' . __('Patient') . '</legend>' . htmlspecialchars($patientInfo) . '
		</fieldset>
		<fieldset>
			<legend title="' . htmlspecialchars($pharmacyInfo) . '">' . __('Pharmacy') . '</legend>' . htmlspecialchars($pharmacyInfo) . '
		</fieldset>
		<fieldset title="' . htmlspecialchars($medicationInfo) . '">
			<legend>' . __('Medication') . '</legend>' . htmlspecialchars($medicationInfo) . '
		</fieldset></div>';
             $node = $leaf->addChild('row');
             $guid = NSDR::create_guid();
             $node->addAttribute('id', $guid);
             //				$node->addAttribute('style','vertical-align:top;height:50px;');
             $node->addChild('cell', '<![CDATA[' . $info . ']]>');
             $node->addChild('cell', '');
             $node->addChild('cell', '');
             $node->addChild('cell', '');
         }
     }
     header('content-type: text/xml');
     $this->view->content = $xml->asXml();
     $this->view->content = html_entity_decode($this->view->content);
     file_put_contents('/tmp/esign.xml', $this->view->content);
     $this->render();
 }
Example #28
0
 /**
  * Creates a new upload result object from the given SimpleXMLElement item
  * @param SimpleXMLElement $item
  * @param KalturaBulkUploadAction $action
  * @return KalturaBulkUploadResult
  */
 protected function createUploadResult(SimpleXMLElement $item, $action)
 {
     if ($this->handledRecordsThisRun >= $this->maxRecordsEachRun || $this->maxRecords && $this->currentItem > $this->maxRecords) {
         $this->exceededMaxRecordsEachRun = true;
         return;
     }
     //TODO: What should we write in the bulk upload result for update?
     //only the changed parameters or just the one theat was changed
     //		KalturaLog::debug("Creating upload result");
     KalturaLog::debug("this->handledRecordsThisRun [{$this->handledRecordsThisRun}], this->maxRecordsEachRun [{$this->maxRecordsEachRun}]");
     $bulkUploadResult = new KalturaBulkUploadResultEntry();
     $bulkUploadResult->status = KalturaBulkUploadResultStatus::IN_PROGRESS;
     $bulkUploadResult->action = $action;
     $bulkUploadResult->bulkUploadJobId = $this->job->id;
     $bulkUploadResult->lineIndex = $this->currentItem;
     $bulkUploadResult->partnerId = $this->job->partnerId;
     $bulkUploadResult->rowData = $item->asXml();
     $bulkUploadResult->entryStatus = $this->getEntryStatusFromItem($item);
     $bulkUploadResult->conversionProfileId = $this->getConversionProfileId($item);
     $bulkUploadResult->accessControlProfileId = $this->getAccessControlId($item);
     if (!is_numeric($bulkUploadResult->conversionProfileId)) {
         $bulkUploadResult->conversionProfileId = null;
     }
     if (!is_numeric($bulkUploadResult->accessControlProfileId)) {
         $bulkUploadResult->accessControlProfileId = null;
     }
     if (isset($item->startDate)) {
         if ((string) $item->startDate && !self::isFormatedDate((string) $item->startDate)) {
             $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
             $bulkUploadResult->errorDescription = "Invalid schedule start date {$item->startDate} on item {$item->name}";
         }
     }
     if (isset($item->endDate)) {
         if ((string) $item->endDate && !self::isFormatedDate((string) $item->endDate)) {
             $bulkUploadResult->entryStatus = KalturaEntryStatus::ERROR_IMPORTING;
             $bulkUploadResult->errorDescription = "Invalid schedule end date {$item->endDate} on item {$item->name}";
         }
     }
     if ($bulkUploadResult->entryStatus == KalturaEntryStatus::ERROR_IMPORTING) {
         $this->addBulkUploadResult($bulkUploadResult);
         return;
     }
     $bulkUploadResult->scheduleStartDate = self::parseFormatedDate((string) $item->startDate);
     $bulkUploadResult->scheduleEndDate = self::parseFormatedDate((string) $item->endDate);
     return $bulkUploadResult;
 }
Example #29
0
 public function save()
 {
     if (file_put_contents($this->_path, $this->_xml->asXml()) === false) {
         throw new Exception('Could not write to ' . $this->_path);
     }
 }
Example #30
0
 /**
  * loading file with filter specification for current module or subsection
  *
  * @param  string $module     module name
  * @param  string $subsection subsection name
  * @return array              array with config and state filter
  */
 public function loadFilters(&$module, &$subsection)
 {
     // if file filter.txt exists in models, we will use it
     $filterState = $filterConfig = "";
     $namespaces = $this->getModelNamespaces($this->container->get('request')->get('key'));
     if (isset($namespaces[$module])) {
         $namespace = $namespaces[$module];
         $filter = new \SimpleXMLElement("<" . $module . "></" . $module . ">");
         $filter->addAttribute('xmlns', $namespace);
         if ($subsection) {
             $filter->addChild($subsection);
         }
         $filterState = $filterConfig = str_replace('<?xml version="1.0"?' . '>', '', $filter->asXml());
     }
     return array('config' => $filterConfig, 'state' => $filterState);
 }