123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class NewblogentryAction extends Action
- {
- protected $user;
- protected $title;
- protected $content;
-
-
- function prepare($argarray)
- {
- parent::prepare($argarray);
- if (!$this->isPost()) {
- throw new ClientException(_('Must be a POST.'), 405);
- }
- $this->user = common_current_user();
- if (empty($this->user)) {
-
- throw new ClientException(_m('Must be logged in to post a blog entry.'),
- 403);
- }
- $this->checkSessionToken();
-
- $this->title = $this->trimmed('title');
- if (empty($this->title)) {
-
- throw new ClientException(_m('Title required.'));
- }
- $this->content = $this->trimmed('content');
- if (empty($this->content)) {
-
- throw new ClientException(_m('Content required.'));
- }
-
- return true;
- }
-
- function handle($argarray=null)
- {
- $options = array();
-
- ToSelector::fillOptions($this, $options);
- $options['source'] = 'web';
-
- $profile = $this->user->getProfile();
- $saved = Blog_entry::saveNew($profile,
- $this->title,
- $this->content,
- $options);
-
- if ($this->boolean('ajax')) {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
-
- $this->element('title', null, _m('Blog entry saved'));
- $this->elementEnd('head');
- $this->elementStart('body');
- $nli = new NoticeListItem($saved, $this);
- $nli->show();
- $this->elementEnd('body');
- $this->endHTML();
- } else {
- common_redirect($saved->getUrl(), 303);
- }
- }
- }
|