<?php
namespace JoyPixels;

# include the PHP library (if not autoloaded)
require('./lib/php/autoload.php');

$client = new Client(new Ruleset());

################################################
# Optional:
# default is ignore ASCII smileys like :) but you can easily turn them on
$client->ascii = true;

# default behavior is to match ASCII only when encapsulated by space characters
# setting risky match to true can potentially break HTML tags, such as "<button>.</button>" (">.<" is matched)
$client->riskyMatchAscii = true;

$client->spriteSize = '64';

# if you want to host the images somewhere else
# you can easily change the default paths
$client->imagePathPNG = './assets/png/';
################################################
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
  <title>shortnameToImage($str) - PHP - JoyPixels Labs</title>

  <!-- JoyPixels CSS: -->
  <link rel="stylesheet" href="./assets/css/joypixels.min.css" type="text/css" media="all" />
  
  <!-- JoyPixels Sprites -->
  <link rel="stylesheet" href="./assets/sprites/joypixels-sprite-32.min.css" type="text/css" media="all" />

  <!-- jQuery: -->
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.7.0/dist/jquery.min.js"></script>

  <!-- Demos Stylesheet: -->
  <link rel="stylesheet" href="styles/demos.css"/>

  <!-- Typekit: -->
  <script type="text/javascript" src="https://use.typekit.net/ivu8ilu.js"></script>
  <script type="text/javascript">try{Typekit.load();}catch(e){}</script>

  <!-- Syntax Highlighting -->
  <script type="text/javascript" src="./../scripts/shCore.js"></script>
  <script type="text/javascript" src="./../scripts/shBrushJScript.js"></script>
  <script type="text/javascript" src="./../scripts/shBrushCss.js"></script>
  <script type="text/javascript" src="./../scripts/shBrushPhp.js"></script>
  <script type="text/javascript">SyntaxHighlighter.all();</script>
  <link rel="stylesheet" href="./../styles/shCoreRDark.css"/>

</head>
<body>

<!-- Masthead -->
<header class="masthead">
  <div class="container">
    <h1 class="masthead-title">JoyPixels</h1><span class="version">latest version</span>
  </div>
</header>

<!-- Breadcrum Navigation -->
<nav class="breadcrumbs">
  <div class="container">
    <a class="breadcrumb-item top-level" href="index.html">All Demos</a> &rsaquo;
    <a href="index.html#php">PHP</a> &rsaquo;
    <a class="breadcrumb-item active" href="./phpshortnametoimage.php">shortnameToImage($str)</a>
  </div>
</nav>

<!-- Page: -->
<main>

  <div class="container" id="output">

      <h1>shortnameToImage($str)</h1>
      <h2>convert shortnames to images</h2>

      <p>If you've chosen to unify your inputted text so that it contains only shortnames then this is the function (or its matching Javascript function) you will want to use to convert the shortnames images when displaying it to the client.</p>

      <p>Feel free to enter other shortnames in the input below to test the conversion process.</p>

      <p class="notice"><strong>Note: </strong> Once you start dealing with native unicode characters server side, it's important to ensure that your web stack is set up to handle UTF-8 character encoding. That is outside of the scope of our demos, but a quick <a href="http://lmgtfy.com/?q=web+stack+utf-8" target="_blank">Google Search</a> will guide you in the right direction.</p>

      <div class="clearfix">
      <div class="column-1-2 input">
        <h3>Input:</h3>
        <form method="post" action="phpshortnametoimage.php#output">
          <input type="text" id="inputText" name="inputText" value="<?php echo (isset($_POST['inputText'])) ? $_POST['inputText'] : 'Hello world! :smile:'; ?>"/>
          <input type="submit" value="Convert"/>
        </form>
      </div>
      <div class="column-1-2 output">
        <h3>Output:</h3>
        <p>
          <?php
          if(isset($_POST['inputText'])) {
            echo $client->shortnameToImage($_POST['inputText']);
          }
          ?>
        </p>
      </div>
    </div>

    <h3>PHP Snippet:</h3>
        <pre class="brush: php">
        &lt;?php
            // include the PHP library (if not autoloaded)
            require('./../lib/php/autoload.php');

            $client = new Client(new Ruleset());

            // ###############################################
            # Optional:
            # default is ignore ASCII smileys like :) but you can easily turn them on
            $client->ascii = true;

            # if you want to host the images somewhere else
            # you can easily change the default paths
            $client->imagePathPNG = './assets/png/';
            // ###############################################

            if(isset($_POST['inputText'])) {
            echo $client->shortnameToImage($_POST['inputText']);
            }
        ?&gt;
        </pre>
  </div>

</main>

<footer class="demo-footer">
    <div class="container">
        <small>&copy; Copyright 2025 JoyPixels Inc.</small>
        <small><a href="https://www.joypixels.com/licenses" target="_blank">JoyPixels Image Licensing</a></small>
        <small>JoyPixels demos, documentation, scripts, stylesheets and all other non-artwork is licensed under the <a
                    href="https://opensource.org/license/mit/">MIT</a> License</small>
    </div>
</footer>

</body>
</html>
