Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96473749
PhabricatorProjectWikiCreate.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Dec 27, 02:30
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Dec 29, 02:30 (2 d)
Engine
blob
Format
Raw Data
Handle
23190233
Attached To
rPHINFRA c4science
PhabricatorProjectWikiCreate.php
View Options
<?php
final
class
PhabricatorProjectWikiCreate
extends
PhabricatorController
{
public
function
shouldAllowPublic
()
{
return
false
;
}
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
(
int
)
$request
->
getURIData
(
'id'
);
$project
=
id
(
new
PhabricatorProjectQuery
())
->
withIDs
(
array
(
$id
))
->
setViewer
(
$viewer
)
->
needSlugs
(
true
)
->
executeOne
();
if
(!
$project
)
{
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Error'
))
->
setErrors
(
array
(
'Project doesn
\'
t exit'
))
->
addCancelButton
(
'/project/'
);
}
$project_slug
=
$project
->
getPrimarySlug
();
if
(
$request
->
isFormPost
())
{
$slug
=
PhabricatorSlug
::
normalize
(
$request
->
getStr
(
'slug'
));
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
'/phriction/edit/?slug='
.
$project_slug
.
'/'
.
$slug
);
}
$wiki_document
=
id
(
new
PhrictionDocumentQuery
())
->
setViewer
(
$viewer
)
->
withStatus
(
PhrictionDocumentQuery
::
STATUS_NONSTUB
)
->
withSlugPrefix
(
$project_slug
.
'/'
)
->
execute
();
if
(!
$wiki_document
){
$view
=
id
(
new
PHUIFormLayoutView
())
->
appendChild
(
phutil_tag
(
'p'
,
array
(),
pht
(
'/w/'
.
$project_slug
.
'/'
)));
}
else
{
$view
=
id
(
new
PHUIFormLayoutView
())
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setLabel
(
'/w/'
.
$project_slug
.
'/'
)
->
setValue
(
''
)
->
setName
(
'slug'
));
}
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'New Document'
))
->
setSubmitURI
(
'/project/wiki/create/'
.
$id
.
'/'
)
->
appendChild
(
phutil_tag
(
'p'
,
array
(),
pht
(
'Create a new document at'
)))
->
appendChild
(
$view
)
->
addSubmitButton
(
pht
(
'Create'
))
->
addCancelButton
(
'/project/view/'
.
$id
);
}
protected
function
buildApplicationCrumbs
()
{
$crumbs
=
parent
::
buildApplicationCrumbs
();
id
(
new
AlmanacServiceEditEngine
())
->
setViewer
(
$this
->
getViewer
())
->
addActionToCrumbs
(
$crumbs
);
return
$crumbs
;
}
}
Event Timeline
Log In to Comment