/**
  * This action handles the display configuration page.
  *
  * It displays the display configuration page.
  * If this action is reached through a POST request, it stores all new
  * configuration values then sends a notification to the user.
  *
  * The options available on the page are:
  *   - language (default: en)
  *   - theme (default: Origin)
  *   - content width (default: thin)
  *   - display of read action in header
  *   - display of favorite action in header
  *   - display of date in header
  *   - display of open action in header
  *   - display of read action in footer
  *   - display of favorite action in footer
  *   - display of sharing action in footer
  *   - display of tags in footer
  *   - display of date in footer
  *   - display of open action in footer
  *   - html5 notification timeout (default: 0)
  * Default values are false unless specified.
  */
 public function displayAction()
 {
     if (Minz_Request::isPost()) {
         FreshRSS_Context::$user_conf->language = Minz_Request::param('language', 'en');
         FreshRSS_Context::$user_conf->theme = Minz_Request::param('theme', FreshRSS_Themes::$defaultTheme);
         FreshRSS_Context::$user_conf->content_width = Minz_Request::param('content_width', 'thin');
         FreshRSS_Context::$user_conf->topline_read = Minz_Request::param('topline_read', false);
         FreshRSS_Context::$user_conf->topline_favorite = Minz_Request::param('topline_favorite', false);
         FreshRSS_Context::$user_conf->topline_date = Minz_Request::param('topline_date', false);
         FreshRSS_Context::$user_conf->topline_link = Minz_Request::param('topline_link', false);
         FreshRSS_Context::$user_conf->bottomline_read = Minz_Request::param('bottomline_read', false);
         FreshRSS_Context::$user_conf->bottomline_favorite = Minz_Request::param('bottomline_favorite', false);
         FreshRSS_Context::$user_conf->bottomline_sharing = Minz_Request::param('bottomline_sharing', false);
         FreshRSS_Context::$user_conf->bottomline_tags = Minz_Request::param('bottomline_tags', false);
         FreshRSS_Context::$user_conf->bottomline_date = Minz_Request::param('bottomline_date', false);
         FreshRSS_Context::$user_conf->bottomline_link = Minz_Request::param('bottomline_link', false);
         FreshRSS_Context::$user_conf->html5_notif_timeout = Minz_Request::param('html5_notif_timeout', 0);
         FreshRSS_Context::$user_conf->save();
         Minz_Session::_param('language', FreshRSS_Context::$user_conf->language);
         Minz_Translate::reset(FreshRSS_Context::$user_conf->language);
         invalidateHttpCache();
         Minz_Request::good(_t('feedback.conf.updated'), array('c' => 'configure', 'a' => 'display'));
     }
     $this->view->themes = FreshRSS_Themes::get();
     Minz_View::prependTitle(_t('conf.display.title') . ' · ');
 }
Beispiel #2
0
 private function loadStylesAndScripts()
 {
     $theme = FreshRSS_Themes::load(FreshRSS_Context::$user_conf->theme);
     if ($theme) {
         foreach ($theme['files'] as $file) {
             if ($file[0] === '_') {
                 $theme_id = 'base-theme';
                 $filename = substr($file, 1);
             } else {
                 $theme_id = $theme['id'];
                 $filename = $file;
             }
             $filetime = @filemtime(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename);
             Minz_View::appendStyle(Minz_Url::display('/themes/' . $theme_id . '/' . $filename . '?' . $filetime));
         }
     }
     Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')));
     Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js')));
     Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
     if (FreshRSS_Context::$system_conf->auth_type === 'persona') {
         // TODO move it in a plugin
         // Needed for login AND logout with Persona.
         Minz_View::appendScript('https://login.persona.org/include.js');
         $file_mtime = @filemtime(PUBLIC_PATH . '/scripts/persona.js');
         Minz_View::appendScript(Minz_Url::display('/scripts/persona.js?' . $file_mtime));
     }
 }
