Пример #1
0
/** Convert PHP data structure to Javascript */
function xinha_to_js($var, $tabs = 0)
{
    if (is_numeric($var)) {
        return $var;
    }
    if (is_string($var)) {
        return "'" . xinha_js_encode($var) . "'";
    }
    if (is_bool($var)) {
        return $var ? 'true' : 'false';
    }
    if (is_array($var)) {
        $useObject = false;
        foreach (array_keys($var) as $k) {
            if (!is_numeric($k)) {
                $useObject = true;
            }
        }
        $js = array();
        foreach ($var as $k => $v) {
            $i = "";
            if ($useObject) {
                if (preg_match('#^[a-zA-Z]+[a-zA-Z0-9]*$#', $k)) {
                    $i .= "{$k}: ";
                } else {
                    $i .= "'{$k}': ";
                }
            }
            $i .= xinha_to_js($v, $tabs + 1);
            $js[] = $i;
        }
        if ($useObject) {
            $ret = "{\n" . xinha_tabify(implode(",\n", $js), $tabs) . "\n}";
        } else {
            $ret = "[\n" . xinha_tabify(implode(",\n", $js), $tabs) . "\n]";
        }
        return $ret;
    }
    return 'null';
}
Пример #2
0
function drawFiles($list, &$manager)
{
    global $relative;
    global $IMConfig;
    //$IMConfig['ViewMode'] = 'thumbs';
    switch ($IMConfig['ViewMode']) {
        case 'details':
            ?>
        <script language="Javascript">
          <!--
            function showPreview(f_url)
            {              
              window.parent.document.getElementById('f_preview').src = window.parent._backend_url + '__function=thumbs&img=' + encodeURIComponent(f_url);
            }
          //-->
        </script>
        <table class="listview">
        <thead>
        <tr><th>Title</th><th>Description</th><th>Duration</th></tr></thead>
        <tbody>
          <?php 
            foreach ($list as $record) {
                extract(rip_youtube_data($record));
                ?>
            <tr>
              <th><a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php 
                echo xinha_js_encode($combinedImage);
                ?>
', '<?php 
                echo xinha_js_encode($title);
                ?>
', <?php 
                echo $largest[2];
                ?>
, <?php 
                echo $largest[3];
                ?>
);return false;" title="<?php 
                echo htmlspecialchars($title);
                ?>
 - <?php 
                echo htmlspecialchars($duration);
                ?>
" onmouseover="showPreview('<?php 
                echo xinha_js_encode($combinedImage);
                ?>
')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" ><?php 
                echo htmlspecialchars($title);
                ?>
</a></th>
              <td><?php 
                echo htmlspecialchars($description);
                ?>
</td>
              <td><?php 
                echo htmlspecialchars($duration);
                ?>
              
            </tr>
            <?php 
            }
            ?>
        </tbody>
        </table>
        <?php 
            break;
        case 'thumbs':
        default:
            foreach ($list as $record) {
                extract(rip_youtube_data($record));
                ?>
          <div class="thumb_holder" id="holder_<?php 
                echo asc2hex($combinedImage);
                ?>
">
            <a href="#" class="thumb" style="cursor: pointer;" onclick="selectImage('<?php 
                echo xinha_js_encode($combinedImage);
                ?>
', '<?php 
                echo xinha_js_encode($title);
                ?>
', <?php 
                echo $largest[2];
                ?>
, <?php 
                echo $largest[3];
                ?>
);return false;" title="<?php 
                echo htmlspecialchars($title);
                ?>
 - <?php 
                echo htmlspecialchars($duration);
                ?>
">
              <img src="<?php 
                print $thumbImage;
                ?>
" alt="<?php 
                echo $title;
                ?>
 - <?php 
                echo htmlspecialchars($duration);
                ?>
"/>
            </a>
          </div>
          <?php 
            }
    }
}