Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-server
Commits
3b834f25
You need to sign in or sign up before continuing.
Commit
3b834f25
authored
Sep 07, 2018
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Задача 12799] Добавил контроллер для получения ссылки на редактирование
parent
4e191350
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
+33
-4
Typos.php
cp/application/controllers/users/Typos.php
+33
-4
No files found.
cp/application/controllers/users/Typos.php
View file @
3b834f25
...
@@ -76,6 +76,13 @@ class Typos extends CI_Controller {
...
@@ -76,6 +76,13 @@ class Typos extends CI_Controller {
return
;
return
;
}
}
private
function
createJsonResponse
(
$data
,
int
$status
=
200
)
{
$this
->
output
->
set_content_type
(
'application/json'
)
->
set_status_header
(
$status
)
->
set_output
(
json_encode
(
$data
));
}
/**
/**
* Устанавливает статус опечатки, если status = 0, то опечатка отправляется
* Устанавливает статус опечатки, если status = 0, то опечатка отправляется
* в архив, при этом автоматического исправления не происходит, иначе
* в архив, при этом автоматического исправления не происходит, иначе
...
@@ -133,10 +140,32 @@ class Typos extends CI_Controller {
...
@@ -133,10 +140,32 @@ class Typos extends CI_Controller {
$response
[
"message"
]
=
$e
->
getMessage
();
$response
[
"message"
]
=
$e
->
getMessage
();
}
}
return
$this
->
output
return
$this
->
createJsonResponse
(
$data
);
->
set_content_type
(
'application/json'
)
}
->
set_status_header
(
200
)
->
set_output
(
json_encode
(
$response
));
/**
* Получает ссылку на редактирование статьи и возвращает её
*
* @return string JSON массив, по ключу editUrl находится url для редактирования статьи
*/
function
getEditUrl
()
{
if
(
!
$this
->
input
->
get
(
"typoId"
))
{
return
$this
->
createJsonResponse
(
""
,
400
);
}
$typoId
=
intval
(
$this
->
input
->
get
(
"typoId"
));
$response
=
[
"editUrl"
=>
""
];
try
{
$response
[
"editUrl"
]
=
$this
->
typo
->
getArticleEditUrl
(
$typoId
);
}
catch
(
Exception
$e
)
{
log_message
(
"error"
,
`Failed to get article edit url: {$e->getMessage()}`
);
}
return
$this
->
createJsonResponse
(
$response
);
}
}
/**
/**
...
...
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