Beispiel #1
0
 public function setAttributes($attributes)
 {
     foreach ($attributes as $key => $value) {
         if (isset($value) && $value !== '') {
             if (!property_exists($this, $key)) {
                 $called_class = get_called_class();
                 TPP::setError($called_class . "->" . $key . ": Property '" . $key . "' does not exist for class '" . $called_class . "'");
             }
             $key = gettype($key) === 'string' && !ctype_alnum(str_replace(['-', '_', ' '], '', $key)) ? Helper::utf8ify($key) : $key;
             $this->{$key} = gettype($value) === 'string' ? Helper::utf8ify($value) : $value;
         }
     }
 }
Beispiel #2
0
 public static function getMilestones()
 {
     $getMilestones = TPP::db()->query("SELECT `id`, `name`, `time` FROM `milestone` WHERE `visible` = 1 ORDER BY `time`");
     $return = [];
     if ($getMilestones) {
         while ($mile = $getMilestones->fetch()) {
             $newMilestone = new self();
             $newMilestone->setAttributes($mile);
             $newMilestone->time = Helper::getDateTime($newMilestone->time);
             $return[] = $newMilestone;
         }
     }
     return $return;
 }
Beispiel #3
0
 public static function toImage($path, $name, $htmlOptions = [])
 {
     $image = IMG_PATH . $path . '/' . Helper::safeName($name) . '.png';
     if (TPP_DEBUG) {
         if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $image)) {
             //				$image = 'http://twitchplayspokemon.org/img/' . $path . '/' . Helper::safeName($name) . '.png';
         }
     }
     $return = '<img src="' . $image . '"';
     if (!empty($htmlOptions)) {
         foreach ($htmlOptions as $key => $value) {
             $return .= ' ' . $key . '="' . $value . '"';
         }
     }
     if (!isset($htmlOptions['title'])) {
         $return .= ' title="' . $name . '"';
     }
     if (!isset($htmlOptions['alt'])) {
         $return .= ' alt="' . $name . '"';
     }
     $return .= '>';
     return $return;
 }
Beispiel #4
0
 public function getComment($secs = false)
 {
     if (is_numeric($this->comment)) {
         return Helper::getDateTime($this->comment, $secs);
     }
     return $this->comment;
 }
Beispiel #5
0
<?php

use TPP\Helpers\Helper;
?>

					<tr><?php 
foreach ($badges as $b) {
    ?>

						<td><?php 
    echo isset($b->time) ? Helper::getDateTime($b->time) : '<em>Not yet</em>';
    ?>
</td><?php 
}
?>

					</tr>
Beispiel #6
0
<?php

use TPP\Models\Image;
use TPP\Helpers\Helper;
?>

			<div class="tpp-app tpp-app-header">
				<div class="page-header">
					<h1>
						<a href="http://www.twitch.tv/twitchplayspokemon"><!--
							--><strong><i class="fa fa-external-link"></i>Twitch Plays Pok&eacute;mon</strong><!--
						--></a><!--
						--><a href="" class="pop-out btn btn-danger btn-xs"><i class="fa fa-expand"></i>Pop out</a>

						<span class="pull-right last-update">Last update: <?php 
echo Helper::getDateTime($general->last_update);
?>
</span>
					</h1><?php 
if (!empty($messages)) {
    $this->render('general/_messages', ['messages' => $messages]);
}
?>

			<div class="pull-left current-status">
				<p>Current Goal: <strong><?php 
echo utf8_decode($general->current_goal);
?>
</strong></p>
				<p>Optional Goal: <strong><?php 
echo !empty($general->optional_goal) ? utf8_decode($general->optional_goal) : '-';
Beispiel #7
0
</strong>
							<?php 
        echo $box->active ? '<small class="box-active">active</small>' : '';
        ?>

							<?php 
        echo isset($box->name) ? '<small>(' . $box->name . ')</small>' : '';
        ?>

							<?php 
        echo !empty($box->content) ? '<small>(' . count($box->pokemon) . ' Pok&eacute;mon)</small>' : '';
        ?>

						</h5>
						<div class="box-background bg-<?php 
        echo Helper::safeName($box->scenery);
        ?>
">
							<?php 
        if (empty($box->pokemon)) {
            ?>

							<em>No Pok&eacute;mon in this box</em><?php 
        } else {
            foreach ($box->content as $key_row => $row) {
                foreach ($row as $pokemon) {
                    /** @var $pokemon Pokemon */
                    $title = isset($pokemon->name) ? $pokemon->name . ' (' . $pokemon->pokemon . ')' : $pokemon->pokemon;
                    echo '<a href="#pokemon-' . $pokemon->id . '">' . $pokemon->showImageMenu(['title' => $title, 'alt' => $title]) . '</a>';
                }
            }