Handles the network sites column output.

@since 2.0.0

@param WP_Network $network The current network object.
436159
public function column_blogs( $network ) {
		$sites = get_network_option( $network->id, 'blog_count' );

		switch_to_network( $network->id );
		$url = network_admin_url( 'sites.php' );
		restore_current_network();

		echo '<a href="' . esc_url( $url ) . '">' . esc_html( $sites ) . '</a>';
	}
1076523
function it_compiles_nodes($node)
    {
        $node->compile($this)->will(function ($args) {
            $args[0]->write('echo $message');
        });

        $this->compile($node)->getSource()->shouldMatch('/\Recho \$message/');
    }
1358639
private function handle_update_network() {
		$network_id = filter_input( INPUT_POST, 'network_id', FILTER_SANITIZE_NUMBER_INT );

		// Bail if invalid network.
		if ( ! get_network( $network_id ) ) {
			wp_die( esc_html__( 'Invalid network id.', 'wp-multi-network' ) );
		}

		$network_title  = wp_unslash( filter_input( INPUT_POST, 'title', FILTER_SANITIZE_STRING ) );
		$network_domain = wp_unslash( filter_input( INPUT_POST, 'domain', FILTER_SANITIZE_STRING ) );
		$network_path   = wp_unslash( filter_input( INPUT_POST, 'path', FILTER_SANITIZE_STRING ) );

		$network_title  = sanitize_text_field( $network_title );
		$network_domain = Requests_IDNAEncoder::encode( str_replace( ' ', '', strtolower( sanitize_text_field( $network_domain ) ) ) );
		$network_path   = str_replace( ' ', '', strtolower( sanitize_text_field( $network_path ) ) );

		// Bail if missing fields.
		if ( empty( $network_title ) || empty( $network_domain ) || empty( $network_path ) ) {
			$this->handle_redirect( array(
				'id'              => $network_id,
				'action'          => 'edit_network',
				'network_updated' => '0',
			) );
		}

		$updated = update_network( $network_id, $network_domain, $network_path );
		$success = '0';

		if ( ! is_wp_error( $updated ) ) {
			update_network_option( $network_id, 'site_name', $network_title );
			$success = '1';
		}

		$this->handle_redirect( array(
			'id'              => $network_id,
			'action'          => 'edit_network',
			'network_updated' => $success,
		) );
	}
1349202
public function text(InputInterface $input, OutputInterface $output)
    {
        foreach ($this->router->getRoutes() as $route) {
            if (!empty($route->getName())) {
                $output->writeln('<fg=cyan;options=bold>'.$route->getName().'</>');
                $output->writeln('    '.implode(', ', $route->getMethods()));
                $output->writeln('    '.$route->getPattern());
                if (is_string($route->getCallable())) {
                    $output->writeln('    '.$route->getCallable());
                }

                $output->writeln('');
            }
        }
    }
1366369
private function outputWebspace(Webspace $webspace)
    {
        $this->output->writeln(
            sprintf(
                '<info>%s</info> - <info>%s</info>',
                $webspace->getKey(),
                $webspace->getName()
            )
        );

        $this->outputWebspaceDefaultTemplates($webspace);
        $this->outputWebspacePageTemplates($webspace);
        $this->outputWebspaceTemplates($webspace);
        $this->outputWebspaceLocalizations($webspace);
    }
530525
protected function handle_row_actions( $network, $column_name, $primary ) {

		// Bail if not primary column.
		if ( $primary !== $column_name ) {
			return;
		}

		switch_to_network( $network->id );
		$network_admin_url = network_admin_url();
		$network_home_url  = network_home_url();
		restore_current_network();

		$base_url = add_query_arg( array(
			'page' => 'networks',
			'id'   => $network->id,
		) );

		$actions = array();

		// Edit the network.
		if ( current_user_can( 'edit_network', $network->id ) ) {
			$edit_network_url = add_query_arg( array(
				'action' => 'edit_network',
			), $base_url );

			$actions['edit'] = '<span class="edit"><a href="' . esc_url( $edit_network_url ) . '">' . esc_html__( 'Edit', 'wp-multi-network' ) . '</a></span>';
		}

		// Visit the network dashboard.
		if ( current_user_can( 'manage_networks' ) ) {
			$actions['network_admin'] = '<span><a href="' . esc_url( $network_admin_url ) . '">' . esc_html__( 'Dashboard', 'wp-multi-network' ) . '</a></span>';
		}

		// Visit the network main site.
		$actions['visit'] = '<span><a href="' . esc_url( $network_home_url ) . '">' . esc_html__( 'Visit', 'wp-multi-network' ) . '</a></span>';

		// Delete the network.
		if ( $this->can_delete( $network ) ) {
			$delete_network_url = wp_nonce_url( add_query_arg( array(
				'action' => 'delete_network',
			), $base_url ) );

			$actions['delete'] = '<span class="delete"><a href="' . esc_url( $delete_network_url ) . '">' . esc_html__( 'Delete', 'wp-multi-network' ) . '</a></span>';
		}

		/**
		 * Filters the networks list table row action links.
		 *
		 * @since 2.0.0
		 *
		 * @param array  Action links as $slug => $link_markup pairs.
		 * @param int    The current network ID.
		 * @param string The current network name.
		 */
		$actions = apply_filters( 'manage_networks_action_links', array_filter( $actions ), $network->id, $network->sitename );

		return $this->row_actions( $actions );
	}
