Append the resources nodes in the Manifest

@return DOMNode
333179
public function put_nodes() {

        $resnodestr = "//imscc:manifest[@identifier='".$this->activemanifest->manifestID().
            "']/imscc:resources";
        $resnode    = $this->node($resnodestr);

        foreach ($this->activemanifest->resources as $k => $v) {
            ($k);
            $depen = $this->check_if_exist_in_other($v->files[0], $v->identifier);
            if (!empty($depen)) {
                $this->replace_file_x_dependency($depen, $v->files[0]);
                $v->type = 'webcontent';
            }
        }

        foreach ($this->activemanifest->resources as $node) {
            $rnode = $this->activemanifest->create_resource_node($node, $this->doc, null);
            $resnode->appendChild($rnode);
            if ($node->instructoronly) {
                $metafileceduc = new cc_metadata_resouce_educational();
                $metafileceduc->set_value(intended_user_role::INSTRUCTOR);
                $metafile = new cc_metadata_resouce();
                $metafile->add_metadata_resource_educational($metafileceduc);
                $this->activemanifest->create_metadata_educational($metafile, $this->doc, $rnode);
            }
        }

        return $resnode;
    }
1050670
public function build()
    {
        foreach ($this->child as $element) {
            $element->build();
            $this->node->appendChild($element->getNode());
        }

        return $this;
    }
1095051
public function append($source)
    {
        $importNode = $this->ownerDocument->importNode($this->ownerDocument->importSourceNode($source), true);

        return $this->insertBefore($importNode, $this->firstChild);
    }
1340311
private function xml() {
    	$document = new DOMDocument('1.0', 'UTF-8');
    	$document->appendChild($this->buildElement($this, $document));
    	return $document;
    }
312627
private function add()
    {
        // skip if it's a key
        if ((null !== ($check = $this->tokens->getToken($this->tokens->key() + 1)))
            && ((DocLexer::T_COLON === $check[0])
                || (DocLexer::T_EQUALS === $check[0]))) {
            return;
        }

        $token = $this->tokens->current();
        $value = $this->result->createElement('value');

        if (null !== ($key = $this->key())) {
            $value->setAttribute('key', $key);
        }

        $this->current->appendChild($value);

        $text = null;
        $type = null;

        switch ($token[0]) {
            case DocLexer::T_FALSE:
                $text = '0';
                $type = 'boolean';

                break;
            case DocLexer::T_FLOAT:
                $text = $token[1];
                $type = 'float';

                break;
            case DocLexer::T_IDENTIFIER:
                $text = $token[1];
                $type = 'constant';

                break;
            case DocLexer::T_INTEGER:
                $text = $token[1];
                $type = 'integer';

                break;
            case DocLexer::T_NULL:
                $type = 'null';

                break;
            case DocLexer::T_STRING:
                $text = $token[1];
                $type = 'string';

                break;
            case DocLexer::T_TRUE:
                $text = '1';
                $type = 'boolean';

                break;
        }

        $value->setAttribute('type', $type);

        if (null !== $text) {
            $value->appendChild(new DOMText($text));
        }
    }
276680
function append() {
  var i, l = this.length, el, args = this.slice.call(arguments);
  function it(node, index) {
    // content elements to insert
    el.each(function(ins) {
      ins = (index < (l - 1)) ? ins.cloneNode(true) : ins;
      node.appendChild(ins);
    });
  }
  for(i = 0;i < args.length;i++) {
    // wrap content
    el = this.air(args[i]);
    // matched parent elements (targets)
    this.each(it);
  }
  return this;
}
336895
public function appendAll($appended)
    {
        foreach ($this->storage as &$path) {
            $path->append($appended);
        }

        return $this;
    }
