Add use of core serializer

This commit is contained in:
Romain Neutron
2012-01-23 18:15:15 +01:00
parent 59fb747ca6
commit 7f0982848a
6 changed files with 345 additions and 288 deletions

View File

@@ -56,7 +56,7 @@ class Edit implements ControllerProviderInterface
try try
{ {
$VC = \databox_Field_VocabularyControl::get($vocabulary); $VC = \Alchemy\Phrasea\Vocabulary\Controller::get($vocabulary);
$databox = \databox::get_instance($sbas_id); $databox = \databox::get_instance($sbas_id);
} }
catch(\Exception $e) catch(\Exception $e)

View File

@@ -33,176 +33,194 @@ class Feed implements ControllerProviderInterface
{ {
$controllers = new ControllerCollection(); $controllers = new ControllerCollection();
/* @var $twig \Twig_Environment */ /* @var $twig \Twig_Environment */
$twig = $app['Core']->getTwig(); $twig = $app['Core']->getTwig();
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance();
/** /**
* I got a selection of docs, which publications are available forthese docs ? * I got a selection of docs, which publications are available forthese docs ?
*/ */
$controllers->post('/requestavailable/', function(Application $app, Request $request) use ($appbox, $twig) $controllers->post('/requestavailable/', function(Application $app, Request $request) use ($appbox, $twig)
{ {
$user = $app["Core"]->getAuthenticatedUser(); $user = $app["Core"]->getAuthenticatedUser();
$feeds = \Feed_Collection::load_all($appbox, $user); $feeds = \Feed_Collection::load_all($appbox, $user);
$request = $app['request']; $request = $app['request'];
$publishing = new RecordHelper\Feed($app['Core'], $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 * I've selected a publication for my ocs, let's publish them
*/ */
$controllers->post('/entry/create/', function(Application $app, Request $request) use ($appbox, $twig) $controllers->post('/entry/create/', function(Application $app, Request $request) use ($appbox, $twig)
{ {
try try
{ {
$user = $app["Core"]->getAuthenticatedUser(); $user = $app["Core"]->getAuthenticatedUser();
$feed = new \Feed_Adapter($appbox, $request->get('feed_id')); $feed = new \Feed_Adapter($appbox, $request->get('feed_id'));
$publisher = \Feed_Publisher_Adapter::getPublisher($appbox, $feed, $user); $publisher = \Feed_Publisher_Adapter::getPublisher($appbox, $feed, $user);
$title = $request->get('title'); $title = $request->get('title');
$subtitle = $request->get('subtitle'); $subtitle = $request->get('subtitle');
$author_name = $request->get('author_name'); $author_name = $request->get('author_name');
$author_mail = $request->get('author_mail'); $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) foreach ($publishing->get_elements() as $record)
{ {
$item = \Feed_Entry_Item::create($appbox, $entry, $record); $item = \Feed_Entry_Item::create($appbox, $entry, $record);
} }
$datas = array('error' => false, 'message' => false); $datas = array('error' => false, 'message' => false);
} }
catch (\Exception $e) catch (\Exception $e)
{ {
$datas = array('error' => true, 'message' => _('An error occured'), 'details' => $e->getMessage()); $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) $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()) if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
{ {
throw new \Exception_UnauthorizedAction(); 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) $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' => ''); continue;
try }
{
$appbox->get_connection()->beginTransaction();
$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()) $entry = $twig->render('prod/feeds/entry.html', array('entry' => $entry));
{
throw new \Exception_UnauthorizedAction();
}
$title = $request->get('title'); $datas = array('error' => false, 'message' => 'succes', 'datas' => $entry);
$subtitle = $request->get('subtitle'); }
$author_name = $request->get('author_name'); catch (\Exception_Feed_EntryNotFound $e)
$author_mail = $request->get('author_mail'); {
$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) $Serializer = $app['Core']['Serializer'];
->set_author_name($author_name)
->set_title($title)
->set_subtitle($subtitle);
$items = explode(';', $request->get('sorted_lst')); return new Response(
$Serializer->serialize($datas, 'json')
foreach ($items as $item_sort) , 200
{ , array('Content-Type' => 'application/json')
$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'));
});
$controllers->post('/entry/{id}/delete/', function(Application $app, Request $request, $id) use ($appbox, $twig) $controllers->post('/entry/{id}/delete/', function(Application $app, Request $request, $id) use ($appbox, $twig)
{ {
$datas = array('error' => true, 'message' => ''); $datas = array('error' => true, 'message' => '');
try try
{ {
$appbox->get_connection()->beginTransaction(); $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() if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()
&& $entry->get_feed()->is_owner($user) === false) && $entry->get_feed()->is_owner($user) === false)
{ {
throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher')); throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher'));
} }
$entry->delete(); $entry->delete();
$appbox->get_connection()->commit(); $appbox->get_connection()->commit();
$datas = array('error' => false, 'message' => 'succes'); $datas = array('error' => false, 'message' => 'succes');
} }
catch (\Exception_Feed_EntryNotFound $e) catch (\Exception_Feed_EntryNotFound $e)
{ {
$appbox->get_connection()->rollBack(); $appbox->get_connection()->rollBack();
$datas['message'] = _('Feed entry not found'); $datas['message'] = _('Feed entry not found');
} }
catch (\Exception $e) catch (\Exception $e)
{ {
$appbox->get_connection()->rollBack(); $appbox->get_connection()->rollBack();
$datas['message'] = $e->getMessage(); $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) //$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) $controllers->get('/', function(Application $app, Request $request) use ($appbox, $twig)
{ {
$request = $app['request']; $request = $app['request'];
$page = (int) $request->get('page'); $page = (int) $request->get('page');
$page = $page > 0 ? $page : 1; $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' $datas = $twig->render('prod/feeds/feeds.html'
, array( , array(
'feeds' => $feeds 'feeds' => $feeds
, 'feed' => $feeds->get_aggregate() , 'feed' => $feeds->get_aggregate()
, 'page' => $page , 'page' => $page
) )
); );
return new Response($datas); return new Response($datas);
}); });
$controllers->get('/feed/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig) $controllers->get('/feed/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig)
{ {
$page = (int) $request->get('page'); $page = (int) $request->get('page');
$page = $page > 0 ? $page : 1; $page = $page > 0 ? $page : 1;
$user = $app["Core"]->getAuthenticatedUser(); $user = $app["Core"]->getAuthenticatedUser();
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id); $feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
$feeds = \Feed_Collection::load_all($appbox, $user); $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) $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); $feeds = \Feed_Collection::load_all($appbox, $user);
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$output = \p4string::jsonencode( $output = array(
array( 'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
'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>
. '</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>', <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) $controllers->get('/subscribe/{id}/', function(Application $app, Request $request, $id) use ($appbox, $twig)
{ {
$renew = ($request->get('renew') === 'true'); $renew = ($request->get('renew') === 'true');
$user = $app["Core"]->getAuthenticatedUser(); $user = $app["Core"]->getAuthenticatedUser();
$feed = \Feed_Adapter::load_with_user($appbox, $user, $id); $feed = \Feed_Adapter::load_with_user($appbox, $user, $id);
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$output = \p4string::jsonencode( $output = array(
array( 'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
'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>
. '</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>', <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; return $controllers;
} }

View File

@@ -103,6 +103,8 @@ class Root implements ControllerProviderInterface
/* @var $twig \Twig_Environment */ /* @var $twig \Twig_Environment */
$twig = $app['Core']->getTwig(); $twig = $app['Core']->getTwig();
$Serializer = $app['Core']['Serializer'];
$out = $twig->render('prod/index.html.twig', array( $out = $twig->render('prod/index.html.twig', array(
'module_name' => 'Production', 'module_name' => 'Production',
@@ -122,8 +124,8 @@ class Root implements ControllerProviderInterface
'search_status' => \databox_status::getSearchStatus(), 'search_status' => \databox_status::getSearchStatus(),
'queries_history' => \queries::history(), 'queries_history' => \queries::history(),
'thesau_js_list' => $thjslist, 'thesau_js_list' => $thjslist,
'thesau_json_sbas' => \p4string::jsonencode($sbas), 'thesau_json_sbas' => $Serializer->serialize($sbas, 'json'),
'thesau_json_bas2sbas' => \p4string::jsonencode($bas2sbas), 'thesau_json_bas2sbas' => $Serializer->serialize($bas2sbas, 'json'),
'thesau_languages' => \User_Adapter::avLanguages(), 'thesau_languages' => \User_Adapter::avLanguages(),
'GV_bitly_user' => $registry->get('GV_bitly_user'), 'GV_bitly_user' => $registry->get('GV_bitly_user'),
'GV_bitly_key' => $registry->get('GV_bitly_key') 'GV_bitly_key' => $registry->get('GV_bitly_key')

View File

@@ -33,51 +33,57 @@ class Upgrader implements ControllerProviderInterface
$controllers = new ControllerCollection(); $controllers = new ControllerCollection();
$controllers->get('/', function() use ($app) $controllers->get('/', function() use ($app)
{ {
require_once __DIR__ . '/../../../../bootstrap.php'; require_once __DIR__ . '/../../../../bootstrap.php';
$upgrade_status = \Setup_Upgrade::get_status(); $upgrade_status = \Setup_Upgrade::get_status();
/* @var $twig \Twig_Environment */ /* @var $twig \Twig_Environment */
$twig = $app['Core']->getTwig(); $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');
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) $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) $controllers->post('/execute/', function() use ($app)
{ {
require_once __DIR__ . '/../../../../bootstrap.php'; require_once __DIR__ . '/../../../../bootstrap.php';
set_time_limit(0); set_time_limit(0);
session_write_close(); session_write_close();
ignore_user_abort(true); ignore_user_abort(true);
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance();
$upgrader = new \Setup_Upgrade($appbox); $upgrader = new \Setup_Upgrade($appbox);
$appbox->forceUpgrade($upgrader); $appbox->forceUpgrade($upgrader);
return; return;
}); });
return $controllers; return $controllers;
} }

View File

@@ -25,7 +25,6 @@ use Silex\ControllerCollection;
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
class ConnectionTest implements ControllerProviderInterface class ConnectionTest implements ControllerProviderInterface
{ {
@@ -34,70 +33,78 @@ class ConnectionTest implements ControllerProviderInterface
$controllers = new ControllerCollection(); $controllers = new ControllerCollection();
$controllers->get('/mysql/', function() use ($app) $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'; if ($row["Name"] === 'sitepreff')
$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); $is_appbox = true;
$connection_ok = true;
} }
catch (\Exception $e) if ($row["Name"] === 'pref')
{ {
$is_databox = true;
} }
}
}
catch (\Exception $e)
{
}
}
if ($dbname && $connection_ok === true) $Serializer = $app['Core']['Serializer'];
{
try
{
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname);
$db_ok = true;
$sql = "SHOW TABLE STATUS"; $datas = array(
$stmt = $conn->prepare($sql); 'connection' => $connection_ok
$stmt->execute(); , 'database' => $db_ok
, 'is_empty' => $empty
, 'is_appbox' => $is_appbox
, 'is_databox' => $is_databox
);
$empty = $stmt->rowCount() === 0; return new Response(
$Serializer->serialize($datas, 'json')
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC); , 200
$stmt->closeCursor(); , array('content-type' => 'application/json')
);
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 $controllers; return $controllers;
} }

View File

@@ -33,27 +33,43 @@ class PathFileTest implements ControllerProviderInterface
$controllers = new ControllerCollection(); $controllers = new ControllerCollection();
$controllers->get('/path/', function() use ($app) $controllers->get('/path/', function() use ($app)
{ {
$path = $app['request']->get('path'); $path = $app['request']->get('path');
return new Response(\p4string::jsonencode(array( $Serializer = $app['Core']['Serializer'];
'exists' => file_exists($path)
, 'file' => is_file($path) return new Response(
, 'dir' => is_dir($path) $Serializer->serialize(
, 'readable' => is_readable($path) array(
, 'writeable' => is_writable($path) 'exists' => file_exists($path)
, 'executable' => is_executable($path) , 'file' => is_file($path)
)), 200, array('application/json')); , '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) $controllers->get('/url/', function() use ($app)
{ {
$url = $app['request']->get('url'); $url = $app['request']->get('url');
return new Response(\p4string::jsonencode(array( return new Response(
'code' => \http_query::getHttpCodeFromUrl($url) $Serializer->serialize(
)), 200, array('application/json')); array(
}); 'code' => \http_query::getHttpCodeFromUrl($url)
)
, 'json'
)
, 200
, array('application/json')
);
});
return $controllers; return $controllers;