Exemplo n.º 1
0
 /**
  * Add a label
  *
  * @return void
  * @author Justin Palmer
  **/
 public static function setLabel($key, $value)
 {
     if (!self::$Labels instanceof Hash) {
         self::$Labels = new Hash();
     }
     self::$Labels->set($key, $value);
 }
Exemplo n.º 2
0
 /**
  * 	Send email $to with using the $template file in the
  * 	/app/view/email/ directory otherwise you changed {@link $viewDir}
  * 	@param $to
  * 	@param string			$template	Filename of template to use
  * 	@param string			$subject		Optional alternate subject that should be used
  * 	@param array(string)	$data		optional additional associated array data to render in the view
  * 	@return boolean	true if mail was successfully send, otherwise false
  */
 public function send($to, $template, $subject = null, $data = array())
 {
     // use user logged in email for reply adress
     if ($this->controller->UserLogin->loggedin()) {
         $this->headers->set('Reply-To', $this->controller->UserLogin->User->get('email'));
         $this->headers->set('From', $this->controller->UserLogin->User->get('email'));
     }
     // render content
     $view = Library::create('ephFrame.lib.view.View', array($this->viewDir, $template, array_merge($this->controller->data->toArray(), $data)));
     $view->theme = $this->controller->theme;
     // send mail and return result
     return @mail($to, $subject == null ? $this->subject : $subject, $view->render(), $this->headers->implodef(RTLF, '%s: %s'));
 }
Exemplo n.º 3
0
 /**
  * Add a rule to a column
  *
  * @return void
  * @author Justin Palmer
  **/
 public function rule($column, Rule $rule)
 {
     //Make sure the property exists.
     $this->model->hasProperty($column);
     if ($rule instanceof RequiredRule) {
         $this->required[] = $column;
     }
     //Get the rules for this property.
     $rules = $this->rules->get($column);
     if ($rules === null) {
         $rules = array();
     }
     $rules[] = $rule;
     $this->rules->set($column, $rules);
 }
Exemplo n.º 4
0
 public function decodeHash()
 {
     $h = new Hash();
     $this->nextToken();
     $this->skipBlanks();
     if ($this->c === 125) {
         $this->nextToken();
         return $h;
     }
     while ($this->c !== 125) {
         $key = $this->decodeString();
         $this->skipBlanks();
         if ($this->c !== 58) {
             throw new HException("Expected ':'.");
         }
         $this->nextToken();
         $this->skipBlanks();
         $o = $this->localDecode();
         $h->set($key, $o);
         $this->skipBlanks();
         if ($this->c === 44) {
             $this->nextToken();
             $this->skipBlanks();
         } else {
             if ($this->c !== 125) {
                 throw new HException("Expected ',' or '}'. " . $this->getPositionRepresentation());
             }
         }
         unset($o, $key);
     }
     $this->nextToken();
     return $h;
 }
Exemplo n.º 5
0
 /**
  * __set vars
  *
  * @return void
  * @author Justin Palmer
  **/
 public function __set($key, $value)
 {
     if (!$this->columns()->isKey($key)) {
         throw new NoColumnInTableException($key, $this->table_name());
     }
     $this->props_changed[] = $key;
     $this->props->set($key, $value);
 }
 static function hashOfAssociativeArray($arr)
 {
     $h = new Hash();
     reset($arr);
     while (list($k, $v) = each($arr)) {
         $h->set($k, $v);
     }
     return $h;
 }
 static function fromProperties($prop)
 {
     $ht = new Hash();
     $key = "";
     $value = "";
     foreach ($prop as $key => $value) {
         $ht->set($key, $value);
     }
     return $ht;
 }
Exemplo n.º 8
0
 static function computeInverse($dict)
 {
     $keys = $dict->keys();
     $outDict = new Hash();
     while ($keys->hasNext()) {
         $key = $keys->next();
         $outDict->set($dict->get($key), $key);
         unset($key);
     }
     return $outDict;
 }
