/**
  * Get the videos and audio we scanned for this post and it's replacement code
  * 
  * @param int $post_id the content id we are processing
  * @return array $replacements the array with the instructions for str_replace
  */
 function _getSpecialComponentsCode($post_id)
 {
     $replacements = array('find' => array(), 'replace' => array());
     $specialElements = $GLOBALS['WiziappDB']->get_content_special_elements($post_id);
     if ($specialElements !== FALSE) {
         $ve = new WiziappVideoEmbed();
         foreach ($specialElements as $element) {
             $info = json_decode($element['attachment_info'], TRUE);
             if ($element['attachment_type'] == $GLOBALS['WiziappDB']->media_types['video']) {
                 $replaceCode = $ve->getCode($info['actionURL'], $element['id'], $info['bigThumb']);
             } else {
                 // audio should convert to a component
                 // @todo Add single component export from the simulator engine
                 $info['actionURL'] = str_replace('audio', 'video', $info['actionURL']);
                 $style = '';
                 if (!empty($info['imageURL'])) {
                     $style = "background-image: url({$this->_getAdminImagePath()}{$info['imageURL']}.png);";
                 }
                 if (strlen($info['title']) > 35) {
                     $title = substr($info['title'], 0, 35) . '...';
                 }
                 $replaceCode = "<a href='" . $info['actionURL'] . "'><div class='audioCellItem'>\n                            <div class='col1'>\n                                <div class='imageURL' style='{$style}'></div>\n                            </div>\n                            <div class='col2'>\n                                <p class='title'>{$title}</p>\n                                <p class='duration'>{$info['duration']}</p>\n                            </div>\n                            <div class='col3'>\n                                <div class='playButton'></div>\n                            </div>\n                        </div></a>";
             }
             if ($replaceCode) {
                 $replacements['find'][] = $element['original_code'];
                 $replacements['replace'][] = $replaceCode;
             }
             if (isset($_GET['sim']) && $_GET['sim'] == 1) {
                 // The original code might have been altered a bit to be valid xhtml, check it
                 if (strpos($element['original_code'], '=""') !== FALSE) {
                     $replacements['find'][] = str_replace('=""', '', $element['original_code']);
                     $replacements['replace'][] = $replaceCode;
                 }
             }
             /**
              * The content might have been inserted with ='' instead of =""
              */
             if (!empty($element['original_code'])) {
                 $replacements['find'][] = str_replace('"', "'", $element['original_code']);
                 $replacements['replace'][] = $replaceCode;
             }
             if (strpos($element['original_code'], '<iframe') === FALSE || isset($_GET['sim']) && $_GET['sim'] == 1) {
                 if (strpos($element['original_code'], '&') !== FALSE) {
                     $replacements['find'][] = str_replace('&', '&amp;', $element['original_code']);
                     $replacements['replace'][] = $replaceCode;
                 }
                 if (strpos($element['original_code'], '<img') !== FALSE) {
                     $replacements['find'][] = str_replace(' />', '>', $element['original_code']);
                     $replacements['replace'][] = $replaceCode;
                 }
                 /**
                  * The following is indeed ugly but for some reason sometimes we are getting </param> which mess up everything
                  */
                 if (strpos($element['original_code'], '</param>') !== FALSE) {
                     $replacements['find'][] = str_replace('</param>', '', $element['original_code']);
                     $replacements['replace'][] = $replaceCode;
                 }
             }
         }
     }
     $GLOBALS['WiziappLog']->write('info', ">>> The replacement code is:" . print_r($replacements, TRUE), '_getSpecialComponentsCode');
     return $replacements;
 }
<div class="page_content">
    <div class="post">
        <h2 class="pageitem">
            <?php 
echo $video['title'];
?>
        </h2>
        <div class="pageitem">
            <div class="video" id="video-<?php 
echo $video_row['id'];
?>
">
                <div id="singlentry">
                    <?php 
$ve = new WiziappVideoEmbed();
echo $ve->getCode($video['actionURL'], $video_row['id'], $video['bigThumb']);
?>
                    <div id="video_description">
                        <?php 
echo $video['description'];
?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <br />
    <?php 
/**
 * The link below is for handing video in the simulator, the application shows the video itself
 * while the simulator only shows an image.