コード例 #1
0
 public function API_sync()
 {
     $xpath = DH::elementToPanXPath($this->xmlroot);
     $con = findConnectorOrDie($this);
     $con->sendEditRequest($xpath, $this->getXmlText_inline());
 }
コード例 #2
0
ファイル: class-DH.php プロジェクト: shpapy/pan-configurator
 /**
  * @param DOMNode $element
  * @return string
  */
 public static function &elementToPanXPath($element)
 {
     $xpath = '';
     if ($element->nodeType == XML_DOCUMENT_NODE) {
         $element = DH::firstChildElement($element);
     }
     if ($element->nodeType == 1) {
         if ($element->hasAttribute('name')) {
             $xpath = '/' . $element->tagName . "[@name='{$element->getAttribute('name')}']";
         } else {
             $xpath = '/' . $element->tagName;
         }
         $parent = $element->parentNode;
         if ($parent === null) {
             derr('unsupported node that has no parent (null)');
         }
         if ($parent->nodeType == 9 || $parent->nodeType == 10) {
             return $xpath;
         }
         $xpath = DH::elementToPanXPath($parent) . $xpath;
     } else {
         derr('unsupported node type=' . $element->nodeType);
     }
     return $xpath;
 }
コード例 #3
0
function mwarning($msg, $object = null)
{
    global $PANC_WARN;
    if (isset($PANC_WARN) && $PANC_WARN == 0) {
        return;
    }
    if ($object !== null) {
        $class = get_class($object);
        if ($class == 'DOMNode' || $class == 'DOMElement' || is_subclass_of($object, 'DOMNode')) {
            $msg .= "\nXML line #" . $object->getLineNo() . ", XPATH: " . DH::elementToPanXPath($object) . "\nRaw xml:" . DH::dom_to_xml($object, 0, true, 3);
        }
    }
    fwrite(STDERR, "\n*WARNING* " . $msg . "\n");
    //debug_print_backtrace();
    $d = debug_backtrace();
    $skip = 0;
    print " *** Backtrace ***\n";
    foreach ($d as $l) {
        if ($skip >= 0) {
            if ($skip == 0 && isset($l['object'])) {
                fwrite(STDERR, $l['object']->toString() . "\n");
            }
            fwrite(STDERR, $l['function'] . "()\n");
            if (isset($l['object'])) {
                fwrite(STDERR, '       ' . $l['class'] . '::' . $l['file'] . " line " . $l['line'] . "\n");
            } else {
                fwrite(STDERR, '       ::' . $l['file'] . " line " . $l['line'] . "\n");
            }
        }
        $skip++;
    }
    fwrite(STDERR, "\n\n");
}