示例#1
0
 /**
  * Adds a new sub-directory to the list that will be prepended
  *
  * @param String $dir
  * @return \r8\Finder\BaseDir Returns a self reference
  */
 public function addDir($dir)
 {
     $dir = rtrim((string) $dir, "/");
     if (!\r8\IsEmpty($dir)) {
         $this->dirs[] = $dir;
     }
     return $this;
 }
示例#2
0
 /**
  * Adds a new sub-directory to the list that will be prepended
  *
  * @param String $subdir
  * @return \r8\Finder\SubDir Returns a self reference
  */
 public function addSubDir($subdir)
 {
     $subdir = trim((string) $subdir, "/");
     if (!\r8\IsEmpty($subdir)) {
         $this->subdirs[] = $subdir;
     }
     return $this;
 }
示例#3
0
 /**
  * Adds a new extension to the list that will be appended
  *
  * @param String $ext
  * @return \r8\Finder\Extension Returns a self reference
  */
 public function addExt($ext)
 {
     $ext = ltrim((string) $ext, ".");
     if (!\r8\IsEmpty($ext)) {
         $this->exts[] = $ext;
     }
     return $this;
 }
示例#4
0
 /**
  * Constructor...
  *
  * @param String $namespace The namespace to nest values within
  * @param \r8\iface\Session $decorated The object being decorated
  */
 public function __construct($namespace, \r8\iface\Session $decorated)
 {
     parent::__construct($decorated);
     $namespace = \r8\indexVal($namespace);
     if (\r8\IsEmpty($namespace)) {
         throw new \r8\Exception\Argument(0, "Namespace", "Must be a valid key");
     }
     $this->namespace = $namespace;
 }
示例#5
0
 /**
  * Constructor...
  *
  * @param String $key The key to reference within the session
  * @param \r8\iface\Session $session The session to pull and push values to
  */
 public function __construct($key, \r8\iface\Session $session)
 {
     $key = \r8\indexVal($key);
     if (\r8\IsEmpty($key)) {
         throw new \r8\Exception\Argument(0, "key", "Must be a valid key");
     }
     $this->key = $key;
     $this->session = $session;
 }
示例#6
0
 /**
  * Adds a new mutation to this instance
  *
  * @param String $from The structure to replace. This value must
  * @param String $to The replacement structure
  * @return \r8\Finder\Mutation Returns a self reference
  */
 public function addMutation($from, $to)
 {
     $from = trim((string) $from, "/");
     $from = \r8\FileSys::resolvePath($from);
     $to = trim((string) $to, "/");
     if (!\r8\IsEmpty($from) && $from != $to) {
         $this->mutations[] = array("from" => $from, "to" => $to);
     }
     return $this;
 }
示例#7
0
 /**
  * Constructor...
  *
  * @param String $name The original name of the file on the client machine
  * @param Integer $code The error code associated with this file
  * @param \r8\FileSys\File $file $file The temporary file the upload was saved to
  */
 public function __construct($name, $code, \r8\FileSys\File $file)
 {
     $file->requirePath();
     $this->file = $file;
     $name = trim((string) $name);
     if (\r8\IsEmpty($name)) {
         throw new \r8\Exception\Argument(0, "File Name", "Must not be empty");
     }
     $this->name = $name;
     $this->code = max((int) $code, 0);
 }
示例#8
0
 /**
  * Returns the SQL Where expression represented by this object
  *
  * @param \r8\iface\DB\Link $link The database connection this WHERE clause
  *      is being run against. This is being passed in for escaping purposes
  * @return String
  */
 public function toWhereSQL(\r8\iface\DB\Link $link)
 {
     $prec = $this->getPrecedence();
     $result = array();
     foreach ($this->clauses as $clause) {
         $sql = trim($clause->toWhereSQL($link));
         if (\r8\IsEmpty($sql)) {
             continue;
         }
         // Wrap the clause in parenthesis if it has lower precedence
         // For a list of operation precedence, look here:
         // http://dev.mysql.com/doc/refman/5.4/en/operator-precedence.html
         if ($clause->getPrecedence() < $prec) {
             $sql = "(" . $sql . ")";
         }
         $result[] = $sql;
     }
     // Combine all the sub-clauses with the delimiter
     return implode(" " . trim($this->getDelimiter()) . " ", $result);
 }
示例#9
0
 /**
  * Parses a string into a SQL expression and it's alias
  *
  * @param String $name The SQL string to parse
  * @return array Returns an array where the first element is the
  *      SQL expression and the second is the alias
  */
 public static function parseSQLAlias($string)
 {
     $string = (string) $string;
     // If there is no obvious alias, take an easy out
     if (!\r8\str\contains(" AS ", $string)) {
         $alias = null;
     } else {
         if (!\r8\str\contains("`", $string)) {
             list($string, $alias) = explode(" AS ", $string, 2);
             $alias = trim($alias);
         } else {
             $parser = new \r8\Quoter();
             list($string, $alias) = $parser->clearQuotes()->setQuote("`")->parse($string)->setIncludeQuoted(FALSE)->explode(" AS ");
             $alias = trim($alias);
         }
     }
     $string = trim($string);
     if (\r8\IsEmpty($string)) {
         $string = null;
     }
     $alias = \r8\str\stripW($alias);
     if (\r8\IsEmpty($alias)) {
         $alias = null;
     }
     return array($string, $alias);
 }