create a new mid

@param $nCenter	int
@param $nNode	int
@param $sSource	string
@param $arrData array
@return	int
166548
static function createMId( $nCenter = 0, $nNode = 0, $sSource = null, & $arrData = null )
	{
		return CDId::getInstance()->createId( $nCenter, $nNode, $sSource, $arrData );
	}
274074
public function similarize(AbstractNodeData $sourceNode, $isCopy = false)
    {
        $this->properties = [];
        foreach ($sourceNode->getProperties() as $propertyName => $propertyValue) {
            $this->setProperty($propertyName, $propertyValue);
        }

        $propertyNames = [
            'nodeType',
            'hidden',
            'hiddenAfterDateTime',
            'hiddenBeforeDateTime',
            'hiddenInIndex',
            'accessRoles'
        ];
        if (!$isCopy) {
            $propertyNames[] = 'creationDateTime';
            $propertyNames[] = 'lastModificationDateTime';
        }
        if ($sourceNode instanceof NodeData) {
            $propertyNames[] = 'index';
        }
        foreach ($propertyNames as $propertyName) {
            ObjectAccess::setProperty($this, $propertyName, ObjectAccess::getProperty($sourceNode, $propertyName));
        }

        $contentObject = $sourceNode->getContentObject();
        if ($contentObject !== null) {
            $this->setContentObject($contentObject);
        }
    }
1194799
public static function Nsec(string $nextDomainName, array $typeBitMaps)
    {
        $rdata = new NSEC();
        $rdata->setNextDomainName($nextDomainName);
        array_map([$rdata, 'addTypeBitMap'], $typeBitMaps);

        return $rdata;
    }
960289
public function moveNode( $sourceNode, $position, $relatedNode )
    {
        $sourceNode = (int) $sourceNode;
        $sourceRoot = $this->getMapper()
                           ->findRootOf( $sourceNode );

        if ( empty( $sourceRoot ) ||
             ! $sourceRoot->isEditable() )
        {
            return array(
                'sourceNode'    => null,
                'position'      => $position,
                'relatedNode'   => $relatedNode,
                'success'       => false,
            );
        }

        $relatedNode = (int) $relatedNode;
        $relatedRoot = $this->getMapper()
                            ->findRootOf( $relatedNode );

        if ( empty( $relatedRoot ) ||
             ! $relatedRoot->isEditable() )
        {
            return array(
                'sourceNode'    => $sourceNode,
                'position'      => $position,
                'relatedNode'   => null,
                'success'       => false,
            );
        }

        $success = $this->getMapper()
                        ->moveNode( $sourceNode,
                                    strtolower( $position ),
                                    $relatedNode );

        return array(
            'sourceNode'    => $sourceNode,
            'position'      => $position,
            'relatedNode'   => $relatedNode,
            'success'       => (bool) $success,
        );
    }
181492
public function copyDir($sSourceDir, $sTargetDir)
    {
        $oStr = getStr();
        $handle = opendir($sSourceDir);
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                if (is_dir($sSourceDir . '/' . $file)) {
                    // recursive
                    $sNewSourceDir = $sSourceDir . '/' . $file;
                    $sNewTargetDir = $sTargetDir . '/' . $file;
                    if (strcasecmp($file, 'CVS') && strcasecmp($file, '.svn')) {
                        @mkdir($sNewTargetDir, 0777);
                        $this->copyDir($sNewSourceDir, $sNewTargetDir);
                    }
                } else {
                    $sSourceFile = $sSourceDir . '/' . $file;
                    $sTargetFile = $sTargetDir . '/' . $file;

                    //do not copy files within dyn_images
                    if (!$oStr->strstr($sSourceDir, 'dyn_images') || $file == 'nopic.jpg' || $file == 'nopic_ico.jpg') {
                        @copy($sSourceFile, $sTargetFile);
                    }
                }
            }
        }
        closedir($handle);
    }
