Example #1
0
 protected function time_array($timestamp)
 {
     $time = array_combine(array('month', 'day', 'year', 'hour', 'minute', 'am_pm'), explode('--', date('n--j--Y--g--i--A', $timestamp)));
     // Minutes should always be in 5 minute increments
     $time['minute'] = num::round($time['minute'], current($this->parts['minute']));
     return $time;
 }
Example #2
0
 public function render()
 {
     $v = new View("form_uploadify.html");
     $v->album = $this->data["album"];
     $v->script_data = $this->data["script_data"];
     $v->simultaneous_upload_limit = module::get_var("gallery", "simultaneous_upload_limit");
     $v->movies_allowed = movie::allow_uploads();
     $v->extensions = legal_file::get_filters();
     $v->suhosin_session_encrypt = (bool) ini_get("suhosin.session.encrypt");
     list($toolkit_max_filesize_bytes, $toolkit_max_filesize) = graphics::max_filesize();
     $upload_max_filesize = trim(ini_get("upload_max_filesize"));
     $upload_max_filesize_bytes = num::convert_to_bytes($upload_max_filesize);
     if ($upload_max_filesize_bytes < $toolkit_max_filesize_bytes) {
         $v->size_limit_bytes = $upload_max_filesize_bytes;
         $v->size_limit = $upload_max_filesize;
     } else {
         $v->size_limit_bytes = $toolkit_max_filesize_bytes;
         $v->size_limit = $toolkit_max_filesize;
     }
     return $v;
 }
Example #3
0
echo __('Errors');
?>
 <b><?php 
echo $totals['errors'];
?>
</b>.
	</span>
	<?php 
if ($xdebug_enabled and isset($coverage)) {
    ?>
	<span class="code_coverage">
		<?php 
    $level_class = $coverage > 75 ? 'excellent' : ($coverage > 35 ? 'ok' : 'terrible');
    ?>
		<?php 
    echo __('Tests covered :percent of the :codebase', array(':percent' => '<b class="' . $level_class . '">' . num::format($coverage, 2) . '%</b>', ':codebase' => !empty($coverage_explanation) ? '<span title="' . $coverage_explanation . '" style="display:inline;">modules</span>' : 'codebase'));
    ?>
,
		<?php 
    echo HTML::anchor($report_uri, 'View');
    ?>
		or
		<?php 
    echo HTML::anchor($report_uri . '&archive=1', 'Download');
    ?>
		the report
	</span>
	<?php 
}
?>
</div>
Example #4
0
	<span class="time"><?php echo __('Time') ?>: <b><?php echo $time?></b></span>
	<span class="summary">
		<?php echo __('Tests') ?> <b><?php echo $totals['tests']?></b>, 
		<?php echo __('Assertions') ?> <b><?php echo $totals['assertions']?></b>, 
		<?php echo __('Failures') ?> <b><?php echo $totals['failures']?></b>, 
		<?php echo __('Skipped') ?> <b><?php echo $totals['skipped']?></b>, 
		<?php echo __('Errors') ?> <b><?php echo $totals['errors']?></b>.
	</span>
	<?php if($xdebug_enabled AND isset($coverage)): ?>
	<span class="code_coverage">
		<?php $level_class = ($coverage > 75 ? 'excellent' : ($coverage > 35 ? 'ok' : 'terrible')); ?>
		<?php
			echo __('Tests covered :percent of the :codebase',
				array
				(
					':percent'	=> '<b class="'.$level_class.'">'.num::format($coverage, 2).'%</b>',
					':codebase' => ( ! empty($coverage_explanation) ? '<span title="'.$coverage_explanation.'" style="display:inline;">modules</span>' : 'codebase')
				)
			);
		?>,
		
		<?php echo Form::open($report_uri, array('method' => 'POST', 'id' => 'download-report')); ?>
			<label><?php echo __('Download report as'); ?></label>
			<?php echo Form::select('format', $report_formats); ?>
			<input type="submit" value="Get it!" />
		<?php echo Form::close(); ?>
	</span>
	<?php endif; ?>
</div>

<div id="results">
Example #5
0
    post_params: {
      "g3sid": "<?php 
echo Session::instance()->id();
?>
",
      "user_agent": "<?php 
echo Input::instance()->server("HTTP_USER_AGENT");
?>
",
      "csrf": "<?php 
echo $csrf;
?>
"
    },
    file_size_limit : "<?php 
echo ini_get("upload_max_filesize") ? num::convert_to_bytes(ini_get("upload_max_filesize")) . "B" : "100MB";
?>
",
    file_types : "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4",
    file_types_description : "<?php 
echo t("Photos and Movies");
?>
",
    file_upload_limit : 1000,
    file_queue_limit : 0,
    custom_settings : { },
    debug: false,

    // Button settings
    button_image_url: "<?php 
echo url::file("themes/default/images/select-photos-backg.png");
Example #6
0
 /**
  * User friends
  */
 public function _friends()
 {
     $this->tab_id = 'friends';
     $owner = $this->user && $this->member->id == $this->user->id;
     // handle pagination
     $pagination = new Pagination(array('items_per_page' => 25, 'total_items' => $this->member->get_friend_count()));
     $this->page_subtitle .= __(':friends friends, page :page of :pages', array(':friends' => '<var>' . num::format($pagination->total_items) . '</var>', ':page' => '<var>' . $pagination->current_page . '</var>', ':pages' => '<var>' . $pagination->total_pages . '</var>'));
     $friends = $this->member->find_friends($pagination->current_page, $pagination->items_per_page);
     widget::add('main', $pagination);
     widget::add('main', View::factory('member/friends', array('friends' => $friends)));
     widget::add('main', $pagination);
     $this->_side_views();
 }
