/**
	 * This method should be used for getting new or existing nodes
	 * If a node does not exist yet, it will be created
	 *
	 * @param $id			string, node id
	 * @param $label		string, node label
 	 * @return				Object of type ProcessNode
	 */
	public function makeNode( $id, $label ) {
		// check if node exists
		if ( isset( $this->m_nodes[$id] ) ) {
			// take existing node
			$node = $this->m_nodes[$id];

		} else {
			// create new node

			$node = new ProcessNode();
			$node->setId( $id );
			$node->setLabel( $label );
			$node->setProcess( $this );

			// is actual node name the same like the one to highlight?
			if ( strcasecmp( $id , $this->m_highlightNode ) == 0 ) {
				$node->setFontColor( $this->m_highlightColor );
			}

			// is the node a red link (i.e. corresponding wiki page does not yet exist)?
			if ( $this->m_showRedLinks ) {
				$title = Title::newFromDBkey( $id );
				if ( isset( $title ) && ( !$title->exists() ) ) $node->setFontColor( $this->m_redLinkColor );
			}

			// add new node to process
			$this->m_nodes[$id] = $node;
		}

		return $node;

	}
Beispiel #2
0
// Enviamos nuestra configuración al servidor
$sync = array($target);
$w->sendSync($sync);
// Sincronizamos el contacto
$w->pollMessage();
// Volvemos a poner en cola mensajes
$w->sendPresenceSubscription($target);
// Nos suscribimos a la presencia del usuario
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
while (1) {
    $w->pollMessage();
    $msgs = $w->getMessages();
    foreach ($msgs as $m) {
        # process inbound messages
        $node = new ProcessNode();
        $messaggio = $node->process($m);
        $messaggioTesto = strtolower($messaggio['testo']);
        if ($messaggioTesto == strtolower($nickname . " che fai?")) {
            $risposta = chefai($messaggio);
            $target = $messaggio['from'];
            $w->sendMessage($target, $risposta);
        } else {
            if ($messaggioTesto == strtolower($nickname . " perla")) {
                $risposta = barzellette($messaggio);
                $target = $messaggio['from'];
                $w->sendMessage($target, $risposta);
            } else {
                if ($messaggioTesto == strtolower($nickname . " dammi un numero")) {
                    $risposta = numero($messaggio);
                    $target = $messaggio['from'];