/** * getImgTag - get a full HTML img tag to display a QR Code image of supplied text * * @param Response $response \Xoops\Core\Service\Response object * @param string $qrText text to encode in QR Code * @param array $attributes array of attribute name => value pairs for img tag * * @return void - response->value set to image tag */ public function getImgTag(Response $response, $qrText, $attributes = array()) { $url = $this->getQRUrl($qrText); $imgTag = new Img(array('src' => $url)); $imgTag->setAttributes($attributes); $response->setValue($imgTag->render()); }
/** * renderEmojiSelector - provide emoji selector support for editing * * This should return an HTML string that, when displayed, will provide a link to an emoji selector. * Additionally, this should perform any additional tasks required to make the link function, such * as adding script or stylesheet assets to the active theme. * * @param Response $response \Xoops\Core\Service\Response object * @param string $identifier element identifier to receive emoji from selector * * @return void - $response->value (string) HTML code to launch the emoji selector, i.e. button */ public function renderEmojiSelector(Response $response, $identifier) { $selector = '<img src="' . \XoopsBaseConfig::get('url') . '/images/smiley.gif" alt="' . \XoopsLocale::SMILIES . '" title="' . \XoopsLocale::SMILIES . '" onclick=\'openWithSelfMain("' . \XoopsBaseConfig::get('url') . '/modules/smilies/popup.php?target=' . $identifier . '","smilies",300,650);\' onmouseover=\'style.cursor="hand"\'/> '; $response->setValue($selector); }
/** * @covers Xoops\Core\Service\Response::addErrorMessage */ public function testAddErrorMessage() { $value = 'value'; $error = 'error'; $instance = new Response($value, true, $error); $error1 = 'error1'; $result = $instance->addErrorMessage($error1); $this->assertSame($instance, $result); $data = array('error2', 'error3'); $result = $instance->addErrorMessage($data); $result = $instance->getErrorMessage(); $this->assertTrue(is_array($result)); $this->assertTrue(in_array($error, $result)); $this->assertTrue(in_array($error1, $result)); $this->assertTrue(in_array('error2', $result)); $this->assertTrue(in_array('error3', $result)); }
/** * All static methods go here and will return null response * * @param type $name not used * @param type $arguments not used * * @return Response Response */ public static function __callStatic($name, $arguments) { $response = new Response(); $response->setSuccess(false)->addErrorMessage(sprintf("No provider installed for %s", get_called_class())); return $response; }
/** * getImgTag - get a full HTML tag or string to display a flag based on county code * * @param Response $response \Xoops\Core\Service\Response object * @param string $countryCode ISO 3166-1 alpha-2 code to select flag * @param array $attributes array of attribute name => value pairs for img tag * @param string $size 'small', 'medium' or 'large' * * @return void - response->value set to image tag */ public function getImgTag(Response $response, $countryCode, $attributes = array(), $size = 'large') { $url = $this->getFlagUrl($countryCode, $size); if (!is_array($attributes)) { $attributes = array(); } $imgTag = new Img(array('src' => $url, 'alt' => $countryCode)); $imgTag->setMerge($attributes); $response->setValue($imgTag->render()); }
/** * getAssignableUserRankList - return a list of ranks that can be assigned * * @param Response $response \Xoops\Core\Service\Response object * * @return void - response->value set to array of (int) id => (string) rank title * entries of assignable ranks */ public function getAssignableUserRankList(Response $response) { $db = \Xoops::getInstance()->db(); $myts = \MyTextSanitizer::getInstance(); $ret = array(); $sql = $db->createXoopsQueryBuilder(); $eb = $sql->expr(); $sql->select('rank_id')->addSelect('rank_title')->fromPrefix('userrank_rank', 'r')->where($eb->eq('rank_special', ':rankspecial'))->orderBy('rank_title')->setParameter(':rankspecial', 1); $result = $sql->execute(); while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) { $ret[$myrow['rank_id']] = $myts->htmlspecialchars($myrow['rank_title']); } $response->setValue($ret); }
/** * getImgTag - get a full HTML img tag to display a thumbnail of the supplied image * * @param Response $response \Xoops\Core\Service\Response object * @param string $imgPath path to image to be thumbed * @param integer $width maximum width of thumbnail in pixels, 0 to use default * @param integer $height maximum height of thumbnail in pixels, 0 to use default * @param array $attributes array of attribute name => value pairs for img tag * * @return void - response->value set to image tag */ public function getImgTag(Response $response, $imgPath, $width = 0, $height = 0, $attributes = array()) { $url = $this->getThumbnailUrl($imgPath, $width, $height); $imgTag = new Img(array('src' => $url)); $imgTag->setAttributes($attributes); $response->setValue($imgTag->render()); }