Exemplo n.º 9
0
 public function key()
 {
     $reg = "^";
     $chars = _hx_explode("", $this->str);
     $ch = "";
     $inKey = false;
     $keyName = "";
     $matchIndex = 0;
     $keys = new Hash();
     while (($ch = $chars->shift()) !== null) {
         if ($ch == ":") {
             $matchIndex++;
             $keyName = "";
             $inKey = true;
         } else {
             if ($inKey && _hx_deref(new EReg("[^a-z]", "i"))->match($ch)) {
                 $inKey = false;
                 $keys->set($keyName, $matchIndex);
                 $reg .= "([a-zA-Z0-9]+)" . $this->escape($ch);
             } else {
                 if ($inKey) {
                     $keyName .= $ch;
                 } else {
                     $reg .= $this->escape($ch);
                 }
             }
         }
     }
     if ($inKey) {
         $keys->set($keyName, $matchIndex);
         $reg .= "([a-zA-Z0-9]+)";
     }
     $reg .= "\$";
     haxe_Log::trace("(key) From pattern: " . $this->str . " we created expression: " . $reg . " and found these keys: " . $keys, _hx_anonymous(array("fileName" => "Route.hx", "lineNumber" => 144, "className" => "sinatra.RouteParser", "methodName" => "key")));
     return new EReg($reg, "");
 }
Exemplo n.º 10
0
 function __construct(Controller $controller)
 {
     $this->controller = $controller;
     $filters = new Hash();
     $filters->set(self::before, new Hash());
     $filters->set($this->exceptName(self::before), new Hash());
     $filters->set(self::around, new Hash());
     $filters->set($this->exceptName(self::around), new Hash());
     $filters->set(self::after, new Hash());
     $filters->set($this->exceptName(self::after), new Hash());
     $this->filters = $filters;
 }
Exemplo n.º 11
0
 public function computeDigest($mml, $param)
 {
     $ss = $this->getEditorParametersList();
     $i = null;
     $renderParams = new Hash();
     $_g1 = 0;
     $_g = $ss->length;
     while ($_g1 < $_g) {
         $i1 = $_g1++;
         $key = $ss[$i1];
         $value = com_wiris_system_PropertiesTools::getProperty($param, $key, null);
         if ($value !== null) {
             $renderParams->set($key, $value);
         }
         unset($value, $key, $i1);
     }
     if ($mml !== null) {
         $renderParams->set("mml", $mml);
     }
     $s = com_wiris_util_sys_IniFile::propertiesToString($renderParams);
     return $this->plugin->getStorageAndCache()->codeDigest($s);
 }
Exemplo n.º 12
0
 static function getMultipart($maxSize)
 {
     $h = new Hash();
     $buf = null;
     $curname = null;
     php_Web::parseMultipart(array(new _hx_lambda(array(&$buf, &$curname, &$h, &$maxSize), "php_Web_1"), 'execute'), array(new _hx_lambda(array(&$buf, &$curname, &$h, &$maxSize), "php_Web_2"), 'execute'));
     if ($curname !== null) {
         $h->set($curname, $buf->b);
     }
     return $h;
 }
Exemplo n.º 13
0
 static function getMultipart($maxSize)
 {
     $h = new Hash();
     $buf = null;
     $curname = null;
     php_Web::parseMultipart(array(new _hx_lambda(array("buf" => &$buf, "curname" => &$curname, "h" => &$h, "maxSize" => &$maxSize), null, array('p', '_'), "{\n\t\t\tif(\$curname !== null) {\n\t\t\t\t\$h->set(\$curname, \$buf->b);\n\t\t\t}\n\t\t\t\$curname = \$p;\n\t\t\t\$buf = new StringBuf();\n\t\t\t\$maxSize -= strlen(\$p);\n\t\t\tif(\$maxSize < 0) {\n\t\t\t\tthrow new HException(\"Maximum size reached\");\n\t\t\t}\n\t\t}"), 'execute2'), array(new _hx_lambda(array("buf" => &$buf, "curname" => &$curname, "h" => &$h, "maxSize" => &$maxSize), null, array('str', 'pos', 'len'), "{\n\t\t\t\$maxSize -= \$len;\n\t\t\tif(\$maxSize < 0) {\n\t\t\t\tthrow new HException(\"Maximum size reached\");\n\t\t\t}\n\t\t\t\$buf->b .= _hx_substr(\$str, \$pos, \$len);\n\t\t}"), 'execute3'));
     if ($curname !== null) {
         $h->set($curname, $buf->b);
     }
     return $h;
 }