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
コード例 #1
0
ファイル: variables.php プロジェクト: narrenfrei/kirbycms
 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;
 }
コード例 #2
0
ファイル: kirby.php プロジェクト: sdvig/kirbycms
 /**
  * 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);
 }
コード例 #3
0
ファイル: data.php プロジェクト: nilshendriks/kirbycms-panel
 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'));
 }
コード例 #4
0
ファイル: route.php プロジェクト: ajmalafif/bradshawsguide
</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">