508976
public function enterNode(Node $node): void
    {
        $name = null;

        if ($node instanceof Name) {
            $name = $node->toString();
        }

        if ($name === null
            || (array_key_exists($name, $this->symbols)
                && $this->symbols[$name] === false
            )
        ) {
            return;
        }

        if (!$this->filter->__invoke($name)) {
            $this->symbols[$name] = false;
            return;
        }

        if (!array_key_exists($name, $this->symbols)) {
            $this->symbols[$name] = [];
        }

        $this->symbols[$name][] = $node;
    }
1056818
void resolveNetworkLocation(DatanodeInfo node) {
    List<String> names = new ArrayList<String>(1);
    if (dnsToSwitchMapping instanceof CachedDNSToSwitchMapping) {
      // get the node's IP address
      names.add(node.getHost());
    } else if (dnsToSwitchMapping instanceof StaticMapping) {
      names.add(toHostPort(node));
    } else {
      // get the node's host name
      String hostName = node.getHostName();
      int colon = hostName.indexOf(":");
      hostName = (colon == -1) ? hostName : hostName.substring(0, colon);
      names.add(hostName);
    }

    // resolve its network location
    List<String> rName = dnsToSwitchMapping.resolve(names);
    String networkLocation;
    if (rName == null) {
      LOG.error("The resolve call returned null! Using " +
        NetworkTopology.DEFAULT_RACK + " for host " + names);
      networkLocation = NetworkTopology.DEFAULT_RACK;
    } else {
      networkLocation = rName.get(0);
    }
    node.setNetworkLocation(networkLocation);
  }
628775
private function executeTableShowFooter(array $columns): void
  {
    $separator = '+';

    foreach ($columns as $column)
    {
      $separator .= str_repeat('-', $column['length'] + 2).'+';
    }
    echo $separator, "\n";
  }
98775
public function network_admin_notices() {
		$message = '';
		$type    = '';
		foreach ( $this->feedback_strings as $slug => $messages ) {
			$passed = filter_input( INPUT_GET, $slug );

			if ( is_string( $passed ) ) {
				if ( '1' === $passed ) {
					$message = $messages['1'];
					$type    = 'updated';
				} else {
					$message = $messages['0'];
					$type    = 'error';
				}

				break;
			}
		}

		if ( empty( $message ) || empty( $type ) ) {
			return;
		}
		?>

		<div id="message" class="<?php echo esc_attr( $type ); ?> notice is-dismissible">
			<p>
				<?php echo esc_html( $message ); ?>
				<a href="<?php echo esc_url( $this->admin_url() ); ?>"><?php esc_html_e( 'Back to Networks.', 'wp-multi-network' ); ?></a>
			</p>
			<button type="button" class="notice-dismiss">
				<span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice', 'wp-multi-network' ); ?></span>
			</button>
		</div>

		<?php
	}
33678
protected function handleParens($node) {
    $open_paren = $node->getOpenParen();
    $this->removeSpaceAfter($open_paren);
    $this->spaceBefore($open_paren);
    $close_paren = $node->getCloseParen();
    $this->removeSpaceBefore($close_paren);
  }
1263306
protected function displayOutput($type, $host, $line)
    {
        $lines = explode("\n", $line);

        foreach ($lines as $line) {
            if (strlen(trim($line)) === 0) {
                continue;
            }

            if ($type == Process::OUT) {
                $this->output->write('<comment>['.$host.']</comment>: '.trim($line).PHP_EOL);
            } else {
                $this->output->write('<comment>['.$host.']</comment>: <fg=red>'.trim($line).'</>'.PHP_EOL);
            }
        }
    }
1025463
public function publishNodeAction(NodeInterface $node, $targetWorkspaceName = null)
    {
        $targetWorkspace = ($targetWorkspaceName !== null) ? $this->workspaceRepository->findOneByName($targetWorkspaceName) : null;
        $this->publishingService->publishNode($node, $targetWorkspace);

        $this->throwStatus(204, 'Node published', '');
    }
