예제 #1
0
 /**
  * @desc This function required object Notation containing the module_name, id in module and notation_scale.
  * @param object $notation Notation
  * @param boolean $average_notes
  */
 public static function display_static_image(Notation $notation)
 {
     $notation_scale = $notation->get_notation_scale();
     if (!empty($notation_scale)) {
         $template = new FileTemplate('framework/content/notation/notation.tpl');
         $average_notes = $notation->get_average_notes();
         $int = intval($average_notes);
         $decimal = floatval('0.' . substr($average_notes, strpos($average_notes, '.') + 1));
         for ($i = 1; $i <= $notation->get_notation_scale(); $i++) {
             $star_full = false;
             $star_half = false;
             $star_empty = false;
             if ($int >= $i || $int + 1 == $i && $decimal >= 0.75) {
                 $star_full = true;
             } else {
                 if ($int + 1 == $i && $decimal > 0.25 && $decimal < 0.75) {
                     $star_half = true;
                 } else {
                     $star_empty = true;
                 }
             }
             $template->assign_block_vars('star', array('I' => $i, 'STAR_EMPTY' => $star_empty, 'STAR_HALF' => $star_half, 'STAR_FULL' => $star_full));
         }
         $count_notes = $notation->get_number_notes();
         $template->put_all(array('C_STATIC_DISPLAY' => true, 'C_NOTES' => $count_notes > 0 ? true : false, 'NUMBER_NOTES' => $notation->get_number_notes(), 'AVERAGE_NOTES' => $average_notes, 'NOTATION_SCALE' => $notation->get_notation_scale(), 'L_NO_NOTE' => LangLoader::get_message('no_note', 'common')));
         return $template->render();
     } else {
         throw new Exception('The notation scale is empty');
     }
 }