Transform block to string

@param string|null $message Any message to pass to the page
@param mixed       $results If string will redirect otherwise pass this to page

@return string
2047
protected function success($message = null, $results = null)
    {
        if($message) {
            $_SESSION['flash']['message'] = $message;
            $_SESSION['flash']['type'] = 'success';
        }

        $this->trigger('html-success', $this, $message, $results);
        $this->trigger('response-success', $this, $message, $results);

        if(is_string($results)) {
            //redirect will forcefully exit
            return (string) eve()->redirect($results);
        }

        if(!is_null($results)) {
            $this->body['results'] = $results;
        }

        return $this->build($this->getTemplate());
    }
357344
public function addNextPage(Result $result): ? string
    {
        $query = $result->getQuery();
        $urlParameters = $this->generateQueryUrlParameters($result);
        $page = $query->getPage();
        $nextPage = $page + 1;

        if ((($nextPage - 1) * $query->getSize()) > $result->getTotalHits()) {
            return null;
        }

        $urlParameters['page'] = $nextPage;

        return $this->createUrlByUrlParameters(
            $result,
            $urlParameters
        )['route'];
    }
680521
public function render($messages = null)
	{
		if ($messages)
		{
			$this->setMessages($messages);
		}

		$messages = $this->getMessages();

		$output = array();
		$output[] = '<div class="debug-varlist">';
		foreach ($messages as $item)
		{
			$output[] = $this->line($item);
		}
		$output[] = '</div>';
		return implode("\n", $output);
	}
369022
protected function formatMessage( $sql, $bindings, $previous ) {
		foreach ( $bindings as $value ) {
			$sql = preg_replace( '/\?/', $value, $sql, 1 );
		}

		return $previous->getMessage() . ' (SQL: ' . $sql . ')';
	}
976561
public static String composeMessage(List<ValidationResult> results) {
		StringBuilder builder = new StringBuilder();
		builder.append("Validation failed");

		if (results != null && results.size() > 0) {
			boolean first = true;
			for (ValidationResult result : results) {
				if (result.getType() != ValidationResultType.Information) {
					if (!first)
						builder.append(": ");
					else
						builder.append(", ");
					builder.append(result.getMessage());
					first = false;
				}
			}
		}

		return builder.toString();
	}
187191
private function getRows($results) {
    $table = '<h3>Rows Of Data</h3>';

    if (count($results->getRows()) > 0) {
      $table .= '<table>';

      // Print headers.
      $table .= '<tr>';

      foreach ($results->getColumnHeaders() as $header) {
        $table .= '<th>' . $header->name . '</th>';
      }
      $table .= '</tr>';

      // Print table rows.
      foreach ($results->getRows() as $row) {
        $table .= '<tr>';
          foreach ($row as $cell) {
            $table .= '<td>'
                   . htmlspecialchars($cell, ENT_NOQUOTES)
                   . '</td>';
          }
        $table .= '</tr>';
      }
      $table .= '</table>';

    } else {
      $table .= '<p>No results found.</p>';
    }

    return $table;
  }
177561
public static function text($message, $data = null)
    {
        if (!static::$on) {
            return;
        }

        echo "--------------------------------------------------------------------------------\n";
        static::indent();
        echo static::getTime() . " - " . $message . "\n";
        if (is_array($data)) {
            print_r($data);
        } elseif ($data) {
            static::indent();
            echo "    " . $data . "\n";
        }
    }
518390
public function processColumnListing($results)
	{
		$mapping = function ($r) {
			$r = (object) $r;

			return $r->name;
		};

		return array_map($mapping, $results);
	}
1286720
protected function restoreVerbatimBlocks($result)
    {
        $result = preg_replace_callback(
            '/' . preg_quote($this->verbatimPlaceholder) . '/',
            function () {
                return array_shift($this->verbatimBlocks);
            },
            $result
        );

        $this->verbatimBlocks = [];

        return $result;
    }
1112576
public function addPrevPage(Result $result): ? string
    {
        $query = $result->getQuery();
        $urlParameters = $this->generateQueryUrlParameters($result);
        $page = $query->getPage();
        $prevPage = $page - 1;

        if ($prevPage < 1) {
            return null;
        }

        $urlParameters['page'] = $prevPage;

        return $this->createUrlByUrlParameters(
            $result,
            $urlParameters
        )['route'];
    }
4788
protected function fail($message = null, $validation = null)
    {
        $this->trigger('json-fail', $this, $message, $validation);
        $this->trigger('response-fail', $this, $message, $validation);

        $json = array('error' => true);

        if($message) {
            $json['message'] = $message;
        }

        if($validation) {
            $json['validation'] = $validation;
        }

        $body = json_encode($json, JSON_PRETTY_PRINT);

        $this->response
            ->set('headers', 'Content-Type', 'text/json')
            ->set('body', $body);

        return $body;
    }
406380
protected function restoreRawContent($result)
    {
        $result = preg_replace_callback('/'.$this->getRawPlaceholder('(\d+)').'/', function ($matches) {
            return $this->rawBlocks[$matches[1]];
        }, $result);

        $this->rawBlocks = [];

        return $result;
    }
261513
public function loadMessagesFrom($result)
    {
        // Set message on either a field or the parent form
        foreach ($result->getMessages() as $message) {
            $fieldName = $message['fieldName'];

            if ($fieldName) {
                $owner = $this->fields->dataFieldByName($fieldName) ?: $this;
            } else {
                $owner = $this;
            }

            $owner->setMessage($message['message'], $message['messageType'], $message['messageCast']);
        }
        return $this;
    }
612953
protected function format($message, array $placeholders = [])
    {
        foreach ($placeholders as $name => $value) {
            $placeholders[":$name"] = $value;
            unset($placeholders[$name]);
        }
        
        return strtr($message, $placeholders);
    }
1189369
public function renderMessageBox($data=null)
	{
	    $needData = [
	        'url'      => '_stop',
	        'rootUrl'  => Config::getRootUrl(),
	        'errtype'  => '提示'
	    ];
	    
	    $data = $data ? : [];
	    $data = array_merge($needData, $data);
	    $template = $this->getMessageBoxTemplate();
	    return $this->setLayout(null)->render($template, $data);
	}
586618
public function url($message = null)
    {
        $this->setRule(__FUNCTION__, function($val)
                       {
                           return (strlen(trim($val)) === 0 || filter_var($val, FILTER_VALIDATE_URL) !== FALSE);
                       }, $message);
        return $this;
    }
676321
private function formatMessage(Message $message)
    {
        $nodes = $this->nodeStatementsRemover->removeInnerStatements($message->getNodes());
        $prettyPrintedNodes = str_replace("\n", "\n    ", $this->prettyPrinter->prettyPrint($nodes));

        $text = $message->getRawText();
        $color = self::$colors[$message->getLevel()];
        $levelText = self::$levelText[$message->getLevel()];

        if ($color) {
            $text = sprintf(
                '<fg=%s>[%s] %s</fg=%s>',
                $color,
                $levelText,
                $text,
                $color
            );
        }

        return sprintf(
            "> Line <fg=cyan>%s</fg=cyan>: %s\n    %s",
            $message->getLine(),
            $text,
            $prettyPrintedNodes
        );
    }