consistent plugin usage - spartacus
this and followup commits touches: use load_languiage API class method parenthesis "\n{\n <code>\n}\n", case break switches, consistent boolean usage, append css to eventData and other cleanups
This commit is contained in:
parent
3d7b8fa803
commit
f94c85c8e1
@ -15,11 +15,6 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
var $title = PLUGIN_EVENT_SPARTACUS_NAME;
|
||||
var $purgeCache = false;
|
||||
|
||||
function microtime_float() {
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
function introspect(&$propbag)
|
||||
{
|
||||
global $serendipity;
|
||||
@ -28,36 +23,38 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$propbag->add('description', PLUGIN_EVENT_SPARTACUS_DESC);
|
||||
$propbag->add('stackable', false);
|
||||
$propbag->add('author', 'Garvin Hicking');
|
||||
$propbag->add('version', '2.32');
|
||||
$propbag->add('version', '2.33');
|
||||
$propbag->add('requirements', array(
|
||||
'serendipity' => '0.9',
|
||||
'serendipity' => '1.6',
|
||||
'smarty' => '2.6.7',
|
||||
'php' => '4.1.0'
|
||||
));
|
||||
$propbag->add('event_hooks', array(
|
||||
'backend_plugins_fetchlist' => true,
|
||||
'backend_plugins_fetchplugin' => true,
|
||||
'backend_plugins_fetchlist' => true,
|
||||
'backend_plugins_fetchplugin' => true,
|
||||
|
||||
'backend_templates_fetchlist' => true,
|
||||
'backend_templates_fetchtemplate' => true,
|
||||
'backend_templates_fetchlist' => true,
|
||||
'backend_templates_fetchtemplate' => true,
|
||||
|
||||
'backend_pluginlisting_header' => true,
|
||||
|
||||
'external_plugin' => true,
|
||||
'backend_pluginlisting_header' => true,
|
||||
|
||||
'backend_directory_create' => true,
|
||||
'cronjob' => true,
|
||||
'external_plugin' => true,
|
||||
|
||||
'backend_directory_create' => true,
|
||||
'cronjob' => true,
|
||||
));
|
||||
$propbag->add('groups', array('BACKEND_FEATURES'));
|
||||
$propbag->add('configuration', array('enable_plugins', 'enable_themes', 'enable_remote', 'remote_url', 'cronjob', 'mirror_xml', 'mirror_files', 'custommirror', 'chown', 'chmod_files', 'chmod_dir', 'use_ftp', 'ftp_server', 'ftp_username', 'ftp_password', 'ftp_basedir'));
|
||||
|
||||
}
|
||||
|
||||
function generate_content(&$title) {
|
||||
function generate_content(&$title)
|
||||
{
|
||||
$title = $this->title;
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
function cleanup()
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
// Purge DB cache
|
||||
@ -77,7 +74,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
|
||||
function &getMirrors($type = 'xml', $loc = false) {
|
||||
function &getMirrors($type = 'xml', $loc = false)
|
||||
{
|
||||
static $mirror = array(
|
||||
'xml' => array(
|
||||
'Netmirror.org',
|
||||
@ -130,7 +128,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
|
||||
function introspect_config_item($name, &$propbag) {
|
||||
function introspect_config_item($name, &$propbag)
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
switch($name) {
|
||||
@ -142,7 +141,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$propbag->add('default', 'none');
|
||||
$propbag->add('select_values', serendipity_event_cronjob::getValues());
|
||||
} else {
|
||||
$propbag->add('type', 'content');
|
||||
$propbag->add('type', 'content');
|
||||
$propbag->add('default', PLUGIN_EVENT_SPARTACUS_CRONJOB);
|
||||
}
|
||||
break;
|
||||
@ -231,7 +230,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'ftp_server':
|
||||
if (function_exists('ftp_connect')) {
|
||||
$propbag->add('type', 'string');
|
||||
@ -240,7 +239,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$propbag->add('default', '');
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'ftp_username':
|
||||
if (function_exists('ftp_connect')) {
|
||||
$propbag->add('type', 'string');
|
||||
@ -249,7 +248,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$propbag->add('default', '');
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'ftp_password':
|
||||
if (function_exists('ftp_connect')) {
|
||||
$propbag->add('type', 'string');
|
||||
@ -258,7 +257,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$propbag->add('default', '');
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'ftp_basedir':
|
||||
if (function_exists('ftp_connect')) {
|
||||
$propbag->add('type', 'string');
|
||||
@ -274,7 +273,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetChildren(&$vals, &$i) {
|
||||
function GetChildren(&$vals, &$i)
|
||||
{
|
||||
$children = array();
|
||||
$cnt = sizeof($vals);
|
||||
while (++$i < $cnt) {
|
||||
@ -308,18 +308,20 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
|
||||
// remove double slashes without breaking URL
|
||||
protected function fixUrl($s) {
|
||||
protected function fixUrl($s)
|
||||
{
|
||||
return preg_replace('%([^:])([/]{2,})%', '\\1/', $s);
|
||||
}
|
||||
|
||||
// Create recursive directories; begins at serendipity plugin root folder level
|
||||
function rmkdir($dir, $sub = 'plugins') {
|
||||
function rmkdir($dir, $sub = 'plugins')
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
if (serendipity_db_bool($this->get_config('use_ftp')) && $this->get_config('ftp_password') != '') {
|
||||
return $this->make_dir_via_ftp($dir);
|
||||
}
|
||||
|
||||
|
||||
$spaths = explode('/', $serendipity['serendipityPath'] . $sub . '/');
|
||||
$paths = explode('/', $dir);
|
||||
|
||||
@ -342,7 +344,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
|
||||
// Apply file permission settings.
|
||||
function fileperm($stack, $is_dir) {
|
||||
function fileperm($stack, $is_dir)
|
||||
{
|
||||
$chmod_dir = intval($this->get_config('chmod_dir'), 8);
|
||||
$chmod_files = intval($this->get_config('chmod_files'), 8);
|
||||
$chown = $this->get_config('chown');
|
||||
@ -367,7 +370,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
return true;
|
||||
}
|
||||
|
||||
function outputMSG($status, $msg) {
|
||||
function outputMSG($status, $msg)
|
||||
{
|
||||
global $serendipity;
|
||||
switch($status) {
|
||||
case 'notice':
|
||||
@ -382,20 +386,21 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'success':
|
||||
default:
|
||||
echo '<span class="msg_success"><span class="icon-ok-circled"></span> '. $msg .'</span>' . "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function &fetchfile($url, $target, $cacheTimeout = 0, $decode_utf8 = false, $sub = 'plugins') {
|
||||
function &fetchfile($url, $target, $cacheTimeout = 0, $decode_utf8 = false, $sub = 'plugins')
|
||||
{
|
||||
global $serendipity;
|
||||
static $error = false;
|
||||
|
||||
// Fix double URL strings.
|
||||
$url = preg_replace('@http(s)?:/@i', 'http\1://', str_replace('//', '/', $url));
|
||||
|
||||
|
||||
// --JAM: Get the URL's IP in the most error-free way possible
|
||||
$url_parts = @parse_url($url);
|
||||
$url_hostname = 'localhost';
|
||||
@ -517,7 +522,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
return $data;
|
||||
}
|
||||
|
||||
function decode(&$data, $force = false) {
|
||||
function decode(&$data, $force = false)
|
||||
{
|
||||
// xml_parser_* functions to recoding from ISO-8859-1/UTF-8
|
||||
if ($force === false && (LANG_CHARSET == 'ISO-8859-1' || LANG_CHARSET == 'UTF-8')) {
|
||||
return true;
|
||||
@ -542,7 +548,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
|
||||
function &fetchOnline($type, $no_cache = false) {
|
||||
function &fetchOnline($type, $no_cache = false)
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
switch($type) {
|
||||
@ -583,7 +590,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
|
||||
$url = $server . '/package_' . $url_type . $lang . '.xml';
|
||||
$target = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/package_' . $url_type . $lang . '.xml';
|
||||
|
||||
|
||||
$xml = $this->fetchfile($url, $target, $cacheTimeout, true);
|
||||
if (strlen($xml) > 0) {
|
||||
$valid = true;
|
||||
@ -595,7 +602,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$url = $mirror . '/package_' . $url_type . $lang . '.xml';
|
||||
$cacheTimeout = 60*60*12; // XML file is cached for half a day
|
||||
$target = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/package_' . $url_type . $lang . '.xml';
|
||||
|
||||
|
||||
$xml = $this->fetchfile($url, $target, $cacheTimeout, true);
|
||||
}
|
||||
|
||||
@ -665,7 +672,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
return $tree;
|
||||
}
|
||||
|
||||
function &getCachedPlugins(&$plugins, $type) {
|
||||
function &getCachedPlugins(&$plugins, $type)
|
||||
{
|
||||
global $serendipity;
|
||||
static $pluginlist = null;
|
||||
|
||||
@ -697,7 +705,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
return $pluginlist;
|
||||
}
|
||||
|
||||
function checkPlugin(&$data, &$plugins, $type) {
|
||||
function checkPlugin(&$data, &$plugins, $type)
|
||||
{
|
||||
$installable = true;
|
||||
$upgradeLink = '';
|
||||
if (in_array($data['class_name'], $plugins)) {
|
||||
@ -725,7 +734,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
return true;
|
||||
}
|
||||
|
||||
function &buildList(&$tree, $type) {
|
||||
function &buildList(&$tree, $type)
|
||||
{
|
||||
$plugins = serendipity_plugin_api::get_installed_plugins();
|
||||
|
||||
if ($tree === 'cached') {
|
||||
@ -743,54 +753,54 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
|
||||
foreach($subtree['children'] AS $child => $childtree) {
|
||||
if (is_array($childtree) && isset($childtree['tag'])) {
|
||||
switch($childtree['tag']) {
|
||||
case 'name':
|
||||
$pluginstack[$i]['plugin_class'] =
|
||||
$pluginstack[$i]['plugin_file'] =
|
||||
$pluginstack[$i]['class_name'] =
|
||||
$pluginstack[$i]['true_name'] = $childtree['value'];
|
||||
break;
|
||||
switch($childtree['tag']) {
|
||||
case 'name':
|
||||
$pluginstack[$i]['plugin_class'] =
|
||||
$pluginstack[$i]['plugin_file'] =
|
||||
$pluginstack[$i]['class_name'] =
|
||||
$pluginstack[$i]['true_name'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'summary':
|
||||
$pluginstack[$i]['name'] = $childtree['value'];
|
||||
break;
|
||||
case 'summary':
|
||||
$pluginstack[$i]['name'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'website':
|
||||
$pluginstack[$i]['website'] = $childtree['value'];
|
||||
break;
|
||||
case 'website':
|
||||
$pluginstack[$i]['website'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'changelog':
|
||||
$pluginstack[$i]['changelog'] = $childtree['value'];
|
||||
break;
|
||||
case 'changelog':
|
||||
$pluginstack[$i]['changelog'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'groups':
|
||||
$pluginstack[$i]['groups'] = explode(',', $childtree['value']);
|
||||
break;
|
||||
case 'groups':
|
||||
$pluginstack[$i]['groups'] = explode(',', $childtree['value']);
|
||||
break;
|
||||
|
||||
case 'description':
|
||||
$pluginstack[$i]['description'] = $childtree['value'];
|
||||
break;
|
||||
case 'description':
|
||||
$pluginstack[$i]['description'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'release':
|
||||
$pluginstack[$i]['version'] = $childtree['children'][0]['value'];
|
||||
case 'release':
|
||||
$pluginstack[$i]['version'] = $childtree['children'][0]['value'];
|
||||
|
||||
$pluginstack[$i]['requirements'] = array(
|
||||
'serendipity' => '',
|
||||
'php' => '',
|
||||
'smarty' => ''
|
||||
);
|
||||
$pluginstack[$i]['requirements'] = array(
|
||||
'serendipity' => '',
|
||||
'php' => '',
|
||||
'smarty' => ''
|
||||
);
|
||||
|
||||
foreach((array)$childtree['children'] AS $relInfo) {
|
||||
if (isset($relInfo['tag']) && $relInfo['tag'] == 'requirements:s9yVersion') {
|
||||
$pluginstack[$i]['requirements']['serendipity'] = $relInfo['value'];
|
||||
foreach((array)$childtree['children'] AS $relInfo) {
|
||||
if (isset($relInfo['tag']) && $relInfo['tag'] == 'requirements:s9yVersion') {
|
||||
$pluginstack[$i]['requirements']['serendipity'] = $relInfo['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'maintainers':
|
||||
$pluginstack[$i]['author'] = $childtree['children'][0]['children'][0]['value']; // I dig my PHP arrays ;-)
|
||||
break;
|
||||
}
|
||||
case 'maintainers':
|
||||
$pluginstack[$i]['author'] = $childtree['children'][0]['children'][0]['value']; // I dig my PHP arrays ;-)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -807,13 +817,19 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
return $pluginstack;
|
||||
}
|
||||
|
||||
function checkArray(&$tree) {
|
||||
function checkArray(&$tree)
|
||||
{
|
||||
if (!is_array($tree) || !is_array($tree[0]['children'])) {
|
||||
echo "DEBUG: The XML file could not be successfully parsed. Download or caching error. Please try again later or switch your XML/File mirror location. You can also try to go to the plugin configuration of the Spartacus Plugin and simply click on 'Save' - this will purge all cached XML files and try to download it again.<div style='display: none'>" . print_r($tree, true) . "</div><br />\n";
|
||||
$msg = "DEBUG: The XML file could not be successfully parsed. Download or caching error. " .
|
||||
"Please try again later or switch your XML/File mirror location. ".
|
||||
"You can also try to go to the plugin configuration of the Spartacus Plugin and simply click on 'Save' - this will purge all cached XML files and try to download it again.\n".
|
||||
'<div style="display: none">' . print_r($tree, true) . "</div>\n";
|
||||
echo '<span class="msg_error"><span class="icon-attention-circled"></span> '. $msg .'</span>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function &buildTemplateList(&$tree) {
|
||||
function &buildTemplateList(&$tree)
|
||||
{
|
||||
global $serendipity;
|
||||
$pluginstack = array();
|
||||
$i = 0;
|
||||
@ -844,50 +860,49 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
|
||||
foreach($subtree['children'] AS $child => $childtree) {
|
||||
if (is_array($childtree) && isset($childtree['tag'])) {
|
||||
switch($childtree['tag']) {
|
||||
case 'name':
|
||||
$pluginstack[$i]['name'] = $childtree['value'];
|
||||
break;
|
||||
switch($childtree['tag']) {
|
||||
case 'name':
|
||||
$pluginstack[$i]['name'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'summary':
|
||||
$pluginstack[$i]['summary'] = $childtree['value'];
|
||||
break;
|
||||
case 'summary':
|
||||
$pluginstack[$i]['summary'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
$pluginstack[$i]['template'] = $childtree['value'];
|
||||
break;
|
||||
case 'template':
|
||||
$pluginstack[$i]['template'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'description':
|
||||
$pluginstack[$i]['description'] = $childtree['value'];
|
||||
break;
|
||||
case 'description':
|
||||
$pluginstack[$i]['description'] = $childtree['value'];
|
||||
break;
|
||||
|
||||
case 'release':
|
||||
$pluginstack[$i]['version'] = $childtree['children'][0]['value'];
|
||||
case 'release':
|
||||
$pluginstack[$i]['version'] = $childtree['children'][0]['value'];
|
||||
|
||||
$pluginstack[$i]['requirements'] = array(
|
||||
'serendipity' => '',
|
||||
'php' => '',
|
||||
'smarty' => ''
|
||||
);
|
||||
$pluginstack[$i]['requirements'] = array(
|
||||
'serendipity' => '',
|
||||
'php' => '',
|
||||
'smarty' => ''
|
||||
);
|
||||
|
||||
foreach((array)$childtree['children'] AS $relInfo) {
|
||||
if (isset($relInfo['tag']) && $relInfo['tag'] == 'requirements:s9yVersion') {
|
||||
$pluginstack[$i]['requirements']['serendipity'] = $relInfo['value'];
|
||||
foreach((array)$childtree['children'] AS $relInfo) {
|
||||
if (isset($relInfo['tag']) && $relInfo['tag'] == 'requirements:s9yVersion') {
|
||||
$pluginstack[$i]['requirements']['serendipity'] = $relInfo['value'];
|
||||
}
|
||||
|
||||
if (isset($relInfo['tag']) && $relInfo['tag'] == 'date') {
|
||||
$pluginstack[$i]['date'] = $relInfo['value'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($relInfo['tag']) && $relInfo['tag'] == 'date') {
|
||||
$pluginstack[$i]['date'] = $relInfo['value'];
|
||||
}
|
||||
$pluginstack[$i]['require serendipity'] = $pluginstack[$i]['requirements']['serendipity'];
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$pluginstack[$i]['require serendipity'] = $pluginstack[$i]['requirements']['serendipity'];
|
||||
break;
|
||||
|
||||
case 'maintainers':
|
||||
$pluginstack[$i]['author'] = $childtree['children'][0]['children'][0]['value']; // I dig my PHP arrays ;-)
|
||||
break;
|
||||
}
|
||||
case 'maintainers':
|
||||
$pluginstack[$i]['author'] = $childtree['children'][0]['children'][0]['value']; // I dig my PHP arrays ;-)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -898,7 +913,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
if (file_exists($serendipity['serendipityPath'] . '/templates_c/template_cache/'. $plugname .'.jpg')) {
|
||||
$pluginstack[$i]['preview_fullsizeURL'] = $preview_fullsizeURL;
|
||||
} else {
|
||||
if ( ! file_exists($serendipity['serendipityPath'] . '/templates_c/template_cache/'. $plugname)) {
|
||||
if ( ! file_exists($serendipity['serendipityPath'] . '/templates_c/template_cache/'. $plugname)) {
|
||||
$file = @fopen($preview_fullsizeURL, 'r');
|
||||
if ($file) {
|
||||
file_put_contents($serendipity['serendipityPath'] . '/templates_c/template_cache/'. $plugname .'.jpg', $file);
|
||||
@ -909,9 +924,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$pluginstack[$i]['customURI'] = '&serendipity[spartacus_fetch]=' . $plugname;
|
||||
$pluginstack[$i]['customIcon'] = '_spartacus';
|
||||
|
||||
@ -924,7 +937,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
return $pluginstack;
|
||||
}
|
||||
|
||||
function download(&$tree, $plugin_to_install, $sub = 'plugins') {
|
||||
function download(&$tree, $plugin_to_install, $sub = 'plugins')
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
$gitloc = '';
|
||||
@ -992,8 +1006,8 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
|
||||
if (count($files) == 0) {
|
||||
echo "DEBUG: ERROR: XML tree did not contain requested plugin:<br />\n";
|
||||
print_r($tree);
|
||||
$msg = "DEBUG: ERROR: XML tree did not contain requested plugin:\n<div>" . print_r($tree) . "</div>\n";
|
||||
echo '<span class="msg_error"><span class="icon-attention-circled"></span> '. $msg .'</span>' . "\n";
|
||||
}
|
||||
|
||||
$mirrors = $this->getMirrors('files', true);
|
||||
@ -1004,7 +1018,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$servers = explode('|', $custom);
|
||||
$mirror = $servers[0];
|
||||
}
|
||||
|
||||
|
||||
if (stristr($mirror, 'github.com')) {
|
||||
$gitloc = 'master/';
|
||||
}
|
||||
@ -1028,13 +1042,14 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
|
||||
function make_dir_via_ftp($dir) {
|
||||
function make_dir_via_ftp($dir)
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
|
||||
if (!serendipity_db_bool($this->get_config('use_ftp'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$ftp_server = $this->get_config('ftp_server');
|
||||
$ftp_user_name = $this->get_config('ftp_username');
|
||||
$ftp_user_pass = $this->get_config('ftp_password');
|
||||
@ -1046,11 +1061,11 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
|
||||
$dir = str_replace($serendipity['serendipityPath'],"",$dir);
|
||||
|
||||
|
||||
// set up basic connection and log in with username and password
|
||||
$conn_id = ftp_connect($ftp_server);
|
||||
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
|
||||
|
||||
|
||||
// check connection
|
||||
if ((!$conn_id) || (!$login_result)) {
|
||||
$this->outputMSG('error',PLUGIN_EVENT_SPARTACUS_FTP_ERROR_CONNECT);
|
||||
@ -1059,7 +1074,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$paths = preg_split('@/@', $basedir.$dir,-1,PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($paths as $path) {
|
||||
// trying to change directory, if not succesfull, it means
|
||||
// the directory does not exist and we must create it
|
||||
// the directory does not exist and we must create it
|
||||
if (!ftp_chdir($conn_id,$path)) {
|
||||
if (!ftp_mkdir($conn_id,$path)) {
|
||||
$this->outputMSG('error',PLUGIN_EVENT_SPARTACUS_FTP_ERROR_MKDIR);
|
||||
@ -1080,13 +1095,16 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
|
||||
function event_hook($event, &$bag, &$eventData, $addData = null) {
|
||||
function event_hook($event, &$bag, &$eventData, $addData = null)
|
||||
{
|
||||
global $serendipity;
|
||||
|
||||
$hooks = &$bag->get('event_hooks');
|
||||
|
||||
if (isset($hooks[$event])) {
|
||||
|
||||
switch($event) {
|
||||
|
||||
case 'cronjob':
|
||||
if ($this->get_config('cronjob') == $eventData) {
|
||||
serendipity_event_cronjob::log('Spartacus', 'plugin');
|
||||
@ -1099,25 +1117,25 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$avail['event'] = $this->buildList($this->fetchOnline('event'), 'event');
|
||||
$avail['sidebar'] = $this->buildList($this->fetchOnline('sidebar'), 'sidebar');
|
||||
#echo "XAVAIL:<pre>" . print_r($avail, true) . "</pre>";
|
||||
|
||||
|
||||
$install['event'] = serendipity_plugin_api::enum_plugin_classes(true);
|
||||
$install['sidebar'] = serendipity_plugin_api::enum_plugin_classes(false);
|
||||
#echo "XINSTALL:<pre>" . print_r($install, true) . "</pre>";
|
||||
|
||||
$mailtext = '';
|
||||
$mailtext = '';
|
||||
foreach($meth AS $method) {
|
||||
foreach ($install[$method] as $class_data) {
|
||||
#echo "Probe " . $class_data['name']. "<br />\n"; // DEBUG
|
||||
$pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
|
||||
$plugin = serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $method);
|
||||
|
||||
|
||||
if (is_object($plugin)) {
|
||||
#echo "Non cached<br />\n";
|
||||
#echo "<pre>" . print_r($avail[$method][$class_data['name']], true) . "</pre>";
|
||||
// Object is returned when a plugin could not be cached.
|
||||
$bag = new serendipity_property_bag;
|
||||
$plugin->introspect($bag);
|
||||
|
||||
|
||||
// If a foreign plugin is upgradable, keep the new version number.
|
||||
if (isset($avail[$method][$class_data['name']])) {
|
||||
$class_data['upgrade_version'] = $avail[$method][$class_data['name']]['upgrade_version'];
|
||||
@ -1132,7 +1150,7 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
$props = false;
|
||||
#echo "Error<br />\n";
|
||||
}
|
||||
|
||||
|
||||
if (is_array($props)) {
|
||||
#echo "<pre>" . print_r($props, true) . "</pre>\n";
|
||||
if (version_compare($props['version'], $props['upgrade_version'], '<')) {
|
||||
@ -1148,8 +1166,9 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
serendipity_sendMail($serendipity['blogMail'], 'Spartacus update report ' . $serendipity['baseURL'], $mailtext, $serendipity['blogMail']);
|
||||
echo nl2br($mailtext);
|
||||
}
|
||||
} else {
|
||||
$propbag->add('type', 'suboption');
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 'external_plugin':
|
||||
@ -1166,34 +1185,34 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
|
||||
$avail['event'] = $this->buildList($this->fetchOnline('event'), 'event');
|
||||
$avail['sidebar'] = $this->buildList($this->fetchOnline('sidebar'), 'sidebar');
|
||||
|
||||
|
||||
$install['event'] = serendipity_plugin_api::enum_plugin_classes(true);
|
||||
$install['sidebar'] = serendipity_plugin_api::enum_plugin_classes(false);
|
||||
|
||||
|
||||
foreach($meth AS $method) {
|
||||
echo "LISTING: $method\n-------------------\n";
|
||||
foreach ($install[$method] as $class_data) {
|
||||
$pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
|
||||
$plugin = serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $method);
|
||||
|
||||
|
||||
if (is_object($plugin)) {
|
||||
// Object is returned when a plugin could not be cached.
|
||||
$bag = new serendipity_property_bag;
|
||||
$plugin->introspect($bag);
|
||||
|
||||
|
||||
// If a foreign plugin is upgradable, keep the new version number.
|
||||
if (isset($avail[$method][$class_data['name']])) {
|
||||
$class_data['upgrade_version'] = $avail[$method][$class_data['name']]['upgrade_version'];
|
||||
}
|
||||
$props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $avail[$method]);
|
||||
|
||||
|
||||
} elseif (is_array($plugin)) {
|
||||
// Array is returned if a plugin could be fetched from info cache
|
||||
$props = $plugin;
|
||||
} else {
|
||||
$props = false;
|
||||
}
|
||||
|
||||
|
||||
if (is_array($props)) {
|
||||
#print_r($props);
|
||||
if (version_compare($props['version'], $props['upgrade_version'], '<')) {
|
||||
@ -1207,27 +1226,21 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 'backend_pluginlisting_header':
|
||||
if (serendipity_db_bool($this->get_config('enable_plugins'))) {
|
||||
echo '<div id="upgrade_notice" class="clearfix">';
|
||||
echo '<a id="upgrade_sidebar" class="button_link" href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE">'. PLUGIN_EVENT_SPARTACUS_CHECK_SIDEBAR .'</a>';
|
||||
echo '<a id="upgrade_event" class="button_link" href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE&serendipity[type]=event">'. PLUGIN_EVENT_SPARTACUS_CHECK_EVENT .'</a> ';
|
||||
echo ' <a id="upgrade_sidebar" class="button_link" href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE">'. PLUGIN_EVENT_SPARTACUS_CHECK_SIDEBAR .'</a>';
|
||||
echo ' <a id="upgrade_event" class="button_link" href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE&serendipity[type]=event">'. PLUGIN_EVENT_SPARTACUS_CHECK_EVENT .'</a> ';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 'backend_templates_fetchlist':
|
||||
if (serendipity_db_bool($this->get_config('enable_themes'))) {
|
||||
$eventData = $this->buildTemplateList($this->fetchOnline('template', true), 'template');
|
||||
}
|
||||
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 'backend_templates_fetchtemplate':
|
||||
@ -1240,8 +1253,6 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 'backend_plugins_fetchlist':
|
||||
@ -1255,8 +1266,6 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
'baseURI' => '&serendipity[spartacus_fetch]=' . $type
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
break;
|
||||
|
||||
case 'backend_plugins_fetchplugin':
|
||||
@ -1277,26 +1286,25 @@ class serendipity_event_spartacus extends serendipity_event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 'backend_directory_create' :
|
||||
case 'backend_directory_create':
|
||||
if (serendipity_db_bool($this->get_config('use_ftp')) && (!is_dir($eventData))) {
|
||||
return $this->make_dir_via_ftp($eventData);
|
||||
}
|
||||
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user