diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index 435b350..2785953 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -105,8 +105,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$router = $this->getResource('front')->getRouter();
-
-
+
$router->addRoute('default', new Zend_Controller_Router_Route(':lang/:controller/:action',
array(
@@ -117,6 +116,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
)
));
+
+
$router->addRoute('index', new Zend_Controller_Router_Route(
':lang/:action',
array(
@@ -128,12 +129,13 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
));
$router->addRoute('blog', new Zend_Controller_Router_Route(
- ':lang/blog/:action',
+ ':lang/blog/:action/:id',
array(
'lang' => 'sv',
'module' => 'blog',
'controller' => 'index',
- 'action' => 'latest'
+ 'action' => 'latest',
+ 'id' => ''
)
));
@@ -157,6 +159,20 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
)
));
+
+ $router->addRoute('auth', new Zend_Controller_Router_Route(
+ ':lang/:action',
+ array(
+ 'lang' => 'sv',
+ 'module' => 'default',
+ 'controller' => 'auth',
+ ),
+ array(
+ 'action' => '(login|logout)'
+ )
+ ));
+
+
return $router;
}
diff --git a/application/languages/en.ini b/application/languages/en.ini
index cb442b7..1251186 100644
--- a/application/languages/en.ini
+++ b/application/languages/en.ini
@@ -10,7 +10,12 @@ LOGIN_TXT = "Fill out your information below to login.
There
START_TXT = "Welcome to fiktivkod.org. ...."
ABOUT_TXT = "Fiktiv (fiktivkod.org) is ... that started ..."
-BLOG_TXT = "We at fiktivkod use this blog to tell our stories about happy times and maybe not so happy experience ... "
+
+BLOG_LATEST_INTRO = "We at fiktivkod use this blog to tell our stories about happy times and maybe not so happy experience ... "
+BLOG_ARCHIVE_INTRO = "Take a moment and look through our blog archive."
+
+
+PORTFOLIO_INTRO = "This is some of the projects we have been working with."
ERROR_404 = "The page could not be found"
ERROR_404_TXT = "The page you are trying to visit does not exist."
diff --git a/application/languages/se.ini b/application/languages/se.ini
index ee71ee8..cc8710e 100644
--- a/application/languages/se.ini
+++ b/application/languages/se.ini
@@ -10,7 +10,15 @@ LOGIN_TXT = "Ange dina uppgifter nedan för att logga in.
De START_TXT = "Välkommen till fiktivkod.org. ...." ABOUT_TXT = "Fiktiv (fiktivkod.org) är ... som startade ..." -BLOG_TXT = "Här på bloggen delar vi med oss av våra erfarenheter och andra dumheter ... " + + +BLOG_LATEST_INTRO = "Här på bloggen delar vi med oss av våra erfarenheter och andra dumheter ... " +BLOG_ARCHIVE_INTRO = "Titta gärna igenom vårat bloggarkiv efter guldkorn." + + +PORTFOLIO_INTRO = "Det här är lite av de projekt vi har jobbat med." + + ERROR_404 = "Sidan kunde inte visas" ERROR_404_TXT = "Sidan du försöker besöka existerar inte." @@ -26,4 +34,9 @@ line = rad latest = senaste archive = arkiv -readable = läsbart \ No newline at end of file +readable = läsbart +back = tillbaka + + +ERROR_FORM_EMPTY = fältet får inte vara tomt +ERROR_FORM_EMAIL_INVALID = epost adressen är inte gilltig \ No newline at end of file diff --git a/application/models/BlogPost.php b/application/models/BlogPost.php index 4f6f05b..7d7d881 100644 --- a/application/models/BlogPost.php +++ b/application/models/BlogPost.php @@ -2,7 +2,7 @@ class BlogPost { - + protected $_id; protected $_title; protected $_content; protected $_author; @@ -10,6 +10,17 @@ class BlogPost protected $_isPublished = false; + public function getId() + { + return $this->_id; + } + + public function setId($id) + { + if (is_numeric($id)) + $this->_id = $id; + } + public function getTitle() { return $this->_title; diff --git a/application/models/Mapper/BlogPost.php b/application/models/Mapper/BlogPost.php index c56a4d3..0a1f04a 100644 --- a/application/models/Mapper/BlogPost.php +++ b/application/models/Mapper/BlogPost.php @@ -1,10 +1,25 @@ '-', + ); + + $permalink = $post->getTitle(); + + foreach ($chars as $ch => $rep) { + $permalink = str_replace($ch, $rep, $permalink); + } + + return strtolower($permalink); + } + public function __construct($dbtable = null) { parent::__construct($dbtable); @@ -17,6 +32,7 @@ class Mapper_BlogPost extends Fiktiv_Data_Mapper_DbTable_Abstract if ($obj instanceof Zend_Db_Table_Row) { + $blogPost->setId($obj->id); $blogPost->setTitle($obj->title); $blogPost->setContent($obj->content); $blogPost->setPubDate(new Fiktiv_Date($obj->pubDate)); @@ -29,6 +45,16 @@ class Mapper_BlogPost extends Fiktiv_Data_Mapper_DbTable_Abstract return $blogPost; } + + public function findById($id) + { + if (is_numeric($id)) { + return $this->_createBlogPost($this->_dbTable->find($id)->current()); + } + + return null; + } + public function findAllPostByAuthor($user) { if ($user instanceof User) { diff --git a/application/models/Mapper/User.php b/application/models/Mapper/User.php index f8e14f0..e5ba43d 100644 --- a/application/models/Mapper/User.php +++ b/application/models/Mapper/User.php @@ -1,6 +1,6 @@ view->post = $this->dataService->BlogPost->findById($this->_getParam('id', null)); + + if (!$this->view->post) + $this->_redirect(array('action' => 'latest')); + + } } diff --git a/application/modules/blog/views/scripts/index/archive.phtml b/application/modules/blog/views/scripts/index/archive.phtml index 5ef7103..7722c88 100644 --- a/application/modules/blog/views/scripts/index/archive.phtml +++ b/application/modules/blog/views/scripts/index/archive.phtml @@ -1 +1,10 @@ -
=$this->translate('BLOG_ARCHIVE_INTRO') ?>
+ +=$this->translate('BLOG_TXT') ?>
+=$this->translate('BLOG_LATEST_INTRO') ?>
-posts as $post): ?> +posts); +for ($i = 0; $i < $postCount; $i++): +$post = $this->posts[$i]; +?> -'; + print_r($r); + echo ''; } public function aboutAction() @@ -24,4 +29,12 @@ class IndexController extends Fiktiv_Controller_Action echo $me; } + + public function test() + { + $r = rand(100,999); + for ($i=0;$i<$r;$i++) { + $s = $i+$i; + } + } } \ No newline at end of file diff --git a/application/modules/default/views/scripts/portfolio/index.phtml b/application/modules/default/views/scripts/portfolio/index.phtml index e69de29..85129cc 100644 --- a/application/modules/default/views/scripts/portfolio/index.phtml +++ b/application/modules/default/views/scripts/portfolio/index.phtml @@ -0,0 +1,2 @@ +
=$this->translate('PORTFOLIO_INTRO') ?>
\ No newline at end of file diff --git a/library/Fiktiv/Controller/Plugin/Language.php b/library/Fiktiv/Controller/Plugin/Language.php index 558ba11..b401bad 100644 --- a/library/Fiktiv/Controller/Plugin/Language.php +++ b/library/Fiktiv/Controller/Plugin/Language.php @@ -12,13 +12,40 @@ class Fiktiv_Controller_Plugin_Language extends Zend_Controller_Plugin_Abstract $lang = $request->getParam('lang'); // If lang is not supplied we use default. - if (is_null($lang)) { + if (is_null($lang) || !in_array($lang, array('sv', 'en'))) { + $config = $bootstrap->getApplication()->getOption('defaults'); $lang = $config['lang']; + + $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); + $url = $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('url'); + $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); + + + $pos = strpos($url->url(), $baseUrl); + + if (false === $pos) { + return; + } else { + + + $url = substr_replace($url->url(), $lang, $pos, strlen($baseUrl)); + } + + //echo $url; + $redirector->gotoSimpleAndExit('/sv/blog/archive'); + } if ($translate->isAvailable($lang)) { $translate->setLocale($lang); } } + + protected function test() + { + $pos = strpos($mystring, $findme); + + + } } \ No newline at end of file diff --git a/library/Fiktiv/Data/Mapper/DbTable/Abstract.php b/library/Fiktiv/Model/Mapper/DbTableAbstract.php similarity index 91% rename from library/Fiktiv/Data/Mapper/DbTable/Abstract.php rename to library/Fiktiv/Model/Mapper/DbTableAbstract.php index 95ff6cb..649918a 100644 --- a/library/Fiktiv/Data/Mapper/DbTable/Abstract.php +++ b/library/Fiktiv/Model/Mapper/DbTableAbstract.php @@ -1,6 +1,6 @@ null, + 'total' => null, + 'max' => null, + 'min' => null, + 'results' => array() + ); + + for ($x=0;$x<$times;$x++) { + + self::begin(); + + for ($y=0;$y<$iterations;$y++) { + call_user_func_array($function, $params); + } + + $result['results'][] = self::end(); + + $result['total'] += self::result(); + + if ($result['min'] > self::result() || empty($result['min'])) + $result['min'] = self::result(); + + if ($result['max'] < self::result()) + $result['max'] = self::result(); + + } + + $result['avg'] = array_sum($result['results']) / count($result['results']); + + return $result; + } + +} diff --git a/library/Fiktiv/View/Helper/AuthLink.php b/library/Fiktiv/View/Helper/AuthLink.php index 01e3a2e..70ce110 100644 --- a/library/Fiktiv/View/Helper/AuthLink.php +++ b/library/Fiktiv/View/Helper/AuthLink.php @@ -7,8 +7,7 @@ class Fiktiv_View_Helper_AuthLink extends Zend_View_Helper_Abstract $auth = Zend_Auth::getInstance(); $options = array( - 'route' => 'default', - 'module' => 'default', + 'module' => 'index', 'controller' => 'auth' ); @@ -20,6 +19,6 @@ class Fiktiv_View_Helper_AuthLink extends Zend_View_Helper_Abstract $display = 'u:login'; } - return '' . $this->view->translate($display) . ''; + return '' . $this->view->translate($display) . ''; } } \ No newline at end of file diff --git a/public/css/default.css b/public/css/default.css index 1953c9d..731437f 100644 --- a/public/css/default.css +++ b/public/css/default.css @@ -232,6 +232,16 @@ div#agrement { border: 1px solid #f1f1f1; } +/* Custom List dots */ +ul.custom { + padding: 0 0 0 20px; + list-style-image: url('../img/ulli.png'); +} + +ul.custom li { + margin: 5px; +} + /* Footer */ #footer { @@ -251,3 +261,24 @@ div#agrement { #footer #info { float: left; } + + +/* Blog stuff */ +.blogpost { + padding: 0 0 30px 0; + margin: 30px 0 20px 0; +} + +.blogpost h3 { + padding: 0; + margin: 0; + font-size: 1.8em; +} + +.blogpost .publish { + color: grey; +} + +.blogpost .content { + margin: 10px 0; +} diff --git a/public/img/ulli.png b/public/img/ulli.png new file mode 100644 index 0000000..2e6eadd Binary files /dev/null and b/public/img/ulli.png differ