764118
protected function buildXml()
    {
        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");

        // Create the "ConnectorInfo" node.
        $_oConnInfo = new Ckfinder_Connector_Utils_XmlNode("ConnectorInfo");
        $this->_connectorNode->addChild($_oConnInfo);
        $_oConnInfo->addAttribute("enabled", $_config->getIsEnabled() ? "true" : "false");

        if (!$_config->getIsEnabled()) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED);
        }

        $_ln = '' ;
        $_lc = $_config->getLicenseKey() . '                                  ' ;
        $pos = strpos( CKFINDER_CHARS, $_lc[0] ) % 5;
        if ( $pos == 1 || $pos == 4 ) {
            $_ln = $_config->getLicenseName() ;
        }

        $_oConnInfo->addAttribute("s", $_ln);
        $_oConnInfo->addAttribute("c", trim( $_lc[11] . $_lc[0] . $_lc [8] . $_lc[12] . $_lc[26] . $_lc[2] . $_lc[3] . $_lc[25] . $_lc[1] ));
        $_thumbnailsConfig = $_config->getThumbnailsConfig();
        $_thumbnailsEnabled = $_thumbnailsConfig->getIsEnabled() ;
        $_oConnInfo->addAttribute("thumbsEnabled", $_thumbnailsEnabled ? "true" : "false");
        if ($_thumbnailsEnabled) {
            $_oConnInfo->addAttribute("thumbsUrl", $_thumbnailsConfig->getUrl());
            $_oConnInfo->addAttribute("thumbsDirectAccess", $_thumbnailsConfig->getDirectAccess() ? "true" : "false" );
            $_oConnInfo->addAttribute("thumbsWidth", $_thumbnailsConfig->getMaxWidth());
            $_oConnInfo->addAttribute("thumbsHeight", $_thumbnailsConfig->getMaxHeight());
        }
        $_imagesConfig = $_config->getImagesConfig();
        $_oConnInfo->addAttribute("imgWidth", $_imagesConfig->getMaxWidth());
        $_oConnInfo->addAttribute("imgHeight", $_imagesConfig->getMaxHeight());

        // Create the "ResourceTypes" node.
        $_oResourceTypes = new Ckfinder_Connector_Utils_XmlNode("ResourceTypes");
        $this->_connectorNode->addChild($_oResourceTypes);
        // Create the "PluginsInfo" node.
        $_oPluginsInfo = new Ckfinder_Connector_Utils_XmlNode("PluginsInfo");
        $this->_connectorNode->addChild($_oPluginsInfo);

        // Load the resource types in an array.
        $_aTypes = $_config->getDefaultResourceTypes();

        if (!sizeof($_aTypes)) {
            $_aTypes = $_config->getResourceTypeNames();
        }

        $_aTypesSize = sizeof($_aTypes);
        if ($_aTypesSize) {
            $phpMaxSize = 0;
            $max_upload = CKFinder_Connector_Utils_Misc::returnBytes(ini_get('upload_max_filesize'));
            if ($max_upload) {
              $phpMaxSize = $max_upload;
            }
            $max_post = CKFinder_Connector_Utils_Misc::returnBytes(ini_get('post_max_size'));
            if ($max_post) {
              $phpMaxSize = $phpMaxSize ? min($phpMaxSize, $max_post) : $max_post;
            }
            //ini_get('memory_limit') only works if compiled with "--enable-memory-limit"
            $memory_limit = CKFinder_Connector_Utils_Misc::returnBytes(@ini_get('memory_limit'));
            if ($memory_limit && $memory_limit != -1) {
              $phpMaxSize = $phpMaxSize ? min($phpMaxSize, $memory_limit) : $memory_limit;
            }
            $_oConnInfo->addAttribute("uploadMaxSize", $phpMaxSize);
            $_oConnInfo->addAttribute("uploadCheckImages", $_config->checkSizeAfterScaling() ? "false" : "true");
            for ($i = 0; $i < $_aTypesSize; $i++)
            {
                $_resourceTypeName = $_aTypes[$i];

                $_acl = $_config->getAccessControlConfig();
                $_aclMask = $_acl->getComputedMask($_resourceTypeName, "/");

                if ( ($_aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW ) {
                    continue;
                }

                if (!isset($_GET['type']) || $_GET['type'] === $_resourceTypeName) {
                    //print $_resourceTypeName;
                    $_oTypeInfo = $_config->getResourceTypeConfig($_resourceTypeName);
                    //print_r($_oTypeInfo);
                    $_oResourceType[$i] = new Ckfinder_Connector_Utils_XmlNode("ResourceType");
                    $_oResourceTypes->addChild($_oResourceType[$i]);

                    $_oResourceType[$i]->addAttribute("name", $_resourceTypeName);
                    $_oResourceType[$i]->addAttribute("url", $_oTypeInfo->getUrl());
                    $_oResourceType[$i]->addAttribute("allowedExtensions", implode(",", $_oTypeInfo->getAllowedExtensions()));
                    $_oResourceType[$i]->addAttribute("deniedExtensions", implode(",", $_oTypeInfo->getDeniedExtensions()));
                    $_oResourceType[$i]->addAttribute("hash", $_oTypeInfo->getHash());
                    $_oResourceType[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren('/', $_oTypeInfo) ? "true" : "false");
                    $_oResourceType[$i]->addAttribute("acl", $_aclMask);
                    $maxSize = $_oTypeInfo->getMaxSize();
                    if ($phpMaxSize) {
                      $maxSize = $maxSize ? min($maxSize, $phpMaxSize) : $phpMaxSize;
                    }
                    $_oResourceType[$i]->addAttribute("maxSize", $maxSize);
                }
            }
        }

        $config = $GLOBALS['config'];
        if (!empty($config['Plugins']) && is_array($config['Plugins']) ) {
            $_oConnInfo->addAttribute("plugins", implode(",", $config['Plugins']));
        }

        CKFinder_Connector_Core_Hooks::run('InitCommand', array(&$this->_connectorNode));
    }