Beispiel #3
0
 public static function load($theme_id)
 {
     $infos = self::get_infos($theme_id);
     if (!$infos) {
         if ($theme_id !== self::$defaultTheme) {
             //Fall-back to default theme
             return self::load(self::$defaultTheme);
         }
         $themes_list = self::getList();
         if (!empty($themes_list)) {
             if ($theme_id !== $themes_list[0]) {
                 //Fall-back to first theme
                 return self::load($themes_list[0]);
             }
         }
         return false;
     }
     self::$themeIconsUrl = self::$themesUrl . $theme_id . '/icons/';
     self::$themeIcons = is_dir(PUBLIC_PATH . self::$themeIconsUrl) ? array_fill_keys(array_diff(scandir(PUBLIC_PATH . self::$themeIconsUrl), array('..', '.')), 1) : array();
     return $infos;
 }
 public function displayAction()
 {
     if (Minz_Request::isPost()) {
         $this->view->conf->_language(Minz_Request::param('language', 'en'));
         $this->view->conf->_posts_per_page(Minz_Request::param('posts_per_page', 10));
         $this->view->conf->_view_mode(Minz_Request::param('view_mode', 'normal'));
         $this->view->conf->_default_view(Minz_Request::param('default_view', 'a'));
         $this->view->conf->_auto_load_more(Minz_Request::param('auto_load_more', false));
         $this->view->conf->_display_posts(Minz_Request::param('display_posts', false));
         $this->view->conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false));
         $this->view->conf->_lazyload(Minz_Request::param('lazyload', false));
         $this->view->conf->_sort_order(Minz_Request::param('sort_order', 'DESC'));
         $this->view->conf->_mark_when(array('article' => Minz_Request::param('mark_open_article', false), 'site' => Minz_Request::param('mark_open_site', false), 'scroll' => Minz_Request::param('mark_scroll', false), 'reception' => Minz_Request::param('mark_upon_reception', false)));
         $themeId = Minz_Request::param('theme', '');
         if ($themeId == '') {
             $themeId = FreshRSS_Themes::defaultTheme;
         }
         $this->view->conf->_theme($themeId);
         $this->view->conf->_topline_read(Minz_Request::param('topline_read', false));
         $this->view->conf->_topline_favorite(Minz_Request::param('topline_favorite', false));
         $this->view->conf->_topline_date(Minz_Request::param('topline_date', false));
         $this->view->conf->_topline_link(Minz_Request::param('topline_link', false));
         $this->view->conf->_bottomline_read(Minz_Request::param('bottomline_read', false));
         $this->view->conf->_bottomline_favorite(Minz_Request::param('bottomline_favorite', false));
         $this->view->conf->_bottomline_sharing(Minz_Request::param('bottomline_sharing', false));
         $this->view->conf->_bottomline_tags(Minz_Request::param('bottomline_tags', false));
         $this->view->conf->_bottomline_date(Minz_Request::param('bottomline_date', false));
         $this->view->conf->_bottomline_link(Minz_Request::param('bottomline_link', false));
         $this->view->conf->save();
         Minz_Session::_param('language', $this->view->conf->language);
         Minz_Translate::reset();
         invalidateHttpCache();
         $notif = array('type' => 'good', 'content' => Minz_Translate::t('configuration_updated'));
         Minz_Session::_param('notification', $notif);
         Minz_Request::forward(array('c' => 'configure', 'a' => 'display'), true);
     }
     $this->view->themes = FreshRSS_Themes::get();
     Minz_View::prependTitle(Minz_Translate::t('reading_configuration') . ' · ');
 }
