- (re)added feature : in remote site management, if a listing.xml file is
found at PhpWebGallery root directory, it can be used to update a remote site - size and maxlength of prefix_thumbnail in admin/configuration are 10 git-svn-id: http://piwigo.org/svn/trunk@534 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
c2ceeae013
commit
acfbcac7bb
5 changed files with 184 additions and 53 deletions
|
|
@ -158,6 +158,56 @@ INSERT INTO '.$table_name.'
|
||||||
mysql_query($query);
|
mysql_query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* read $listing_file and update a remote site according to its id
|
||||||
|
*
|
||||||
|
* @param string listing_file
|
||||||
|
* @param int site_id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function update_remote_site($listing_file, $site_id)
|
||||||
|
{
|
||||||
|
global $lang, $counts, $template, $removes, $errors;
|
||||||
|
|
||||||
|
if (@fopen($listing_file, 'r'))
|
||||||
|
{
|
||||||
|
$counts = array(
|
||||||
|
'new_elements' => 0,
|
||||||
|
'new_categories' => 0,
|
||||||
|
'del_elements' => 0,
|
||||||
|
'del_categories' => 0
|
||||||
|
);
|
||||||
|
$removes = array();
|
||||||
|
|
||||||
|
$xml_content = getXmlCode($listing_file);
|
||||||
|
insert_remote_category($xml_content, $site_id, 'NULL', 0);
|
||||||
|
update_category();
|
||||||
|
|
||||||
|
$template->assign_block_vars(
|
||||||
|
'update',
|
||||||
|
array(
|
||||||
|
'NB_NEW_CATEGORIES'=>$counts['new_categories'],
|
||||||
|
'NB_DEL_CATEGORIES'=>$counts['del_categories'],
|
||||||
|
'NB_NEW_ELEMENTS'=>$counts['new_elements'],
|
||||||
|
'NB_DEL_ELEMENTS'=>$counts['del_elements']
|
||||||
|
));
|
||||||
|
|
||||||
|
if (count($removes) > 0)
|
||||||
|
{
|
||||||
|
$template->assign_block_vars('update.removes', array());
|
||||||
|
}
|
||||||
|
foreach ($removes as $remove)
|
||||||
|
{
|
||||||
|
$template->assign_block_vars('update.removes.remote_remove',
|
||||||
|
array('NAME'=>$remove));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
array_push($errors, $lang['remote_site_listing_not_found']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* searchs the "dir" node of the xml_dir given and insert the contained
|
* searchs the "dir" node of the xml_dir given and insert the contained
|
||||||
* categories if the are not in the database yet. The function also deletes
|
* categories if the are not in the database yet. The function also deletes
|
||||||
|
|
@ -318,14 +368,21 @@ SELECT id,file
|
||||||
WHERE storage_category_id = '.$category_id.'
|
WHERE storage_category_id = '.$category_id.'
|
||||||
;';
|
;';
|
||||||
$result = mysql_query($query);
|
$result = mysql_query($query);
|
||||||
|
$to_delete = array();
|
||||||
while ($row = mysql_fetch_array($result))
|
while ($row = mysql_fetch_array($result))
|
||||||
{
|
{
|
||||||
if (!in_array($row['file'], $xml_files))
|
if (!in_array($row['file'], $xml_files))
|
||||||
{
|
{
|
||||||
array_push($removes, $row['file']);
|
// local_dir is cached
|
||||||
delete_element($row['id']);
|
if (!isset($local_dir))
|
||||||
|
{
|
||||||
|
$local_dir = get_local_dir($category_id);
|
||||||
|
}
|
||||||
|
array_push($removes, $local_dir.$row['file']);
|
||||||
|
array_push($to_delete, $row['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete_elements($to_delete);
|
||||||
|
|
||||||
$database_elements = array();
|
$database_elements = array();
|
||||||
$query = '
|
$query = '
|
||||||
|
|
@ -442,6 +499,9 @@ $template->assign_vars(
|
||||||
'L_NB_DEL_CATEGORIES'=>$lang['update_nb_del_categories'],
|
'L_NB_DEL_CATEGORIES'=>$lang['update_nb_del_categories'],
|
||||||
'L_REMOTE_SITE_REMOVED_TITLE'=>$lang['remote_site_removed_title'],
|
'L_REMOTE_SITE_REMOVED_TITLE'=>$lang['remote_site_removed_title'],
|
||||||
'L_REMOTE_SITE_REMOVED'=>$lang['remote_site_removed'],
|
'L_REMOTE_SITE_REMOVED'=>$lang['remote_site_removed'],
|
||||||
|
'L_REMOTE_SITE_LOCAL_FOUND'=>$lang['remote_site_local_found'],
|
||||||
|
'L_REMOTE_SITE_LOCAL_NEW'=>$lang['remote_site_local_new'],
|
||||||
|
'L_REMOTE_SITE_LOCAL_UPDATE'=>$lang['remote_site_local_update'],
|
||||||
|
|
||||||
'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=remote_site')
|
'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=remote_site')
|
||||||
)
|
)
|
||||||
|
|
@ -523,86 +583,120 @@ if (isset($_GET['site']) and is_numeric($_GET['site']))
|
||||||
|
|
||||||
if (isset($_GET['action']))
|
if (isset($_GET['action']))
|
||||||
{
|
{
|
||||||
$query = '
|
if (isset($page['site']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
SELECT galleries_url
|
SELECT galleries_url
|
||||||
FROM '.SITES_TABLE.'
|
FROM '.SITES_TABLE.'
|
||||||
WHERE id = '.$page['site'].'
|
WHERE id = '.$page['site'].'
|
||||||
;';
|
;';
|
||||||
$row = mysql_fetch_array(mysql_query($query));
|
list($galleries_url) = mysql_fetch_array(mysql_query($query));
|
||||||
$clf = $row['galleries_url'].'create_listing_file.php';
|
}
|
||||||
|
|
||||||
switch($_GET['action'])
|
switch($_GET['action'])
|
||||||
{
|
{
|
||||||
case 'delete' :
|
case 'delete' :
|
||||||
{
|
{
|
||||||
delete_site($page['site']);
|
delete_site($page['site']);
|
||||||
|
|
||||||
$template->assign_block_vars(
|
$template->assign_block_vars(
|
||||||
'confirmation',
|
'confirmation',
|
||||||
array(
|
array(
|
||||||
'CONTENT'=>$row['galleries_url'].' '.$lang['remote_site_deleted']
|
'CONTENT'=>$galleries_url.' '.$lang['remote_site_deleted']
|
||||||
));
|
));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'generate' :
|
case 'generate' :
|
||||||
{
|
{
|
||||||
$title = $row['galleries_url'].' : '.$lang['remote_site_generate'];
|
$title = $galleries_url.' : '.$lang['remote_site_generate'];
|
||||||
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
|
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
|
||||||
remote_output($clf.'?action=generate');
|
remote_output($galleries_url.'create_listing_file.php?action=generate');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'update' :
|
case 'update' :
|
||||||
{
|
{
|
||||||
$title = $row['galleries_url'].' : '.$lang['remote_site_update'];
|
$title = $galleries_url.' : '.$lang['remote_site_update'];
|
||||||
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
|
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
|
||||||
|
update_remote_site($galleries_url.'listing.xml', $page['site']);
|
||||||
if (@fopen($row['galleries_url'].'listing.xml', 'r'))
|
|
||||||
{
|
|
||||||
$counts = array(
|
|
||||||
'new_elements' => 0,
|
|
||||||
'new_categories' => 0,
|
|
||||||
'del_elements' => 0,
|
|
||||||
'del_categories' => 0
|
|
||||||
);
|
|
||||||
$removes = array();
|
|
||||||
|
|
||||||
$xml_content = getXmlCode($row['galleries_url'].'listing.xml');
|
|
||||||
insert_remote_category($xml_content, $page{'site'}, 'NULL', 0);
|
|
||||||
update_category();
|
|
||||||
|
|
||||||
$template->assign_block_vars(
|
|
||||||
'update',
|
|
||||||
array(
|
|
||||||
'NB_NEW_CATEGORIES'=>$counts['new_categories'],
|
|
||||||
'NB_DEL_CATEGORIES'=>$counts['del_categories'],
|
|
||||||
'NB_NEW_ELEMENTS'=>$counts['new_elements'],
|
|
||||||
'NB_DEL_ELEMENTS'=>$counts['del_elements']
|
|
||||||
));
|
|
||||||
|
|
||||||
if (count($removes) > 0)
|
|
||||||
{
|
|
||||||
$template->assign_block_vars('update.removes', array());
|
|
||||||
}
|
|
||||||
foreach ($removes as $remove)
|
|
||||||
{
|
|
||||||
$template->assign_block_vars('update.removes.remote_remove',
|
|
||||||
array('NAME'=>$remove));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
array_push($errors, $lang['remote_site_listing_not_found']);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'clean' :
|
case 'clean' :
|
||||||
{
|
{
|
||||||
$title = $row['galleries_url'].' : '.$lang['remote_site_clean'];
|
$title = $galleries_url.' : '.$lang['remote_site_clean'];
|
||||||
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
|
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
|
||||||
remote_output($clf.'?action=clean');
|
remote_output($galleries_url.'create_listing_file.php?action=clean');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'local_update' :
|
||||||
|
{
|
||||||
|
$local_listing = PHPWG_ROOT_PATH.'listing.xml';
|
||||||
|
$xml_content = getXmlCode($local_listing);
|
||||||
|
$url = getAttribute(getChild($xml_content, 'informations'), 'url');
|
||||||
|
|
||||||
|
// is the site already existing ?
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.SITES_TABLE.'
|
||||||
|
WHERE galleries_url = \''.addslashes($url).'\'
|
||||||
|
;';
|
||||||
|
$result = mysql_query($query);
|
||||||
|
if (mysql_num_rows($result) == 0)
|
||||||
|
{
|
||||||
|
// we have to register this site in the database
|
||||||
|
$query = '
|
||||||
|
INSERT INTO '.SITES_TABLE.'
|
||||||
|
(galleries_url)
|
||||||
|
VALUES
|
||||||
|
(\''.$url.'\')
|
||||||
|
;';
|
||||||
|
mysql_query($query);
|
||||||
|
$site_id = mysql_insert_id();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we get the already registered id
|
||||||
|
$row = mysql_fetch_array($result);
|
||||||
|
$site_id = $row['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = $url.' : '.$lang['remote_site_local_update'];
|
||||||
|
$template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
|
||||||
|
update_remote_site($local_listing, $site_id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we search a "local" listing.xml file
|
||||||
|
$local_listing = PHPWG_ROOT_PATH.'listing.xml';
|
||||||
|
if (is_file($local_listing))
|
||||||
|
{
|
||||||
|
$xml_content = getXmlCode($local_listing);
|
||||||
|
$url = getAttribute(getChild($xml_content, 'informations'), 'url');
|
||||||
|
|
||||||
|
$base_url = PHPWG_ROOT_PATH.'admin.php?page=remote_site&action=';
|
||||||
|
|
||||||
|
$template->assign_block_vars(
|
||||||
|
'local',
|
||||||
|
array(
|
||||||
|
'URL' => $url,
|
||||||
|
'U_UPDATE' => add_session_id($base_url.'local_update')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// is the site already existing ?
|
||||||
|
$query = '
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM '.SITES_TABLE.'
|
||||||
|
WHERE galleries_url = \''.addslashes($url).'\'
|
||||||
|
;';
|
||||||
|
list($count) = mysql_fetch_array(mysql_query($query));
|
||||||
|
if ($count == 0)
|
||||||
|
{
|
||||||
|
$template->assign_block_vars('local.new_site', array());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | en_UK/admin.lang.php |
|
// | en_UK/admin.lang.php |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | application : PhpWebGallery <http://phpwebgallery.net> |
|
// | application : PhpWebGallery <http://phpwebgallery.net> |
|
||||||
// | branch : BSF (Best So Far) |
|
// | branch : BSF (Best So Far) |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | file : $RCSfile$
|
// | file : $RCSfile$
|
||||||
// | last update : $Date$
|
// | last update : $Date$
|
||||||
|
|
@ -66,11 +66,14 @@ $lang['remote_site_delete'] = 'delete';
|
||||||
$lang['remote_site_delete_hint'] = 'delete this site and all its attached elements';
|
$lang['remote_site_delete_hint'] = 'delete this site and all its attached elements';
|
||||||
$lang['remote_site_file_not_found'] = 'file create_listing_file.php on remote site was not found';
|
$lang['remote_site_file_not_found'] = 'file create_listing_file.php on remote site was not found';
|
||||||
$lang['remote_site_error'] = 'an error happened';
|
$lang['remote_site_error'] = 'an error happened';
|
||||||
$lang['remote_site_listing_not_found'] = 'remote listing file was not found';
|
$lang['remote_site_listing_not_found'] = 'listing.xml file was not found';
|
||||||
$lang['remote_site_removed'] = 'was removed on remote site';
|
$lang['remote_site_removed'] = 'was removed on remote site';
|
||||||
$lang['remote_site_removed_title'] = 'Removed elements';
|
$lang['remote_site_removed_title'] = 'Removed elements';
|
||||||
$lang['remote_site_created'] = 'created';
|
$lang['remote_site_created'] = 'created';
|
||||||
$lang['remote_site_deleted'] = 'deleted';
|
$lang['remote_site_deleted'] = 'deleted';
|
||||||
|
$lang['remote_site_local_found'] = 'A local listing.xml file has been found for ';
|
||||||
|
$lang['remote_site_local_new'] = '(new site)';
|
||||||
|
$lang['remote_site_local_update'] = 'read local listing.xml and update';
|
||||||
|
|
||||||
// Categorie words
|
// Categorie words
|
||||||
$lang['cat_up'] = 'Move up';
|
$lang['cat_up'] = 'Move up';
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>{general.L_CONF_TN_PREFIX} :</strong><br /><span class="small">{general.L_CONF_TN_PREFIX_INFO}</span></td>
|
<td><strong>{general.L_CONF_TN_PREFIX} :</strong><br /><span class="small">{general.L_CONF_TN_PREFIX_INFO}</span></td>
|
||||||
<td class="row1"><input type="text" size="3" maxlength="4" name="prefix_thumbnail" value="{general.THUMBNAIL_PREFIX}" /></td>
|
<td class="row1"><input type="text" size="10" maxlength="10" name="prefix_thumbnail" value="{general.THUMBNAIL_PREFIX}" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>{general.L_CONF_ACCESS} :</strong><br /><span class="small">{general.L_CONF_ACCESS_INFO}</span></td>
|
<td><strong>{general.L_CONF_ACCESS} :</strong><br /><span class="small">{general.L_CONF_ACCESS_INFO}</span></td>
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,16 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- END remote_output -->
|
<!-- END remote_output -->
|
||||||
|
|
||||||
|
<!-- BEGIN local -->
|
||||||
|
<div class="remoteLocal">
|
||||||
|
{L_REMOTE_SITE_LOCAL_FOUND} {local.URL}
|
||||||
|
<!-- BEGIN new_site -->
|
||||||
|
{L_REMOTE_SITE_LOCAL_NEW}
|
||||||
|
<!-- END new_site -->
|
||||||
|
[<a href="{local.U_UPDATE}">{L_REMOTE_SITE_LOCAL_UPDATE}</a>]
|
||||||
|
</div>
|
||||||
|
<!-- END local -->
|
||||||
|
|
||||||
<form action="{F_ACTION}" method="post">
|
<form action="{F_ACTION}" method="post">
|
||||||
{L_REMOTE_SITE_CREATE}
|
{L_REMOTE_SITE_CREATE}
|
||||||
<input type="text" name="galleries_url" value="{F_GALLERIES_URL}" />
|
<input type="text" name="galleries_url" value="{F_GALLERIES_URL}" />
|
||||||
|
|
|
||||||
|
|
@ -412,3 +412,27 @@ span.update_error_element, span.update_category_error {
|
||||||
.update_summary_del {
|
.update_summary_del {
|
||||||
color:#ffe1e1;
|
color:#ffe1e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.remoteOutput, div.remoteLocal {
|
||||||
|
background-color:#444444;
|
||||||
|
border:1px solid black;
|
||||||
|
margin:10px;
|
||||||
|
text-align:left;
|
||||||
|
padding:5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.remoteInfo {
|
||||||
|
color:gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.remoteWarning {
|
||||||
|
color:#ffe1e1;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.remoteError {
|
||||||
|
color:orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.remoteLocal {
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue