X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Faction.php;h=c2d60e11e974bec1414fe2b9b143b4babdb4ce0d;hb=8b78e01d4c4b9512a7b74efa52fcaf37de0dc6f1;hp=b26db428d41568ecf7d60788380eabafcf6b2f25;hpb=9a92b8ba33e445174aae46acac58c91c78df5f9b;p=quix0rs-gnu-social.git diff --git a/lib/action.php b/lib/action.php index b26db428d4..c2d60e11e9 100644 --- a/lib/action.php +++ b/lib/action.php @@ -118,16 +118,17 @@ class Action extends HTMLOutputter // lawsuit common_config_set('db', 'database', $mirror); } - $status = $this->prepare($args); - if ($status) { - $this->handle($args); - } else { - common_debug('Prepare failed for Action.'); - } - - $this->flush(); + if (Event::handle('StartActionExecute', array($this, &$args))) { + $prepared = $this->prepare($args); + if ($prepared) { + $this->handle($args); + } else { + common_debug('Prepare failed for Action.'); + } - Event::handle('EndActionExecute', array($status, $this)); + $this->flush(); + Event::handle('EndActionExecute', array($this)); + } } /** @@ -156,8 +157,8 @@ class Action extends HTMLOutputter // lawsuit $this->action = strtolower($this->trimmed('action')); if ($this->ajax || $this->boolean('ajax')) { - // check with StatusNet::isAjax() - StatusNet::setAjax(true); + // check with GNUsocial::isAjax() + GNUsocial::setAjax(true); } if ($this->needLogin) { @@ -204,9 +205,9 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function showPage() + public function showPage() { - if (StatusNet::isAjax()) { + if (GNUsocial::isAjax()) { self::showAjax(); return; } @@ -235,11 +236,11 @@ class Action extends HTMLOutputter // lawsuit $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title for conversation page. - $this->element('title', null, _m('TITLE','Notice')); + $this->element('title', null, $this->title()); $this->elementEnd('head'); $this->elementStart('body'); if ($this->getError()) { - $this->element('p', array('id'=>'error'), $msg); + $this->element('p', array('id'=>'error'), $this->getError()); } else { $this->showContent(); } @@ -326,7 +327,7 @@ class Action extends HTMLOutputter // lawsuit } else { // favicon.ico should be HTTPS if the rest of the page is $this->element('link', array('rel' => 'shortcut icon', - 'href' => common_path('favicon.ico', StatusNet::isHTTPS()))); + 'href' => common_path('favicon.ico', GNUsocial::isHTTPS()))); } if (common_config('site', 'mobile')) { @@ -415,8 +416,7 @@ class Action extends HTMLOutputter // lawsuit $this->script('extlib/jquery.form.js'); $this->script('extlib/jquery-ui/jquery-ui.js'); $this->script('extlib/jquery.cookie.js'); - $this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/extlib/json2.js', StatusNet::isHTTPS()).'"); }'); - $this->script('extlib/jquery.infieldlabel.js'); + $this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("'.common_path('js/extlib/json2.js', GNUsocial::isHTTPS()).'"); }'); Event::handle('EndShowJQueryScripts', array($this)); } @@ -430,6 +430,7 @@ class Action extends HTMLOutputter // lawsuit $this->inlineScript('var _peopletagAC = "' . common_local_url('peopletagautocomplete') . '";'); $this->showScriptMessages(); + $this->showScriptVariables(); // Anti-framing code to avoid clickjacking attacks in older browsers. // This will show a blank page if the page is being framed, which is // consistent with the behavior of the 'X-Frame-Options: SAMEORIGIN' @@ -459,12 +460,7 @@ class Action extends HTMLOutputter // lawsuit // TRANS: Localized tooltip for '...' expansion button on overlong remote messages. $messages['showmore_tooltip'] = _m('TOOLTIP', 'Show more'); - - // TRANS: Inline reply form submit button: submits a reply comment. - $messages['reply_submit'] = _m('BUTTON', 'Reply'); - - // TRANS: Placeholder text for inline reply form. Clicking in this box will turn it into a mini notice form. - $messages['reply_placeholder'] = _m('Write a reply...'); + $messages['popup_close_button'] = _m('TOOLTIP', 'Close popup'); $messages = array_merge($messages, $this->getScriptMessages()); @@ -478,6 +474,19 @@ class Action extends HTMLOutputter // lawsuit return $messages; } + protected function showScriptVariables() + { + $vars = array(); + + if (Event::handle('StartScriptVariables', array($this, &$vars))) { + $vars['urlNewNotice'] = common_local_url('newnotice'); + } + if (!empty($vars)) { + $this->inlineScript('SN.V = ' . json_encode($vars)); + } + return $vars; + } + /** * If the action will need localizable text strings, export them here like so: * @@ -526,15 +535,11 @@ class Action extends HTMLOutputter // lawsuit */ function showFeeds() { - $feeds = $this->getFeeds(); - - if ($feeds) { - foreach ($feeds as $feed) { - $this->element('link', array('rel' => $feed->rel(), - 'href' => $feed->url, - 'type' => $feed->mimeType(), - 'title' => $feed->title)); - } + foreach ($this->getFeeds() as $feed) { + $this->element('link', array('rel' => $feed->rel(), + 'href' => $feed->url, + 'type' => $feed->mimeType(), + 'title' => $feed->title)); } } @@ -638,7 +643,7 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('a', array('class' => 'home bookmark', 'href' => $url)); - if (StatusNet::isHTTPS()) { + if (GNUsocial::isHTTPS()) { $logoUrl = common_config('site', 'ssllogo'); if (empty($logoUrl)) { // if logo is an uploaded file, try to fall back to HTTPS file URL @@ -726,6 +731,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')); @@ -736,9 +743,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); @@ -752,16 +756,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); @@ -1032,9 +1032,9 @@ class Action extends HTMLOutputter // lawsuit function showExportData() { $feeds = $this->getFeeds(); - if ($feeds) { - $fl = new FeedList($this); - $fl->show($feeds); + if (!empty($feeds)) { + $fl = new FeedList($this, $feeds); + $fl->show(); } } @@ -1149,7 +1149,7 @@ class Action extends HTMLOutputter // lawsuit $image = common_config('license', 'image'); $sslimage = common_config('license', 'sslimage'); - if (StatusNet::isHTTPS()) { + if (GNUsocial::isHTTPS()) { if (!empty($sslimage)) { $url = $sslimage; } else if (preg_match('#^http://i.creativecommons.org/#', $image)) { @@ -1172,12 +1172,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'); @@ -1361,6 +1359,19 @@ class Action extends HTMLOutputter // lawsuit } } + /** + * This is a cheap hack to avoid a bug in DB_DataObject + * where '' is non-type-aware compared to 0, which means it + * will always be true for values like false and 0 too... + * + * Upstream bug is:: + * https://pear.php.net/bugs/bug.php?id=20291 + */ + function booleanintstring($key, $def=false) + { + return $this->boolean($key, $def) ? '1' : '0'; + } + /** * Integer value of an argument * @@ -1479,7 +1490,7 @@ class Action extends HTMLOutputter // lawsuit } $this->initDocument('json'); $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']); - $this->text(json_encode($error_array)); + print(json_encode($error_array)); $this->endDocument('json'); break; case 'text': @@ -1644,7 +1655,7 @@ class Action extends HTMLOutputter // lawsuit */ function getFeeds() { - return null; + return array(); } /**