1315905
protected function nodesToArray($locale, $rootNodes, $depth = 2)
    {
        /** @var DomainConfiguration $domainconfig */
        $domainconfig = $this->get('kunstmaan_admin.domain_configuration');
        $isMultiDomain = $domainconfig->isMultiDomainHost();
        $switchedHost = $domainconfig->getHostSwitched();
        $switched = $domainconfig->getHost() == $switchedHost['host'];

        $results = [];

        /** @var Node $rootNode */
        foreach ($rootNodes as $rootNode) {
            if ($nodeTranslation = $rootNode->getNodeTranslation($locale, true)) {
                if ($isMultiDomain && !$switched) {
                    $slug = sprintf('[%s:%s]', $switchedHost['id'], 'NT'.$nodeTranslation->getId());
                } else {
                    $slug = sprintf('[%s]', 'NT'.$nodeTranslation->getId());
                }

                switch (true) {
                    case !$nodeTranslation->isOnline():
                        $type = 'offline';
                        break;
                    case $rootNode->isHiddenFromNav():
                        $type = 'hidden-from-nav';
                        break;
                    default:
                        $type = 'default';
                }

                $root = [
                    'id' => $rootNode->getId(),
                    'type' => $type,
                    'text' => $nodeTranslation->getTitle(),
                    'li_attr' => ['class' => 'js-url-chooser-link-select', 'data-slug' => $slug, 'data-id' => $rootNode->getId()],
                ];

                if ($rootNode->getChildren()->count()) {
                    if ($depth - 1) {
                        $root['children'] = $this->nodesToArray($locale, $rootNode->getChildren(), --$depth);
                    } else {
                        $root['children'] = true;
                    }
                }
                $results[] = $root;
            }
        }

        return $results;
    }
143675
function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
	{
		return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,2);
	}
338031
public function resolveNextNode(NodeContract $node, NodeContract $new_node)
    {
        if ($new_node->next() && $new_node->next() instanceof ComparableNodeContract) {
            $new_node->moveNodeAsChild($new_node->next());
        } else {
            throw new Exceptions\QuerySyntaxException($node->getRoot()->getValue());
        }
    }
538899
protected function create_resource(cc_i_resource &$res, DOMDocument &$doc, $xmlnode=null) {
        $usenew = is_object($xmlnode);
        $dnode  = $usenew ? $xmlnode : $doc->createElementNS($this->ccnamespaces['imscc'], "resource");
        $this->update_attribute($doc, 'identifier', $res->identifier, $dnode);
        $this->update_attribute($doc, 'type', $res->type, $dnode);
        !is_null($res->href) ? $this->update_attribute($doc, 'href', $res->href, $dnode) : null;
        $this->update_attribute($doc, 'base', $res->base, $dnode);

        foreach ($res->files as $file) {
            $nd = $doc->createElementNS($this->ccnamespaces['imscc'], 'file');
            $ndatt = $doc->createAttribute('href');
            $ndatt->nodeValue = $file;
            $nd->appendChild($ndatt);
            $dnode->appendChild($nd);
        }
        $this->resources[$res->identifier]   = $res;
        $this->resources_ind[$res->files[0]] = $res->identifier;

        foreach ($res->dependency as $dependency) {
            $nd = $doc->createElementNS($this->ccnamespaces['imscc'], 'dependency');
            $ndatt = $doc->createAttribute('identifierref');
            $ndatt->nodeValue = $dependency;
            $nd->appendChild($ndatt);
            $dnode->appendChild($nd);
        }

        return $dnode;
    }
320525
public function beforeNodeCopy(NodeInterface $sourceNode, NodeInterface $targetParentNode)
    {
        if (!$this->eventEmittingService->isEnabled()) {
            return;
        }

        if ($this->currentlyCopying) {
            throw new \Exception('TODO: already copying...');
        }

        $this->currentlyCopying = true;

        /* @var $nodeEvent NodeEvent */
        $nodeEvent = $this->eventEmittingService->emit(self::NODE_COPY, [
            'copiedInto' => $targetParentNode->getContextPath()
        ], NodeEvent::class);
        $nodeEvent->setNode($sourceNode);
        $this->eventEmittingService->pushContext();
    }
