begin plugin api
This commit is contained in:
parent
1a9f8eacc4
commit
ddec422de6
5 changed files with 80 additions and 5 deletions
60
boot.php
60
boot.php
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
define ( 'BUILD_ID', 1026 );
|
define ( 'BUILD_ID', 1027 );
|
||||||
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
|
define ( 'DFRN_PROTOCOL_VERSION', '2.0' );
|
||||||
|
|
||||||
define ( 'EOL', "<br />\r\n" );
|
define ( 'EOL', "<br />\r\n" );
|
||||||
|
@ -174,8 +174,10 @@ class App {
|
||||||
public $pager;
|
public $pager;
|
||||||
public $strings;
|
public $strings;
|
||||||
public $path;
|
public $path;
|
||||||
|
public $hooks;
|
||||||
public $interactive = true;
|
public $interactive = true;
|
||||||
|
|
||||||
|
|
||||||
private $scheme;
|
private $scheme;
|
||||||
private $hostname;
|
private $hostname;
|
||||||
private $baseurl;
|
private $baseurl;
|
||||||
|
@ -1945,4 +1947,58 @@ function profile_sidebar($profile) {
|
||||||
));
|
));
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
if(! function_exists('register_hook')) {
|
||||||
|
function register_hook($hook,$file,$function) {
|
||||||
|
|
||||||
|
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`) VALUES ( '%s', '%s', '%s' ) ",
|
||||||
|
dbesc($hook),
|
||||||
|
dbesc($file),
|
||||||
|
dbesc($function)
|
||||||
|
);
|
||||||
|
return $r;
|
||||||
|
}}
|
||||||
|
|
||||||
|
if(! function_exists('unregister_hook')) {
|
||||||
|
function unregister_hook($hook,$file,$function) {
|
||||||
|
|
||||||
|
$r = q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1",
|
||||||
|
dbesc($hook),
|
||||||
|
dbesc($file),
|
||||||
|
dbesc($function)
|
||||||
|
);
|
||||||
|
return $r;
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
if(! function_exists('load_hooks')) {
|
||||||
|
function load_hooks() {
|
||||||
|
$a = get_app();
|
||||||
|
$r = q("SELECT * FROM `hook` WHERE 1");
|
||||||
|
if(count($r)) {
|
||||||
|
foreach($r as $rr) {
|
||||||
|
$a->hooks[] = array($rr['hook'], $rr['file'], $rr['function']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
if(! function_exists('call_hooks')) {
|
||||||
|
function call_hooks($name, $data = null) {
|
||||||
|
$a = get_app();
|
||||||
|
|
||||||
|
if(count($a->hooks)) {
|
||||||
|
foreach($a->hooks as $hook) {
|
||||||
|
if($hook[0] === $name) {
|
||||||
|
@require_once($hook[1]);
|
||||||
|
if(function_exists($hook[2])) {
|
||||||
|
$func = $hook[2];
|
||||||
|
$func($a,$data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
|
@ -433,3 +433,11 @@ CREATE TABLE IF NOT EXISTS `pconfig` (
|
||||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `hook` (
|
||||||
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||||
|
`hook` CHAR( 255 ) NOT NULL ,
|
||||||
|
`file` CHAR( 255 ) NOT NULL ,
|
||||||
|
`function` CHAR( 255 ) NOT NULL
|
||||||
|
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
require_once('library/HTML5/Parser.php');
|
require_once('library/HTML5/Parser.php');
|
||||||
|
|
||||||
|
|
||||||
function parse_url_content(&$a) {
|
function parse_url_content(&$a) {
|
||||||
|
|
||||||
$url = trim($_GET['url']);
|
$url = trim($_GET['url']);
|
||||||
|
@ -16,13 +17,13 @@ function parse_url_content(&$a) {
|
||||||
echo '';
|
echo '';
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $s) {
|
if(! $s) {
|
||||||
echo sprintf($template,$url,$url,'');
|
echo sprintf($template,$url,$url,'');
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
$dom = HTML5_Parser::parse($s);
|
$dom = @HTML5_Parser::parse($s);
|
||||||
|
|
||||||
if(! $dom)
|
if(! $dom)
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
10
update.php
10
update.php
|
@ -251,3 +251,13 @@ function update_1025() {
|
||||||
q("ALTER TABLE `user` ADD `maxreq` int(11) NOT NULL DEFAULT '10' AFTER `pwdreset` ");
|
q("ALTER TABLE `user` ADD `maxreq` int(11) NOT NULL DEFAULT '10' AFTER `pwdreset` ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_1026() {
|
||||||
|
q("CREATE TABLE IF NOT EXISTS `hook` (
|
||||||
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||||
|
`hook` CHAR( 255 ) NOT NULL ,
|
||||||
|
`file` CHAR( 255 ) NOT NULL ,
|
||||||
|
`function` CHAR( 255 ) NOT NULL
|
||||||
|
) ENGINE = MYISAM DEFAULT CHARSET=utf8 ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ $hide_friends
|
||||||
<div class="profile-edit-submit-end"></div>
|
<div class="profile-edit-submit-end"></div>
|
||||||
|
|
||||||
<div id="profile-edit-marital-wrapper" >
|
<div id="profile-edit-marital-wrapper" >
|
||||||
<label id="profile-edit-marital-label" for="profile-edit-marital" >Marital Status: </label>
|
<label id="profile-edit-marital-label" for="profile-edit-marital" ><span class="heart">♥</span> (Marital) Status: </label>
|
||||||
$marital
|
$marital
|
||||||
</div>
|
</div>
|
||||||
<label id="profile-edit-with-label" for="profile-edit-with" > Who: (if applicable) </label>
|
<label id="profile-edit-with-label" for="profile-edit-with" > Who: (if applicable) </label>
|
||||||
|
|
Loading…
Reference in a new issue