public function setOutput($output, $jsonDecode = true) { if ($this->interceptOutput === true) { $this->interceptedOutput = $output; } else { if ($jsonDecode === true) { if (!empty($output)) { // All data is saved to DB with HTML encoding so need to decode. $this->htmlDecode($output); $output = str_replace('\\/', '/', json_encode($output)); } else { $output = null; } } parent::setOutput($output); } }
//для шаблона рейтинга топ-5 $image = new Image(DIR_IMAGE . $_template); $font_size = 34; $font_path = DIR_APPLICATION . 'Pribambas.ttf'; $image->addText($text, $font_size, $x, $y, 'FFFFFF', $font_path, 0); $image->save(DIR_IMAGE . $new_image); } if ($code) { $json['success'] = 1; $json['share_image'] = HTTP_SERVER . 'share/' . $code . '.jpg'; $json['share_url'] = HTTP_SERVER . '/share.php?share_id=' . $code . '&point=' . (int) $request->get['point']; } else { $json['error'] = 'ERROR DB'; } $response->addHeader('Content-Type: application/json'); $response->setOutput(json_encode($json)); } else { $share_id = $request->get['share_id']; $point = $request->get['point']; $template = new Template(); $template->base = HTTP_SERVER; $template->image = 'share/' . $share_id . '.jpg'; $template->share_url = HTTP_SERVER . 'share.php?share_id=' . $share_id . '&point=' . $point; if ((int) $point > 10) { $template->title = 'Я собрал ' . $point . ' ' . getNumEnding($point, array('услугу', 'услуги', 'услуг')); $template->description = 'А ты сможешь лучше?'; } elseif ((int) $point < 10 && (int) $point >= 5) { $template->title = 'Я собрал ' . $point . ' ' . getNumEnding($point, array('услугу', 'услуги', 'услуг')); $template->description = 'А ты сможешь лучше?'; } else { $template->title = 'Я собрал ' . $point . ' ' . getNumEnding($point, array('услугу', 'услуги', 'услуг'));