Beispiel #1
0
 /**
  * Generic call-Method instead of numerous setter methods
  * @param             string              $method                       The name of the method, which is called for the Item-Object
  * @param             array               $args                         The arguments with them the method is called - minOccurance = 0, maxOccurance = 2:
  *                                                                      The first argument must be a positive integer (will be used as a index)
  *                                                                      The second argument is optional and would be used as value for the DOMNode
  */
 public function __call($method, $args)
 {
     if (substr($method, 0, 3) == "set" && $args[0] != '') {
         $attributeName = substr($method, 3);
         $value = $args[0];
         if (preg_match('/[0-9]+,[0-9]+/', $value, $match)) {
             $value = str_replace(',', '.', $match[0]);
         }
         if (preg_match('/[0-9]+.[0-9]+/', $value, $match) && $value == $match[0] && $attributeName != 'shippingCosts' && (is_int(strpos($attributeName, 'price')) || is_int(strpos($attributeName, 'Price')) || is_int(strpos($attributeName, 'Tax')) || is_int(strpos($attributeName, 'cost')) || is_int(strpos($attributeName, 'Cost')))) {
             $value = number_format(floatval($match[0]), 2, '.', '');
         }
         $this->node->setAttribute($attributeName, $value);
     } elseif ($args[0] != '') {
         if (sizeof($args) > 2) {
             die("It is not allowed to set more than 2 arguments for the node '{$method}'!");
         }
         if (!is_int($args[0]) || $args[0] < 1) {
             die("The first argument for the node '{$method}' must be whole number, bigger than 0!");
         }
         $name = $method . '[' . $args[0] . ']';
         $xpath = new \DOMXPath($this->doc);
         $qry = $xpath->query($name, $this->node);
         if ($qry->length > 0) {
             return new ORDER($this->doc, $qry->item(0));
         } else {
             if (array_key_exists(1, $args)) {
                 $value = $args[1];
                 if (preg_match('/[0-9]+,[0-9]+/', $value, $match)) {
                     $value = str_replace(',', '.', $match[0]);
                 }
                 if (preg_match('/[0-9]+.[0-9]+/', $value, $match) && $value == $match[0] && $name != 'shippingCosts' && (is_int(strpos($name, 'price')) || is_int(strpos($name, 'Price')) || is_int(strpos($name, 'Tax')) || is_int(strpos($name, 'cost')) || is_int(strpos($name, 'Cost')))) {
                     $value = number_format(floatval($match[0]), 2, '.', '');
                 }
                 $node = $this->doc->createElement($method, $value);
             } else {
                 $node = $this->doc->createElement($method);
             }
             $node = $this->node->appendChild($node);
             return new ORDER($this->doc, $node);
         }
     }
 }
Beispiel #2
0
        $Registry = RegistryModuleFactory::GetInstance()->GetRegistryByExtension($_SESSION["TLD"]);
        $registry_exists = true;
    } catch (Exception $e) {
        $registry_exists = false;
    }
}
if ($_SESSION["selected_domain"] && $registry_exists) {
    $node = new DOMDocument("1.0", "UTF-8");
    $node->loadXML(@file_get_contents(dirname(__FILE__) . "/../../../etc/client_domain_nav.xml"));
    $XMLNav->AddNode($node->documentElement, $XMLNav->XML->documentElement);
    $XPath = new DOMXPath($XMLNav->XML);
    $entries = $XPath->query('//node[@type = "tasks"]', $XMLNav->XML->documentElement);
    if ($entries && $entries->item(0)) {
        foreach ($entries as $node) {
            if ($node instanceof DOMElement) {
                $node->setAttribute("title", sprintf(_("Tasks for %s"), "{$_SESSION['domain']}.{$_SESSION['TLD']}"));
            }
        }
    }
    $entries = $XPath->query('//item[@type != ""]', $XMLNav->XML->documentElement);
    if ($entries && $entries->item(0)) {
        foreach ($entries as $node) {
            if ($node instanceof DOMElement) {
                $exists = false;
                $type = $node->getAttribute("type");
                foreach (UI::GetContactsListForSmarty($Registry->Manifest->GetSectionConfig()) as $ck => $cv) {
                    if ($cv["type"] == $type) {
                        $exists = true;
                    }
                }
                if (!$exists) {
 /**
  * @param \DOMDocument $document
  * @param \DOMElement|\DOMDocument|null $parentElement
  * @param string $type
  *
  * @return \DOMElement
  */
 private static function createTypeElement(\DOMDocument $document, $parentElement = null, $type)
 {
     if ($parentElement->parentNode === null) {
         $typeElement = $document->createElementNS('https://github.com/RhubarbPHP/Rhubarb/blob/master/docs/simple-xml-transcoder.md', self::XMLNS . ':' . $type);
         $parentElement->appendChild($typeElement);
     } else {
         $parentElement->setAttribute(self::XMLNS . ':' . self::ATTR_TYPE, $type);
         $typeElement = $parentElement;
     }
     return $typeElement;
 }