Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
963f4156
Commit
963f4156
authored
Dec 26, 2017
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap action calls into own method to allow extension
parent
89df11c3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
11 deletions
+24
-11
options.php
qa-include/app/options.php
+1
-1
page.php
qa-include/app/page.php
+1
-1
BaseController.php
qa-src/Controllers/BaseController.php
+13
-0
UserMessages.php
qa-src/Controllers/User/UserMessages.php
+1
-1
Route.php
qa-src/Http/Route.php
+8
-8
No files found.
qa-include/app/options.php
View file @
963f4156
...
...
@@ -645,7 +645,7 @@ function qa_message_html_defaults()
/**
* Return $voteview parameter to pass to qa_post_html_fields() in /qa-include/app/format.php.
* @param $postorbasetype The post, or for compatibility just a basetype, i.e. 'Q', 'A' or 'C'
* @param
string|array
$postorbasetype The post, or for compatibility just a basetype, i.e. 'Q', 'A' or 'C'
* @param bool $full Whether full post is shown
* @param bool $enabledif Whether to do checks for voting buttons (i.e. will always disable voting if false)
* @return bool|string Possible values:
...
...
qa-include/app/page.php
View file @
963f4156
...
...
@@ -193,7 +193,7 @@ function qa_get_request_content()
qa_set_template
(
$route
->
getId
());
$controllerClass
=
$route
->
getController
();
$ctrl
=
new
$controllerClass
();
$qa_content
=
call_user_func_array
(
array
(
$ctrl
,
$route
->
getFunction
()
),
$route
->
getParameters
());
$qa_content
=
$ctrl
->
executeAction
(
$route
->
getAction
(
),
$route
->
getParameters
());
}
elseif
(
isset
(
$routing
[
$requestlower
]))
{
qa_set_template
(
$firstlower
);
...
...
qa-src/Controllers/BaseController.php
View file @
963f4156
...
...
@@ -21,4 +21,17 @@ namespace Q2A\Controllers;
abstract
class
BaseController
{
// TODO: constructor taking Database class parameter
/**
* Execute the given action with the given parameters on this controller.
*
* @param string $action Action to execute
* @param array $parameters Parameters to send to the action
*
* @return mixed
*/
public
function
executeAction
(
$action
,
$parameters
)
{
return
call_user_func_array
(
array
(
$this
,
$action
),
$parameters
);
}
}
qa-src/Controllers/User/UserMessages.php
View file @
963f4156
...
...
@@ -143,7 +143,7 @@ class UserMessages extends \Q2A\Controllers\BaseController
// Sub menu for navigation in user pages
$ismyuser
=
isset
(
$loginuserid
)
&&
$loginuserid
==
(
QA_FINAL_EXTERNAL_USERS
?
$userid
:
$useraccount
[
'userid'
])
;
$ismyuser
=
isset
(
$loginuserid
)
&&
$loginuserid
==
$useraccount
[
'userid'
]
;
$qa_content
[
'navigation'
][
'sub'
]
=
qa_user_sub_navigation
(
$handle
,
'wall'
,
$ismyuser
);
...
...
qa-src/Http/Route.php
View file @
963f4156
...
...
@@ -33,18 +33,18 @@ class Route
private
$controller
;
/** @var string */
private
$
fun
ction
;
private
$
a
ction
;
/** @var array */
private
$parameters
;
public
function
__construct
(
$id
=
null
,
$httpMethod
=
null
,
$routePath
=
null
,
$controller
=
null
,
$
fun
ction
=
null
)
public
function
__construct
(
$id
=
null
,
$httpMethod
=
null
,
$routePath
=
null
,
$controller
=
null
,
$
a
ction
=
null
)
{
$this
->
id
=
$id
;
$this
->
setHttpMethod
(
$httpMethod
);
$this
->
routePath
=
$routePath
;
$this
->
controller
=
$controller
;
$this
->
function
=
$fun
ction
;
$this
->
action
=
$a
ction
;
$this
->
parameters
=
array
();
}
...
...
@@ -126,17 +126,17 @@ class Route
/**
* @return string
*/
public
function
get
Fun
ction
()
public
function
get
A
ction
()
{
return
$this
->
fun
ction
;
return
$this
->
a
ction
;
}
/**
* @param string $
fun
ction
* @param string $
a
ction
*/
public
function
set
Function
(
$fun
ction
)
public
function
set
Action
(
$a
ction
)
{
$this
->
function
=
$fun
ction
;
$this
->
action
=
$a
ction
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment