/**
  * Normalize a path to what we need to work with.
  * Essentially, remove the starting slash and ensure there is an extension
  *
  * @param  string $path
  * @return string
  */
 public function normalizePath(&$path)
 {
     $path = Path::removeStartingSlash($path);
     $ext = '.' . Config::getContentType();
     if (!Pattern::endsWith($path, $ext)) {
         $path .= $ext;
     }
     return $path;
 }
Esempio n. 2
0
 /**
  * Parses a string or pipe-delimited string into an array
  * 
  * @param mixed  $list  String to parse
  * @return array
  */
 public static function pipeList($list)
 {
     $output = array();
     // make an array of all options
     if (is_array($list)) {
         foreach ($list as $list_item) {
             if (strpos($list_item, "|") !== false) {
                 $output = explode("|", $list_item) + $output;
             } else {
                 array_push($output, $list_item);
             }
         }
     } else {
         if (strpos($list, "|") !== false) {
             $output = explode("|", $list);
         } else {
             array_push($output, $list);
         }
     }
     // now fix the array
     if (!count($output)) {
         $output = array();
     } else {
         $output = array_map(function ($item) {
             return Path::removeStartingSlash($item);
         }, $output);
     }
     return array_unique($output);
 }
Esempio n. 3
0
File: helper.php Progetto: nob/joi
 /**
  * Parses a mixed folder representation into a standardized array
  *
  * @param mixed  $folders  Folders
  * @return array
  */
 public static function parseForFolders($folders)
 {
     $output = array();
     // make an array of all options
     if (is_array($folders)) {
         foreach ($folders as $folder) {
             if (strpos($folder, "|") !== false) {
                 $output = array_merge($output, explode("|", $folder));
             } else {
                 array_push($output, $folder);
             }
         }
     } else {
         if (strpos($folders, "|") !== false) {
             $output = explode("|", $folders);
         } else {
             array_push($output, $folders);
         }
     }
     // now fix the array
     if (!count($output)) {
         $output = array();
     } else {
         $output = array_map(function ($item) {
             return Path::removeStartingSlash($item);
         }, $output);
     }
     return array_unique($output);
 }