Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Drobne optymalizacje ;)

  • Loading branch information...
commit f798e82b87eadfec2d2dca957600ecbbe7e2a073 1 parent 5f8a41b
Radosław Zieliński authored
View
2  application/controllers/IndexController.php
@@ -16,7 +16,7 @@ public function indexAction()
$this->view->entries = $home->fetchAll("type='home'");
$picture = new Application_Model_PictureMapper();
- $this->view->entries2 = $picture->fetchAll();
+ $this->view->pictures = $picture->fetchAll();
}
}
View
31 application/layouts/scripts/layout.phtml
@@ -3,26 +3,25 @@
<head>
<meta charset="utf-8">
<title>Buffet</title>
- <?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>
+ <?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>
<script type="text/javascript">
- var imgs = new Array('wiosna1.jpg', 'wiosna2.jpg', 'wiosna3.jpg', 'wiosna4.jpg', 'wiosna6.jpg');
- var pos = 0;
+ imgs = [];
+ var pos = 0;
- function chImg()
- {
- var i = document.getElementById( 'imgField' );
-
- i.src = 'pictures/' + imgs[ pos++ ];
-
- if( pos >= 4 )
- {
- pos = 0;
- }
+ function chImg() {
+ var i = document.getElementById( 'imgField' );
+ if (!i || !imgs.length) return;
+
+ i.src = imgs[ pos++ ];
+
+ if( pos >= imgs.length ) {
+ pos = 0;
+ }
- window.setTimeout( 'chImg()', 5000 );
- }
-</script>
+ window.setTimeout( 'chImg()', 5000 );
+ }
+ </script>
</head>
<body onload=chImg();>
View
8 application/views/scripts/contact/index.phtml
@@ -1,10 +1,4 @@
-<div id="main_image">
- <?php foreach ($this->entries2 as $entry2): ?>
- <?php $sciezka = $this->escape($entry2->getName());
- echo "<img class=\"main\" src=\"/pictures/wiosna1.jpg\" id=\"imgField\" />" ?>
- <?php endforeach ?>
-</div>
-
+<?= $this->partial('shared/main_images.phtml', array('pictures' => $this->entries2)); ?>
<div id="main_content">
View
9 application/views/scripts/index/index.phtml
@@ -1,11 +1,4 @@
-<div id="main_image">
- <?php foreach ($this->entries2 as $entry2): ?>
- <?php $sciezka = $this->escape($entry2->getName());
- echo "<img class=\"main\" src=\"/pictures/wiosna1.jpg\" id=\"imgField\" />" ?>
- <?php endforeach ?>
-</div>
-
-<script type="text/javascript">chImg();</script>
+<?= $this->partial('shared/main_images.phtml', array('pictures' => $this->pictures)); ?>
<div id="main_content">
View
8 application/views/scripts/offer/index.phtml
@@ -1,10 +1,4 @@
-<div id="main_image">
- <?php foreach ($this->entries2 as $entry2): ?>
- <?php $sciezka = $this->escape($entry2->getName());
- echo "<img class=\"main\" src=\"/pictures/wiosna1.jpg\" id=\"imgField\" />" ?>
- <?php endforeach ?>
-</div>
-
+<?= $this->partial('shared/main_images.phtml', array('pictures' => $this->entries2)); ?>
<div id="main_content">
View
8 application/views/scripts/partners/index.phtml
@@ -1,10 +1,4 @@
-<div id="main_image">
- <?php foreach ($this->entries2 as $entry2): ?>
- <?php $sciezka = $this->escape($entry2->getName());
- echo "<img class=\"main\" src=\"/pictures/wiosna1.jpg\" id=\"imgField\" />" ?>
- <?php endforeach ?>
-</div>
-
+<?= $this->partial('shared/main_images.phtml', array('pictures' => $this->entries2)); ?>
<div id="main_content">
View
13 application/views/scripts/shared/main_images.phtml
@@ -0,0 +1,13 @@
+<div id="main_image">
+ <?php if ($this->pictures) : ?>
+ <img class="main" src="<?= $this->escape($this->pictures[0]->getName()) ?>" id="imgField" />
+ <?php
+ $imagesNames = array();
+ foreach ($this->pictures as $picture) {
+ $imagesNames[] = '"' . $this->escape($picture->getName()) . '"';
+ } ?>
+ <script type="text/javascript">
+ imgs = [<?= implode(', ', $imagesNames)?>];
+ </script>
+ <?php endif ?>
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.