123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- require_once INSTALLDIR . '/lib/form.php';
- class ApplicationEditForm extends Form
- {
-
- var $application = null;
-
- function __construct($out=null, $application=null)
- {
- parent::__construct($out);
- $this->application = $application;
- }
-
- function id()
- {
- if ($this->application) {
- return 'form_application_edit-' . $this->application->id;
- } else {
- return 'form_application_add';
- }
- }
-
- function method()
- {
- $this->enctype = 'multipart/form-data';
- return 'post';
- }
-
- function formClass()
- {
- return 'form_settings';
- }
-
- function action()
- {
- $cur = common_current_user();
- if (!empty($this->application)) {
- return common_local_url('editapplication',
- array('id' => $this->application->id));
- } else {
- return common_local_url('newapplication');
- }
- }
-
- function formLegend()
- {
-
- $this->out->element('legend', null, _('Edit application'));
- }
-
- function formData()
- {
- if ($this->application) {
- $id = $this->application->id;
- $icon = $this->application->icon;
- $name = $this->application->name;
- $description = $this->application->description;
- $source_url = $this->application->source_url;
- $organization = $this->application->organization;
- $homepage = $this->application->homepage;
- $callback_url = $this->application->callback_url;
- $this->type = $this->application->type;
- $this->access_type = $this->application->access_type;
- } else {
- $id = '';
- $icon = '';
- $name = '';
- $description = '';
- $source_url = '';
- $organization = '';
- $homepage = '';
- $callback_url = '';
- $this->type = '';
- $this->access_type = '';
- }
- $this->out->elementStart('ul', 'form_data');
- $this->out->elementStart('li', array('id' => 'application_icon'));
- if (!empty($icon)) {
- $this->out->element('img', array('src' => $icon));
- }
- $this->out->element('input', array('name' => 'MAX_FILE_SIZE',
- 'type' => 'hidden',
- 'id' => 'MAX_FILE_SIZE',
- 'value' => ImageFile::maxFileSizeInt()));
- $this->out->element('label', array('for' => 'app_icon'),
-
- _('Icon'));
- $this->out->element('input', array('name' => 'app_icon',
- 'type' => 'file',
- 'id' => 'app_icon'));
-
- $this->out->element('p', 'form_guide', _('Icon for this application'));
- $this->out->elementEnd('li');
- $this->out->elementStart('li');
- $this->out->hidden('application_id', $id);
-
- $this->out->input('name', _('Name'),
- ($this->out->arg('name')) ? $this->out->arg('name') : $name);
- $this->out->elementEnd('li');
- $this->out->elementStart('li');
- $maxDesc = Oauth_application::maxDesc();
- if ($maxDesc > 0) {
-
-
- $descInstr = sprintf(_m('Describe your application in %d character','Describe your application in %d characters',$maxDesc),
- $maxDesc);
- } else {
-
- $descInstr = _('Describe your application');
- }
-
- $this->out->textarea('description', _('Description'),
- ($this->out->arg('description')) ? $this->out->arg('description') : $description,
- $descInstr);
- $this->out->elementEnd('li');
- $this->out->elementStart('li');
-
- $instruction = _('URL of the homepage of this application');
-
- $this->out->input('source_url', _('Source URL'),
- ($this->out->arg('source_url')) ? $this->out->arg('source_url') : $source_url,
- $instruction);
- $this->out->elementEnd('li');
- $this->out->elementStart('li');
-
- $instruction = _('Organization responsible for this application');
-
- $this->out->input('organization', _('Organization'),
- ($this->out->arg('organization')) ? $this->out->arg('organization') : $organization,
- $instruction);
- $this->out->elementEnd('li');
- $this->out->elementStart('li');
-
- $instruction = _('URL for the homepage of the organization');
-
- $this->out->input('homepage', _('Homepage'),
- ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage,
- $instruction);
- $this->out->elementEnd('li');
- $this->out->elementStart('li');
-
- $instruction = _('URL to redirect to after authentication');
-
- $this->out->input('callback_url', ('Callback URL'),
- ($this->out->arg('callback_url')) ? $this->out->arg('callback_url') : $callback_url,
- $instruction);
- $this->out->elementEnd('li');
- $this->out->elementStart('li', array('id' => 'application_types'));
- $attrs = array('name' => 'app_type',
- 'type' => 'radio',
- 'id' => 'app_type-browser',
- 'class' => 'radio',
- 'value' => Oauth_application::$browser);
-
- if (empty($this->application)
- || empty($this->application->type)
- || $this->application->type == Oauth_application::$browser) {
- $attrs['checked'] = 'checked';
- }
- $this->out->element('input', $attrs);
- $this->out->element('label', array('for' => 'app_type-browser',
- 'class' => 'radio'),
-
- _('Browser'));
- $attrs = array('name' => 'app_type',
- 'type' => 'radio',
- 'id' => 'app_type-dekstop',
- 'class' => 'radio',
- 'value' => Oauth_application::$desktop);
- if (!empty($this->application) && $this->application->type == Oauth_application::$desktop) {
- $attrs['checked'] = 'checked';
- }
- $this->out->element('input', $attrs);
- $this->out->element('label', array('for' => 'app_type-desktop',
- 'class' => 'radio'),
-
- _('Desktop'));
-
- $this->out->element('p', 'form_guide', _('Type of application, browser or desktop'));
- $this->out->elementEnd('li');
- $this->out->elementStart('li', array('id' => 'default_access_types'));
- $attrs = array('name' => 'default_access_type',
- 'type' => 'radio',
- 'id' => 'default_access_type-r',
- 'class' => 'radio',
- 'value' => 'r');
-
- if (empty($this->application)
- || empty($this->application->access_type)
- || $this->application->access_type & Oauth_application::$readAccess) {
- $attrs['checked'] = 'checked';
- }
- $this->out->element('input', $attrs);
- $this->out->element('label', array('for' => 'default_access_type-ro',
- 'class' => 'radio'),
-
- _('Read-only'));
- $attrs = array('name' => 'default_access_type',
- 'type' => 'radio',
- 'id' => 'default_access_type-rw',
- 'class' => 'radio',
- 'value' => 'rw');
- if (!empty($this->application)
- && $this->application->access_type & Oauth_application::$readAccess
- && $this->application->access_type & Oauth_application::$writeAccess
- ) {
- $attrs['checked'] = 'checked';
- }
- $this->out->element('input', $attrs);
- $this->out->element('label', array('for' => 'default_access_type-rw',
- 'class' => 'radio'),
-
- _('Read-write'));
-
- $this->out->element('p', 'form_guide', _('Default access for this application: read-only, or read-write'));
- $this->out->elementEnd('li');
- $this->out->elementEnd('ul');
- }
-
- function formActions()
- {
-
- $this->out->submit('cancel', _m('BUTTON','Cancel'), 'submit form_action-primary',
-
- 'cancel', _('Cancel application changes.'));
-
- $this->out->submit('save', _m('BUTTON','Save'), 'submit form_action-secondary',
-
- 'save', _('Save application changes.'));
- }
- }
|