Model work and som library changes
This commit is contained in:
parent
2dd98c8253
commit
469ea99678
8 changed files with 45 additions and 27 deletions
|
|
@ -30,7 +30,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
|
||||
// Set userrole for navigation
|
||||
$auth = Zend_Auth::getInstance();
|
||||
//var_dump($auth->getIdentity()->userRole);
|
||||
|
||||
if ($auth->hasIdentity()) {
|
||||
$view->navigation()->setRole($auth->getIdentity()->userRole);
|
||||
} else {
|
||||
|
|
@ -117,7 +117,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
$this->bootstrap('front');
|
||||
|
||||
$router = $this->getResource('front')->getRouter();
|
||||
|
||||
|
||||
// Set global lang param
|
||||
$router->setGlobalParam('lang', 'sv');
|
||||
|
||||
|
|
|
|||
|
|
@ -50,9 +50,10 @@ class BlogPost extends Fiktiv_Model_Abstract
|
|||
|
||||
public function setTitle($title)
|
||||
{
|
||||
if (is_string($title) && null == $title[30]) {
|
||||
if (is_string($title) && !isset($title[30])) {
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
$this->generatePermalink();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -131,6 +132,16 @@ class BlogPost extends Fiktiv_Model_Abstract
|
|||
$this->_data['isPublished'] = (boolean)$flag;
|
||||
}
|
||||
|
||||
public function setPermalink($permalink)
|
||||
{
|
||||
if (is_string($permalink)) {
|
||||
$this->_data['permalink'] = $permalink;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function generatePermalink()
|
||||
{
|
||||
$permalink = $this->_data['title'];
|
||||
|
|
@ -139,14 +150,19 @@ class BlogPost extends Fiktiv_Model_Abstract
|
|||
$permalink = strtolower($permalink);
|
||||
|
||||
// Remove special characters
|
||||
//$permalink = filter_var($permalink, FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
|
||||
$permalink = filter_var($permalink, FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
|
||||
// Replace stuff
|
||||
$replace = array(
|
||||
' ' => '-',
|
||||
'å' => 'a',
|
||||
'ä' => 'a',
|
||||
'ö' => 'o',
|
||||
'_' => '-',
|
||||
'!' => '',
|
||||
'?' => '',
|
||||
'.' => '',
|
||||
',' => '',
|
||||
);
|
||||
foreach($replace as $char => $value) {
|
||||
$permalink = str_replace($char,$value,$permalink);
|
||||
|
|
|
|||
|
|
@ -103,8 +103,12 @@ class Mapper_BlogPost extends Fiktiv_Model_Mapper_DbTableAbstract
|
|||
public function save(BlogPost $post)
|
||||
{
|
||||
$data = $post->toArray();
|
||||
|
||||
unset($data['id']);
|
||||
|
||||
$tags = $data['tags'];
|
||||
unset($data['tags']);
|
||||
|
||||
return $this->_dbTable->update(
|
||||
$data,
|
||||
$this->quoteInto('id = ?',$post->getId())
|
||||
|
|
|
|||
|
|
@ -16,4 +16,15 @@ class Fiktiv_Controller_Action extends Zend_Controller_Action
|
|||
return call_user_func(array($this->_helper, $name));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct access to translate with out going
|
||||
* through view.
|
||||
* @return string
|
||||
*/
|
||||
public function translate()
|
||||
{
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this->view, 'translate'), $args);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Fiktiv_Controller_Acation_Helper_Translate extends Zend_Controller_Action_Helper_Abstract
|
||||
{
|
||||
public function translate()
|
||||
{
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($this->view, 'translate'), $args);
|
||||
}
|
||||
|
||||
public function direct()
|
||||
{
|
||||
return $this->translate();
|
||||
}
|
||||
}
|
||||
|
|
@ -11,10 +11,9 @@ class Fiktiv_Controller_Plugin_Layout extends Zend_Controller_Plugin_Abstract
|
|||
|
||||
public function preDispatch(Zend_Controller_Request_Abstract $request) {
|
||||
|
||||
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
|
||||
$layout = $bootstrap->getResource('layout');
|
||||
|
||||
$moduleName = $request->getModuleName();
|
||||
$layout = Zend_Layout::getMvcInstance();
|
||||
|
||||
$moduleName = strtolower($request->getModuleName());
|
||||
|
||||
if (file_exists(APPLICATION_PATH . '/modules/' . $moduleName . '/views/layout/' . $this->_default . '.phtml')) {
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ class Fiktiv_View_Helper_Translate extends Zend_View_Helper_Translate
|
|||
{
|
||||
$options = func_get_args();
|
||||
$key = array_shift($options);
|
||||
|
||||
if ($options[count($options)-1] === true) {
|
||||
|
||||
if (isset($options[0]) && $options[count($options)-1] === true) {
|
||||
foreach ($options as &$opt) {
|
||||
$opt = parent::translate($opt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,7 @@ RewriteCond %{REQUEST_FILENAME} -s [OR]
|
|||
RewriteCond %{REQUEST_FILENAME} -l [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
RewriteRule ^.*$ - [NC,L]
|
||||
RewriteRule ^.*$ index.php [NC,L]
|
||||
RewriteRule ^.*$ index.php [NC,L]
|
||||
|
||||
|
||||
php_flag short_open_tag on
|
||||
Reference in a new issue