diff --git a/TODO b/TODO index f021570..061170f 100644 --- a/TODO +++ b/TODO @@ -3,4 +3,4 @@ - Blog - Administration UI - Implement form decorators -- Do not connect models and datapoints. If datapoints want to return a model object thats fine but the model is not a part of the data storage(!) \ No newline at end of file +- Use Zend db structure \ No newline at end of file diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 44bdae6..327d6ee 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -208,6 +208,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap */ protected function _initAutoloader() { + $this->bootstrap('session'); + $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('Fiktiv_'); $autoloader->setFallbackAutoloader(true); @@ -297,4 +299,4 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/../library/Fiktiv/Controller/Action/Helper', 'Fiktiv_Controller_Action_Helper'); } -} \ No newline at end of file +} diff --git a/application/languages/se.ini b/application/languages/se.ini index b2f4227..01582da 100644 --- a/application/languages/se.ini +++ b/application/languages/se.ini @@ -59,4 +59,7 @@ by = av cookies = kakor behind the site = om webbplatsen -February = februari \ No newline at end of file +filter archive by = filtrera arkivet på + +date = datum +tag = tagg \ No newline at end of file diff --git a/application/models/ModelBlogPost.php b/application/models/ModelBlogPost.php index 1e4b585..f143a42 100644 --- a/application/models/ModelBlogPost.php +++ b/application/models/ModelBlogPost.php @@ -27,42 +27,53 @@ class ModelBlogPost extends Fiktiv_Model_Abstract } } - + + /** + * Find all posts with tag. + * + * @param string $tag + * @return mixed + */ public function findByTag($tag) { - // Is this right? - $tags = new ModelTag(); - $row = $tags->fetchRow("name = 'Linux'"); - $posts = $row->findManyToManyRowset('ModelBlogPost', 'ModelPostTag'); + + $row = $tags->fetchRow($this->quoteInto('name = ?', $tag)); + + if ($row) { + $posts = $row->findManyToManyRowset('ModelBlogPost', 'ModelPostTag'); - return $posts; + return $posts; + } + + return null; } public function findByDate($date, $format) { - // This is a joke, FIXIT! - - $date = new Fiktiv_Date($date,$format); - - $where = $this->quoteInto('DATE_FORMAT(pubDate,"%Y %M") LIKE ?', $date->toString('Y MMMM')); + $date = new Fiktiv_Date($date, $format, Zend_Registry::get('Zend_Locale')); + + $where = $this->quoteInto('DATE_FORMAT(pubDate,"%Y %m") LIKE ?', $date->toString('yyyy MM')); return $this->fetchAll($where); } public function findByPermlink($permlink) { - return $this->fetchRow($this->quoteInto('permlink', $permlink)); + return $this->fetchRow($this->quoteInto('permlink = ?', $permlink)); } public function createPost($data, $id = null) { $myTags = explode(',', $data['tags']); unset($data['tags']); - $data['userId'] = Zend_Auth::getInstance()->getIdentity()->id; - $data['pubDate'] = Zend_Date::now()->getIso(); - $data['isPublished'] = 1; + if (null == $id) { + $data['userId'] = Zend_Auth::getInstance()->getIdentity()->id; + $data['pubDate'] = Zend_Date::now()->getIso(); + $data['isPublished'] = 1; + $data['permlink'] = $this->generatePermalink($data['title']); + } if ($id) { $row = $this->find($id)->current(); @@ -79,9 +90,9 @@ class ModelBlogPost extends Fiktiv_Model_Abstract } - protected function generatePermalink() + protected function generatePermalink($title) { - $permalink = $this->_data['title']; + $permalink = date('Y-m').'-'.$title; // All to lowercase $permalink = strtolower($permalink); @@ -105,6 +116,6 @@ class ModelBlogPost extends Fiktiv_Model_Abstract $permalink = str_replace($char,$value,$permalink); } - $this->_data['permalink'] = $permalink; + return $permalink; } } \ No newline at end of file diff --git a/application/models/ModelTag.php b/application/models/ModelTag.php index 0a1a709..8197f65 100644 --- a/application/models/ModelTag.php +++ b/application/models/ModelTag.php @@ -16,6 +16,9 @@ class ModelTag extends Fiktiv_Model_Abstract foreach ($tags as $key => $tag) { $tags[$key] = trim($tag); + if (empty($tags[$key])) + continue; + $tag = $this->fetchRow($this->quoteInto('name = ?', $tags[$key])); if (!$tag) { diff --git a/application/modules/admin/views/layout/default.phtml b/application/modules/admin/views/layout/default.phtml index 48c17c0..e49f3d2 100644 --- a/application/modules/admin/views/layout/default.phtml +++ b/application/modules/admin/views/layout/default.phtml @@ -7,7 +7,9 @@ + + =$this->headScript() ?> diff --git a/application/modules/blog/controllers/ArchiveController.php b/application/modules/blog/controllers/ArchiveController.php index ad2aa5f..2deb669 100644 --- a/application/modules/blog/controllers/ArchiveController.php +++ b/application/modules/blog/controllers/ArchiveController.php @@ -10,19 +10,20 @@ class Blog_ArchiveController extends Fiktiv_Controller_Action public function filterAction() { - - $params = $this->_getAllParams(); - $blogposts = new ModelBlogPost(); + $params = $this->_getAllParams(); + if (array_key_exists('date', $params)) { - - $this->view->posts = $blogposts->findByDate($params['date'], '%Y-%MM'); + $this->view->filterType = 'date'; + $this->view->filterValue = str_replace('-',' ',$params['date']); + $this->view->posts = $blogposts->findByDate($params['date'], 'yyyy-MMMM'); } else if (array_key_exists('tag', $params)) { - + $this->view->filterType = 'tag'; + $this->view->filterValue = $params['tag']; $this->view->posts = $blogposts->findByTag($params['tag']); - } + } } \ No newline at end of file diff --git a/application/modules/blog/controllers/IndexController.php b/application/modules/blog/controllers/IndexController.php index 016a211..135be51 100644 --- a/application/modules/blog/controllers/IndexController.php +++ b/application/modules/blog/controllers/IndexController.php @@ -22,8 +22,9 @@ class Blog_IndexController extends Fiktiv_Controller_Action public function readAction() { $posts = new ModelBlogPost(); - $this->view->post = $posts->findByPermlink($this->_getParam('id', null)); + $this->view->post = $posts->findByPermlink($this->_getParam('id', null)); + if (!$this->view->post) $this->_redirect(array('action' => 'latest')); diff --git a/application/modules/blog/views/scripts/archive/filter.phtml b/application/modules/blog/views/scripts/archive/filter.phtml index 540d4f9..1f1382b 100644 --- a/application/modules/blog/views/scripts/archive/filter.phtml +++ b/application/modules/blog/views/scripts/archive/filter.phtml @@ -1,12 +1,20 @@ « =$this->translate('u:back') ?> +
=$post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->firstName ?>
=$this->post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$this->post->getPubDate()->toString('HH:mm').' '.$this->translate('by').' '.$this->post->getAuthor()->firstName ?>
-');
+
+ // calling the function
+ insertAtCursor(document.getElementById('content'), 'test');
+
+ }
+});
+
+nicEditors.registerPlugin(nicPlugin,nicExampleOptions);
\ No newline at end of file
diff --git a/public/js/nicEdit/nicEdit.js b/public/js/nicEdit/nicEdit.js
index 79f0aa2..02bb990 100644
--- a/public/js/nicEdit/nicEdit.js
+++ b/public/js/nicEdit/nicEdit.js
@@ -110,4 +110,4 @@ var nicCodeOptions = {
};
-var nicCodeButton=nicEditorAdvancedButton.extend({width:"350px",addPane:function(){this.addForm({"":{type:"title",txt:"Edit HTML"},code:{type:"content",value:this.ne.selectedInstance.getContent(),style:{width:"340px",height:"200px"}}})},submit:function(B){var A=this.inputs.code.value;this.ne.selectedInstance.setContent(A);this.removePane()}});nicEditors.registerPlugin(nicPlugin,nicCodeOptions);
+var nicCodeButton=nicEditorAdvancedButton.extend({width:"600px",addPane:function(){this.addForm({"":{type:"title",txt:"Edit HTML"},code:{type:"content",value:this.ne.selectedInstance.getContent(),style:{width:"590px",height:"300px"}}})},submit:function(B){var A=this.inputs.code.value;this.ne.selectedInstance.setContent(A);this.removePane()}});nicEditors.registerPlugin(nicPlugin,nicCodeOptions);