643081
public function listRedirectionNodeAction($siteId, $nodeId, $locale)
    {
        $node = $this->get('open_orchestra_model.repository.node')->findOneByNodeAndSite($nodeId, $siteId);
        if (!$node instanceof NodeInterface) {
            throw new NodeNotFoundException();
        }
        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, $node);

        $repository = $this->get('open_orchestra_model.repository.redirection');
        $redirectionList = $repository->findByNode($nodeId, $locale, $siteId);

        return $this->get('open_orchestra_api.transformer_manager')->transform('redirection_collection', $redirectionList);
    }
1031433
public static function create(
        array $visitors = [],
        InstantiatorInterface $instantiator = null,
        AccessorInterface $accessor = null,
        MutatorInterface $mutator = null
    ) {
        $instantiator = $instantiator ?: new DoctrineInstantiator();
        $accessor = $accessor ?: new ReflectionAccessor();
        $mutator = $mutator ?: new ReflectionMutator();

        return new static(array_replace_recursive([
            Direction::SERIALIZATION => [
                Format::CSV  => new CsvSerializationVisitor($accessor),
                Format::JSON => new JsonSerializationVisitor($accessor),
                Format::XML  => new XmlSerializationVisitor($accessor),
                Format::YAML => new YamlSerializationVisitor($accessor),
            ],
            Direction::DESERIALIZATION => [
                Format::CSV  => new CsvDeserializationVisitor($instantiator, $mutator),
                Format::JSON => new JsonDeserializationVisitor($instantiator, $mutator),
                Format::XML  => new XmlDeserializationVisitor($instantiator, $mutator),
                Format::YAML => new YamlDeserializationVisitor($instantiator, $mutator),
            ],
        ], $visitors));
    }
1041832
private void createMDAGNode(SimpleMDAGNode current, int fromIndex, MDAGNode[] toNodeArray, MDAGNode[] fromNodeArray)
    {
        MDAGNode from = (fromIndex == -1 ? sourceNode : toNodeArray[fromIndex]);
        int transitionSetBegin = current.getTransitionSetBeginIndex();
        int onePastTransitionSetEnd = transitionSetBegin + current.getOutgoingTransitionSetSize();

        for (int i = transitionSetBegin; i < onePastTransitionSetEnd; i++)
        {
            SimpleMDAGNode targetNode = mdagDataArray[i];
            if (toNodeArray[i] != null)
            {
                fromNodeArray[fromIndex].addOutgoingTransition(current.getLetter(), fromNodeArray[i]);
                toNodeArray[fromIndex] = fromNodeArray[i];
                continue;
            }
            toNodeArray[i] = from.addOutgoingTransition(targetNode.getLetter(), targetNode.isAcceptNode());
            fromNodeArray[i] = from;
            createMDAGNode(targetNode, i, toNodeArray, fromNodeArray);
        }
    }