718708
private function delegate_connection( $sites = null ) {
            $this->_logger->entrance();

            $this->_admin_notices->remove_sticky( 'connect_account' );

            if ( is_null( $sites ) ) {
                // All sites delegation.
                $this->_storage->store( 'is_delegated_connection', true, true, true );
            } else {
                // Specified sites delegation.
                foreach ( $sites as $site ) {
                    $this->delegate_site_connection( $site['blog_id'] );
                }
            }

            $this->network_upgrade_mode_completed();
        }
811867
public function handleStop(ConnectionInterface $conn, array $data)
    {
        $connSubscriptions = $this->connStorage->offsetGet($conn);
        $subscription = array_get($connSubscriptions, $data['id']);

        if (!is_null($subscription)) {
            unset($this->subscriptions[$subscription['name']][$subscription['index']]);
            unset($connSubscriptions[$subscription['id']]);
            $this->connStorage->offsetSet($conn, $connSubscriptions);
            $this->callListener(ON_DISCONNECT, [$subscription, $this->rootValue, $this->context]);
        }
    }
538155
private function parseDsn(string $location, array $dsnParts): void
    {
        array_splice($dsnParts, 0, 0, $location);
        $this->dsn = implode(';', $dsnParts);
    }
1204544
private function renderModelStructure( $network )
	{
		$structureTable =
			"	<div class='structure-table'>" .
			"		<div>Label</div>" .
			"		<div>Fact set type</div>" .
			"		<div>Report Element Class</div>" .
			"		<div>Period Type</div>" .
			"		<div>Balance</div>" .
			"		<div>Name</div>";

			$renderStructure = function( $nodes ) use( &$renderStructure )
			{
				$result = array();

				foreach( $nodes as $label => $node )
				{
					if ( ! isset( $node['modelType'] ) ) continue;

					/**
					 *
					 * @var XBRL $nodeTaxonomy
					 */
					$nodeTaxonomy = $this->getTaxonomyForXSD( $label );
					$nodeElement = $nodeTaxonomy->getElementById( $label );

					$preferredLabels = isset( $node['preferredLabel'] ) ? array( $node['preferredLabel'] ) : null;
					// Do this because $label includes the preferred label roles and the label passed cannot include it
					$text = $nodeTaxonomy->getTaxonomyDescriptionForIdWithDefaults( $nodeTaxonomy->getTaxonomyXSD() . '#' . $nodeElement['id'], $preferredLabels );

					$name = $nodeTaxonomy->getPrefix() . ":" . $nodeElement['name'];
					$class = "";
					$reportElement = "";
					$periodType = "";
					$balance = "";
					$factSetType = "";

					switch ( $node['modelType'] )
					{
						case 'cm.xsd#cm_Table':
							$class = "hypercube";
							$reportElement = "[Table]";
							break;

						case 'cm.xsd#cm_Axis':
							$class = "axis";
							$reportElement = "[Axis]";
							break;

						case 'cm.xsd#cm_Member':
							$class = "member";
							$reportElement = "[Member]";
							break;

						case 'cm.xsd#cm_LineItems':
							$class = "lineitem";
							$reportElement = "[Line item]";
							$factSetType = isset( $node['patterntype'] ) ? $node['patterntype'] : '';
							break;

						case 'cm.xsd#cm_Concept':
							$class = "concept";
							$reportElement = "[Concept]";
							if ( $nodeElement['type'] == 'xbrli:stringItemType' )
							{
								$reportElement .= " string";
							}
							else if ( $this->context->types->resolvesToBaseType( $nodeElement['type'], array( "xbrli:monetaryItemType" ) ) )
							{
								$reportElement .= " monetary";
							}
							else if ( $nodeElement['type'] == 'xbrli:sharesItemType' )
							{
								$reportElement .= " shares";
							}
							else
							{
								$reportElement .= " " . $nodeElement['type'];
							}
							$periodType = $nodeElement['periodType'];
							$balance = isset( $nodeElement['balance'] ) ? $nodeElement['balance'] : 'n/a';
							$factSetType = isset( $node['patterntype'] ) ? $node['patterntype'] : '';
							break;

						case 'cm.xsd#cm_Abstract':
							$class = "abstract";
							$reportElement = "[Abstract]";
							$factSetType = isset( $node['patterntype'] ) ? $node['patterntype'] : '';
							break;
					}

					$result[] = "<div><span class='depth{$node['depth']} $class'>$text</span></div>";
					$result[] = "<div>$factSetType</div>";
					$result[] = "<div>$reportElement</div>"; // This text should be based on some lookup
					$result[] = "<div>$periodType</div>";
					$result[] = "<div>$balance</div>";
					$result[] = "<div>$name</div>";

					if ( ! isset( $node['children'] ) || ! $node['children'] ) continue;
					$result = array_merge( $result, $renderStructure( $node['children'] ) );
				}

				return $result;
			};

			$result = $renderStructure( $network['hierarchy'] );

		$structureTable .= implode( '', $result ) . "	</div>";

		return $structureTable;
	}