hiphop type hint placeholders
This commit is contained in:
parent
6e64857936
commit
52ff412b38
@ -31,7 +31,7 @@ class Block {
|
|||||||
*/
|
*/
|
||||||
var $position;
|
var $position;
|
||||||
|
|
||||||
public function __construct($header, $body, $section="main", $position=50) {
|
public function __construct($header, $body, /*string*/ $section="main", /*int*/ $position=50) {
|
||||||
$this->header = $header;
|
$this->header = $header;
|
||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
$this->section = $section;
|
$this->section = $section;
|
||||||
|
@ -40,7 +40,7 @@ class PageRequestEvent extends Event {
|
|||||||
*
|
*
|
||||||
* If it matches, store the remaining path elements in $args
|
* If it matches, store the remaining path elements in $args
|
||||||
*/
|
*/
|
||||||
public function page_matches($name) {
|
public function page_matches(/*string*/ $name) {
|
||||||
$parts = explode("/", $name);
|
$parts = explode("/", $name);
|
||||||
$this->part_count = count($parts);
|
$this->part_count = count($parts);
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ class PageRequestEvent extends Event {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_arg($n) {
|
public function get_arg(/*int*/ $n) {
|
||||||
$offset = $this->part_count + $n;
|
$offset = $this->part_count + $n;
|
||||||
if($offset >= 0 && $offset < $this->arg_count) {
|
if($offset >= 0 && $offset < $this->arg_count) {
|
||||||
return $this->args[$offset];
|
return $this->args[$offset];
|
||||||
@ -120,7 +120,7 @@ class TextFormattingEvent extends Event {
|
|||||||
*/
|
*/
|
||||||
var $stripped;
|
var $stripped;
|
||||||
|
|
||||||
public function __construct($text) {
|
public function __construct(/*string*/ $text) {
|
||||||
$h_text = html_escape(trim($text));
|
$h_text = html_escape(trim($text));
|
||||||
$this->original = $h_text;
|
$this->original = $h_text;
|
||||||
$this->formatted = $h_text;
|
$this->formatted = $h_text;
|
||||||
|
@ -92,7 +92,7 @@ abstract class SimpleExtension implements Extension {
|
|||||||
var $theme;
|
var $theme;
|
||||||
var $_child;
|
var $_child;
|
||||||
|
|
||||||
public function i_am($child) {
|
public function i_am(Extension $child) {
|
||||||
$this->_child = $child;
|
$this->_child = $child;
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($child, false);
|
if(is_null($this->theme)) $this->theme = get_theme_object($child, false);
|
||||||
}
|
}
|
||||||
@ -115,13 +115,13 @@ abstract class SimpleExtension implements Extension {
|
|||||||
* Several extensions have this in common, make a common API
|
* Several extensions have this in common, make a common API
|
||||||
*/
|
*/
|
||||||
abstract class FormatterExtension extends SimpleExtension {
|
abstract class FormatterExtension extends SimpleExtension {
|
||||||
public function onTextFormatting($event) {
|
public function onTextFormatting(TextFormatting $event) {
|
||||||
$event->formatted = $this->format($event->formatted);
|
$event->formatted = $this->format($event->formatted);
|
||||||
$event->stripped = $this->strip($event->stripped);
|
$event->stripped = $this->strip($event->stripped);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function format($text);
|
abstract public function format(/*string*/ $text);
|
||||||
abstract public function strip($text);
|
abstract public function strip(/*string*/ $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +129,7 @@ abstract class FormatterExtension extends SimpleExtension {
|
|||||||
* so we have a base class to extend from
|
* so we have a base class to extend from
|
||||||
*/
|
*/
|
||||||
abstract class DataHandlerExtension extends SimpleExtension {
|
abstract class DataHandlerExtension extends SimpleExtension {
|
||||||
public function onDataUpload($event) {
|
public function onDataUpload(DataUploadEvent $event) {
|
||||||
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||||
if(!move_upload_to_archive($event)) return;
|
if(!move_upload_to_archive($event)) return;
|
||||||
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
|
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
|
||||||
@ -188,7 +188,7 @@ abstract class DataHandlerExtension extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onThumnbnailGeneration($event) {
|
public function onThumnbnailGeneration(ThumbnailGenerationEvent $event) {
|
||||||
if($this->supported_ext($event->type)) {
|
if($this->supported_ext($event->type)) {
|
||||||
if (method_exists($this, 'create_thumb_force') && $event->force == true) {
|
if (method_exists($this, 'create_thumb_force') && $event->force == true) {
|
||||||
$this->create_thumb_force($event->hash);
|
$this->create_thumb_force($event->hash);
|
||||||
@ -199,14 +199,14 @@ abstract class DataHandlerExtension extends SimpleExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onDisplayingImage($event) {
|
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||||
global $page;
|
global $page;
|
||||||
if($this->supported_ext($event->image->ext)) {
|
if($this->supported_ext($event->image->ext)) {
|
||||||
$this->theme->display_image($page, $event->image);
|
$this->theme->display_image($page, $event->image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding($event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
$sb = $this->setup();
|
$sb = $this->setup();
|
||||||
if($sb) $event->panel->add_block($sb);
|
if($sb) $event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class Image {
|
|||||||
*
|
*
|
||||||
* @retval Image
|
* @retval Image
|
||||||
*/
|
*/
|
||||||
public static function by_id($id) {
|
public static function by_id(/*int*/ $id) {
|
||||||
assert(is_numeric($id));
|
assert(is_numeric($id));
|
||||||
global $database;
|
global $database;
|
||||||
$image = null;
|
$image = null;
|
||||||
@ -79,7 +79,7 @@ class Image {
|
|||||||
*
|
*
|
||||||
* @retval Image
|
* @retval Image
|
||||||
*/
|
*/
|
||||||
public static function by_hash($hash) {
|
public static function by_hash(/*string*/ $hash) {
|
||||||
assert(is_string($hash));
|
assert(is_string($hash));
|
||||||
global $database;
|
global $database;
|
||||||
$image = null;
|
$image = null;
|
||||||
@ -1011,7 +1011,7 @@ class Tag {
|
|||||||
* Move a file from PHP's temporary area into shimmie's image storage
|
* Move a file from PHP's temporary area into shimmie's image storage
|
||||||
* heirachy, or throw an exception trying
|
* heirachy, or throw an exception trying
|
||||||
*/
|
*/
|
||||||
function move_upload_to_archive($event) {
|
function move_upload_to_archive(DataUploadEvent $event) {
|
||||||
$target = warehouse_path("images", $event->hash);
|
$target = warehouse_path("images", $event->hash);
|
||||||
if(!file_exists(dirname($target))) mkdir(dirname($target), 0755, true);
|
if(!file_exists(dirname($target))) mkdir(dirname($target), 0755, true);
|
||||||
if(!@copy($event->tmpname, $target)) {
|
if(!@copy($event->tmpname, $target)) {
|
||||||
@ -1026,7 +1026,7 @@ function move_upload_to_archive($event) {
|
|||||||
* Given a full size pair of dimentions, return a pair scaled down to fit
|
* Given a full size pair of dimentions, return a pair scaled down to fit
|
||||||
* into the configured thumbnail square, with ratio intact
|
* into the configured thumbnail square, with ratio intact
|
||||||
*/
|
*/
|
||||||
function get_thumbnail_size($orig_width, $orig_height) {
|
function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if($orig_width == 0) $orig_width = 192;
|
if($orig_width == 0) $orig_width = 192;
|
||||||
|
@ -38,7 +38,7 @@ class User {
|
|||||||
$this->passhash = $row['pass'];
|
$this->passhash = $row['pass'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_session($name, $session) {
|
public static function by_session(/*string*/ $name, /*string*/ $session) {
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
if($database->engine->name == "mysql") {
|
if($database->engine->name == "mysql") {
|
||||||
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
|
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
|
||||||
@ -50,7 +50,7 @@ class User {
|
|||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_id($id) {
|
public static function by_id(/*int*/ $id) {
|
||||||
assert(is_numeric($id));
|
assert(is_numeric($id));
|
||||||
global $database;
|
global $database;
|
||||||
if($id == 1) {
|
if($id == 1) {
|
||||||
@ -62,14 +62,14 @@ class User {
|
|||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_name($name) {
|
public static function by_name(/*string*/ $name) {
|
||||||
assert(is_string($name));
|
assert(is_string($name));
|
||||||
global $database;
|
global $database;
|
||||||
$row = $database->get_row("SELECT * FROM users WHERE name = :name", array("name"=>$name));
|
$row = $database->get_row("SELECT * FROM users WHERE name = :name", array("name"=>$name));
|
||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_name_and_hash($name, $hash) {
|
public static function by_name_and_hash(/*string*/ $name, /*string*/ $hash) {
|
||||||
assert(is_string($name));
|
assert(is_string($name));
|
||||||
assert(is_string($hash));
|
assert(is_string($hash));
|
||||||
assert(strlen($hash) == 32);
|
assert(strlen($hash) == 32);
|
||||||
@ -78,7 +78,7 @@ class User {
|
|||||||
return is_null($row) ? null : new User($row);
|
return is_null($row) ? null : new User($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function by_list($offset, $limit=50) {
|
public static function by_list(/*int*/ $offset, /*int*/ $limit=50) {
|
||||||
assert(is_numeric($offset));
|
assert(is_numeric($offset));
|
||||||
assert(is_numeric($limit));
|
assert(is_numeric($limit));
|
||||||
global $database;
|
global $database;
|
||||||
@ -120,7 +120,7 @@ class User {
|
|||||||
return $this->admin;
|
return $this->admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_admin($admin) {
|
public function set_admin(/*bool*/ $admin) {
|
||||||
assert(is_bool($admin));
|
assert(is_bool($admin));
|
||||||
global $database;
|
global $database;
|
||||||
$yn = $admin ? 'Y' : 'N';
|
$yn = $admin ? 'Y' : 'N';
|
||||||
@ -128,14 +128,14 @@ class User {
|
|||||||
log_info("core-user", "Made {$this->name} admin=$yn");
|
log_info("core-user", "Made {$this->name} admin=$yn");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_password($password) {
|
public function set_password(/*string*/ $password) {
|
||||||
global $database;
|
global $database;
|
||||||
$hash = md5(strtolower($this->name) . $password);
|
$hash = md5(strtolower($this->name) . $password);
|
||||||
$database->Execute("UPDATE users SET pass=:hash WHERE id=:id", array("hash"=>$hash, "id"=>$this->id));
|
$database->Execute("UPDATE users SET pass=:hash WHERE id=:id", array("hash"=>$hash, "id"=>$this->id));
|
||||||
log_info("core-user", "Set password for {$this->name}");
|
log_info("core-user", "Set password for {$this->name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_email($address) {
|
public function set_email(/*string*/ $address) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->Execute("UPDATE users SET email=:email WHERE id=:id", array("email"=>$address, "id"=>$this->id));
|
$database->Execute("UPDATE users SET email=:email WHERE id=:id", array("email"=>$address, "id"=>$this->id));
|
||||||
log_info("core-user", "Set email for {$this->name}");
|
log_info("core-user", "Set email for {$this->name}");
|
||||||
|
@ -276,7 +276,7 @@ function modify_url($url, $changes) {
|
|||||||
*
|
*
|
||||||
* @retval string
|
* @retval string
|
||||||
*/
|
*/
|
||||||
function make_http($link) {
|
function make_http(/*string*/ $link) {
|
||||||
if(strpos($link, "ttp://") > 0) return $link;
|
if(strpos($link, "ttp://") > 0) return $link;
|
||||||
if(strlen($link) > 0 && $link[0] != '/') $link = get_base_href().'/'.$link;
|
if(strlen($link) > 0 && $link[0] != '/') $link = get_base_href().'/'.$link;
|
||||||
$link = "http://".$_SERVER["HTTP_HOST"].$link;
|
$link = "http://".$_SERVER["HTTP_HOST"].$link;
|
||||||
@ -504,7 +504,7 @@ function get_memory_limit() {
|
|||||||
*
|
*
|
||||||
* @retval string
|
* @retval string
|
||||||
*/
|
*/
|
||||||
function get_session_ip($config) {
|
function get_session_ip(Config $config) {
|
||||||
$mask = $config->get_string("session_hash_mask", "255.255.0.0");
|
$mask = $config->get_string("session_hash_mask", "255.255.0.0");
|
||||||
$addr = $_SERVER['REMOTE_ADDR'];
|
$addr = $_SERVER['REMOTE_ADDR'];
|
||||||
$addr = inet_ntop(inet_pton($addr) & inet_pton($mask));
|
$addr = inet_ntop(inet_pton($addr) & inet_pton($mask));
|
||||||
@ -516,7 +516,7 @@ function get_session_ip($config) {
|
|||||||
* prefix prepended to it, eg username -> shm_username, to prevent
|
* prefix prepended to it, eg username -> shm_username, to prevent
|
||||||
* conflicts from multiple installs within one domain.
|
* conflicts from multiple installs within one domain.
|
||||||
*/
|
*/
|
||||||
function get_prefixed_cookie($name) {
|
function get_prefixed_cookie(/*string*/ $name) {
|
||||||
global $config;
|
global $config;
|
||||||
$full_name = COOKIE_PREFIX."_".$name;
|
$full_name = COOKIE_PREFIX."_".$name;
|
||||||
if(isset($_COOKIE[$full_name])) {
|
if(isset($_COOKIE[$full_name])) {
|
||||||
@ -569,13 +569,13 @@ function get_base_href() {
|
|||||||
*
|
*
|
||||||
* @retval string
|
* @retval string
|
||||||
*/
|
*/
|
||||||
function format_text($string) {
|
function format_text(/*string*/ $string) {
|
||||||
$tfe = new TextFormattingEvent($string);
|
$tfe = new TextFormattingEvent($string);
|
||||||
send_event($tfe);
|
send_event($tfe);
|
||||||
return $tfe->formatted;
|
return $tfe->formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function warehouse_path($base, $hash, $create=true) {
|
function warehouse_path(/*string*/ $base, /*string*/ $hash, /*bool*/ $create=true) {
|
||||||
$ab = substr($hash, 0, 2);
|
$ab = substr($hash, 0, 2);
|
||||||
$cd = substr($hash, 2, 2);
|
$cd = substr($hash, 2, 2);
|
||||||
if(WH_SPLITS == 2) {
|
if(WH_SPLITS == 2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user