urlify() static public method

Convert a string to a safe version to be used in an URL
static public urlify ( string $text ) : string
$text string The unsafe string
return string The safe string
Esempio n. 1
0
 static function fetch($file)
 {
     if (!file_exists($file)) {
         return array();
     }
     $content = f::read($file);
     $content = str_replace("", '', $content);
     $sections = preg_split('![\\r\\n]+[-]{4,}!i', $content);
     $data = array();
     foreach ($sections as $s) {
         $parts = explode(':', $s);
         if (count($parts) == 1 && count($sections) == 1) {
             return $content;
         }
         $key = str::urlify($parts[0]);
         if (empty($key)) {
             continue;
         }
         $value = trim(implode(':', array_slice($parts, 1)));
         $data[$key] = $value;
     }
     return $data;
 }
Esempio n. 2
0
 /**
  * Sanitize a filename to strip unwanted special characters
  * 
  * @param  string $string The file name
  * @return string
  */
 static function safe_name($string)
 {
     return str::urlify($string);
 }
Esempio n. 3
0
 static function write($file, $values)
 {
     if (file_exists($file) && !is_writable($file)) {
         return array('status' => 'error', 'msg' => l::get('writer.errors.permissions'));
     }
     $break = false;
     $result = "";
     $keys = array();
     foreach ($values as $k => $v) {
         $k = str::urlify($k);
         $k = str::ucfirst(str_replace('-', '_', $k));
         if (in_array($k, $keys) || empty($k)) {
             continue;
         }
         $keys[] = $k;
         $result .= $break . $k . ': ' . trim($v);
         $break = "\n\n----\n\n";
     }
     @chmod(basename($file), 0666);
     $write = f::write($file, $result);
     if (!$write || !file_exists($file)) {
         return array('status' => 'error', 'msg' => l::get('writer.errors.write'));
     }
     return array('status' => 'success', 'msg' => l::get('writer.success'));
 }
Esempio n. 4
0
</h1>
                <nav>
<?php 
$company = $page->company();
if ($company == 'Isle of Wight') {
    ?>
                    <a rel="up" href="/regions/england/isle-of-wight">Isle of Wight</a>
<?php 
} elseif ($company == 'London') {
    ?>
                    <a rel="up" href="/regions/england/london">London</a>
<?php 
} else {
    ?>
                    <a rel="up" href="/companies/<?php 
    echo preg_replace('/-railway$/', '', str::urlify($page->company()));
    ?>
"><?php 
    echo smartypants($page->company());
    ?>
</a>
<?php 
}
?>
                </nav>
            </header>

<?php 
if ($page->text != "") {
    ?>
            <div class="e-content prose">