Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F984801
PhabricatorEditPreferencesController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
PhabricatorEditPreferencesController.php
View Options
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class
PhabricatorEditPreferencesController
extends
PhabricatorPreferencesController
{
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$preferences
=
$user
->
loadPreferences
();
if
(
$request
->
isFormPost
())
{
$monospaced
=
$request
->
getStr
(
PhabricatorUserPreferences
::
PREFERENCE_MONOSPACED
);
// Prevent the user from doing stupid things.
$monospaced
=
preg_replace
(
'/[^a-z0-9 ,"]+/i'
,
''
,
$monospaced
);
$pref_dict
=
array
(
PhabricatorUserPreferences
::
PREFERENCE_TITLES
=>
$request
->
getStr
(
PhabricatorUserPreferences
::
PREFERENCE_TITLES
),
PhabricatorUserPreferences
::
PREFERENCE_MONOSPACED
=>
$monospaced
);
$preferences
->
setPreferences
(
$pref_dict
);
$preferences
->
save
();
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
'/preferences/?saved=true'
);
}
$example_string
=
<<<EXAMPLE
// This is what your monospaced font currently looks like.
function helloWorld() {
alert("Hello world!");
}
EXAMPLE;
$form
=
id
(
new
AphrontFormView
())
->
setAction
(
'/preferences/'
)
->
setUser
(
$user
)
->
appendChild
(
id
(
new
AphrontFormSelectControl
())
->
setLabel
(
'Page Titles'
)
->
setName
(
PhabricatorUserPreferences
::
PREFERENCE_TITLES
)
->
setValue
(
$preferences
->
getPreference
(
PhabricatorUserPreferences
::
PREFERENCE_TITLES
))
->
setOptions
(
array
(
'glyph'
=>
"In page titles, show Tool names as unicode glyphs:
\x
E2
\x
9A
\x
99"
,
'text'
=>
'In page titles, show Tool names as plain text: [Differential]'
,
)))
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setLabel
(
'Monospaced Font'
)
->
setName
(
PhabricatorUserPreferences
::
PREFERENCE_MONOSPACED
)
->
setCaption
(
'Overrides default fonts in tools like Differential. '
.
'(Default: 10px "Menlo", "Consolas", "Monaco", '
.
'monospace)'
)
->
setValue
(
$preferences
->
getPreference
(
PhabricatorUserPreferences
::
PREFERENCE_MONOSPACED
)))
->
appendChild
(
id
(
new
AphrontFormMarkupControl
())
->
setValue
(
'<pre class="PhabricatorMonospaced">'
.
phutil_escape_html
(
$example_string
).
'</pre>'
))
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
'Save Preferences'
));
$panel
=
new
AphrontPanelView
();
$panel
->
appendChild
(
$form
);
$error_view
=
null
;
if
(
$request
->
getStr
(
'saved'
)
===
'true'
)
{
$error_view
=
id
(
new
AphrontErrorView
())
->
setTitle
(
'Preferences Saved'
)
->
setSeverity
(
AphrontErrorView
::
SEVERITY_NOTICE
)
->
setErrors
(
array
(
'Your preferences have been saved.'
));
}
return
$this
->
buildStandardPageResponse
(
array
(
$error_view
,
$panel
,
),
array
(
'title'
=>
'Edit Preferences'
,
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jun 18, 3:35 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
237823
Default Alt Text
PhabricatorEditPreferencesController.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment