BFC
This commit is contained in:
parent
d648d58628
commit
359e42a44b
19 changed files with 260 additions and 28 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,12 @@ LOGIN_TXT = "Fill out your information below to login.<br /><p class="red">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."
|
||||
|
|
|
|||
|
|
@ -10,7 +10,15 @@ LOGIN_TXT = "Ange dina uppgifter nedan för att logga in.<br /><p class="red">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
|
||||
readable = läsbart
|
||||
back = tillbaka
|
||||
|
||||
|
||||
ERROR_FORM_EMPTY = fältet får inte vara tomt
|
||||
ERROR_FORM_EMAIL_INVALID = epost adressen är inte gilltig
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,25 @@
|
|||
<?php
|
||||
|
||||
class Mapper_BlogPost extends Fiktiv_Data_Mapper_DbTable_Abstract
|
||||
class Mapper_BlogPost extends Fiktiv_Model_Mapper_DbTableAbstract
|
||||
{
|
||||
|
||||
protected $_mapperUser = null;
|
||||
|
||||
public static function generatePermalink(BlogPost $post)
|
||||
{
|
||||
$chars = array(
|
||||
' ' => '-',
|
||||
);
|
||||
|
||||
$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) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Mapper_User extends Fiktiv_Data_Mapper_DbTable_Abstract
|
||||
class Mapper_User extends Fiktiv_Model_Mapper_DbTableAbstract
|
||||
{
|
||||
|
||||
protected function _createUser($object)
|
||||
|
|
|
|||
|
|
@ -15,5 +15,15 @@ class Blog_IndexController extends Fiktiv_Controller_Action
|
|||
public function archiveAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function readAction()
|
||||
{
|
||||
$this->view->post = $this->dataService->BlogPost->findById($this->_getParam('id', null));
|
||||
|
||||
if (!$this->view->post)
|
||||
$this->_redirect(array('action' => 'latest'));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,10 @@
|
|||
<h1><?=$this->translate('u:archive') ?></h1>
|
||||
<h1><?=$this->translate('u:archive') ?></h1>
|
||||
|
||||
<p><?=$this->translate('BLOG_ARCHIVE_INTRO') ?></p>
|
||||
|
||||
<ul class="custom">
|
||||
<li><a href="#">September 2010</a></li>
|
||||
<li><a href="#">Augusti 2010</a></li>
|
||||
<li><a href="#">Juli 2010</a></li>
|
||||
<li><a href="#">Juni 2010</a></li>
|
||||
</ul>
|
||||
|
|
@ -1,14 +1,22 @@
|
|||
<h1><?=$this->translate('u:blog') ?></h1>
|
||||
|
||||
<p><?=$this->translate('BLOG_TXT') ?></p>
|
||||
<p><?=$this->translate('BLOG_LATEST_INTRO') ?></p>
|
||||
|
||||
|
||||
<?php foreach ($this->posts as $post): ?>
|
||||
<?php
|
||||
$postCount = count($this->posts);
|
||||
for ($i = 0; $i < $postCount; $i++):
|
||||
$post = $this->posts[$i];
|
||||
?>
|
||||
|
||||
<div>
|
||||
<h3><?=$post->getTitle() ?></h3>
|
||||
<div><?=$post->getContent() ?></div>
|
||||
<div><?=$post->getPubDate()->toString('yyyy-MM-dd').' at '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->getFirstName() ?></div>
|
||||
<div class="blogpost">
|
||||
<h3><a href="<?=$this->url(array('action' => 'read','id' => $post->getId()),'blog') ?>"><?=$post->getTitle() ?></a></h3>
|
||||
<div class="publish"><?=$post->getPubDate()->toString('yyyy-MM-dd').' at '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->getFirstName() ?></div>
|
||||
<div class="content"><?=$post->getContent() ?></div>
|
||||
</div>
|
||||
|
||||
<?php endforeach; ?>
|
||||
<?php if ($i+1 != $postCount): ?>
|
||||
<div class="line"></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endfor; ?>
|
||||
13
application/modules/blog/views/scripts/index/read.phtml
Normal file
13
application/modules/blog/views/scripts/index/read.phtml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
|
||||
<?php if (isset($this->post)): ?>
|
||||
|
||||
<a href="<?=$this->url(array('action' => 'latest', 'id' => ''), 'blog') ?>">« <?=$this->translate('u:back') ?></a>
|
||||
|
||||
<div class="blogpost">
|
||||
<h1><?=$this->post->getTitle() ?></h1>
|
||||
<div class="publish"><?=$this->post->getPubDate()->toString('yyyy-MM-dd').' at '.$this->post->getPubDate()->toString('HH:mm').' '.$this->post->getAuthor()->getFirstName() ?></div>
|
||||
<div class="content"><?=$this->post->getContent() ?></div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
|
@ -22,11 +22,19 @@ class AuthController extends Fiktiv_Controller_Action
|
|||
$emailElement = new Zend_Form_Element_Text('email');
|
||||
$emailElement->setLabel($this->translate('u:email'))
|
||||
->setRequired(true)
|
||||
->addValidator(new Zend_Validate_EmailAddress());
|
||||
->addValidator('NotEmpty', true)
|
||||
->addValidator('EmailAddress', true);
|
||||
|
||||
$emailElement->getValidator('EmailAddress')->setMessage('u:ERROR_FORM_EMAIL_INVALID', Zend_Validate_EmailAddress::INVALID_FORMAT);
|
||||
$emailElement->getValidator('NotEmpty')->setMessage('u:ERROR_FORM_EMPTY', Zend_Validate_NotEmpty::IS_EMPTY);
|
||||
|
||||
|
||||
$passwordElement = new Zend_Form_Element_Password('password');
|
||||
$passwordElement->setLabel($this->translate('u:password'))
|
||||
->setRequired(true);
|
||||
->setRequired(true)
|
||||
->addValidator('NotEmpty', true);
|
||||
|
||||
$passwordElement->getValidator('NotEmpty')->setMessage('u:ERROR_FORM_EMPTY', Zend_Validate_NotEmpty::IS_EMPTY);
|
||||
|
||||
$buttonElement = new Zend_Form_Element_Submit('login');
|
||||
|
||||
|
|
@ -41,10 +49,12 @@ class AuthController extends Fiktiv_Controller_Action
|
|||
// TODO: redirect user
|
||||
} else {
|
||||
// TODO: Wrong email / password
|
||||
var_dump($emailElement->getErrors());
|
||||
echo "Wrong email / password";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "You are ";
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if ($auth->hasIdentity()) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ class IndexController extends Fiktiv_Controller_Action
|
|||
$me = $this->dataService->User->findRandom();
|
||||
echo $me;
|
||||
|
||||
|
||||
$r = Fiktiv_Performance::benchmark(array('IndexController','test'));
|
||||
echo '<pre>';
|
||||
print_r($r);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<h1>Portfolio</h1>
|
||||
<p><?=$this->translate('PORTFOLIO_INTRO') ?></p>
|
||||
|
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
abstract class Fiktiv_Data_Mapper_DbTable_Abstract
|
||||
abstract class Fiktiv_Model_Mapper_DbTableAbstract
|
||||
{
|
||||
protected $_dbTable = null;
|
||||
|
||||
|
|
@ -5,6 +5,7 @@ class Fiktiv_Performance
|
|||
|
||||
protected static $_start = null;
|
||||
protected static $_end = null;
|
||||
protected static $_result = null;
|
||||
|
||||
public static function begin()
|
||||
{
|
||||
|
|
@ -14,11 +15,49 @@ class Fiktiv_Performance
|
|||
public static function end()
|
||||
{
|
||||
self::$_end = microtime(true);
|
||||
return self::$_end - self::$_start;
|
||||
self::$_result = self::$_end - self::$_start;
|
||||
|
||||
return self::result();
|
||||
}
|
||||
|
||||
public static function results()
|
||||
public static function result()
|
||||
{
|
||||
return self::$_end - self::$_start;
|
||||
return self::$_result;
|
||||
}
|
||||
|
||||
public static function benchmark($function, $params = array(), $iterations = 1000, $times = 10)
|
||||
{
|
||||
$result = array(
|
||||
'avg' => 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 '<a href="' . $this->view->url($options) . '">' . $this->view->translate($display) . '</a>';
|
||||
return '<a href="' . $this->view->url($options, 'auth') . '">' . $this->view->translate($display) . '</a>';
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
BIN
public/img/ulli.png
Normal file
BIN
public/img/ulli.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 502 B |
Reference in a new issue