1139125
function attachNeighborArrayCreator(Class, description) {
  const {
    name,
    type,
    direction
  } = description;

  /**
   * Function returning an array or the count of certain neighbors.
   *
   * Arity 1: Return all of a node's relevant neighbors.
   * @param  {any}   node   - Target node.
   *
   * Arity 2: Return whether the two nodes are indeed neighbors.
   * @param  {any}   source - Source node.
   * @param  {any}   target - Target node.
   *
   * @return {array|number} - The neighbors or the number of neighbors.
   *
   * @throws {Error} - Will throw if there are too many arguments.
   */
  Class.prototype[name] = function(node) {

    // Early termination
    if (type !== 'mixed' && this.type !== 'mixed' && type !== this.type)
      return [];

    if (arguments.length === 2) {
      const node1 = '' + arguments[0],
            node2 = '' + arguments[1];

      if (!this._nodes.has(node1))
        throw new NotFoundGraphError(`Graph.${name}: could not find the "${node1}" node in the graph.`);

      if (!this._nodes.has(node2))
        throw new NotFoundGraphError(`Graph.${name}: could not find the "${node2}" node in the graph.`);

      // Here, we want to assess whether the two given nodes are neighbors
      return nodeHasNeighbor(
        this,
        type,
        direction,
        node1,
        node2
      );
    }
    else if (arguments.length === 1) {
      node = '' + node;

      const nodeData = this._nodes.get(node);

      if (typeof nodeData === 'undefined')
        throw new NotFoundGraphError(`Graph.${name}: could not find the "${node}" node in the graph.`);

      // Here, we want to iterate over a node's relevant neighbors
      const neighbors = createNeighborArrayForNode(
        type === 'mixed' ? this.type : type,
        direction,
        nodeData
      );

      return neighbors;
    }

    throw new InvalidArgumentsGraphError(`Graph.${name}: invalid number of arguments (expecting 1 or 2 and got ${arguments.length}).`);
  };
}
186440
function EmailNode(n) {
        RED.nodes.createNode(this, n);
        this.topic = n.topic;
        this.name = n.name;
        this.outserver = n.server;
        this.outport = n.port;
        this.secure = n.secure;
        let flag = false;
        if (this.credentials && this.credentials.hasOwnProperty('userid')) {
            this.userid = this.credentials.userid;
        } else {
            if (globalkeys) {
                this.userid = globalkeys.user;
                flag = true;
            }
        }
        if (this.credentials && this.credentials.hasOwnProperty('password')) {
            this.password = this.credentials.password;
        } else {
            if (globalkeys) {
                this.password = globalkeys.pass;
                flag = true;
            }
        }
        if (flag) {
            RED.nodes.addCredentials(n.id, {userid: this.userid, password: this.password, global: true});
        }
        let node = this;

        let smtpOptions = {
            host: node.outserver,
            port: node.outport,
            secure: node.secure,
        };

        if (this.userid && this.password) {
            smtpOptions.auth = {
                user: node.userid,
                pass: node.password,
            };
        }
        let smtpTransport = nodemailer.createTransport(smtpOptions);

        this.on('input', function(msg) {
            let params = processValuesFromContext(node, msg, [
                {name: 'port', type: 'portType'},
                {name: 'server', type: 'serverType'},
                {name: 'userid', type: 'useridType'},
                {name: 'password', type: 'passwordType'},
            ]);
            console.log('params are ....');
            console.log(JSON.stringify(params));

            if (params.userid && params.password) {
                smtpOptions.auth = {
                    user: params.userid,
                    pass: params.password,
                };
            }

            if (params.port && params.server) {
                smtpOptions.host = params.server;
                smtpOptions.port = params.port;
            }


            if (msg.hasOwnProperty('payload')) {
                if (smtpTransport) {
                    node.status({fill: 'blue', shape: 'dot', text: 'email.status.sending'});
                    if (msg.to && node.name && (msg.to !== node.name)) {
                        node.warn(RED._('node-red:common.errors.nooverride'));
                    }
                    let sendopts = {from: ((msg.from) ? msg.from : node.userid)}; // sender address
                    sendopts.to = node.name || msg.to; // comma separated list of addressees
                    if (node.name === '') {
                        sendopts.cc = msg.cc;
                        sendopts.bcc = msg.bcc;
                    }
                    sendopts.subject = msg.topic || msg.title || 'Message from Node-RED'; // subject line
                    if (msg.hasOwnProperty('envelope')) {
                        sendopts.envelope = msg.envelope;
                    }
                    if (Buffer.isBuffer(msg.payload)) { // if it's a buffer in the payload then auto create an attachment instead
                        if (!msg.filename) {
                            let fe = 'bin';
                            if ((msg.payload[0] === 0xFF) && (msg.payload[1] === 0xD8)) {
                                fe = 'jpg';
                            }
                            if ((msg.payload[0] === 0x47) && (msg.payload[1] === 0x49)) {
                                fe = 'gif';
                            } // 46
                            if ((msg.payload[0] === 0x42) && (msg.payload[1] === 0x4D)) {
                                fe = 'bmp';
                            }
                            if ((msg.payload[0] === 0x89) && (msg.payload[1] === 0x50)) {
                                fe = 'png';
                            } // 4E
                            msg.filename = 'attachment.' + fe;
                        }
                        let fname = msg.filename.replace(/^.*[\\\/]/, '') || 'file.bin';
                        sendopts.attachments = [{content: msg.payload, filename: fname}];
                        if (msg.hasOwnProperty('headers') && msg.headers.hasOwnProperty('content-type')) {
                            sendopts.attachments[0].contentType = msg.headers['content-type'];
                        }
                        // Create some body text..
                        sendopts.text = RED._('email.default-message', {filename: fname, description: (msg.description || '')});
                    } else {
                        let payload = RED.util.ensureString(msg.payload);
                        sendopts.text = payload; // plaintext body
                        if (/<[a-z][\s\S]*>/i.test(payload)) {
                            sendopts.html = payload;
                        } // html body
                        if (msg.attachments) {
                            sendopts.attachments = msg.attachments;
                        } // add attachments
                    }
                    smtpTransport.sendMail(sendopts, function(error, info) {
                        if (error) {
                            node.error(error, msg);
                            node.status({fill: 'red', shape: 'ring', text: 'email.status.sendfail'});
                        } else {
                            node.log(RED._('email.status.messagesent', {response: info.response}));
                            node.status({});
                        }
                    });
                } else {
                    node.warn(RED._('email.errors.nosmtptransport'));
                }
            } else {
                node.warn(RED._('email.errors.nopayload'));
            }
        });
    }
