/** * Setup the info for the subscription handler. Allow overriding * to point at another cloud hub (not currently used). * * @return void */ function onInitializePlugin() { $this->domain = common_config('rsscloud', 'domain'); $this->port = common_config('rsscloud', 'port'); $this->path = common_config('rsscloud', 'path'); $this->funct = common_config('rsscloud', 'function'); $this->protocol = common_config('rsscloud', 'protocol'); // set defaults $local_server = parse_url(common_path('main/rsscloud/request_notify')); if (empty($this->domain)) { $this->domain = $local_server['host']; } if (empty($this->port)) { $this->port = '80'; } if (empty($this->path)) { $this->path = $local_server['path']; } if (empty($this->funct)) { $this->funct = ''; } if (empty($this->protocol)) { $this->protocol = 'http-post'; } }
function onEndShowScripts($action) { $timeline = $this->_getTimeline($action); // If there's not a timeline on this page, // just return true if (empty($timeline)) { return true; } $base = $action->selfUrl(); if (mb_strstr($base, '?')) { $url = $base . '&realtime=1'; } else { $url = $base . '?realtime=1'; } $scripts = $this->_getScripts(); foreach ($scripts as $script) { $action->script($script); } $user = common_current_user(); if (!empty($user->id)) { $user_id = $user->id; } else { $user_id = 0; } if ($action->boolean('realtime')) { $realtimeUI = ' RealtimeUpdate.initPopupWindow();'; } else { $pluginPath = common_path('plugins/Realtime/'); $realtimeUI = ' RealtimeUpdate.initActions("' . $url . '", "' . $timeline . '", "' . $pluginPath . '");'; } $script = ' $(document).ready(function() { ' . $realtimeUI . $this->_updateInitialize($timeline, $user_id) . '}); '; $action->inlineScript($script); return true; }
function _getScripts() { $scripts = parent::_getScripts(); $scripts[] = 'http://' . $this->webserver . ($this->webport == 80 ? '' : ':' . $this->webport) . '/meteor.js'; $scripts[] = common_path('plugins/Meteor/meteorupdater.js'); return $scripts; }
/** * Class handler. * * @param array $args query arguments * * @return boolean false if user doesn't exist */ function handle($args) { parent::handle($args); $type = $this->trimmed('type'); $short_name = ''; if ($type == 'people') { $type = 'peoplesearch'; // TRANS: ShortName in the OpenSearch interface when trying to find users. $short_name = _('People Search'); } else { $type = 'noticesearch'; // TRANS: ShortName in the OpenSearch interface when trying to find notices. $short_name = _('Notice Search'); } header('Content-Type: application/opensearchdescription+xml'); $this->startXML(); $this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/')); $short_name = common_config('site', 'name') . ' ' . $short_name; $this->element('ShortName', null, $short_name); $this->element('Contact', null, common_config('site', 'email')); $this->element('Url', array('type' => 'text/html', 'method' => 'get', 'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---'))))); $this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico')); $this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), Theme::path('logo.png')); $this->element('AdultContent', null, 'false'); $this->element('Language', null, common_language()); $this->element('OutputEncoding', null, 'UTF-8'); $this->element('InputEncoding', null, 'UTF-8'); $this->elementEnd('OpenSearchDescription'); $this->endXML(); }
function showTagsDropdown() { $tag = $this->trimmed('tag'); $tags = $this->getAllTags(); $content = array(); foreach ($tags as $t) { $content[$t] = $t; } if ($tags) { $this->elementStart('dl', array('id' => 'filter_tags')); $this->element('dt', null, _('Tags')); $this->elementStart('dd'); $this->elementStart('ul'); $this->elementStart('li', array('id' => 'filter_tags_all', 'class' => 'child_1')); $this->element('a', array('href' => common_local_url($this->trimmed('action'), array('nickname' => $this->target->getNickname()))), _m('TAGS', 'All')); $this->elementEnd('li'); $this->elementStart('li', array('id' => 'filter_tags_item')); $this->elementStart('form', array('name' => 'bytag', 'id' => 'form_filter_bytag', 'action' => common_path('?action=' . $this->getActionName()), 'method' => 'post')); $this->elementStart('fieldset'); // TRANS: Fieldset legend on gallery action page. $this->element('legend', null, _('Select tag to filter')); // TRANS: Dropdown field label on gallery action page for a list containing tags. $this->dropdown('tag', _('Tag'), $content, _('Choose a tag to narrow list.'), false, $tag); $this->hidden('nickname', $this->target->getNickname()); // TRANS: Submit button text on gallery action page. $this->submit('submit', _m('BUTTON', 'Go')); $this->elementEnd('fieldset'); $this->elementEnd('form'); $this->elementEnd('li'); $this->elementEnd('ul'); $this->elementEnd('dd'); $this->elementEnd('dl'); } }
function _getScripts() { $scripts = parent::_getScripts(); $ours = array('jquery.comet.js', 'cometupdate.js'); foreach ($ours as $script) { $scripts[] = common_path('plugins/Comet/' . $script); } return $scripts; }
/** * Gets the full URL of a file in a theme dir based on its relative name * * @param string $relative relative path within the theme directory * @param string $theme name of the theme; defaults to current theme * * @return string URL of the file */ function theme_path($relative, $theme = null) { if (!$theme) { $theme = common_config('site', 'theme'); } $server = common_config('theme', 'server'); if ($server) { return 'http://' . $server . '/' . $theme . '/' . $relative; } else { return common_path('theme/' . $theme . '/' . $relative); } }
function showContent() { if (empty($this->user)) { $this->element('p', array('class' => 'notespdf-generate-error'), _m('Login first!')); } else { $this->element('h2', null, 'Grupos Disponibles'); // Obtenemos los grupos a los que pertenece el usuario. $groupsUser = $this->user->getGroups()->fetchAll(); // Si no pertenece a ninguno, le animamos a que se una a alguno de los existentes. if (empty($groupsUser)) { $this->elementStart('p', array('class' => 'notes-empty-groups')); $this->raw("Todavía no perteneces a ningún grupo."); $this->element('br'); $this->raw("Prueba uniéndote a alguno de los "); $this->element('a', array('href' => common_root_url() . 'groups/'), "Grupos Disponibles"); $this->elementEnd('p'); } else { // Obtenemos los grupos que contienen tweets puntuados. $groupsGraded = Grades::getIDsGroupsWithGrades(); $this->elementStart('ul'); foreach ($groupsUser as $group) { $this->elementStart('li', array('class' => 'notespdf-group-item')); $avatar = $group->getAvatar(); $this->element('img', array('src' => $avatar, 'width' => '48', 'height' => '48')); $this->elementStart('p'); $name = $group->getBestName(); $this->raw($name); $this->elementEnd('p'); // Si el grupo no tiene puntuaciones no se pueden generar apuntes if (!in_array($group->id, $groupsGraded)) { $butGenerate = new Notesgroupsform($this, $group->id, 'true'); $butGenerate->show(); $this->elementStart('div'); $this->elementStart('p', array('class' => 'notes-error-group-text')); $this->raw("No es posible generar apuntes. Grupo sin puntuaciones."); $this->elementEnd('p'); $path = common_path('local/plugins/NotesPDF/css/x.gif'); $this->element('img', array('class' => 'notes-error-group', 'src' => $path)); $this->elementEnd('div'); } else { $butGenerate = new Notesgroupsform($this, $group->id); $butGenerate->show(); } $this->elementEnd('li'); } $this->elementEnd('ul'); } } }
function handle() { $nick = $this->user->nickname; $profile = $this->user->getProfile(); if (empty($this->xrd)) { $xrd = new XRD(); } else { $xrd = $this->xrd; } if (empty($xrd->subject)) { $xrd->subject = self::normalize($this->uri); } if (Event::handle('StartXrdActionAliases', array(&$xrd, $this->user))) { // Possible aliases for the user $uris = array($this->user->uri, $profile->profileurl); // FIXME: Webfinger generation code should live somewhere on its own $path = common_config('site', 'path'); if (empty($path)) { $uris[] = sprintf('acct:%s@%s', $nick, common_config('site', 'server')); } foreach ($uris as $uri) { if ($uri != $xrd->subject) { $xrd->alias[] = $uri; } } Event::handle('EndXrdActionAliases', array(&$xrd, $this->user)); } if (Event::handle('StartXrdActionLinks', array(&$xrd, $this->user))) { $xrd->links[] = array('rel' => self::PROFILEPAGE, 'type' => 'text/html', 'href' => $profile->profileurl); // XFN $xrd->links[] = array('rel' => 'http://gmpg.org/xfn/11', 'type' => 'text/html', 'href' => $profile->profileurl); // FOAF $xrd->links[] = array('rel' => 'describedby', 'type' => 'application/rdf+xml', 'href' => common_local_url('foaf', array('nickname' => $nick))); $xrd->links[] = array('rel' => 'http://apinamespace.org/atom', 'type' => 'application/atomsvc+xml', 'href' => common_local_url('ApiAtomService', array('id' => $nick)), 'property' => array(array('type' => 'http://apinamespace.org/atom/username', 'value' => $nick))); if (common_config('site', 'fancy')) { $apiRoot = common_path('api/', true); } else { $apiRoot = common_path('index.php/api/', true); } $xrd->links[] = array('rel' => 'http://apinamespace.org/twitter', 'href' => $apiRoot, 'property' => array(array('type' => 'http://apinamespace.org/twitter/username', 'value' => $nick))); Event::handle('EndXrdActionLinks', array(&$xrd, $this->user)); } if (common_config('discovery', 'cors')) { header('Access-Control-Allow-Origin: *'); } header('Content-type: application/xrd+xml'); print $xrd->toXML(); }
/** * Constructor * * Determines the proper directory and path for this theme. * * @param string $name Name of the theme; defaults to config value */ function __construct($name = null) { if (empty($name)) { $name = common_config('site', 'theme'); } // Check to see if it's in the local dir $localroot = self::localRoot(); $fulldir = $localroot . '/' . $name; if (file_exists($fulldir) && is_dir($fulldir)) { $this->dir = $fulldir; $this->path = common_path('local/theme/' . $name . '/'); return; } // Check to see if it's in the distribution dir $instroot = self::installRoot(); $fulldir = $instroot . '/' . $name; if (file_exists($fulldir) && is_dir($fulldir)) { $this->dir = $fulldir; $path = common_config('theme', 'path'); if (empty($path)) { $path = common_config('site', 'path') . '/theme/'; } if ($path[strlen($path) - 1] != '/') { $path .= '/'; } if ($path[0] != '/') { $path = '/' . $path; } $server = common_config('theme', 'server'); if (empty($server)) { $server = common_config('site', 'server'); } $ssl = common_config('theme', 'ssl'); if (is_null($ssl)) { // null -> guess if (common_config('site', 'ssl') == 'always' && !common_config('theme', 'server')) { $ssl = true; } else { $ssl = false; } } $protocol = $ssl ? 'https' : 'http'; $this->path = $protocol . '://' . $server . $path . $name; } }
function showProviders(array $providers) { $out = $this->out; $out->elementStart('div', 'provider-list'); // TRANS: Heading for feed mirroring selection form. $out->element('h2', null, _m('Select a feed provider')); $out->elementStart('table'); foreach ($providers as $provider) { $icon = common_path('plugins/SubMirror/images/providers/' . $provider['id'] . '.png'); $targetUrl = common_local_url('mirrorsettings', array('provider' => $provider['id'])); $out->elementStart('tr', array('class' => 'provider')); $out->elementStart('td'); $out->elementStart('div', 'provider-heading'); $out->element('img', array('src' => $icon)); $out->element('a', array('href' => $targetUrl), $provider['name']); $out->elementEnd('div'); $out->elementEnd('td'); $out->elementEnd('tr'); } $out->elementEnd('table'); $out->elementEnd('div'); }
/** * Handle request * * This is the main method for handling a request. Note that * most preparation should be done in the prepare() method; * by the time handle() is called the action should be * more or less ready to go. * * @param array $args $_REQUEST args; handled in prepare() * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } $file = basename($this->trimmed('filename')); $url = common_path() . 'local/plugins/Guia/files/'; $dir = substr($_SERVER['SCRIPT_FILENAME'], 0, -9) . 'local/plugins/Guia/files/'; $pathURL = $url . $file; $pathDIR = $dir . $file; if (is_file($pathDIR)) { // Definir headers header("Content-type: application/pdf"); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"" . $file . "\""); readfile($pathURL); } else { die("El archivo no existe."); } }
public function updateXRD(XML_XRD $xrd) { if (Event::handle('StartWebFingerProfileLinks', array($xrd, $this->object))) { $xrd->links[] = new XML_XRD_Element_Link(self::PROFILEPAGE, $this->object->getUrl(), 'text/html'); // XFN $xrd->links[] = new XML_XRD_Element_Link('http://gmpg.org/xfn/11', $this->object->getUrl(), 'text/html'); // FOAF $xrd->links[] = new XML_XRD_Element_Link('describedby', common_local_url('foaf', array('nickname' => $this->object->nickname)), 'application/rdf+xml'); $link = new XML_XRD_Element_Link('http://apinamespace.org/atom', common_local_url('ApiAtomService', array('id' => $this->object->nickname)), 'application/atomsvc+xml'); // XML_XRD must implement changing properties first $link['http://apinamespace.org/atom/username'] = $this->object->nickname; $xrd->links[] = clone $link; if (common_config('site', 'fancy')) { $apiRoot = common_path('api/', true); } else { $apiRoot = common_path('index.php/api/', true); } $link = new XML_XRD_Element_Link('http://apinamespace.org/twitter', $apiRoot); // XML_XRD must implement changing properties first $link['http://apinamespace.org/twitter/username'] = $this->object->nickname; $xrd->links[] = clone $link; Event::handle('EndWebFingerProfileLinks', array($xrd, $this->object)); } }
/** * output a css link * * @param string $src relative path within the theme directory, or an absolute path * @param string $theme 'theme' that contains the stylesheet * @param string media 'media' attribute of the tag * * @return void */ function cssLink($src, $theme = null, $media = null) { if (Event::handle('StartCssLinkElement', array($this, &$src, &$theme, &$media))) { $url = parse_url($src); if (empty($url['scheme']) && empty($url['host']) && empty($url['query']) && empty($url['fragment'])) { if (file_exists(Theme::file($src, $theme))) { $src = Theme::path($src, $theme); } else { $src = common_path($src, GNUsocial::isHTTPS()); } $src .= '?version=' . GNUSOCIAL_VERSION; } $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $src, 'media' => $media)); Event::handle('EndCssLinkElement', array($this, $src, $theme, $media)); } }
function showContent() { $this->elementStart('a', array('href' => common_local_url('twitterauthorization', null, array('signin' => true)))); $this->element('img', array('src' => common_path('plugins/TwitterBridge/Sign-in-with-Twitter-lighter.png'), 'alt' => 'Sign in with Twitter')); $this->elementEnd('a'); }
*/ function _commonPath($dirList) { $arr = array(); foreach ($dirList as $i => $path) { $dirList[$i] = explode('/', $path); unset($dirList[$i][0]); $arr[$i] = count($dirList[$i]); } $min = min($arr); for ($i = 0; $i < count($dirList); $i++) { while (count($dirList[$i]) > $min) { array_pop($dirList[$i]); } $dirList[$i] = '/' . implode('/', $dirList[$i]); } $dirList = array_unique($dirList); while (count($dirList) !== 1) { $dirList = array_map('dirname', $dirList); $dirList = array_unique($dirList); } reset($dirList); return current($dirList); } /* TEST */ $dirs = array('/home/user1/tmp/coverage/test', '/home/user1/tmp/covert/operator', '/home/user1/tmp/coven/members'); if ('/home/user1/tmp' !== common_path($dirs)) { echo 'test fail'; } else { echo 'test success'; }
function showQvitter() { $logged_in_user_nickname = ''; $logged_in_user_obj = false; $logged_in_user = common_current_user(); if ($logged_in_user) { $logged_in_user_nickname = $logged_in_user->nickname; $logged_in_user_obj = ApiAction::twitterUserArray($logged_in_user->getProfile()); } $registrationsclosed = false; if (common_config('site', 'closed') == 1 || common_config('site', 'inviteonly') == 1) { $registrationsclosed = true; } // check if the client's ip address is blocked for registration if (is_array(QvitterPlugin::settings("blocked_ips"))) { $client_ip_is_blocked = in_array($_SERVER['REMOTE_ADDR'], QvitterPlugin::settings("blocked_ips")); } $sitetitle = common_config('site', 'name'); $siterootdomain = common_config('site', 'server'); $qvitterpath = Plugin::staticPath('Qvitter', ''); $apiroot = common_path('api/', StatusNet::isHTTPS()); $attachmentroot = common_path('attachment/', StatusNet::isHTTPS()); $instanceurl = common_path('', StatusNet::isHTTPS()); // user's browser's language setting $user_browser_language = 'en'; // use english if we can't find the browser language if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $user_browser_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); } common_set_returnto(''); // forget this // if this is a profile we add a link header for LRDD Discovery (see WebfingerPlugin.php) if (substr_count($_SERVER['REQUEST_URI'], '/') == 1) { $nickname = substr($_SERVER['REQUEST_URI'], 1); if (preg_match("/^[a-zA-Z0-9]+\$/", $nickname) == 1) { $acct = 'acct:' . $nickname . '@' . common_config('site', 'server'); $url = common_local_url('webfinger') . '?resource=' . $acct; foreach (array(Discovery::JRD_MIMETYPE, Discovery::XRD_MIMETYPE) as $type) { header('Link: <' . $url . '>; rel="' . Discovery::LRDD_REL . '"; type="' . $type . '"'); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php print $sitetitle; ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0"> <link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?> css/qvitter.css?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/css/qvitter.css')); ?> " /> <link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?> css/jquery.minicolors.css" /> <link rel="shortcut icon" type="image/x-icon" href="<?php print $qvitterpath; print QvitterPlugin::settings("favicon"); ?> "> <?php // if qvitter is a webapp and this is a users url we add feeds if (substr_count($_SERVER['REQUEST_URI'], '/') == 1) { $nickname = substr($_SERVER['REQUEST_URI'], 1); if (preg_match("/^[a-zA-Z0-9]+\$/", $nickname) == 1) { $user = User::getKV('nickname', $nickname); if (!isset($user->id)) { //error_log("QVITTER: Could not get user id for user with nickname: $nickname – REQUEST_URI: ".$_SERVER['REQUEST_URI']); } else { print '<link title="Notice feed for ' . $nickname . ' (Activity Streams JSON)" type="application/stream+json" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.as" rel="alternate">' . "\n"; print ' <link title="Notice feed for ' . $nickname . ' (RSS 1.0)" type="application/rdf+xml" href="' . $instanceurl . $nickname . '/rss" rel="alternate">' . "\n"; print ' <link title="Notice feed for ' . $nickname . ' (RSS 2.0)" type="application/rss+xml" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.rss" rel="alternate">' . "\n"; print ' <link title="Notice feed for ' . $nickname . ' (Atom)" type="application/atom+xml" href="' . $instanceurl . 'api/statuses/user_timeline/' . $user->id . '.atom" rel="alternate">' . "\n"; print ' <link title="FOAF for ' . $nickname . '" type="application/rdf+xml" href="' . $instanceurl . $nickname . '/foaf" rel="meta">' . "\n"; print ' <link href="' . $instanceurl . $nickname . '/microsummary" rel="microsummary">' . "\n"; // maybe openid if (array_key_exists('OpenID', StatusNet::getActivePlugins())) { print ' <link rel="openid2.provider" href="' . common_local_url('openidserver') . '"/>' . "\n"; print ' <link rel="openid2.local_id" href="' . $user->getProfile()->profileurl . '"/>' . "\n"; print ' <link rel="openid2.server" href="' . common_local_url('openidserver') . '"/>' . "\n"; print ' <link rel="openid2.delegate" href="' . $user->getProfile()->profileurl . '"/>' . "\n"; } } } } elseif (substr($_SERVER['REQUEST_URI'], 0, 7) == '/group/') { $group_id_or_name = substr($_SERVER['REQUEST_URI'], 7); if (stristr($group_id_or_name, '/id')) { $group_id_or_name = substr($group_id_or_name, 0, strpos($group_id_or_name, '/id')); $group = User_group::getKV('id', $group_id_or_name); if ($group instanceof User_group) { $group_name = $group->nickname; $group_id = $group_id_or_name; } } else { $group = Local_group::getKV('nickname', $group_id_or_name); if ($group instanceof Local_group) { $group_id = $group->group_id; $group_name = $group_id_or_name; } } if (preg_match("/^[a-zA-Z0-9]+\$/", $group_id_or_name) == 1 && isset($group_name) && isset($group_id)) { ?> <link rel="alternate" href="<?php echo htmlspecialchars(common_local_url('ApiTimelineGroup', array('id' => $group_id, 'format' => 'as'))); ?> " type="application/stream+json" title="Notice feed for '<?php echo htmlspecialchars($group_name); ?> ' group (Activity Streams JSON)" /> <link rel="alternate" href="<?php echo htmlspecialchars(common_local_url('grouprss', array('nickname' => $group_name))); ?> " type="application/rdf+xml" title="Notice feed for '<?php echo htmlspecialchars($group_name); ?> ' group (RSS 1.0)" /> <link rel="alternate" href="<?php echo htmlspecialchars(common_local_url('ApiTimelineGroup', array('id' => $group_id, 'format' => 'rss'))); ?> " type="application/rss+xml" title="Notice feed for '<?php echo htmlspecialchars($group_name); ?> ' group (RSS 2.0)" /> <link rel="alternate" href="<?php echo htmlspecialchars(common_local_url('ApiTimelineGroup', array('id' => $group_id, 'format' => 'atom'))); ?> " type="application/atom+xml" title="Notice feed for '<?php echo htmlspecialchars($group_name); ?> ' group (Atom)" /> <link rel="meta" href="<?php echo htmlspecialchars(common_local_url('foafgroup', array('nickname' => $group_name))); ?> " type="application/rdf+xml" title="FOAF for '<?php echo htmlspecialchars($group_name); ?> ' group" /> <?php } } // oembed discovery for local notices if (substr($_SERVER['REQUEST_URI'], 0, 8) == '/notice/' && $this->arg('notice') && array_key_exists('Oembed', StatusNet::getActivePlugins())) { $notice = Notice::getKV('id', $this->arg('notice')); if ($notice instanceof Notice) { if ($notice->isLocal()) { try { $notice_url = $notice->getUrl(); print '<link title="oEmbed" href="' . common_local_url('apiqvitteroembednotice', array('id' => $notice->id, 'format' => 'json')) . '?url=' . urlencode($notice_url) . '" type="application/json+oembed" rel="alternate">'; print '<link title="oEmbed" href="' . common_local_url('apiqvitteroembednotice', array('id' => $notice->id, 'format' => 'xml')) . '?url=' . urlencode($notice_url) . '" type="application/xml+oembed" rel="alternate">'; } catch (Exception $e) { // } } } } ?> <script> /* @licstart The following is the entire license notice for the JavaScript code in this page. Copyright (C) 2015 Hannes Mannerheim and other contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. @licend The above is the entire license notice for the JavaScript code in this page. */ window.usersLanguageCode = <?php print json_encode($user_browser_language); ?> ; window.usersLanguageNameInEnglish = <?php print json_encode(Locale::getDisplayLanguage($user_browser_language, 'en')); ?> ; window.englishLanguageData = <?php print file_get_contents(QVITTERDIR . '/locale/en.json'); ?> ; window.defaultAvatarStreamSize = <?php print json_encode(Avatar::defaultImage(AVATAR_STREAM_SIZE)); ?> ; window.defaultAvatarProfileSize = <?php print json_encode(Avatar::defaultImage(AVATAR_PROFILE_SIZE)); ?> ; window.textLimit = <?php print json_encode((int) common_config('site', 'textlimit')); ?> ; window.registrationsClosed = <?php print json_encode($registrationsclosed); ?> ; window.thisSiteThinksItIsHttpButIsActuallyHttps = <?php // this is due to a crazy setup at quitter.se, sorry about that $siteSSL = common_config('site', 'ssl'); if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' && $siteSSL == 'never') { $this_site_thinks_it_is_http_but_is_actually_https = true; print 'true'; } else { $this_site_thinks_it_is_http_but_is_actually_https = false; print 'false'; } ?> ; window.siteTitle = <?php print json_encode($sitetitle); ?> ; window.loggedIn = <?php $logged_in_user_json = json_encode($logged_in_user_obj); $logged_in_user_json = str_replace('http:\\/\\/quitter.se\\/', 'https:\\/\\/quitter.se\\/', $logged_in_user_json); print $logged_in_user_json; ?> ; window.timeBetweenPolling = <?php print QvitterPlugin::settings("timebetweenpolling"); ?> ; window.apiRoot = <?php $api_root = common_path("api/", StatusNet::isHTTPS()); if ($this_site_thinks_it_is_http_but_is_actually_https) { $api_root = str_replace('http://', 'https://', $api_root); } print '\'' . $api_root . '\''; ?> ; window.fullUrlToThisQvitterApp = '<?php print $qvitterpath; ?> '; window.siteRootDomain = '<?php print $siterootdomain; ?> '; window.siteInstanceURL = '<?php print $instanceurl; ?> '; window.defaultLinkColor = '<?php print QvitterPlugin::settings("defaultlinkcolor"); ?> '; window.defaultBackgroundColor = '<?php print QvitterPlugin::settings("defaultbackgroundcolor"); ?> '; window.siteBackground = '<?php print QvitterPlugin::settings("sitebackground"); ?> '; window.enableWelcomeText = <?php print json_encode(QvitterPlugin::settings("enablewelcometext")); ?> ; window.customWelcomeText = <?php print json_encode(QvitterPlugin::settings("customwelcometext")); ?> ; window.urlShortenerAPIURL = '<?php print QvitterPlugin::settings("urlshortenerapiurl"); ?> '; window.urlShortenerSignature = '<?php print QvitterPlugin::settings("urlshortenersignature"); ?> '; window.commonSessionToken = '<?php print common_session_token(); ?> '; window.siteMaxThumbnailSize = <?php print common_config('thumbnail', 'maxsize'); ?> ; window.siteAttachmentURLBase = '<?php print $attachmentroot; ?> '; window.siteEmail = '<?php print common_config('site', 'email'); ?> '; window.siteLicenseTitle = '<?php print common_config('license', 'title'); ?> '; window.siteLicenseURL = '<?php print common_config('license', 'url'); ?> '; window.customTermsOfUse = <?php print json_encode(QvitterPlugin::settings("customtermsofuse")); ?> ; window.siteLocalOnlyDefaultPath = <?php print common_config('public', 'localonly') ? 'true' : 'false'; ?> ; <?php // Get all topics in Qvitter's namespace in Profile_prefs if ($logged_in_user) { try { $qvitter_profile_prefs = Profile_prefs::getNamespace(Profile::current(), 'qvitter'); } catch (Exception $e) { $qvitter_profile_prefs = array(); } if (count($qvitter_profile_prefs) > 0) { $topic_data = new stdClass(); foreach ($qvitter_profile_prefs as $pref) { $topic_data->{$pref->topic} = $pref->data; } print 'window.qvitterProfilePrefs = ' . json_encode($topic_data) . ';'; } else { print 'window.qvitterProfilePrefs = false;'; } } ?> // available language files and their last update time window.availableLanguages = {<?php // scan all files in the locale directory and create a json object with their change date added $available_languages = array_diff(scandir(QVITTERDIR . '/locale'), array('..', '.')); foreach ($available_languages as $lankey => $lan) { $lancode = substr($lan, 0, strpos($lan, '.')); // for the paranthesis containing language region to work with rtl in ltr enviroment and vice versa, we add a // special rtl or ltr html char after the paranthesis // this list is incomplete, but if any rtl language gets a regional translation, it will probably be arabic $rtl_or_ltr_special_char = '‎'; $base_lancode = substr($lancode, 0, strpos($lancode, '_')); if ($base_lancode == 'ar' || $base_lancode == 'fa' || $base_lancode == 'he') { $rtl_or_ltr_special_char = '‏'; } // also make an array with all language names, to use for generating menu $languagecodesandnames[$lancode]['english_name'] = Locale::getDisplayLanguage($lancode, 'en'); $languagecodesandnames[$lancode]['name'] = Locale::getDisplayLanguage($lancode, $lancode); if (Locale::getDisplayRegion($lancode, $lancode)) { $languagecodesandnames[$lancode]['name'] .= ' (' . Locale::getDisplayRegion($lancode, $lancode) . ')' . $rtl_or_ltr_special_char; } // ahorita meme only on quitter.es if ($lancode == 'es_ahorita') { if ($siterootdomain == 'quitter.es') { $languagecodesandnames[$lancode]['name'] = 'español (ahorita)'; } else { unset($available_languages[$lankey]); unset($languagecodesandnames[$lancode]); continue; } } print "\n" . ' "' . $lancode . '": "' . $lan . '?changed=' . date('YmdHis', filemtime(QVITTERDIR . '/locale/' . $lan)) . '",'; } ?> }; </script> <?php // event for other plugins to use to add head elements to qvitter Event::handle('QvitterEndShowHeadElements', array($this)); ?> </head> <body style="background-color:<?php print QvitterPlugin::settings("defaultbackgroundcolor"); ?> "> <?php // add an accessibility toggle link to switch to standard UI, if we're logged in if ($logged_in_user) { print '<a id="accessibility-toggle-link" href="#"></a>'; } ?> <input id="upload-image-input" class="upload-image-input" type="file" name="upload-image-input"> <div class="topbar"> <a href="<?php // if we're logged in, the logo links to the home stream // if logged out it links to the site's public stream if ($logged_in_user) { print $instanceurl . $logged_in_user_nickname . '/all'; } else { print $instanceurl . 'main/public'; } ?> "><div id="logo"></div></a><?php // menu for logged in users if ($logged_in_user) { ?> <a id="settingslink"> <div class="dropdown-toggle"> <div class="nav-session" style="background-image:url('<?php print htmlspecialchars($logged_in_user_obj['profile_image_url_profile_size']); ?> ')"></div> </div> </a><?php } ?> <div id="top-compose" class="hidden"></div> <ul class="quitter-settings dropdown-menu"> <li class="dropdown-caret right"> <span class="caret-outer"></span> <span class="caret-inner"></span> </li> <li class="fullwidth"><a id="logout"></a></li> <li class="fullwidth dropdown-divider"></li> <li class="fullwidth"><a id="edit-profile-header-link"></a></li> <li class="fullwidth"><a id="settings" href="<?php print $instanceurl; ?> settings/profile" donthijack></a></li> <li class="fullwidth"><a id="faq-link"></a></li> <li class="fullwidth"><a id="shortcuts-link"></a></li> <?php if (common_config('invite', 'enabled') && !common_config('site', 'closed')) { ?> <li class="fullwidth"><a id="invite-link" href="<?php print $instanceurl; ?> main/invite"></a></li> <?php } ?> <li class="fullwidth"><a id="classic-link"></a></li> <li class="fullwidth language dropdown-divider"></li> <?php // languages foreach ($languagecodesandnames as $lancode => $lan) { print '<li class="language"><a class="language-link" title="' . $lan['english_name'] . '" data-lang-code="' . $lancode . '">' . $lan['name'] . '</a></li>'; } ?> <li class="fullwidth language dropdown-divider"></li> <li class="fullwidth"><a href="https://git.gnu.io/h2p/Qvitter/tree/master/locale" target="_blank" id="add-edit-language-link"></a></li> </ul> <div class="global-nav"> <div class="global-nav-inner"> <div class="container"> <div id="search"> <input type="text" spellcheck="false" autocomplete="off" name="q" placeholder="Sök" id="search-query" class="search-input"> <span class="search-icon"> <button class="icon nav-search" type="submit" tabindex="-1"> <span> Sök </span> </button> </span> </div> <ul class="language-dropdown"> <li class="dropdown"> <a class="dropdown-toggle"> <small></small> <span class="current-language"></span> <b class="caret"></b> </a> <ul class="dropdown-menu"> <li class="dropdown-caret right"> <span class="caret-outer"></span> <span class="caret-inner"></span> </li> <?php // languages foreach ($languagecodesandnames as $lancode => $lan) { print '<li><a class="language-link" title="' . $lan['english_name'] . '" data-lang-code="' . $lancode . '">' . $lan['name'] . '</a></li>'; } ?> </ul> </li> </ul> </div> </div> </div> </div> <div id="no-js-error">Please enable javascript to use this site.<script>var element = document.getElementById('no-js-error'); element.parentNode.removeChild(element);</script></div> <div id="page-container"> <?php $site_notice = common_config('site', 'notice'); if (!empty($site_notice)) { print '<div id="site-notice">' . common_config('site', 'notice') . '</div>'; } // welcome text, login and register container if logged out if ($logged_in_user === null) { ?> <div class="front-welcome-text <?php if ($registrationsclosed) { print 'registrations-closed'; } ?> "></div> <div id="login-register-container"> <div id="login-content"> <form id="form_login" class="form_settings" action="<?php print common_local_url('qvitterlogin'); ?> " method="post"> <div id="username-container"> <input id="nickname" name="nickname" type="text" value="<?php print $logged_in_user_nickname; ?> " tabindex="1" /> </div> <table class="password-signin"><tbody><tr> <td class="flex-table-primary"> <div class="placeholding-input"> <input id="password" name="password" type="password" tabindex="2" value="" /> </div> </td> <td class="flex-table-secondary"> <button class="submit" type="submit" id="submit-login" tabindex="4"></button> </td> </tr></tbody></table> <div id="remember-forgot"> <input type="checkbox" id="rememberme" name="rememberme" value="yes" tabindex="3" checked="checked"> <span id="rememberme_label"></span> · <a id="forgot-password" href="<?php print $instanceurl; ?> main/recoverpassword" ></a> <input type="hidden" id="token" name="token" value="<?php print common_session_token(); ?> "> <?php if (array_key_exists('OpenID', StatusNet::getActivePlugins())) { print '<a href="' . $instanceurl . 'main/openid" id="openid-login" title="OpenID" donthijack>OpenID</a>'; } ?> </div> </form> </div> <?php if ($registrationsclosed === false && $client_ip_is_blocked === false) { ?> <div class="front-signup"> <h2></h2> <div class="signup-input-container"><input placeholder="" type="text" name="user[name]" autocomplete="off" class="text-input" id="signup-user-name"></div> <div class="signup-input-container"><input placeholder="" type="text" name="user[email]" autocomplete="off" id="signup-user-email"></div> <div class="signup-input-container"><input placeholder="" type="password" name="user[user_password]" class="text-input" id="signup-user-password"></div> <button id="signup-btn-step1" class="signup-btn" type="submit"></button> </div> <div id="other-servers-link"></div><?php } ?> <div id="qvitter-notice-logged-out"><?php print common_config('site', 'qvitternoticeloggedout'); ?> </div> </div><?php } // box containing the logged in users queet count and compose form if ($logged_in_user) { ?> <div id="user-container" style="display:none;"> <div id="user-header" style="background-image:url('<?php print htmlspecialchars($logged_in_user_obj['cover_photo']); ?> ')"> <div id="mini-edit-profile-button"></div> <div class="profile-header-inner-overlay"></div> <div id="user-avatar-container"><img id="user-avatar" src="<?php print htmlspecialchars($logged_in_user_obj['profile_image_url_profile_size']); ?> " /></div> <div id="user-name"><?php print htmlspecialchars($logged_in_user_obj['name']); ?> </div> <div id="user-screen-name"><?php print htmlspecialchars($logged_in_user_obj['screen_name']); ?> </div> </div> <ul id="user-body"> <li><a href="<?php print $instanceurl . $logged_in_user->nickname; ?> " id="user-queets"><span class="label"></span><strong><?php print $logged_in_user_obj['statuses_count']; ?> </strong></a></li> <li><a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /subscriptions" id="user-following"><span class="label"></span><strong><?php print $logged_in_user_obj['friends_count']; ?> </strong></a></li> <li><a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /groups" id="user-groups"><span class="label"></span><strong><?php print $logged_in_user_obj['groups_count']; ?> </strong></a></li> </ul> <div id="user-footer"> <div id="user-footer-inner"> <div id="queet-box" class="queet-box queet-box-syntax" data-start-text=""></div> <div class="syntax-middle"></div> <div class="syntax-two" contenteditable="true"></div> <div class="mentions-suggestions"></div> <div class="queet-toolbar"> <div class="queet-box-extras"> <button class="upload-image"></button> <button class="shorten disabled">URL</button> </div> <div class="queet-button"> <span class="queet-counter"></span> <button></button> </div> </div> </div> </div> <div id="main-menu" class="menu-container"><?php if ($logged_in_user) { ?> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /all" class="stream-selection friends-timeline"><i class="chev-right"></i></a> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /notifications" class="stream-selection notifications"><span id="unseen-notifications"></span><i class="chev-right"></i></a> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /replies" class="stream-selection mentions"><i class="chev-right"></i></a> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> " class="stream-selection my-timeline"><i class="chev-right"></i></a> <a href="<?php print $instanceurl . $logged_in_user->nickname; ?> /favorites" class="stream-selection favorites"><i class="chev-right"></i></a> <a href="<?php print $instanceurl; ?> main/public" class="stream-selection public-timeline"><i class="chev-right"></i></a> <a href="<?php print $instanceurl; ?> main/all" class="stream-selection public-and-external-timeline"><i class="chev-right"></i></a> <?php } ?> </div> <div class="menu-container" id="bookmark-container"></div> <div class="menu-container" id="history-container"></div> <div id="clear-history"></div> <div id="qvitter-notice"><?php print common_config('site', 'qvitternotice'); ?> </div> </div><?php } ?> <div id="feed"> <div id="feed-header"> <div id="feed-header-inner"> <h2></h2> <div class="reload-stream"></div> </div> </div> <div id="new-queets-bar-container" class="hidden"><div id="new-queets-bar"></div></div> <div id="feed-body"></div> </div> <div id="hidden-html"><?php // adds temporary support for microformats and linkbacks on the notice page if (substr($_SERVER['REQUEST_URI'], 0, 8) == '/notice/' && $this->arg('notice')) { echo '<ol class="notices xoxo">'; if ($notice instanceof Notice) { $widget = new NoticeListItem($notice, $this); $widget->show(); $this->flush(); } echo '</ol>'; } Event::handle('QvitterHiddenHtml', array($this)); ?> </div> <div id="footer"><div id="footer-spinner-container"></div></div> </div> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/jquery-2.1.4.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/jquery-2.1.4.min.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/jquery-ui.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/jquery-ui.min.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/jquery.minicolors.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/jquery.minicolors.min.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/jquery.jWindowCrop.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/jquery.jWindowCrop.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/load-image.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/load-image.min.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/xregexp-all-3.0.0-pre.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/xregexp-all-3.0.0-pre.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/lz-string.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/lz-string.js')); ?> "></script> <script type="text/javascript" src="<?php print $qvitterpath; ?> js/lib/bowser.min.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/lib/bowser.min.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/dom-functions.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/dom-functions.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/misc-functions.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/misc-functions.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/ajax-functions.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/ajax-functions.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/stream-router.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/stream-router.js')); ?> "></script> <script charset="utf-8" type="text/javascript" src="<?php print $qvitterpath; ?> js/qvitter.js?changed=<?php print date('YmdHis', filemtime(QVITTERDIR . '/js/qvitter.js')); ?> "></script> <?php // event for other plugins to add scripts to qvitter Event::handle('QvitterEndShowScripts', array($this)); // we might have custom javascript in the config file that we want to add if (QvitterPlugin::settings('js')) { print '<script type="text/javascript">' . QvitterPlugin::settings('js') . '</script>'; } ?> <div id="dynamic-styles"> <style> a, a:visited, a:active, ul.stats li:hover a, ul.stats li:hover a strong, #user-body a:hover div strong, #user-body a:hover div div, .permalink-link:hover, .stream-item.expanded > .queet .stream-item-expand, .stream-item-footer .with-icn .requeet-text a b:hover, .queet-text span.attachment.more, .stream-item-header .created-at a:hover, .stream-item-header a.account-group:hover .name, .queet:hover .stream-item-expand, .show-full-conversation:hover, #new-queets-bar, .menu-container div, .cm-mention, .cm-tag, .cm-group, .cm-url, .cm-email, div.syntax-middle span, #user-body strong, ul.stats, .stream-item:not(.temp-post) ul.queet-actions li .icon:not(.is-mine):hover:before, .show-full-conversation, #user-body #user-queets:hover .label, #user-body #user-groups:hover .label, #user-body #user-following:hover .label, ul.stats a strong, .queet-box-extras button, #openid-login:hover:after, .post-to-group { color:/*COLORSTART*/<?php print QvitterPlugin::settings("defaultlinkcolor"); ?> /*COLOREND*/; } #unseen-notifications, .stream-item.notification.not-seen > .queet::before, #top-compose, #logo, .queet-toolbar button, #user-header, .profile-header-inner, .topbar, .menu-container, .member-button.member, .external-follow-button.following, .qvitter-follow-button.following, .save-profile-button, .crop-and-save-button, .topbar .global-nav.show-logo:before, .topbar .global-nav.pulse-logo:before, .dropdown-menu li:not(.dropdown-caret) a:hover { background-color:/*BACKGROUNDCOLORSTART*/<?php print QvitterPlugin::settings("defaultlinkcolor"); ?> /*BACKGROUNDCOLOREND*/; } .queet-box-syntax[contenteditable="true"]:focus, .stream-item.selected-by-keyboard::before { border-color:/*BORDERCOLORSTART*/#999999/*BORDERCOLOREND*/; } #user-footer-inner, .inline-reply-queetbox, #popup-faq #faq-container p.indent { background-color:/*LIGHTERBACKGROUNDCOLORSTART*/rgb(205,230,239)/*LIGHTERBACKGROUNDCOLOREND*/; } #user-footer-inner, .queet-box, .queet-box-syntax[contenteditable="true"], .inline-reply-queetbox, span.inline-reply-caret, .stream-item.expanded .stream-item.first-visible-after-parent, #popup-faq #faq-container p.indent, .post-to-group, .quoted-notice:hover, .oembed-item:hover, .stream-item:hover:not(.expanded) .quoted-notice:hover, .stream-item:hover:not(.expanded) .oembed-item:hover { border-color:/*LIGHTERBORDERCOLORSTART*/rgb(155,206,224)/*LIGHTERBORDERCOLOREND*/; } span.inline-reply-caret .caret-inner { border-bottom-color:/*LIGHTERBORDERBOTTOMCOLORSTART*/rgb(205,230,239)/*LIGHTERBORDERBOTTOMCOLOREND*/; } .modal-close .icon, .chev-right, .close-right, button.icon.nav-search, .member-button .join-text i, .external-member-button .join-text i, .external-follow-button .follow-text i, .qvitter-follow-button .follow-text i, #logo, .upload-cover-photo, .upload-avatar, .upload-background-image, button.shorten i, .reload-stream, .topbar .global-nav:before, .stream-item.notification.repeat .dogear, .stream-item.notification.like .dogear, .ostatus-link, .close-edit-profile-window { background-image: url("<?php print QvitterPlugin::settings("sprite"); ?> "); background-size: 500px 1329px; } @media (max-width: 910px) { #search-query, .menu-container a, .menu-container a.current, .stream-selection.friends-timeline:after, .stream-selection.notifications:after, .stream-selection.my-timeline:after, .stream-selection.public-timeline:after { background-image: url("<?php print QvitterPlugin::settings("sprite"); ?> "); background-size: 500px 1329px; } } </style> </div> </body> </html> <?php }
function onStartPrimaryNav($action) { $user = common_current_user(); if (!empty($user)) { $fbuid = $this->loggedIn(); if (!empty($fbuid)) { /* Default FB silhouette pic for FB users who haven't uploaded a profile pic yet. */ $silhouetteUrl = 'http://static.ak.fbcdn.net/pics/q_silhouette.gif'; $url = $this->getProfilePicURL($fbuid); $action->elementStart('li', array('id' => 'nav_fb')); $action->element('img', array('id' => 'fbc_profile-pic', 'src' => !empty($url) ? $url : $silhouetteUrl, 'alt' => 'Facebook Connect User', 'width' => '16'), ''); $iconurl = common_path('plugins/FBConnect/fbfavicon.ico'); $action->element('img', array('id' => 'fb_favicon', 'src' => $iconurl)); $action->elementEnd('li'); } $action->menuItem(common_local_url('all', array('nickname' => $user->nickname)), _('Home'), _('Personal profile and friends timeline'), false, 'nav_home'); $action->menuItem(common_local_url('profilesettings'), _('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account'); if (common_config('xmpp', 'enabled')) { $action->menuItem(common_local_url('imsettings'), _('Connect'), _('Connect to IM, SMS, Twitter'), false, 'nav_connect'); } else { $action->menuItem(common_local_url('smssettings'), _('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect'); } if (common_config('invite', 'enabled')) { $action->menuItem(common_local_url('invite'), _('Invite'), sprintf(_('Invite friends and colleagues to join you on %s'), common_config('site', 'name')), false, 'nav_invitecontact'); } // Need to override the Logout link to make it do FB stuff if (!empty($fbuid)) { $logout_url = common_local_url('logout'); $title = _('Logout from the site'); $text = _('Logout'); $html = sprintf('<li id="nav_logout"><a href="%s" title="%s" ' . 'onclick="FB.Connect.logout(function() { goto_logout() })">%s</a></li>', $logout_url, $title, $text); $action->raw($html); } else { $action->menuItem(common_local_url('logout'), _('Logout'), _('Logout from the site'), false, 'nav_logout'); } } else { if (!common_config('site', 'closed')) { $action->menuItem(common_local_url('register'), _('Register'), _('Create an account'), false, 'nav_register'); } $action->menuItem(common_local_url('login'), _('Login'), _('Login to the site'), false, 'nav_login'); } $action->menuItem(common_local_url('doc', array('title' => 'help')), _('Help'), _('Help me!'), false, 'nav_help'); $action->menuItem(common_local_url('peoplesearch'), _('Search'), _('Search for people or text'), false, 'nav_search'); return false; }
static function url($filename) { return common_path('avatar/' . $filename); }
/** * Show feed specific Atom elements * * @return void */ function showFeed() { // TODO: A9 OpenSearch stuff like search.twitter.com? $server = common_config('site', 'server'); $sitename = common_config('site', 'name'); // XXX: Use xmlns:statusnet instead? $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xmlns:twitter' => 'http://api.twitter.com/', 'xml:lang' => 'en-US')); // XXX Other locales ? $taguribase = TagURI::base(); $this->element('id', null, "tag:{$taguribase}:search/{$server}"); $site_uri = common_path(false); $search_uri = $site_uri . 'api/search.atom?q=' . urlencode($this->query); if ($this->rpp != 15) { $search_uri .= '&rpp=' . $this->rpp; } // FIXME: this alternate link is not quite right because our // web-based notice search doesn't support a rpp (responses per // page) param yet $this->element('link', array('type' => 'text/html', 'rel' => 'alternate', 'href' => $site_uri . 'search/notice?q=' . urlencode($this->query))); // self link $self_uri = $search_uri; $self_uri .= $this->page > 1 ? '&page=' . $this->page : ''; $this->element('link', array('type' => 'application/atom+xml', 'rel' => 'self', 'href' => $self_uri)); // @todo Needs i18n? $this->element('title', null, "{$this->query} - {$sitename} Search"); $this->element('updated', null, common_date_iso8601('now')); // XXX: The below "rel" links are not valid Atom, but it's what // Twitter does... // refresh link $refresh_uri = $search_uri . "&since_id=" . $this->max_id; $this->element('link', array('type' => 'application/atom+xml', 'rel' => 'refresh', 'href' => $refresh_uri)); // pagination links if ($this->cnt > $this->rpp) { $next_uri = $search_uri . "&max_id=" . $this->max_id . '&page=' . ($this->page + 1); $this->element('link', array('type' => 'application/atom+xml', 'rel' => 'next', 'href' => $next_uri)); } if ($this->page > 1) { $previous_uri = $search_uri . "&max_id=" . $this->max_id . '&page=' . ($this->page - 1); $this->element('link', array('type' => 'application/atom+xml', 'rel' => 'previous', 'href' => $previous_uri)); } }
function onEndShowScripts($action) { $action->script(common_path('plugins/TinyMCE/js/jquery.tinymce.js')); $action->inlineScript('var _tinymce_path = "' . common_path('plugins/TinyMCE/js/tiny_mce.js') . '";' . "\n" . 'var _tinymce_placeholder = "' . common_path('plugins/TinyMCE/icons/placeholder.png') . '";' . "\n"); $action->script($this->path('blog.js')); return true; }
/** * Replace GNU Social's default FAQ with Qvitter's * * @return boolean hook flag */ public function onEndLoadDoc($title, &$output) { if ($title == 'faq') { $faq = file_get_contents(QVITTERDIR . '/doc/en/faq.html'); $faq = str_replace('{instance-name}', common_config('site', 'name'), $faq); $faq = str_replace('{instance-url}', common_config('site', 'server'), $faq); $faq = str_replace('{instance-url-with-protocol}', common_path('', true), $faq); if (common_logged_in()) { $user = common_current_user(); $faq = str_replace('{nickname}', $user->nickname, $faq); } $output = $faq; } return true; }
function common_root_url($ssl = false) { $url = common_path('', $ssl, false); $i = strpos($url, '?'); if ($i !== false) { $url = substr($url, 0, $i); } return $url; }
/** * Uses the nickname part of the subscribed feed URL to figure out * whethere there's really a user with such a feed. Used to * validate feeds before adding a subscription. * * @param string $feed the feed in question * * @return boolean success */ function userFromFeed($feed) { // We only do canonical RSS2 profile feeds (specified by ID), e.g.: // http://www.example.com/api/statuses/user_timeline/2.rss $path = common_path('api/statuses/user_timeline/'); $valid = '%^' . $path . '(?<id>.*)\\.rss$%'; if (preg_match($valid, $feed, $matches)) { $user = User::staticGet('id', $matches['id']); if (!empty($user)) { return $user; } } return false; }
/** * Show javascript headers * * @return nothing */ function showScripts() { if (Event::handle('StartShowScripts', array($this))) { if (Event::handle('StartShowJQueryScripts', array($this))) { $this->script('jquery.min.js'); $this->script('jquery.form.js'); $this->script('jquery.cookie.js'); $this->inlineScript('if (typeof window.JSON !== "object") { $.getScript("' . common_path('js/json2.js') . '"); }'); $this->script('jquery.joverlay.min.js'); Event::handle('EndShowJQueryScripts', array($this)); } if (Event::handle('StartShowStatusNetScripts', array($this)) && Event::handle('StartShowLaconicaScripts', array($this))) { $this->script('xbImportNode.js'); $this->script('util.js'); $this->script('geometa.js'); // Frame-busting code to avoid clickjacking attacks. $this->inlineScript('if (window.top !== window.self) { window.top.location.href = window.self.location.href; }'); Event::handle('EndShowStatusNetScripts', array($this)); Event::handle('EndShowLaconicaScripts', array($this)); } Event::handle('EndShowScripts', array($this)); } }
function qvitterTwitterUserArray($profile) { $twitter_user = array(); try { $user = $profile->getUser(); } catch (NoSuchUserException $e) { $user = null; } $twitter_user['id'] = intval($profile->id); $twitter_user['name'] = $profile->getBestName(); $twitter_user['screen_name'] = $profile->nickname; $twitter_user['location'] = $profile->location ? $profile->location : null; $twitter_user['description'] = $profile->bio ? $profile->bio : null; // TODO: avatar url template (example.com/user/avatar?size={x}x{y}) $twitter_user['profile_image_url'] = Avatar::urlByProfile($profile, AVATAR_STREAM_SIZE); $twitter_user['profile_image_url_https'] = $twitter_user['profile_image_url']; // START introduced by qvitter API, not necessary for StatusNet API $twitter_user['profile_image_url_profile_size'] = Avatar::urlByProfile($profile, AVATAR_PROFILE_SIZE); try { $avatar = Avatar::getUploaded($profile); $origurl = $avatar->displayUrl(); } catch (Exception $e) { // ugly fix if avatar is missing in the db but exists on the server $largest_avatar = array('name' => false, 'size' => 0); foreach (glob('avatar/' . $profile->id . '-*') as $filename) { $size = filesize($filename); if ($size > $largest_avatar['size']) { $largest_avatar['size'] = $size; $largest_avatar['name'] = $filename; } } if ($largest_avatar['size'] > 0) { $origurl = common_path('', StatusNet::isHTTPS()) . $largest_avatar['name']; } else { $origurl = $twitter_user['profile_image_url_profile_size']; } } $twitter_user['profile_image_url_original'] = $origurl; $twitter_user['groups_count'] = $profile->getGroupCount(); foreach (array('linkcolor', 'backgroundcolor') as $key) { $twitter_user[$key] = Profile_prefs::getConfigData($profile, 'theme', $key); } // END introduced by qvitter API, not necessary for StatusNet API $twitter_user['url'] = $profile->homepage ? $profile->homepage : null; $twitter_user['protected'] = !empty($user) && $user->private_stream ? true : false; $twitter_user['followers_count'] = $profile->subscriberCount(); // Note: some profiles don't have an associated user $twitter_user['friends_count'] = $profile->subscriptionCount(); $twitter_user['created_at'] = ApiAction::dateTwitter($profile->created); $timezone = 'UTC'; if (!empty($user) && $user->timezone) { $timezone = $user->timezone; } $t = new DateTime(); $t->setTimezone(new DateTimeZone($timezone)); $twitter_user['utc_offset'] = $t->format('Z'); $twitter_user['time_zone'] = $timezone; $twitter_user['statuses_count'] = $profile->noticeCount(); // Is the requesting user following this user? $twitter_user['following'] = false; $twitter_user['statusnet_blocking'] = false; $logged_in_profile = null; if (common_logged_in()) { $logged_in_profile = Profile::current(); $twitter_user['following'] = $logged_in_profile->isSubscribed($profile); $twitter_user['statusnet_blocking'] = $logged_in_profile->hasBlocked($profile); } // StatusNet-specific $twitter_user['statusnet_profile_url'] = $profile->profileurl; Event::handle('TwitterUserArray', array($profile, &$twitter_user, $logged_in_profile, array())); return $twitter_user; }
/** * Add the jCrop scripts * * @return void */ function showScripts() { parent::showScripts(); if ($this->mode == 'crop') { $jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js'); $jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js'); $this->element('script', array('type' => 'text/javascript', 'src' => $jcropPack)); $this->element('script', array('type' => 'text/javascript', 'src' => $jcropGo)); } }
function showTagsDropdown() { $tag = $this->trimmed('tag'); $tags = $this->getAllTags(); $content = array(); foreach ($tags as $t) { $content[$t] = $t; } if ($tags) { $this->elementStart('dl', array('id' => 'filter_tags')); $this->element('dt', null, _('Filter tags')); $this->elementStart('dd'); $this->elementStart('ul'); $this->elementStart('li', array('id' => 'filter_tags_all', 'class' => 'child_1')); $this->element('a', array('href' => common_local_url($this->trimmed('action'), array('nickname' => $this->user->nickname))), _('All')); $this->elementEnd('li'); $this->elementStart('li', array('id' => 'filter_tags_item')); $this->elementStart('form', array('name' => 'bytag', 'id' => 'form_filter_bytag', 'action' => common_path('?action=' . $this->trimmed('action')), 'method' => 'post')); $this->elementStart('fieldset'); $this->element('legend', null, _('Select tag to filter')); $this->dropdown('tag', _('Tag'), $content, _('Choose a tag to narrow list'), false, $tag); $this->hidden('nickname', $this->user->nickname); $this->submit('submit', _('Go')); $this->elementEnd('fieldset'); $this->elementEnd('form'); $this->elementEnd('li'); $this->elementEnd('ul'); $this->elementEnd('dd'); $this->elementEnd('dl'); } }
/** * Save a new notice bookmark * * @param Profile $profile To save the bookmark for * @param string $title Title of the bookmark * @param string $url URL of the bookmark * @param mixed $rawtags array of tags or string * @param string $description Description of the bookmark * @param array $options Options for the Notice::saveNew() * * @return Notice saved notice */ static function saveNew($profile, $title, $url, $rawtags, $description, $options = null) { if (!common_valid_http_url($url)) { throw new ClientException(_m('Only web bookmarks can be posted (HTTP or HTTPS).')); } $nb = self::getByURL($profile, $url); if (!empty($nb)) { // TRANS: Client exception thrown when trying to save a new bookmark that already exists. throw new ClientException(_m('Bookmark already exists.')); } if (empty($options)) { $options = array(); } if (array_key_exists('uri', $options)) { $other = Bookmark::getKV('uri', $options['uri']); if (!empty($other)) { // TRANS: Client exception thrown when trying to save a new bookmark that already exists. throw new ClientException(_m('Bookmark already exists.')); } } if (is_string($rawtags)) { if (empty($rawtags)) { $rawtags = array(); } else { $rawtags = preg_split('/[\\s,]+/', $rawtags); } } $nb = new Bookmark(); $nb->id = UUID::gen(); $nb->profile_id = $profile->id; $nb->url = $url; $nb->title = $title; $nb->description = $description; if (array_key_exists('created', $options)) { $nb->created = $options['created']; } else { $nb->created = common_sql_now(); } if (array_key_exists('uri', $options)) { $nb->uri = $options['uri']; } else { // FIXME: hacks to work around router bugs in // queue daemons $r = Router::get(); $path = $r->build('showbookmark', array('id' => $nb->id)); if (empty($path)) { $nb->uri = common_path('bookmark/' . $nb->id, false, false); } else { $nb->uri = common_local_url('showbookmark', array('id' => $nb->id), null, null, false); } } $nb->insert(); $tags = array(); $replies = array(); // filter "for:nickname" tags foreach ($rawtags as $tag) { if (strtolower(mb_substr($tag, 0, 4)) == 'for:') { // skip if done by caller if (!array_key_exists('replies', $options)) { $nickname = mb_substr($tag, 4); $other = common_relative_profile($profile, $nickname); if (!empty($other)) { $replies[] = $other->getUri(); } } } else { $tags[] = common_canonical_tag($tag); } } $hashtags = array(); $taglinks = array(); foreach ($tags as $tag) { $hashtags[] = '#' . $tag; $attrs = array('href' => Notice_tag::url($tag), 'rel' => $tag, 'class' => 'tag'); $taglinks[] = XMLStringer::estring('a', $attrs, $tag); } // Use user's preferences for short URLs, if possible try { $user = User::getKV('id', $profile->id); $shortUrl = File_redirection::makeShort($url, empty($user) ? null : $user); } catch (Exception $e) { // Don't let this stop us. $shortUrl = $url; } // TRANS: Bookmark content. // TRANS: %1$s is a title, %2$s is a short URL, %3$s is the bookmark description, // TRANS: %4$s is space separated list of hash tags. $content = sprintf(_m('"%1$s" %2$s %3$s %4$s'), $title, $shortUrl, $description, implode(' ', $hashtags)); // TRANS: Rendered bookmark content. // TRANS: %1$s is a URL, %2$s the bookmark title, %3$s is the bookmark description, // TRANS: %4$s is space separated list of hash tags. $rendered = sprintf(_m('<span class="xfolkentry">' . '<a class="taggedlink" href="%1$s">%2$s</a> ' . '<span class="description">%3$s</span> ' . '<span class="meta">%4$s</span>' . '</span>'), htmlspecialchars($url), htmlspecialchars($title), htmlspecialchars($description), implode(' ', $taglinks)); $options = array_merge(array('urls' => array($url), 'rendered' => $rendered, 'tags' => $tags, 'replies' => $replies, 'object_type' => ActivityObject::BOOKMARK), $options); if (!array_key_exists('uri', $options)) { $options['uri'] = $nb->uri; } try { $saved = Notice::saveNew($profile->id, $content, array_key_exists('source', $options) ? $options['source'] : 'web', $options); } catch (Exception $e) { $nb->delete(); throw $e; } if (empty($saved)) { $nb->delete(); } return $saved; }
/** * Return current site's API root * * Varies based on URL parameters, like if fancy URLs are * turned on. * * @return string API root URI for this site */ private function _apiRoot() { if (common_config('site', 'fancy')) { return common_path('api/', true); } else { return common_path('index.php/api/', true); } }