Example #7
0
 /**
  * Return the max file size that this graphics toolkit can handle.
  */
 static function max_filesize()
 {
     if (module::get_var("gallery", "graphics_toolkit") == "gd") {
         $memory_limit = trim(ini_get("memory_limit"));
         $memory_limit_bytes = num::convert_to_bytes($memory_limit);
         // GD expands images in memory and uses 4 bytes of RAM for every byte
         // in the file.
         $max_filesize = $memory_limit_bytes / 4;
         $max_filesize_human_readable = num::convert_to_human_readable($max_filesize);
         return array($max_filesize, $max_filesize_human_readable);
     }
     // Some arbitrarily large size
     return array(1000000000, "1G");
 }
Example #8
0
 public static function hsb2rgb($hue, $saturation, $brightness)
 {
     $hue = num::round($hue, 3);
     $saturation = num::round($saturation, 3);
     $brightness = num::round($brightness, 3);
     $hexBrightness = (int) round($brightness * 2.55);
     if ($saturation == 0) {
         return array('red' => $hexBrightness, 'green' => $hexBrightness, 'blue' => $hexBrightness);
     }
     $Hi = floor($hue / 60);
     $f = $hue / 60 - $Hi;
     $p = (int) round($brightness * (100 - $saturation) * 0.0255);
     $q = (int) round($brightness * (100 - $f * $saturation) * 0.0255);
     $t = (int) round($brightness * (100 - (1 - $f) * $saturation) * 0.0255);
     switch ($Hi) {
         case 0:
             return array('red' => $hexBrightness, 'green' => $t, 'blue' => $p);
         case 1:
             return array('red' => $q, 'green' => $hexBrightness, 'blue' => $p);
         case 2:
             return array('red' => $p, 'green' => $hexBrightness, 'blue' => $t);
         case 3:
             return array('red' => $p, 'green' => $q, 'blue' => $hexBrightness);
         case 4:
             return array('red' => $t, 'green' => $p, 'blue' => $hexBrightness);
         case 5:
             return array('red' => $hexBrightness, 'green' => $p, 'blue' => $q);
     }
     return false;
 }
 /**
  * Tests the num::round() function.
  * @dataProvider round_provider
  * @group core.helpers.num.round
  * @test
  */
 public function round($input_number, $input_nearest, $expected_result)
 {
     $result = num::round($input_number, $input_nearest);
     $this->assertEquals($expected_result, $result);
 }
Example #10
0
 /**
  * Returns num::ordinal with the number prepended
  *
  * @param string $number 
  * @return string
  * @author Jonathan Geiger
  */
 public static function ordinal($number)
 {
     return $number . num::ordinal($number);
 }
 public function convert_to_human_readable_test()
 {
     $this->assert_equal("6K", num::convert_to_human_readable(5615));
     $this->assert_equal("1M", num::convert_to_human_readable(1205615));
     $this->assert_equal("3G", num::convert_to_human_readable(3091205615));
 }
Example #12
0
<script type="text/javascript">
  var swfu = new SWFUpload({
    flash_url: <?php 
echo html::js_string(url::file("lib/swfupload/swfupload.swf"));
?>
,
    upload_url: <?php 
echo html::js_string(url::site("simple_uploader/add_photo/{$item->id}"));
?>
,
    post_params: <?php 
echo json_encode(array("g3sid" => Session::instance()->id(), "user_agent" => Input::instance()->server("HTTP_USER_AGENT"), "csrf" => $csrf));
?>
,
    file_size_limit: <?php 
echo html::js_string(ini_get("upload_max_filesize") ? num::convert_to_bytes(ini_get("upload_max_filesize")) . "B" : "100MB");
?>
,
    file_types: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4",
    file_types_description: <?php 
echo t("Photos and Movies")->for_js();
?>
,
    file_upload_limit: 1000,
    file_queue_limit: 0,
    custom_settings: { },
    debug: false,

    // Button settings
    button_image_url: <?php 
echo html::js_string(url::file("themes/default/images/select-photos-backg.png"));
 /**
  * Calculates the font size of a tag cloud item
  */
 private function _calculate_font_size($cur_frequency, $max_frequency, $min_frequency)
 {
     if ($max_frequency - $min_frequency === 0) {
         return $this->min_font_size;
     }
     // Calculate the weight using a power law - consider switching to a logarithmic one
     $weight = ($cur_frequency - $min_frequency) / ($max_frequency - $min_frequency);
     return $this->min_font_size + num::round(($this->max_font_size - $this->min_font_size) * $weight);
 }
Example #14
0
 /**
  * Print icon with value
  *
  * @param  integer|array  $value     :var => value
  * @param  string         $singular  title for singular value
  * @param  string         $plural    title for plural value
  * @param  string         $class     icon class
  */
 public static function icon_value($value, $singular = '', $plural = '', $class = '')
 {
     $class = $class ? 'icon ' . $class : 'icon';
     if (is_array($value)) {
         $var = key($value);
         $value = $value[$var];
     }
     $formatted = num::format($value);
     $plural = $plural ? $plural : $singular;
     $title = $singular && $plural ? ' title="' . __2($singular, $plural, $value, array($var => $formatted)) . '"' : '';
     return '<var class="' . $class . '"' . $title . '>' . $formatted . '</var>';
 }