Exemple #1
0
 /**
  * 
  * @param type $id
  * @return \Sokil\Vast\Ad
  */
 public function setId($id)
 {
     $this->_domElement->setAttribute('id', $id);
     return $this;
 }
Exemple #2
0
/**
* Extract the sig node looking at the user object type
* @param array $sig_model as a DomNode
* @param DomNode $parent_node - The parent node to add the content 
* @param DomNode $root_node - The top most of parent
* @param mixed $user_obj - class object to pass
* @param $prefix_i - next available prefix index 
* @param $namespace_map - Just make sure the unique namespace is used.
   Newly added (passed by reference)
*/
function wsf_infer_sig_node_from_user_obj($sig_node, $parent_node, $root_node, $user_obj, $classmap, &$prefix_i, array &$namespace_map)
{
    ws_log_write(__FILE__, __LINE__, WSF_LOG_DEBUG, "Calling infer sig mode from user obj");
    // first loop the through sig child whther there is is inheriting-types in there
    $inheriting_type_sigs = array();
    $inheriting_type_namespaces = array();
    $sig_child_nodes = $sig_node->childNodes;
    foreach ($sig_child_nodes as $sig_child_node) {
        if ($sig_child_node->localName == WSF_INHERITING_TYPE) {
            $sig_child_attris = $sig_child_node->attributes;
            $type_name = $type_ns = "";
            if ($sig_child_attris->getNamedItem(WSF_XSI_TYPE)) {
                $type_name = $sig_child_attris->getNamedItem(WSF_XSI_TYPE)->value;
            }
            if ($sig_child_attris->getNamedItem(WSF_XSI_TYPE_NS)) {
                $type_ns = $sig_child_attris->getNamedItem(WSF_XSI_TYPE_NS)->value;
            }
            ws_log_write(__FILE__, __LINE__, WSF_LOG_DEBUG, "type name {$type_name} ; {$type_ns} ");
            $inheriting_type_sigs[$type_name] = $sig_child_node;
            $inheriting_type_namespaces[$type_name] = $type_ns;
        }
    }
    ws_log_write(__FILE__, __LINE__, WSF_LOG_DEBUG, print_r($inheriting_type_namespaces, TRUE));
    // if not inheriting types just let the sig_node to be the sig node
    if (count($inheriting_type_sigs) == 0) {
        return $sig_node;
    }
    $reflex_obj = new ReflectionObject($user_obj);
    if (!$reflex_obj) {
        return $sig_node;
    }
    $class_name = $reflex_obj->getName();
    // find the type name
    $type_name = $class_name;
    // if the classmap is present we need to check the type name from the map
    if ($classmap && is_array($classmap)) {
        foreach ($classmap as $type_name_key => $class_name_value) {
            if ($class_name_value == $class_name) {
                $type_name = $type_name_key;
                break;
            }
        }
    }
    // so we found the type, check with the collected inherited_types
    $the_sig_node = NULL;
    $the_type_name = NULL;
    $the_type_namespace = NULL;
    if (array_key_exists($type_name, $inheriting_type_sigs)) {
        $the_type_name = $type_name;
        $the_type_namespace = $inheriting_type_namespaces[$type_name];
        $the_sig_node = $inheriting_type_sigs[$type_name];
    } else {
        // not in inherited map, so should be the same sig,
        return $sig_node;
    }
    //now retrieve the namespace or declare it if it is not present
    $the_type_ns_prefix = NULL;
    if (array_key_exists($the_type_namespace, $namespace_map)) {
        $the_type_ns_prefix = $namespace_map[$the_type_namespace];
    } else {
        $the_type_ns_prefix = "ns" . $prefix_i;
        $prefix_i++;
        $root_node->setAttribute("xmlns:" . $the_type_ns_prefix, $the_type_namespace);
        $namespace_map[$the_type_namespace] = $the_type_ns_prefix;
    }
    $xsi_namespace_prefix = NULL;
    if (array_key_exists(WSF_XSI_NAMESPACE, $namespace_map)) {
        $xsi_namespace_prefix = $namespace_map[WSF_XSI_NAMESPACE];
    } else {
        $xsi_namespace_prefix = "xsi";
        $root_node->setAttribute("xmlns:" . $xsi_namespace_prefix, WSF_XSI_NAMESPACE);
        $namespace_map[WSF_XSI_NAMESPACE] = $xsi_namespace_prefix;
    }
    $attribute_name = $xsi_namespace_prefix . ":" . "type";
    $attribute_value = $the_type_ns_prefix . ":" . $the_type_name;
    $parent_node->setAttribute($attribute_name, $attribute_value);
    ws_log_write(__FILE__, __LINE__, WSF_LOG_DEBUG, wsf_test_serialize_node($the_sig_node));
    return $the_sig_node;
}
 /**
  *
  * @param DomNode $node
  * @param array $error
  */
 public function displayXmlError($node, $error)
 {
     $a = $this->errors->createAttribute("line");
     $t = $this->errors->createAttribute("code");
     $m = $this->errors->createTextNode(trim($error->message));
     $node->appendChild($a);
     $node->appendChild($t);
     $node->appendChild($m);
     $node->setAttribute("line", $error->line);
     switch ($error->level) {
         case LIBXML_ERR_WARNING:
             $node->setAttribute("code", $error->code);
             break;
         case LIBXML_ERR_ERROR:
             $node->setAttribute("code", $error->code);
             break;
         case LIBXML_ERR_FATAL:
             $node->setAttribute("code", $error->code);
             break;
     }
 }
Exemple #4
0
 /**
  * store classes
  */
 private function store()
 {
     $content = trim(implode(" ", $this->classes));
     if ($this->node instanceof \DOMElement) {
         if ($content) {
             $this->node->setAttribute('class', $content);
         } else {
             $this->node->removeAttribute('class');
         }
     }
 }