mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 14:33:14 +00:00
Add use of core serializer
This commit is contained in:
@@ -56,7 +56,7 @@ class Edit implements ControllerProviderInterface
|
||||
|
||||
try
|
||||
{
|
||||
$VC = \databox_Field_VocabularyControl::get($vocabulary);
|
||||
$VC = \Alchemy\Phrasea\Vocabulary\Controller::get($vocabulary);
|
||||
$databox = \databox::get_instance($sbas_id);
|
||||
}
|
||||
catch(\Exception $e)
|
||||
|
@@ -33,176 +33,194 @@ class Feed implements ControllerProviderInterface
|
||||
{
|
||||
$controllers = new ControllerCollection();
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
$appbox = \appbox::get_instance();
|
||||
$twig = $app['Core']->getTwig();
|
||||
$appbox = \appbox::get_instance();
|
||||
|
||||
/**
|
||||
* I got a selection of docs, which publications are available forthese docs ?
|
||||
*/
|
||||
$controllers->post('/requestavailable/', function(Application $app, Request $request) use ($appbox, $twig)
|
||||
{
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$request = $app['request'];
|
||||
$publishing = new RecordHelper\Feed($app['Core'], $request);
|
||||
{
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$request = $app['request'];
|
||||
$publishing = new RecordHelper\Feed($app['Core'], $request);
|
||||
|
||||
$datas = $twig->render('prod/actions/publish/publish.html', array('publishing' => $publishing, 'feeds' => $feeds));
|
||||
$datas = $twig->render('prod/actions/publish/publish.html', array('publishing' => $publishing, 'feeds' => $feeds));
|
||||
|
||||
return new Response($datas);
|
||||
});
|
||||
return new Response($datas);
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* I've selected a publication for my ocs, let's publish them
|
||||
*/
|
||||
$controllers->post('/entry/create/', function(Application $app, Request $request) use ($appbox, $twig)
|
||||
{
|
||||
try
|
||||
{
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feed = new \Feed_Adapter($appbox, $request->get('feed_id'));
|
||||
$publisher = \Feed_Publisher_Adapter::getPublisher($appbox, $feed, $user);
|
||||
{
|
||||
try
|
||||
{
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feed = new \Feed_Adapter($appbox, $request->get('feed_id'));
|
||||
$publisher = \Feed_Publisher_Adapter::getPublisher($appbox, $feed, $user);
|
||||
|
||||
$title = $request->get('title');
|
||||
$subtitle = $request->get('subtitle');
|
||||
$author_name = $request->get('author_name');
|
||||
$author_mail = $request->get('author_mail');
|
||||
$title = $request->get('title');
|
||||
$subtitle = $request->get('subtitle');
|
||||
$author_name = $request->get('author_name');
|
||||
$author_mail = $request->get('author_mail');
|
||||
|
||||
$entry = \Feed_Entry_Adapter::create($appbox, $feed, $publisher, $title, $subtitle, $author_name, $author_mail);
|
||||
$entry = \Feed_Entry_Adapter::create($appbox, $feed, $publisher, $title, $subtitle, $author_name, $author_mail);
|
||||
|
||||
$publishing = new RecordHelper\Feed($app['Core'], $app['request']);
|
||||
$publishing = new RecordHelper\Feed($app['Core'], $app['request']);
|
||||
|
||||
foreach ($publishing->get_elements() as $record)
|
||||
{
|
||||
$item = \Feed_Entry_Item::create($appbox, $entry, $record);
|
||||
}
|
||||
$datas = array('error' => false, 'message' => false);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$datas = array('error' => true, 'message' => _('An error occured'), 'details' => $e->getMessage());
|
||||
}
|
||||
foreach ($publishing->get_elements() as $record)
|
||||
{
|
||||
$item = \Feed_Entry_Item::create($appbox, $entry, $record);
|
||||
}
|
||||
$datas = array('error' => false, 'message' => false);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$datas = array('error' => true, 'message' => _('An error occured'), 'details' => $e->getMessage());
|
||||
}
|
||||
|
||||
return new Response(\p4string::jsonencode($datas), 200, array('Content-Type' => 'application/json'));
|
||||
});
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json')
|
||||
, 200
|
||||
, array('Content-Type' => 'application/json')
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$controllers->get('/entry/{id}/edit/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
{
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
|
||||
{
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
}
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
|
||||
{
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
}
|
||||
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
|
||||
$datas = $twig->render('prod/actions/publish/publish_edit.html', array('entry' => $entry, 'feeds' => $feeds));
|
||||
$datas = $twig->render('prod/actions/publish/publish_edit.html', array('entry' => $entry, 'feeds' => $feeds));
|
||||
|
||||
return new Response($datas);
|
||||
});
|
||||
return new Response($datas);
|
||||
});
|
||||
|
||||
|
||||
$controllers->post('/entry/{id}/update/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$datas = array('error' => true, 'message' => '', 'datas' => '');
|
||||
try
|
||||
{
|
||||
$appbox->get_connection()->beginTransaction();
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
|
||||
{
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
}
|
||||
|
||||
$title = $request->get('title');
|
||||
$subtitle = $request->get('subtitle');
|
||||
$author_name = $request->get('author_name');
|
||||
$author_mail = $request->get('author_mail');
|
||||
|
||||
$entry->set_author_email($author_mail)
|
||||
->set_author_name($author_name)
|
||||
->set_title($title)
|
||||
->set_subtitle($subtitle);
|
||||
|
||||
$items = explode(';', $request->get('sorted_lst'));
|
||||
|
||||
foreach ($items as $item_sort)
|
||||
{
|
||||
$item_sort_datas = explode('_', $item_sort);
|
||||
if (count($item_sort_datas) != 2)
|
||||
{
|
||||
$datas = array('error' => true, 'message' => '', 'datas' => '');
|
||||
try
|
||||
{
|
||||
$appbox->get_connection()->beginTransaction();
|
||||
continue;
|
||||
}
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$item = new \Feed_Entry_Item($appbox, $entry, $item_sort_datas[0]);
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
$item->set_ord($item_sort_datas[1]);
|
||||
}
|
||||
$appbox->get_connection()->commit();
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
|
||||
{
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
}
|
||||
$entry = $twig->render('prod/feeds/entry.html', array('entry' => $entry));
|
||||
|
||||
$title = $request->get('title');
|
||||
$subtitle = $request->get('subtitle');
|
||||
$author_name = $request->get('author_name');
|
||||
$author_mail = $request->get('author_mail');
|
||||
$datas = array('error' => false, 'message' => 'succes', 'datas' => $entry);
|
||||
}
|
||||
catch (\Exception_Feed_EntryNotFound $e)
|
||||
{
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
$entry->set_author_email($author_mail)
|
||||
->set_author_name($author_name)
|
||||
->set_title($title)
|
||||
->set_subtitle($subtitle);
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
$items = explode(';', $request->get('sorted_lst'));
|
||||
|
||||
foreach ($items as $item_sort)
|
||||
{
|
||||
$item_sort_datas = explode('_', $item_sort);
|
||||
if (count($item_sort_datas) != 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = new \Feed_Entry_Item($appbox, $entry, $item_sort_datas[0]);
|
||||
|
||||
$item->set_ord($item_sort_datas[1]);
|
||||
}
|
||||
$appbox->get_connection()->commit();
|
||||
|
||||
$entry = $twig->render('prod/feeds/entry.html', array('entry' => $entry));
|
||||
|
||||
$datas = array('error' => false, 'message' => 'succes', 'datas' => $entry);
|
||||
}
|
||||
catch (\Exception_Feed_EntryNotFound $e)
|
||||
{
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return new Response(\p4string::jsonencode($datas), 200, array('Content-Type' => 'application/json'));
|
||||
});
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json')
|
||||
, 200
|
||||
, array('Content-Type' => 'application/json')
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$controllers->post('/entry/{id}/delete/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$datas = array('error' => true, 'message' => '');
|
||||
try
|
||||
{
|
||||
$appbox->get_connection()->beginTransaction();
|
||||
{
|
||||
$datas = array('error' => true, 'message' => '');
|
||||
try
|
||||
{
|
||||
$appbox->get_connection()->beginTransaction();
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($appbox, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()
|
||||
&& $entry->get_feed()->is_owner($user) === false)
|
||||
{
|
||||
throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher'));
|
||||
}
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()
|
||||
&& $entry->get_feed()->is_owner($user) === false)
|
||||
{
|
||||
throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher'));
|
||||
}
|
||||
|
||||
$entry->delete();
|
||||
$entry->delete();
|
||||
|
||||
$appbox->get_connection()->commit();
|
||||
$datas = array('error' => false, 'message' => 'succes');
|
||||
}
|
||||
catch (\Exception_Feed_EntryNotFound $e)
|
||||
{
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
$appbox->get_connection()->commit();
|
||||
$datas = array('error' => false, 'message' => 'succes');
|
||||
}
|
||||
catch (\Exception_Feed_EntryNotFound $e)
|
||||
{
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$appbox->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return new Response(\p4string::jsonencode($datas), 200, array('Content-Type' => 'application/json'));
|
||||
});
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json')
|
||||
, 200
|
||||
, array('Content-Type' => 'application/json')
|
||||
);
|
||||
});
|
||||
|
||||
//$app->post('/entry/{id}/addelement/', function($id) use ($app, $appbox, $twig)
|
||||
// {
|
||||
@@ -224,84 +242,92 @@ class Feed implements ControllerProviderInterface
|
||||
// });
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request) use ($appbox, $twig)
|
||||
{
|
||||
$request = $app['request'];
|
||||
$page = (int) $request->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
{
|
||||
$request = $app['request'];
|
||||
$page = (int) $request->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
|
||||
$datas = $twig->render('prod/feeds/feeds.html'
|
||||
, array(
|
||||
'feeds' => $feeds
|
||||
, 'feed' => $feeds->get_aggregate()
|
||||
, 'page' => $page
|
||||
)
|
||||
);
|
||||
$datas = $twig->render('prod/feeds/feeds.html'
|
||||
, array(
|
||||
'feeds' => $feeds
|
||||
, 'feed' => $feeds->get_aggregate()
|
||||
, 'page' => $page
|
||||
)
|
||||
);
|
||||
|
||||
return new Response($datas);
|
||||
});
|
||||
return new Response($datas);
|
||||
});
|
||||
|
||||
|
||||
$controllers->get('/feed/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$page = (int) $request->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
{
|
||||
$page = (int) $request->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
|
||||
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
|
||||
$datas = $twig->render('prod/feeds/feeds.html', array('feed' => $feed, 'feeds' => $feeds, 'page' => $page));
|
||||
$datas = $twig->render('prod/feeds/feeds.html', array('feed' => $feed, 'feeds' => $feeds, 'page' => $page));
|
||||
|
||||
return new Response($datas);
|
||||
});
|
||||
return new Response($datas);
|
||||
});
|
||||
|
||||
|
||||
$controllers->get('/subscribe/aggregated/', function(Application $app, Request $request) use ( $appbox, $twig)
|
||||
{
|
||||
$renew = ($request->get('renew') === 'true');
|
||||
{
|
||||
$renew = ($request->get('renew') === 'true');
|
||||
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$registry = $appbox->get_registry();
|
||||
$feeds = \Feed_Collection::load_all($appbox, $user);
|
||||
$registry = $appbox->get_registry();
|
||||
|
||||
|
||||
$output = \p4string::jsonencode(
|
||||
array(
|
||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
$output = array(
|
||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
<div><input type="text" readonly="readonly" class="input_select_copy" value="' . $feeds->get_aggregate()->get_user_link($registry, $user, \Feed_Adapter::FORMAT_RSS, null, $renew)->get_href() . '"/></div>',
|
||||
'titre' => _('publications::votre rss personnel')
|
||||
)
|
||||
);
|
||||
'titre' => _('publications::votre rss personnel')
|
||||
);
|
||||
|
||||
return new Response($output, 200, array('Content-Type' => 'application/json'));
|
||||
});
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($output, 'json')
|
||||
, 200
|
||||
, array('Content-Type' => 'application/json')
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$controllers->get('/subscribe/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig)
|
||||
{
|
||||
$renew = ($request->get('renew') === 'true');
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
|
||||
$registry = $appbox->get_registry();
|
||||
{
|
||||
$renew = ($request->get('renew') === 'true');
|
||||
$user = $app["Core"]->getAuthenticatedUser();
|
||||
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
|
||||
$registry = $appbox->get_registry();
|
||||
|
||||
$output = \p4string::jsonencode(
|
||||
array(
|
||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
$output = array(
|
||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
<div><input type="text" style="width:100%" value="' . $feed->get_user_link($registry, $user, \Feed_Adapter::FORMAT_RSS, null, $renew)->get_href() . '"/></div>',
|
||||
'titre' => _('publications::votre rss personnel')
|
||||
)
|
||||
);
|
||||
'titre' => _('publications::votre rss personnel')
|
||||
);
|
||||
|
||||
return new Response($output, 200, array('Content-Type' => 'application/json'));
|
||||
});
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($output, 'json')
|
||||
, 200
|
||||
, array('Content-Type' => 'application/json')
|
||||
);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -103,6 +103,8 @@ class Root implements ControllerProviderInterface
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
$out = $twig->render('prod/index.html.twig', array(
|
||||
'module_name' => 'Production',
|
||||
@@ -122,8 +124,8 @@ class Root implements ControllerProviderInterface
|
||||
'search_status' => \databox_status::getSearchStatus(),
|
||||
'queries_history' => \queries::history(),
|
||||
'thesau_js_list' => $thjslist,
|
||||
'thesau_json_sbas' => \p4string::jsonencode($sbas),
|
||||
'thesau_json_bas2sbas' => \p4string::jsonencode($bas2sbas),
|
||||
'thesau_json_sbas' => $Serializer->serialize($sbas, 'json'),
|
||||
'thesau_json_bas2sbas' => $Serializer->serialize($bas2sbas, 'json'),
|
||||
'thesau_languages' => \User_Adapter::avLanguages(),
|
||||
'GV_bitly_user' => $registry->get('GV_bitly_user'),
|
||||
'GV_bitly_key' => $registry->get('GV_bitly_key')
|
||||
|
@@ -33,51 +33,57 @@ class Upgrader implements ControllerProviderInterface
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/', function() use ($app)
|
||||
{
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
$upgrade_status = \Setup_Upgrade::get_status();
|
||||
{
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
$upgrade_status = \Setup_Upgrade::get_status();
|
||||
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
$html = $twig->render(
|
||||
'/setup/upgrader.html.twig'
|
||||
, array(
|
||||
'locale' => \Session_Handler::get_locale()
|
||||
, 'upgrade_status' => $upgrade_status
|
||||
, 'available_locales' => $app['Core']::getAvailableLanguages()
|
||||
, 'bad_users' => \User_Adapter::get_wrong_email_users(\appbox::get_instance())
|
||||
, 'version_number' => $app['Core']['Version']->getNumber()
|
||||
, 'version_name' => $app['Core']['Version']->getName()
|
||||
)
|
||||
);
|
||||
ini_set('display_errors', 'on');
|
||||
/* @var $twig \Twig_Environment */
|
||||
$twig = $app['Core']->getTwig();
|
||||
|
||||
return new Response($html);
|
||||
});
|
||||
$html = $twig->render(
|
||||
'/setup/upgrader.html.twig'
|
||||
, array(
|
||||
'locale' => \Session_Handler::get_locale()
|
||||
, 'upgrade_status' => $upgrade_status
|
||||
, 'available_locales' => $app['Core']::getAvailableLanguages()
|
||||
, 'bad_users' => \User_Adapter::get_wrong_email_users(\appbox::get_instance())
|
||||
, 'version_number' => $app['Core']['Version']->getNumber()
|
||||
, 'version_name' => $app['Core']['Version']->getName()
|
||||
)
|
||||
);
|
||||
ini_set('display_errors', 'on');
|
||||
|
||||
return new Response($html);
|
||||
});
|
||||
|
||||
$controllers->get('/status/', function() use ($app)
|
||||
{
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
{
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
|
||||
$datas = \Setup_Upgrade::get_status();
|
||||
$datas = \Setup_Upgrade::get_status();
|
||||
|
||||
return new Response(\p4string::jsonencode($datas), 200, array('Content-Type: application/json'));
|
||||
});
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json')
|
||||
, 200
|
||||
, array('Content-Type: application/json')
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->post('/execute/', function() use ($app)
|
||||
{
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
set_time_limit(0);
|
||||
session_write_close();
|
||||
ignore_user_abort(true);
|
||||
{
|
||||
require_once __DIR__ . '/../../../../bootstrap.php';
|
||||
set_time_limit(0);
|
||||
session_write_close();
|
||||
ignore_user_abort(true);
|
||||
|
||||
$appbox = \appbox::get_instance();
|
||||
$upgrader = new \Setup_Upgrade($appbox);
|
||||
$appbox->forceUpgrade($upgrader);
|
||||
$appbox = \appbox::get_instance();
|
||||
$upgrader = new \Setup_Upgrade($appbox);
|
||||
$appbox->forceUpgrade($upgrader);
|
||||
|
||||
return;
|
||||
});
|
||||
return;
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ use Silex\ControllerCollection;
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
|
||||
class ConnectionTest implements ControllerProviderInterface
|
||||
{
|
||||
|
||||
@@ -34,70 +33,78 @@ class ConnectionTest implements ControllerProviderInterface
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/mysql/', function() use ($app)
|
||||
{
|
||||
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
||||
|
||||
$request = $app['request'];
|
||||
$hostname = $request->get('hostname', '127.0.0.1');
|
||||
$port = (int) $request->get('port', 3306);
|
||||
$user = $request->get('user');
|
||||
$password = $request->get('password');
|
||||
$dbname = $request->get('dbname');
|
||||
|
||||
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
||||
|
||||
try
|
||||
{
|
||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password);
|
||||
$connection_ok = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if ($dbname && $connection_ok === true)
|
||||
{
|
||||
try
|
||||
{
|
||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname);
|
||||
$db_ok = true;
|
||||
|
||||
$sql = "SHOW TABLE STATUS";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
$empty = $stmt->rowCount() === 0;
|
||||
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
require_once __DIR__ . '/../../../../classes/connection/pdo.class.php';
|
||||
|
||||
$request = $app['request'];
|
||||
$hostname = $request->get('hostname', '127.0.0.1');
|
||||
$port = (int) $request->get('port', 3306);
|
||||
$user = $request->get('user');
|
||||
$password = $request->get('password');
|
||||
$dbname = $request->get('dbname');
|
||||
|
||||
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
||||
|
||||
try
|
||||
if ($row["Name"] === 'sitepreff')
|
||||
{
|
||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password);
|
||||
$connection_ok = true;
|
||||
$is_appbox = true;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
if ($row["Name"] === 'pref')
|
||||
{
|
||||
|
||||
$is_databox = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($dbname && $connection_ok === true)
|
||||
{
|
||||
try
|
||||
{
|
||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname);
|
||||
$db_ok = true;
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
$sql = "SHOW TABLE STATUS";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$datas = array(
|
||||
'connection' => $connection_ok
|
||||
, 'database' => $db_ok
|
||||
, 'is_empty' => $empty
|
||||
, 'is_appbox' => $is_appbox
|
||||
, 'is_databox' => $is_databox
|
||||
);
|
||||
|
||||
$empty = $stmt->rowCount() === 0;
|
||||
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $row)
|
||||
{
|
||||
if ($row["Name"] === 'sitepreff')
|
||||
{
|
||||
$is_appbox = true;
|
||||
}
|
||||
if ($row["Name"] === 'pref')
|
||||
{
|
||||
$is_databox = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return new Response(\p4string::jsonencode(array(
|
||||
'connection' => $connection_ok
|
||||
, 'database' => $db_ok
|
||||
, 'is_empty' => $empty
|
||||
, 'is_appbox' => $is_appbox
|
||||
, 'is_databox' => $is_databox
|
||||
)), 200, array('content-type' => 'application/json'));
|
||||
});
|
||||
return new Response(
|
||||
$Serializer->serialize($datas, 'json')
|
||||
, 200
|
||||
, array('content-type' => 'application/json')
|
||||
);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -33,27 +33,43 @@ class PathFileTest implements ControllerProviderInterface
|
||||
$controllers = new ControllerCollection();
|
||||
|
||||
$controllers->get('/path/', function() use ($app)
|
||||
{
|
||||
$path = $app['request']->get('path');
|
||||
{
|
||||
$path = $app['request']->get('path');
|
||||
|
||||
return new Response(\p4string::jsonencode(array(
|
||||
'exists' => file_exists($path)
|
||||
, 'file' => is_file($path)
|
||||
, 'dir' => is_dir($path)
|
||||
, 'readable' => is_readable($path)
|
||||
, 'writeable' => is_writable($path)
|
||||
, 'executable' => is_executable($path)
|
||||
)), 200, array('application/json'));
|
||||
});
|
||||
$Serializer = $app['Core']['Serializer'];
|
||||
|
||||
return new Response(
|
||||
$Serializer->serialize(
|
||||
array(
|
||||
'exists' => file_exists($path)
|
||||
, 'file' => is_file($path)
|
||||
, 'dir' => is_dir($path)
|
||||
, 'readable' => is_readable($path)
|
||||
, 'writeable' => is_writable($path)
|
||||
, 'executable' => is_executable($path)
|
||||
)
|
||||
, 'json'
|
||||
)
|
||||
, 200
|
||||
, array('application/json')
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->get('/url/', function() use ($app)
|
||||
{
|
||||
$url = $app['request']->get('url');
|
||||
{
|
||||
$url = $app['request']->get('url');
|
||||
|
||||
return new Response(\p4string::jsonencode(array(
|
||||
'code' => \http_query::getHttpCodeFromUrl($url)
|
||||
)), 200, array('application/json'));
|
||||
});
|
||||
return new Response(
|
||||
$Serializer->serialize(
|
||||
array(
|
||||
'code' => \http_query::getHttpCodeFromUrl($url)
|
||||
)
|
||||
, 'json'
|
||||
)
|
||||
, 200
|
||||
, array('application/json')
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
return $controllers;
|
||||
|
Reference in New Issue
Block a user