Beispiel #5
0
function printStep2()
{
    $user_default_config = Minz_Configuration::get('default_user');
    ?>
	<?php 
    $s2 = checkStep2();
    if ($s2['all'] == 'ok') {
        ?>
	<p class="alert alert-success"><span class="alert-head"><?php 
        echo _t('gen.short.ok');
        ?>
</span> <?php 
        echo _t('install.conf.ok');
        ?>
</p>
	<?php 
    } elseif (!empty($_POST)) {
        ?>
	<p class="alert alert-error"><?php 
        echo _t('install.fix_errors_before');
        ?>
</p>
	<?php 
    }
    ?>

	<form action="index.php?step=2" method="post">
		<legend><?php 
    echo _t('install.conf');
    ?>
</legend>

		<div class="form-group">
			<label class="group-name" for="old_entries"><?php 
    echo _t('install.delete_articles_after');
    ?>
</label>
			<div class="group-controls">
				<input type="number" id="old_entries" name="old_entries" required="required" min="1" max="1200" value="<?php 
    echo isset($_SESSION['old_entries']) ? $_SESSION['old_entries'] : $user_default_config->old_entries;
    ?>
" tabindex="2" /> <?php 
    echo _t('gen.date.month');
    ?>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="default_user"><?php 
    echo _t('install.default_user');
    ?>
</label>
			<div class="group-controls">
				<input type="text" id="default_user" name="default_user" required="required" size="16" maxlength="16" pattern="[0-9a-zA-Z]{1,16}" value="<?php 
    echo isset($_SESSION['default_user']) ? $_SESSION['default_user'] : '';
    ?>
" placeholder="<?php 
    echo httpAuthUser() == '' ? 'alice' : httpAuthUser();
    ?>
" tabindex="3" />
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="auth_type"><?php 
    echo _t('install.auth.type');
    ?>
</label>
			<div class="group-controls">
				<select id="auth_type" name="auth_type" required="required" onchange="auth_type_change(true)" tabindex="4">
					<?php 
    function no_auth($auth_type)
    {
        return !in_array($auth_type, array('form', 'persona', 'http_auth', 'none'));
    }
    $auth_type = isset($_SESSION['auth_type']) ? $_SESSION['auth_type'] : '';
    ?>
					<option value="form"<?php 
    echo $auth_type === 'form' || no_auth($auth_type) ? ' selected="selected"' : '', cryptAvailable() ? '' : ' disabled="disabled"';
    ?>
><?php 
    echo _t('install.auth.form');
    ?>
</option>
					<option value="persona"<?php 
    echo $auth_type === 'persona' ? ' selected="selected"' : '';
    ?>
><?php 
    echo _t('install.auth.persona');
    ?>
</option>
					<option value="http_auth"<?php 
    echo $auth_type === 'http_auth' ? ' selected="selected"' : '', httpAuthUser() == '' ? ' disabled="disabled"' : '';
    ?>
><?php 
    echo _t('install.auth.http');
    ?>
(REMOTE_USER = '******')</option>
					<option value="none"<?php 
    echo $auth_type === 'none' ? ' selected="selected"' : '';
    ?>
><?php 
    echo _t('install.auth.none');
    ?>
</option>
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="passwordPlain"><?php 
    echo _t('install.auth.password_form');
    ?>
</label>
			<div class="group-controls">
				<div class="stick">
					<input type="password" id="passwordPlain" name="passwordPlain" pattern=".{7,}" autocomplete="off" <?php 
    echo $auth_type === 'form' ? ' required="required"' : '';
    ?>
 tabindex="5" />
					<a class="btn toggle-password" data-toggle="passwordPlain"><?php 
    echo FreshRSS_Themes::icon('key');
    ?>
</a>
				</div>
				<?php 
    echo _i('help');
    ?>
 <?php 
    echo _t('install.auth.password_format');
    ?>
				<noscript><b><?php 
    echo _t('gen.js.should_be_activated');
    ?>
</b></noscript>
			</div>
		</div>

		<div class="form-group">
			<label class="group-name" for="mail_login"><?php 
    echo _t('install.auth.email_persona');
    ?>
</label>
			<div class="group-controls">
				<input type="email" id="mail_login" name="mail_login" value="<?php 
    echo isset($_SESSION['mail_login']) ? $_SESSION['mail_login'] : '';
    ?>
" placeholder="*****@*****.**" <?php 
    echo $auth_type === 'persona' ? ' required="required"' : '';
    ?>
 tabindex="6"/>
				<noscript><b><?php 
    echo _t('gen.js.should_be_activated');
    ?>
</b></noscript>
			</div>
		</div>

		<script>
			function show_password() {
				var button = this;
				var passwordField = document.getElementById(button.getAttribute('data-toggle'));
				passwordField.setAttribute('type', 'text');
				button.className += ' active';

				return false;
			}
			function hide_password() {
				var button = this;
				var passwordField = document.getElementById(button.getAttribute('data-toggle'));
				passwordField.setAttribute('type', 'password');
				button.className = button.className.replace(/(?:^|\s)active(?!\S)/g , '');

				return false;
			}
			toggles = document.getElementsByClassName('toggle-password');
			for (var i = 0 ; i < toggles.length ; i++) {
				toggles[i].addEventListener('mousedown', show_password);
				toggles[i].addEventListener('mouseup', hide_password);
			}

			function auth_type_change() {
				var auth_value = document.getElementById('auth_type').value,
				    password_input = document.getElementById('passwordPlain'),
				    mail_input = document.getElementById('mail_login');

				if (auth_value === 'form') {
					password_input.required = true;
					mail_input.required = false;
				} else if (auth_value === 'persona') {
					password_input.required = false;
					mail_input.required = true;
				} else {
					password_input.required = false;
					mail_input.required = false;
				}
			}
			auth_type_change();
		</script>

		<div class="form-group form-actions">
			<div class="group-controls">
				<button type="submit" class="btn btn-important" tabindex="7" ><?php 
    echo _t('gen.action.submit');
    ?>
</button>
				<button type="reset" class="btn" tabindex="8" ><?php 
    echo _t('gen.action.cancel');
    ?>
</button>
				<?php 
    if ($s2['all'] == 'ok') {
        ?>
				<a class="btn btn-important next-step" href="?step=3" tabindex="9" ><?php 
        echo _t('install.action.next_step');
        ?>
</a>
				<?php 
    }
    ?>
			</div>
		</div>
	</form>
<?php 
}
Beispiel #6
0
 private function loadStylesAndScripts($loginOk)
 {
     $theme = FreshRSS_Themes::load($this->conf->theme);
     if ($theme) {
         foreach ($theme['files'] as $file) {
             Minz_View::appendStyle(Minz_Url::display('/themes/' . $theme['id'] . '/' . $file . '?' . @filemtime(PUBLIC_PATH . '/themes/' . $theme['id'] . '/' . $file)));
         }
     }
     switch (Minz_Configuration::authType()) {
         case 'form':
             if (!$loginOk) {
                 Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js')));
             }
             break;
         case 'persona':
             Minz_View::appendScript('https://login.persona.org/include.js');
             break;
     }
     $includeLazyLoad = $this->conf->lazyload && ($this->conf->display_posts || Minz_Request::param('output') === 'reader');
     Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')), false, !$includeLazyLoad, !$includeLazyLoad);
     if ($includeLazyLoad) {
         Minz_View::appendScript(Minz_Url::display('/scripts/jquery.lazyload.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js')));
     }
     Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js')));
     Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
 }