862253
public function importSourceNode($source)
    {
        $DOMDocument = new self();
        $DOMDocument->loadHTML($source);

        $this->metaNodes->import($DOMDocument->metaNodes);
        $this->headScriptNodes->import($DOMDocument->headScriptNodes);
        $this->bodyScriptNodes->import($DOMDocument->bodyScriptNodes);
        $this->linkNodes->import($DOMDocument->linkNodes);
        $this->styleContent->import($DOMDocument->styleContent);
        $this->headScriptContent->import($DOMDocument->headScriptContent);
        $this->bodyScriptContent->import($DOMDocument->bodyScriptContent);

        $bodyElement = $DOMDocument->getElementsByTagName('body')->item(0);

        if ($bodyElement->firstChild instanceof Dom\Element) {
            return $bodyElement->firstChild;
        } elseif ($bodyElement->firstChild instanceof \DOMText) {
            foreach ($bodyElement->childNodes as $childNode) {
                if ($childNode instanceof Dom\Element) {
                    return $childNode->cloneNode(true);
                    break;
                }
            }
        }

        return $bodyElement;
    }
184935
private function addChainNode()
    {
        $builder = new TreeBuilder('chain');
        $node    = $this->getRootNode($builder, 'chain');

        $node
            ->fixXmlConfig('provider')
            ->children()
                ->arrayNode('providers')
                    ->prototype('scalar')->end()
                ->end()
            ->end()
        ;

        return $node;
    }
1108784
public function getBodyNode()
    {
        $body = $this->dom->getElementsByTagName('body')->item(0);
        if ($body == null) {
            $body = $this->dom->createElement('body');
            $body = $this->dom->documentElement->appendChild($body);
        }
        return $body;
    }
1262694
public function createManifestFile() {
		
		$app = Application::getInstance();
		
		// lambda method to add an array to the XML
		$addChildArray = function ($element, $list) use ($app, &$addChildArray) {
			
			foreach ($list as $name => $value) {
				
				// if is an array, run again recursively
				if (is_array($value)) {
					$listChild = $element->addChild($name);
					$addChildArray($listChild, $value);
				} else if (is_int($value) or is_string($value)) {
					$element->addChild($name, (string)$value);
				} else {
					$app->logError('Option item ' . $name . ' is not valid');
				}
			
			}
			
		};
		
		// prevent missing folders
		if (!is_dir($this->baseFolder)) {
			$app->logError('Folder ' . $this->baseFolder . ' of ' . $this->name . ' ' . $this->type . ' plugin cannot be accessed');
			return FALSE;
		}
	
		$manifest = new \SimpleXMLElement('<!DOCTYPE xml><manifest></manifest>');
	
		$plugin = $manifest->addChild('plugin');

		// plugin type
		$plugin->addAttribute('type', $this->type);
		
		// more infos
		$plugin->addChild('name',			$this->name);
		$plugin->addChild('folder',			basename($this->baseFolder));
		$plugin->addChild('version',		$this->version);
		$plugin->addChild('dateReleased',	$this->dateReleased);
		$plugin->addChild('appVersion',		$this->appVersion);
		
		// custom options
		$optionsChild = $plugin->addChild('options');
		
		// recursively add options elements
		$addChildArray($optionsChild, $this->options);
		
		// will contains all found files
		$filesChild = $plugin->addChild('files');
		
		// list all found files as multi-dimensional array
		$files = Utilities::getDirectoryFilenames($this->baseFolder);
		
		// adds file to <files> child
		foreach ($files as $file) {
			$filesChild->addChild('file', $file);
		}
	
		$filename = $this->baseFolder . '/manifest.xml';
		
		try {
			$res = $manifest->asXML($filename);
			$app->logEvent('Created manifest file ' . $filename . ' for ' . $this->type . ' plugin');
		} catch (\Exception $e) {
			$res = FALSE;
			$app->logError('Manifest file ' . $filename . ' creation failed for ' . $this->type . ' plugin: ' . $e->getMessage());
		}
		
		return $res;
	
	}
840301
public function append($source)
    {
        foreach ($this as $node) {
            if ($node instanceof Element) {
                $node->prepend($source);
            }
        }

        return $this;
    }
532376
public function addNodes(array $nodes): self
    {
        foreach ($nodes as $node) {
            $this->addNode($node);
        }

        return $this;
    }
640482
public function wrapInner()
    {
        foreach ($this->nodes as $node) {
            self::create($node->childNodes)->wrapAll(\func_get_args());
        }

        return $this;
    }
404498
public function getPayload()
    {
        if (!$this->token) {
            throw new \RuntimeException('Token is mandatory.');
        }

        $descriptionNode = $this->appendDescriptionNode();
        $this->appendTagNode($descriptionNode);
        $this->appendTokenNode($descriptionNode);
        $this->appendTemplateNode($descriptionNode);
        $this->appendAdditionalNode($descriptionNode);

        $this->dom->formatOutput = true;

        return $this->dom->saveXML();
    }
216251
protected function appendChild(Node $node) {
    if ($this->tail === NULL) {
      $this->prependChild($node);
    }
    else {
      $this->insertAfterChild($this->tail, $node);
      $this->tail = $node;
    }
    return $this;
  }