Skip to content
Browse files

Use a regular function for the callbacks (Fixes #138)

  • Loading branch information...
1 parent 6c86a8b commit de8afd1ef1ded4a09a1e542769dd08ee480410c8 @dshafik dshafik committed Apr 24, 2012
Showing with 26 additions and 14 deletions.
  1. +26 −14 src/frapi/custom/Output/html/Introduction.html.tpl
View
40 src/frapi/custom/Output/html/Introduction.html.tpl
@@ -6,33 +6,45 @@ function _makeAnchor($string)
return preg_replace('/[^a-zA-Z0-9_\-]+/', '', $string);
}
-$internal = new Frapi_Internal();
-$actions = $internal->getConfiguration('actions')->getAll('action');
-$errors = $internal->getConfiguration('errors')->getAll('error');
-$outputs = $internal->getConfiguration('outputs')->getAll('output');
-$mimetypes = $internal->getConfiguration('mimetypes')->getAll('mimetype');
-
-usort($actions, function($a, $b) {
+function _sortActions($a, $b)
+{
if ($a['route'] == '/') {
return -1;
}
return ($a['name'] < $b['name']) ? -1 : 1;
-});
+}
-usort($errors, function($a, $b) {
+function _sortErrors($a, $b)
+{
return ($a['http_code'] . $a['name'] < $b['http_code'] . $b['name']) ? -1 : 1;
-});
+}
-usort($outputs, function($a, $b) {
+function _sortOutputs($a, $b)
+{
if ($a['default'] == '1') {
return -1;
}
return ($a['name'] < $b['name']) ? -1 : 1;
-});
+}
-usort($mimetypes, function($a, $b) {
+function _sortMimetypes($a, $b)
+{
return ($a['output_format'] < $b['output_format']) ? -1 : 1;
-});
+}
+
+$internal = new Frapi_Internal();
+$actions = $internal->getConfiguration('actions')->getAll('action');
+$errors = $internal->getConfiguration('errors')->getAll('error');
+$outputs = $internal->getConfiguration('outputs')->getAll('output');
+$mimetypes = $internal->getConfiguration('mimetypes')->getAll('mimetype');
+
+usort($actions, '_sortActions');
+
+usort($errors, '_sortErrors');
+
+usort($outputs, '_sortOutputs');
+
+usort($mimetypes, '_sortMimetypes');
foreach ($mimetypes as $mimetype) {
$grouped[$mimetype['output_format']][] = $mimetype['mimetype'];

0 comments on commit de8afd1

Please sign in to comment.
Something went wrong with that request. Please try again.