Пример #1
0
 private function _test_delimiters()
 {
     $file_options = global_file_options();
     $delimiter = $file_options->path_delimiter;
     $this->_check_equal(false, begins_with_delimiter('path/to/the/folder/'));
     $this->_check_equal(true, begins_with_delimiter($delimiter . 'path/to/the/folder/'));
     $this->_check_equal(true, ends_with_delimiter('path/to/the/folder' . $file_options->path_delimiter));
     $this->_check_equal(false, ends_with_delimiter('path/to/the/folder'));
     $this->_check_equal(true, begins_with_delimiter(ensure_begins_with_delimiter('path/to/the/folder/')));
     $this->_check_equal(true, begins_with_delimiter(ensure_begins_with_delimiter('/path/to/the/folder/')));
     $this->_check_equal(true, ends_with_delimiter(ensure_ends_with_delimiter('path/to/the/folder/')));
     $this->_check_equal(true, ends_with_delimiter(ensure_ends_with_delimiter('path/to/the/folder')));
 }
Пример #2
0
 /**
  * Adds the default registered extension if necessary.
  * Adds an extension to 'fragment' if it does not end in a delimiter, does not already
  * have an extension and there is a default extension registered for 'alias'.
  * @param string $alias
  * @param string $fragment
  * @return string
  * @access private
  */
 protected function _apply_extension_for_alias($alias, $fragment)
 {
     if (!ends_with_delimiter($fragment, $this->_url_options) && !is_file_name($fragment, $this->_url_options)) {
         $ext = $this->extension_for_alias($alias);
         if ($ext) {
             $fragment .= '.' . $ext;
         }
     }
     return $fragment;
 }
Пример #3
0
 /**
  * Is the URL terminated by a delimiter?
  * @access private
  * @return boolean
  */
 public function ends_with_delimiter()
 {
     return ends_with_delimiter($this->_text, $this->options());
 }
Пример #4
0
/**
 * Make sure the given path ends with a delimiter.
 * Neither modifies an empty path nor checks whether the path is a filename.
 * @param string $f The path to check.
 * @param FILE_OPTIONS $opts
 * @return string
 */
function ensure_ends_with_delimiter($f, $opts = null)
{
    if ($f) {
        if (!isset($opts)) {
            $opts = global_file_options();
        }
        if (!ends_with_delimiter($f, $opts)) {
            $f = $f . $opts->path_delimiter;
        } else {
            $f = $f;
        }
    }
    return $f;
}