Esempio n. 1
0
	/**
	 * display quorum bargraph
	 *
	 * @param boolean $supported_by_member proposal is supported by the logged in member
	 * @param boolean $valid               the support by the logged in member is not expired
	 */
	public function bargraph_quorum($supported_by_member, $valid) {

		$value = $this->supporters;
		$population = $this->issue()->area()->population();
		$required = $this->quorum_required();
		$title = sprintf(
			_("%d supporters of %d participants - %d supporters (%s) currently required for admission"),
			$this->supporters,
			$population,
			$required,
			numden($this->quorum_level())
		);

		$min_width = 120;
		$max_width = 360;
		$bar_width     = round( min($value,    $population) / $population * $max_width );
		$required_left = round( min($required, $population) / $population * $max_width );
		$width = max($min_width, $bar_width);

		?><div class="bargraph bargraph_quorum" style="width:<?php 
echo $width;
?>
px" title="<?php 
echo $title;
?>
"><?
		?><div class="bar yes" style="width:<?php 
echo $bar_width;
?>
px"></div><?
		?><div class="required" style="margin-left:<?php 
echo $required_left;
?>
px"></div><?
		?><div class="legend" style="width:<?php 
echo $width;
?>
px"><?php 
echo $value;
?>
</div><?
		if ($supported_by_member) {
			if ($valid) {
				?><div class="supported" title="<?php 
echo _("You support this proposal.");
?>
">&#10003;</div><?
			} else {
				?><div class="supported expired" title="<?php 
echo _("Your support for this proposal is expired.");
?>
">&#10003;</div><?
			}
		}
		?><div class="clear"></div><?
		?></div><?

	}
/**
 * display help text
 *
 * default for logged in members:      show all help
 * default for not logged in sessions: hide all help
 *
 * This function should not be used on pages with forms, because users will lose their already filled in data if they click on the help buttons.
 *
 * @param string  $anchor (optional) for additional help messages on the same page
 * @param boolean $h1     (optional)
 */
function help($anchor="", $h1=false) {
	if ($anchor) {
		$link_anchor = "#help_".$anchor;
		$id = ' id="help_'.$anchor.'"';
		$identifier = BN."#".$anchor;
	} else {
		$link_anchor = "";
		$id = '';
		$identifier = BN;
	}
	if (Login::$member) {
		$show = !in_array($identifier, Login::$member->hide_help());
	} else {
		if ( isset($_SESSION['show_help']) ) {
			$show = in_array($identifier, $_SESSION['show_help']);
		} else {
			$show = false;
		}
	}
	if ($show) {
?>
<section class="help"<?=$id?>>
<?
		form(URI::same().$link_anchor, 'class="hide_help"');
		if ($anchor) {
?>
<input type="hidden" name="anchor" value="<?=$anchor?>">
<?
		}
?>
<input type="hidden" name="action" value="hide_help">
<input type="submit" value="<?=_("hide help")?>">
<?
		form_end();
		// read help content
		$display = false;
		$list = false;
		foreach ( file("locale/help_".LANG.".html", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line ) {
			if ($display) {
				$line_begin = mb_substr($line, 0, 3);
				if ($line_begin == "===") break;
				// replace placeholders
				if ( strpos($line, "%")!==false ) {
					static $replace;
					if (!$replace) {
						$replace = array(
							'%REQUIRED_PROPONENTS'   => REQUIRED_PROPONENTS,
							'%QUORUM_VOTINGMODE'     => numden([QUORUM_VOTINGMODE_NUM, QUORUM_VOTINGMODE_DEN]),
							'%MAIL_SUPPORT'          => MAIL_SUPPORT,
							'%COMMENT_EDIT_INTERVAL' => translate_time_interval(COMMENT_EDIT_INTERVAL)
						);
					}
					$line = strtr($line, $replace);
				}
				// list / paragraph
				if ($line_begin == " * ") {
					if (!$list) {
						$list = true;
?>
<ul>
<?
					}
?>
	<li><?=mb_substr($line, 3)?></li>
<?
				} else {
					if ($list) {
?>
</ul>
<?
						$list = false;
					}
?>
<p><?=$line?></p>
<?
				}
			} elseif ($line == "===".$identifier) {
				$display = true;
			}
		}
?>
</section>
<?
	} else {
		form(URI::same().$link_anchor, 'class="show_help'.($h1?' h1':'').'"'.$id);
		if ($anchor) {
?>
<input type="hidden" name="anchor" value="<?=$anchor?>">
<?
		}
?>
<input type="hidden" name="action" value="show_help">
<input type="submit" value="<?=_("show help")?>">
<?
		form_end();
	}
}