/** * Returns a URL Safe Title Slug, limited to the specified characters * * @param string title * @param int limit (default 25) * @return string url safe slug */ public static function title_slug($title, $limit = 25) { return preg_replace("/([_+]|_)\$/", "", str::limit_chars(inflector::underscore(str::strip_all_but(strtolower($title), "a-z0-9 \\_")), $limit, "")); }
/** * Returns a stacktrace in the form of a string */ public static function trace_string($trace) { $string = ""; // Setup the stack trace $string .= Eight_Exception::trace_string_line("Stack trace:"); $string .= Eight_Exception::trace_string_line(""); $x = 0; foreach (Eight_Exception::trace($trace) as $i => $step) { $msg_line = "#" . str_pad($x, 2, "0", STR_PAD_LEFT) . " "; if ($step['file']) { $source_id = $error_id . 'source' . $i; $msg_line .= Eight_Exception::debug_path($step['file']) . '(' . $step['line'] . "): "; } else { $msg_line .= "{" . __('PHP internal call') . "}: "; } $msg_line .= $step['function'] . '('; $print_able_args = array(); if ($step['args']) { $args_id = $error_id . 'args' . $i; foreach ($step['args'] as $arg) { $arg_name = ""; if (is_object($arg)) { $arg_name = get_class($arg); } else { if (is_array($arg)) { $arg_name = "Array(" . count($arg) . ")"; } else { if (is_null($arg)) { $arg_name = "NULL"; } else { if (is_string($arg)) { $arg_name = $arg; } else { $arg_name = strval($arg); } } } } $arg_name = preg_replace("#\\s+#", " ", $arg_name); $print_able_args[] = str::limit_chars($arg_name, 50, ""); } } $msg_line .= implode(", ", $print_able_args); $msg_line .= ")"; $string .= Eight_Exception::trace_string_line($msg_line); $x++; } return $string; }
function add_line($str) { echo " | " . str_pad(str::limit_chars($str, $_ENV['box_width'] - 4, ""), $_ENV['box_width'] - 4, " ") . " |\n"; }