Ejemplo n.º 1
0
 static function formatImageInfo($info = array())
 {
     $html = '<span class="image-info">';
     $html .= '<span class="image-info-dimensions">' . $info['width'] . 'X' . $info['height'] . '</span>';
     $html .= $info['size'] ? '<span class="image-info-size">' . ImageHelper::formatSize($info['size']) . '</span>' : '';
     $html .= '<span class="scale"></span></span>';
     return $html;
 }
Ejemplo n.º 2
0
    static function parse($files, $allow_download)
    {
        $cache_killer = '?v=' . time();
        foreach ($files as $row) {
            // relative path
            $file = '..' . DS . $row['file'];
            // absolute path
            $path = Configure::read('SITE_ROOT') . DS . preg_replace('/(\\.\\.\\/)/', '', $row['file']);
            if (!file_exists($file)) {
                echo '<div class="missingFile">Missing file: ' . $file . '</div>';
            } else {
                $name = $row['name'];
                $id = $row['id'];
                // setting some JS vars
                ?>
<script>window.all_files.push({file:'<?php 
                echo $file;
                ?>
', name:'<?php 
                echo $name;
                ?>
',id:'<?php 
                echo $id;
                ?>
'});</script><?php 
                $file_type = $row['file_type'];
                $creative_type = $row['creative_type'];
                $width = max($row['width'], $row['width_2']);
                if ($width < 1) {
                    $width = '';
                }
                $height = max($row['height'], $row['height_2']);
                if ($height < 1) {
                    $height = '';
                }
                if ($width !== '' && $height != '') {
                    $formatted_size = ImageHelper::formatImageInfo(array('width' => $width, 'height' => $height, 'size' => $row['size']));
                }
                // ZIP FILES
                if ($file_type == "ZIP") {
                    $index = false;
                    $file_dir = scandir($file);
                    if (in_array('index.html', $file_dir)) {
                        $index = 'index.html';
                    } else {
                        if (in_array('home.html', $file_dir)) {
                            $index = 'home.html';
                        } else {
                            if (in_array('index.php', $file_dir)) {
                                $index = 'index.php';
                            } else {
                                foreach ($file_dir as $f) {
                                    $ext = strtolower(pathinfo($f, PATHINFO_EXTENSION));
                                    // find the first HTML file and assume this is your guy
                                    if ($ext == "html") {
                                        $index = $f;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if ($index) {
                        ?>
						<div class="creativeUnitWrap">
							<div class="creativeUnit html" data-width="<?php 
                        echo $width;
                        ?>
" data-height="<?php 
                        echo $height;
                        ?>
" style="width:<?php 
                        echo $width;
                        ?>
px;">
								<?php 
                        if ($allow_download) {
                            ?>
<div class="addToQueueBtn" id="dlbtn_<?php 
                            echo $id;
                            ?>
" onclick="actions.addToDownloads('<?php 
                            echo $name;
                            ?>
','<?php 
                            echo $file;
                            ?>
','<?php 
                            echo $id;
                            ?>
',this)">add to queue</div><?php 
                        }
                        ?>
								<h2><?php 
                        echo $row['name'];
                        ?>
</h2>
								<?php 
                        if (!empty($row['description'])) {
                            ?>
<h3><?php 
                            echo $row['description'];
                            ?>
</h3><?php 
                        }
                        ?>
								<iframe src="<?php 
                        echo $path;
                        ?>
/<?php 
                        echo $index;
                        ?>
" width="<?php 
                        echo $width;
                        ?>
" height="<?php 
                        echo $height;
                        ?>
"></iframe>
							</div>
						</div>
					<?php 
                    } else {
                        ?>
<div class="creativeUnitWrap">
							<div class="creativeUnit collection">
								<?php 
                        if ($allow_download) {
                            ?>
<div class="addToQueueBtn all" id="dlbtn_<?php 
                            echo $id;
                            ?>
" onclick="actions.addToDownloads('<?php 
                            echo $name;
                            ?>
','<?php 
                            echo $file;
                            ?>
','<?php 
                            echo $id;
                            ?>
',this)"></div><?php 
                        }
                        ?>
								<h2><?php 
                        echo $row['name'];
                        ?>
 (<?php 
                        echo count($file_dir);
                        ?>
 file<?php 
                        echo count($file_dir) == 1 ? '' : 's';
                        ?>
)</h2>
								
								<?php 
                        if (!empty($row['description'])) {
                            ?>
<h3><?php 
                            echo $row['description'];
                            ?>
</h3><?php 
                        }
                        ?>
								
								<?php 
                        // still nothing, so lets just spit out each file in the directory that is viewable
                        $i = 0;
                        foreach ($file_dir as $f) {
                            $ext = strtolower(pathinfo($f, PATHINFO_EXTENSION));
                            if ($ext === 'jpg' || $ext === 'png' || $ext === 'gif') {
                                $sub_id = $id . '-' . $i;
                                $w_h = '';
                                if ($img = ImageHelper::info($file . '/' . $f)) {
                                    $w_h = ' - ' . $img['width'] . 'X' . $img['height'];
                                    $size = $img['size'];
                                }
                                $i++;
                                ?>
									<div class="creativeUnit image" data-width="<?php 
                                echo $img['width'];
                                ?>
" data-height="<?php 
                                echo $img['height'];
                                ?>
" style="width:<?php 
                                echo $img['width'];
                                ?>
px;">
										<?php 
                                if ($allow_download) {
                                    ?>
<div class="addToQueueBtn" id="dlbtn_<?php 
                                    echo $sub_id;
                                    ?>
" onclick="actions.addToDownloads('<?php 
                                    echo $f;
                                    ?>
','<?php 
                                    echo $file;
                                    ?>
/<?php 
                                    echo $f;
                                    ?>
','<?php 
                                    echo $sub_id;
                                    ?>
',this)">add to queue</div><?php 
                                }
                                ?>
										<h4><?php 
                                echo $f;
                                ?>
</h4>
										<h5><?php 
                                echo ImageHelper::info($file . '/' . $f, array("format" => true));
                                ?>
</h5>
										<img src="<?php 
                                echo $path;
                                ?>
/<?php 
                                echo $f;
                                echo $cache_killer;
                                ?>
" width="<?php 
                                echo $img['width'];
                                ?>
" height="<?php 
                                echo $img['height'];
                                ?>
">
									</div>
								<?php 
                            }
                        }
                        ?>
</div>
						</div><?php 
                    }
                } else {
                    if ($file_type == 'IMAGE') {
                        ?>
					<div class="creativeUnitWrap">
						<div class="creativeUnit image"  data-width="<?php 
                        echo $width;
                        ?>
" data-height="<?php 
                        echo $height;
                        ?>
" style="width:<?php 
                        echo $width;
                        ?>
px;">
							<?php 
                        if ($allow_download) {
                            ?>
<div class="addToQueueBtn" id="dlbtn_<?php 
                            echo $id;
                            ?>
" onclick="actions.addToDownloads('<?php 
                            echo $name;
                            ?>
','<?php 
                            echo $file;
                            ?>
',<?php 
                            echo $id;
                            ?>
,this)">add to queue</div><?php 
                        }
                        ?>
							<h2><?php 
                        echo $row['name'];
                        ?>
</h2>
							<?php 
                        if (!empty($row['description'])) {
                            ?>
<h3><?php 
                            echo $row['description'];
                            ?>
</h3><?php 
                        }
                        ?>
							<h4><?php 
                        echo $formatted_size;
                        ?>
</h4>
							<img src="<?php 
                        echo $path;
                        echo $cache_killer;
                        ?>
" width="<?php 
                        echo $width;
                        ?>
" height="<?php 
                        echo $height;
                        ?>
"></div>
					</div>
				<?php 
                    } else {
                        if ($file_type == 'FLASH') {
                            ?>
					<div class="creativeUnitWrap">
						<div class="creativeUnit flash" data-width="<?php 
                            echo $width;
                            ?>
" data-height="<?php 
                            echo $height;
                            ?>
" style="width: <?php 
                            echo $width;
                            ?>
px;">
							<?php 
                            if ($allow_download) {
                                ?>
<div class="addToQueueBtn" id="dlbtn_<?php 
                                echo $id;
                                ?>
" onclick="actions.addToDownloads('<?php 
                                echo $name;
                                ?>
','<?php 
                                echo $file;
                                ?>
','<?php 
                                echo $id;
                                ?>
',this)">add to queue</div><?php 
                            }
                            ?>
							<h2><?php 
                            echo $row['name'];
                            ?>
</h2>
							<?php 
                            if (!empty($row['description'])) {
                                ?>
<h3><?php 
                                echo $row['description'];
                                ?>
</h3><?php 
                            }
                            ?>
							<object width="<?php 
                            echo $width;
                            ?>
" height="<?php 
                            echo $height;
                            ?>
" id="<?php 
                            echo $path;
                            echo $cache_killer;
                            ?>
" align="middle">
					        	<param name="movie" value="<?php 
                            echo $path;
                            echo $cache_killer;
                            ?>
">
								<param name="quality" value="high">
								<param name="bgcolor" value="#ffffff">
								<param name="play" value="true">
								<param name="loop" value="true">
								<param name="wmode" value="window">
								<param name="scale" value="showall">
								<param name="menu" value="true">
								<param name="devicefont" value="false">
								<param name="salign" value="">
								<param name="allowScriptAccess" value="sameDomain">
								<!--[if !IE]>-->
								<object type="application/x-shockwave-flash" data="<?php 
                            echo $path;
                            echo $cache_killer;
                            ?>
" width="<?php 
                            echo $width;
                            ?>
" height="<?php 
                            echo $height;
                            ?>
">
					            	<param name="movie" value="<?php 
                            echo $path;
                            echo $cache_killer;
                            ?>
">
									<param name="quality" value="high">
						            <param name="bgcolor" value="#ffffff">
						            <param name="play" value="true">
						            <param name="loop" value="true">
						            <param name="wmode" value="window">
						            <param name="scale" value="showall">
						            <param name="menu" value="true">
						            <param name="devicefont" value="false">
						            <param name="salign" value="">
						            <param name="allowScriptAccess" value="sameDomain">
						        <!--<![endif]-->
						            <a href="http://www.adobe.com/go/getflash">
						                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player">
						            </a>
						        <!--[if !IE]>-->
						        </object>
						        <!--<![endif]-->
						    </object>
						</div>
					</div>
				<?php 
                        } else {
                            if ($file_type == 'VIDEO') {
                                ?>
				<div class="creativeUnitWrap">
					<div class="creativeUnit video" data-width="<?php 
                                echo $width;
                                ?>
" data-height="<?php 
                                echo $height;
                                ?>
" style="width: <?php 
                                echo $width;
                                ?>
px;">
						<?php 
                                if ($allow_download) {
                                    ?>
<div class="addToQueueBtn" id="dlbtn_<?php 
                                    echo $id;
                                    ?>
" onclick="actions.addToDownloads('<?php 
                                    echo $name;
                                    ?>
','<?php 
                                    echo $file;
                                    ?>
',<?php 
                                    echo $id;
                                    ?>
,this)">add to queue</div><?php 
                                }
                                ?>
						<h2><?php 
                                echo $row['name'];
                                ?>
</h2>
						<?php 
                                if (!empty($row['description'])) {
                                    ?>
<h3><?php 
                                    echo $row['description'];
                                    ?>
</h3><?php 
                                }
                                ?>
						<h4><?php 
                                echo $formatted_size;
                                ?>
</h4>
						<h5>duration: <?php 
                                echo $row['duration'];
                                ?>
 | frame rate: <?php 
                                echo $row['frame_rate'];
                                ?>
 | format: <?php 
                                echo $row['file_format'];
                                ?>
</h5>
						<video src="<?php 
                                echo $path;
                                echo $cache_killer;
                                ?>
" controls ></video>
					</div>
				</div>
				<?php 
                            }
                        }
                    }
                }
            }
        }
    }