+ /**
+ * Show page, a template method.
+ *
+ * @return nothing
+ */
+ function showPage()
+ {
+ if (Event::handle('StartShowHTML', array($this))) {
+ $this->startHTML();
+ Event::handle('EndShowHTML', array($this));
+ }
+ if (Event::handle('StartShowHead', array($this))) {
+ $this->showHead();
+ Event::handle('EndShowHead', array($this));
+ }
+ if (Event::handle('StartShowBody', array($this))) {
+ $this->showBody();
+ Event::handle('EndShowBody', array($this));
+ }
+ if (Event::handle('StartEndHTML', array($this))) {
+ $this->endHTML();
+ Event::handle('EndEndHTML', array($this));
+ }
+ }
+
+ /**
+ * Show head, a template method.
+ *
+ * @return nothing
+ */
+ function showHead()
+ {
+ // XXX: attributes (profile?)
+ $this->elementStart('head');
+ $this->showTitle();
+ $this->showShortcutIcon();
+ $this->showStylesheets();
+ $this->showScripts();
+ $this->showOpenSearch();
+ $this->showFeeds();
+ $this->showDescription();
+ $this->extraHead();
+ $this->elementEnd('head');
+ }
+
+ /**
+ * Show title, a template method.
+ *
+ * @return nothing
+ */
+ function showTitle()
+ {
+ $this->element('title', null,
+ sprintf(_("%s - %s"),
+ $this->title(),
+ common_config('site', 'name')));
+ }
+
+ /**
+ * Returns the page title
+ *
+ * SHOULD overload
+ *
+ * @return string page title
+ */
+
+ function title()
+ {
+ return _("Untitled page");
+ }
+
+ /**
+ * Show themed shortcut icon
+ *
+ * @return nothing
+ */
+ function showShortcutIcon()
+ {
+ if (is_readable(INSTALLDIR . '/theme/' . common_config('site', 'theme') . '/favicon.ico')) {
+ $this->element('link', array('rel' => 'shortcut icon',
+ 'href' => theme_path('favicon.ico')));
+ } else {
+ $this->element('link', array('rel' => 'shortcut icon',
+ 'href' => common_path('favicon.ico')));
+ }
+
+ if (common_config('site', 'mobile')) {
+ if (is_readable(INSTALLDIR . '/theme/' . common_config('site', 'theme') . '/apple-touch-icon.png')) {
+ $this->element('link', array('rel' => 'apple-touch-icon',
+ 'href' => theme_path('apple-touch-icon.png')));
+ } else {
+ $this->element('link', array('rel' => 'apple-touch-icon',
+ 'href' => common_path('apple-touch-icon.png')));
+ }
+ }
+ }
+
+ /**
+ * Show stylesheets
+ *
+ * @return nothing
+ */
+ function showStylesheets()
+ {
+ if (Event::handle('StartShowStyles', array($this))) {
+ if (Event::handle('StartShowLaconicaStyles', array($this))) {
+ $this->element('link', array('rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION,
+ 'media' => 'screen, projection, tv'));
+ if (common_config('site', 'mobile')) {
+ $this->element('link', array('rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'href' => theme_path('css/mobile.css', 'base') . '?version=' . LACONICA_VERSION,
+ // TODO: "handheld" CSS for other mobile devices
+ 'media' => 'only screen and (max-device-width: 480px)')); // Mobile WebKit
+ }
+ $this->element('link', array('rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'href' => theme_path('css/print.css', 'base') . '?version=' . LACONICA_VERSION,
+ 'media' => 'print'));
+ Event::handle('EndShowLaconicaStyles', array($this));
+ }
+ if (Event::handle('StartShowUAStyles', array($this))) {
+ $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
+ 'href="'.theme_path('css/ie.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
+ foreach (array(6,7) as $ver) {
+ if (file_exists(theme_file('css/ie'.$ver.'.css', 'base'))) {
+ // Yes, IE people should be put in jail.
+ $this->comment('[if lte IE '.$ver.']><link rel="stylesheet" type="text/css" '.
+ 'href="'.theme_path('css/ie'.$ver.'.css', 'base').'?version='.LACONICA_VERSION.'" /><![endif]');
+ }
+ }
+ $this->comment('[if IE]><link rel="stylesheet" type="text/css" '.
+ 'href="'.theme_path('css/ie.css', null).'?version='.LACONICA_VERSION.'" /><![endif]');
+ Event::handle('EndShowUAStyles', array($this));
+ }
+ Event::handle('EndShowStyles', array($this));
+ }
+ }
+
+ /**
+ * Show javascript headers
+ *
+ * @return nothing
+ */
+ function showScripts()
+ {
+ if (Event::handle('StartShowScripts', array($this))) {
+ if (Event::handle('StartShowJQueryScripts', array($this))) {
+ $this->element('script', array('type' => 'text/javascript',
+ 'src' => common_path('js/jquery.min.js')),
+ ' ');
+ $this->element('script', array('type' => 'text/javascript',
+ 'src' => common_path('js/jquery.form.js')),
+ ' ');
+ Event::handle('EndShowJQueryScripts', array($this));
+ }
+ if (Event::handle('StartShowLaconicaScripts', array($this))) {
+ $this->element('script', array('type' => 'text/javascript',
+ 'src' => common_path('js/xbImportNode.js')),
+ ' ');
+ $this->element('script', array('type' => 'text/javascript',
+ 'src' => common_path('js/util.js?version='.LACONICA_VERSION)),
+ ' ');
+ // Frame-busting code to avoid clickjacking attacks.
+ $this->element('script', array('type' => 'text/javascript'),
+ 'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }');
+ Event::handle('EndShowLaconicaScripts', array($this));
+ }
+ Event::handle('EndShowScripts', array($this));
+ }
+ }
+
+ /**
+ * Show OpenSearch headers
+ *
+ * @return nothing
+ */
+ function showOpenSearch()
+ {
+ $this->element('link', array('rel' => 'search',
+ 'type' => 'application/opensearchdescription+xml',
+ 'href' => common_local_url('opensearch', array('type' => 'people')),
+ 'title' => common_config('site', 'name').' People Search'));
+ $this->element('link', array('rel' => 'search', 'type' => 'application/opensearchdescription+xml',
+ 'href' => common_local_url('opensearch', array('type' => 'notice')),
+ 'title' => common_config('site', 'name').' Notice Search'));
+ }
+
+ /**
+ * Show feed headers
+ *
+ * MAY overload
+ *
+ * @return nothing
+ */
+
+ 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));
+ }
+ }
+ }
+
+ /**
+ * Show description.
+ *
+ * SHOULD overload
+ *
+ * @return nothing
+ */
+ function showDescription()
+ {
+ // does nothing by default
+ }
+
+ /**
+ * Show extra stuff in <head>.
+ *
+ * MAY overload
+ *
+ * @return nothing
+ */
+ function extraHead()
+ {
+ // does nothing by default
+ }
+
+ /**
+ * Show body.
+ *
+ * Calls template methods
+ *
+ * @return nothing
+ */
+ function showBody()
+ {
+ $this->elementStart('body', (common_current_user()) ? array('id' => $this->trimmed('action'),
+ 'class' => 'user_in')
+ : array('id' => $this->trimmed('action')));
+ $this->elementStart('div', array('id' => 'wrap'));
+ if (Event::handle('StartShowHeader', array($this))) {
+ $this->showHeader();
+ Event::handle('EndShowHeader', array($this));
+ }
+ $this->showCore();
+ if (Event::handle('StartShowFooter', array($this))) {
+ $this->showFooter();
+ Event::handle('EndShowFooter', array($this));
+ }
+ $this->elementEnd('div');
+ $this->elementEnd('body');
+ }
+
+ /**
+ * Show header of the page.
+ *
+ * Calls template methods
+ *
+ * @return nothing
+ */
+ function showHeader()
+ {
+ $this->elementStart('div', array('id' => 'header'));
+ $this->showLogo();
+ $this->showPrimaryNav();
+ $this->showSiteNotice();
+ if (common_logged_in()) {
+ $this->showNoticeForm();
+ } else {
+ $this->showAnonymousMessage();
+ }
+ $this->elementEnd('div');
+ }
+
+ /**
+ * Show configured logo.
+ *
+ * @return nothing
+ */
+ function showLogo()
+ {
+ $this->elementStart('address', array('id' => 'site_contact',
+ 'class' => 'vcard'));
+ $this->elementStart('a', array('class' => 'url home bookmark',
+ 'href' => common_local_url('public')));
+ if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) {
+ $this->element('img', array('class' => 'logo photo',
+ 'src' => (common_config('site', 'logo')) ? common_config('site', 'logo') : theme_path('logo.png'),
+ 'alt' => common_config('site', 'name')));
+ }
+ $this->element('span', array('class' => 'fn org'), common_config('site', 'name'));
+ $this->elementEnd('a');
+ $this->elementEnd('address');
+ }
+
+ /**
+ * Show primary navigation.
+ *
+ * @return nothing
+ */
+ function showPrimaryNav()
+ {
+ $user = common_current_user();
+
+ $this->elementStart('dl', array('id' => 'site_nav_global_primary'));
+ $this->element('dt', null, _('Primary site navigation'));
+ $this->elementStart('dd');
+ $this->elementStart('ul', array('class' => 'nav'));
+ if (Event::handle('StartPrimaryNav', array($this))) {
+ if ($user) {
+ $this->menuItem(common_local_url('all', array('nickname' => $user->nickname)),
+ _('Home'), _('Personal profile and friends timeline'), false, 'nav_home');
+ $this->menuItem(common_local_url('profilesettings'),
+ _('Account'), _('Change your email, avatar, password, profile'), false, 'nav_account');
+ if (common_config('xmpp', 'enabled')) {
+ $this->menuItem(common_local_url('imsettings'),
+ _('Connect'), _('Connect to IM, SMS, Twitter'), false, 'nav_connect');
+ } else {
+ $this->menuItem(common_local_url('smssettings'),
+ _('Connect'), _('Connect to SMS, Twitter'), false, 'nav_connect');
+ }
+ $this->menuItem(common_local_url('invite'),
+ _('Invite'),
+ sprintf(_('Invite friends and colleagues to join you on %s'),
+ common_config('site', 'name')),
+ false, 'nav_invitecontact');
+ $this->menuItem(common_local_url('logout'),
+ _('Logout'), _('Logout from the site'), false, 'nav_logout');
+ }
+ else {
+ if (!common_config('site', 'closed')) {
+ $this->menuItem(common_local_url('register'),
+ _('Register'), _('Create an account'), false, 'nav_register');
+ }
+ $this->menuItem(common_local_url('openidlogin'),
+ _('OpenID'), _('Login with OpenID'), false, 'nav_openid');
+ $this->menuItem(common_local_url('login'),
+ _('Login'), _('Login to the site'), false, 'nav_login');
+ }
+ $this->menuItem(common_local_url('doc', array('title' => 'help')),
+ _('Help'), _('Help me!'), false, 'nav_help');
+ $this->menuItem(common_local_url('peoplesearch'),
+ _('Search'), _('Search for people or text'), false, 'nav_search');
+ Event::handle('EndPrimaryNav', array($this));
+ }
+ $this->elementEnd('ul');
+ $this->elementEnd('dd');
+ $this->elementEnd('dl');
+ }
+
+ /**
+ * Show site notice.
+ *
+ * @return nothing
+ */
+ function showSiteNotice()
+ {
+ // Revist. Should probably do an hAtom pattern here
+ $text = common_config('site', 'notice');
+ if ($text) {
+ $this->elementStart('dl', array('id' => 'site_notice',
+ 'class' => 'system_notice'));
+ $this->element('dt', null, _('Site notice'));
+ $this->elementStart('dd', null);
+ $this->raw($text);
+ $this->elementEnd('dd');
+ $this->elementEnd('dl');
+ }
+ }
+
+ /**
+ * Show notice form.
+ *
+ * MAY overload if no notice form needed... or direct message box????
+ *
+ * @return nothing
+ */
+ function showNoticeForm()
+ {
+ $notice_form = new NoticeForm($this);
+ $notice_form->show();
+ }
+
+ /**
+ * Show anonymous message.
+ *
+ * SHOULD overload
+ *
+ * @return nothing
+ */
+ function showAnonymousMessage()
+ {
+ // needs to be defined by the class
+ }
+
+ /**
+ * Show core.
+ *
+ * Shows local navigation, content block and aside.
+ *
+ * @return nothing
+ */
+ function showCore()
+ {
+ $this->elementStart('div', array('id' => 'core'));
+ if (Event::handle('StartShowLocalNavBlock', array($this))) {
+ $this->showLocalNavBlock();
+ Event::handle('EndShowLocalNavBlock', array($this));
+ }
+ if (Event::handle('StartShowContentBlock', array($this))) {
+ $this->showContentBlock();
+ Event::handle('EndShowContentBlock', array($this));
+ }
+ $this->showAside();
+ $this->elementEnd('div');
+ }
+
+ /**
+ * Show local navigation block.
+ *
+ * @return nothing
+ */
+ function showLocalNavBlock()
+ {
+ $this->elementStart('dl', array('id' => 'site_nav_local_views'));
+ $this->element('dt', null, _('Local views'));
+ $this->elementStart('dd');
+ $this->showLocalNav();
+ $this->elementEnd('dd');
+ $this->elementEnd('dl');
+ }
+
+ /**
+ * Show local navigation.
+ *
+ * SHOULD overload
+ *
+ * @return nothing
+ */
+ function showLocalNav()
+ {
+ // does nothing by default
+ }
+
+ /**
+ * Show content block.
+ *
+ * @return nothing
+ */
+ function showContentBlock()
+ {
+ $this->elementStart('div', array('id' => 'content'));
+ $this->showPageTitle();
+ $this->showPageNoticeBlock();
+ $this->elementStart('div', array('id' => 'content_inner'));
+ // show the actual content (forms, lists, whatever)
+ $this->showContent();
+ $this->elementEnd('div');
+ $this->elementEnd('div');
+ }
+
+ /**
+ * Show page title.
+ *
+ * @return nothing
+ */
+ function showPageTitle()
+ {
+ $this->element('h1', null, $this->title());
+ }