X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Faction.php;h=7c57cbc432a9e8ba7f911bca38652ddbf3b39e6b;hb=c6b1b3e5e3ad1c47c7bd25b5bcfb0a8cb1cb2bb5;hp=b7102739d6c36f6890731272d02ce9a10041c0f7;hpb=e086ef3a8479ff509e271bf7db3974d7b6ea6620;p=quix0rs-gnu-social.git diff --git a/lib/action.php b/lib/action.php index b7102739d6..7c57cbc432 100644 --- a/lib/action.php +++ b/lib/action.php @@ -58,7 +58,8 @@ class Action extends HTMLOutputter // lawsuit protected $ajax = false; protected $menus = true; protected $needLogin = false; - protected $needPost = false; + protected $needPost = false; // implies canPost if true + protected $canPost = false; // can this action handle POST method? // The currently scoped profile (normally Profile::current; from $this->auth_user for API) protected $scoped = null; @@ -143,9 +144,16 @@ class Action extends HTMLOutputter // lawsuit $this->clientError(_('This method requires a POST.'), 405); } + // needPost, of course, overrides canPost if true + if (!$this->canPost) { + $this->canPost = $this->needPost; + } + $this->args = common_copy_args($args); - $this->action = $this->trimmed('action'); + // This could be set with get_called_action and then + // chop off 'Action' from the class name. In lower case. + $this->action = strtolower($this->trimmed('action')); if ($this->ajax || $this->boolean('ajax')) { // check with StatusNet::isAjax() @@ -161,17 +169,36 @@ class Action extends HTMLOutputter // lawsuit return true; } - function updateScopedProfile() { + public function updateScopedProfile() + { $this->scoped = Profile::current(); return $this->scoped; } + public function getScoped() + { + return ($this->scoped instanceof Profile) ? $this->scoped : null; + } + // Must be run _after_ prepare public function getActionName() { return $this->action; } + public function isAction(array $names) + { + foreach ($names as $class) { + // PHP is case insensitive, and we have stuff like ApiUpperCaseAction, + // but we at least make a point out of wanting to do stuff case-sensitive. + $class = ucfirst($class) . 'Action'; + if ($this instanceof $class) { + return true; + } + } + return false; + } + /** * Show page, a template method. * @@ -179,6 +206,10 @@ class Action extends HTMLOutputter // lawsuit */ function showPage() { + if (StatusNet::isAjax()) { + self::showAjax(); + return; + } if (Event::handle('StartShowHTML', array($this))) { $this->startHTML(); $this->flush(); @@ -199,6 +230,23 @@ class Action extends HTMLOutputter // lawsuit } } + public function showAjax() + { + $this->startHTML('text/xml;charset=utf-8'); + $this->elementStart('head'); + // TRANS: Title for conversation page. + $this->element('title', null, $this->title()); + $this->elementEnd('head'); + $this->elementStart('body'); + if ($this->getError()) { + $this->element('p', array('id'=>'error'), $this->getError()); + } else { + $this->showContent(); + } + $this->elementEnd('body'); + $this->endHTML(); + } + function endHTML() { global $_startTime; @@ -311,19 +359,6 @@ class Action extends HTMLOutputter // lawsuit $this->cssLink('js/extlib/jquery-ui/css/smoothness/jquery-ui.css'); if (Event::handle('StartShowUAStyles', array($this))) { - $this->comment('[if IE]>comment('[if lte IE '.$ver.']>comment('[if IE]>elementStart('body', (common_current_user()) ? array('id' => strtolower($this->trimmed('action')), - 'class' => 'user_in') - : array('id' => strtolower($this->trimmed('action')))); + $params = array('id' => $this->getActionName()); + if ($this->scoped instanceof Profile) { + $params['class'] = 'user_in'; + } + $this->elementStart('body', $params); $this->elementStart('div', array('id' => 'wrap')); if (Event::handle('StartShowHeader', array($this))) { $this->showHeader(); @@ -585,8 +622,7 @@ class Action extends HTMLOutputter // lawsuit */ function showLogo() { - $this->elementStart('address', array('id' => 'site_contact', - 'class' => 'vcard')); + $this->elementStart('address', array('id' => 'site_contact', 'class' => 'h-card')); if (Event::handle('StartAddressData', array($this))) { if (common_config('singleuser', 'enabled')) { $user = User::singleUser(); @@ -599,7 +635,7 @@ class Action extends HTMLOutputter // lawsuit $url = common_local_url('public'); } - $this->elementStart('a', array('class' => 'url home bookmark', + $this->elementStart('a', array('class' => 'home bookmark', 'href' => $url)); if (StatusNet::isHTTPS()) { @@ -625,13 +661,11 @@ class Action extends HTMLOutputter // lawsuit } if (!empty($logoUrl)) { - $this->element('img', array('class' => 'logo photo', + $this->element('img', array('class' => 'logo u-photo p-name', 'src' => $logoUrl, 'alt' => common_config('site', 'name'))); } - $this->text(' '); - $this->element('span', array('class' => 'fn org'), common_config('site', 'name')); $this->elementEnd('a'); Event::handle('EndAddressData', array($this)); @@ -692,6 +726,8 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('div', 'input_forms'); + $this->element('label', array('for'=>'input_form_nav'), _m('TAB', 'Share your:')); + if (Event::handle('StartShowEntryForms', array(&$tabs))) { $this->elementStart('ul', array('class' => 'nav', 'id' => 'input_form_nav')); @@ -702,9 +738,6 @@ class Action extends HTMLOutputter // lawsuit 'class' => 'input_form_nav_tab'); if ($tag == 'status') { - // We're actually showing the placeholder form, - // but we special-case the 'Status' tab as if - // it were a small version of it. $attrs['class'] .= ' current'; } $this->elementStart('li', $attrs); @@ -718,16 +751,12 @@ class Action extends HTMLOutputter // lawsuit $this->elementEnd('ul'); - $attrs = array('class' => 'input_form current', - 'id' => 'input_form_placeholder'); - $this->elementStart('div', $attrs); - $form = new NoticePlaceholderForm($this); - $form->show(); - $this->elementEnd('div'); - foreach ($tabs as $tag => $data) { $attrs = array('class' => 'input_form', 'id' => 'input_form_'.$tag); + if ($tag == 'status') { + $attrs['class'] .= ' current'; + } $this->elementStart('div', $attrs); @@ -961,7 +990,7 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function showContent() + protected function showContent() { } @@ -1138,12 +1167,10 @@ class Action extends HTMLOutputter // lawsuit // TRANS: license message in footer. // TRANS: %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration. $notice = _('All %1$s content and data are available under the %2$s license.'); - $link = "" . - htmlspecialchars(common_config('license', 'title')) . - ""; - $this->raw(sprintf(htmlspecialchars($notice), + $link = sprintf('%2$s', + htmlspecialchars(common_config('license', 'url')), + htmlspecialchars(common_config('license', 'title'))); + $this->raw(@sprintf(htmlspecialchars($notice), htmlspecialchars(common_config('site', 'name')), $link)); $this->elementEnd('p'); @@ -1499,7 +1526,7 @@ class Action extends HTMLOutputter // lawsuit */ function returnToArgs() { - $action = $this->trimmed('action'); + $action = $this->getActionName(); $args = $this->args; unset($args['action']); if (common_config('site', 'fancy')) {