489367
public function createCommunity($name, $summary, $description, $rules, $accessToken)
    {
        if (!$this->apiVersionIsGreaterThanV3()) {
            throw new EndpointNotSupportedByApiVersionException();
        }

        if (strlen($name) < 3 || strlen($name) > 25) {
            throw new InvalidParameterLengthException('name');
        }

        if (strlen($summary) > 160) {
            throw new InvalidParameterLengthException('summary');
        }

        if (strlen($description) > 1572864) { // 1.5MB
            throw new InvalidParameterLengthException('description');
        }

        if (strlen($rules) > 1572864) { // 1.5MB
            throw new InvalidParameterLengthException('rules');
        }

        $params = [
            'name' => $name,
            'summary' => $summary,
            'description' => $description,
            'rules' => $rules,
        ];

        return $this->post('communities', $params, $accessToken);
    }
262462
public function create(NodeInterface $referenceNode, array $nodeData, $position)
    {
        if (!in_array($position, ['before', 'into', 'after'], true)) {
            throw new \InvalidArgumentException('The position should be one of the following: "before", "into", "after".', 1347133640);
        }
        $nodeType = $this->nodeTypeManager->getNodeType($nodeData['nodeType']);

        if ($nodeType->isOfType('Neos.Neos:Document') && !isset($nodeData['properties']['uriPathSegment']) && isset($nodeData['properties']['title'])) {
            $nodeData['properties']['uriPathSegment'] = $this->nodeUriPathSegmentGenerator->generateUriPathSegment($referenceNode, $nodeData['properties']['title']);
        }

        $proposedNodeName = isset($nodeData['nodeName']) ? $nodeData['nodeName'] : null;
        $nodeData['nodeName'] = $this->nodeService->generateUniqueNodeName($this->getDesignatedParentNode($referenceNode, $position)->getPath(), $proposedNodeName);

        if ($position === 'into') {
            $newNode = $referenceNode->createNode($nodeData['nodeName'], $nodeType);
        } else {
            $parentNode = $referenceNode->getParent();
            $newNode = $parentNode->createNode($nodeData['nodeName'], $nodeType);

            if ($position === 'before') {
                $newNode->moveBefore($referenceNode);
            } else {
                $newNode->moveAfter($referenceNode);
            }
        }

        if (isset($nodeData['properties']) && is_array($nodeData['properties'])) {
            foreach ($nodeData['properties'] as $propertyName => $propertyValue) {
                $newNode->setProperty($propertyName, $propertyValue);
            }
        }

        return $newNode;
    }