fixed a bunch of stuff
This commit is contained in:
parent
019a1e01dd
commit
2edc535102
19 changed files with 180 additions and 66 deletions
2
TODO
2
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(!)
|
||||
- Use Zend db structure
|
||||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,4 +59,7 @@ by = av
|
|||
cookies = kakor
|
||||
behind the site = om webbplatsen
|
||||
|
||||
February = februari
|
||||
filter archive by = filtrera arkivet på
|
||||
|
||||
date = datum
|
||||
tag = tagg
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/css/reset.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/css/default.css" media="screen" />
|
||||
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/fancybox/jquery.fancybox-1.3.1.css" media="screen" />
|
||||
|
||||
<script type="text/javascript" src="<?=$this->baseUrl()?>/js/nicEdit/nicEdit.js"></script>
|
||||
<script type="text/javascript" src="<?=$this->baseUrl()?>/js/nicEdit/nicCode/nicCode.js"></script>
|
||||
<?=$this->headScript() ?>
|
||||
<script type="text/javascript" src="<?=$this->baseUrl()?>/fancybox/jquery.fancybox-1.3.1.pack.js"></script>
|
||||
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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'));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,20 @@
|
|||
|
||||
<a href="<?=$this->url(array('controller' => 'archive'), 'blog', true) ?>">« <?=$this->translate('u:back') ?></a>
|
||||
|
||||
<h1><?=$this->translate('u:filter archive by') . ' ' . $this->translate($this->filterType) ?> - <?=$this->filterValue ?></h1>
|
||||
|
||||
|
||||
<?php
|
||||
$hl = new Fiktiv_Highlighter();
|
||||
$hl->setHighlighter('geshi');
|
||||
?>
|
||||
|
||||
<?php foreach($this->posts as $post) : ?>
|
||||
<div class="blogpost">
|
||||
<h3><a href="<?=$this->url(array('action' => 'read','id' => $post->permlink),'blog-default') ?>"><?=$post->title ?></a></h3>
|
||||
<p class="publish"><?=$post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->firstName ?></p>
|
||||
<div class="content">
|
||||
<?=$post->content ?>
|
||||
<?= $hl->replaceCodeblock($post->content) ?>
|
||||
</div>
|
||||
|
||||
<?php if ($post->hasTags()): ?>
|
||||
|
|
@ -14,12 +22,13 @@
|
|||
<div class="tags">
|
||||
<?php
|
||||
$count = $post->getTags()->count();
|
||||
for ($i = 0; $i < $count-1; $i++): ?>
|
||||
<a href="#"><?=$post->getTags()->getRow($i)->name ?></a>,
|
||||
<?php
|
||||
endfor;
|
||||
foreach ($post->getTags() as $tag) {
|
||||
|
||||
echo '<a href="'.$this->url(array('controller' => 'archive', 'action' => 'filter', 'tag' => $tag->name), 'blog', true).'">'.$tag->name.'</a>';
|
||||
|
||||
echo (--$count > 0) ? ', ' : '';
|
||||
}
|
||||
?>
|
||||
<a href="#"><?=$post->getTags()->getRow($i)->name ?></a>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@
|
|||
<div class="tags">
|
||||
<?php
|
||||
$count = $post->getTags()->count();
|
||||
for ($i = 0; $i < $count-1; $i++): ?>
|
||||
<a href="#"><?=$post->getTags()->getRow($i)->name ?></a>,
|
||||
<?php
|
||||
endfor;
|
||||
foreach ($post->getTags() as $tag) {
|
||||
|
||||
echo '<a href="'.$this->url(array('controller' => 'archive', 'action' => 'filter', 'tag' => $tag->name), 'blog').'">'.$tag->name.'</a>';
|
||||
|
||||
echo (--$count > 0) ? ', ' : '';
|
||||
}
|
||||
?>
|
||||
<a href="#"><?=$post->getTags()->getRow($i)->name ?></a>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
|
||||
<?php
|
||||
$hl = new Fiktiv_Highlighter();
|
||||
$hl->setHighlighter('geshi');
|
||||
?>
|
||||
|
||||
<?php if (isset($this->post)): ?>
|
||||
|
||||
|
|
@ -7,7 +10,7 @@
|
|||
<div class="blogpost">
|
||||
<h1><?=$this->post->title ?></h1>
|
||||
<p class="publish"><?=$this->post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$this->post->getPubDate()->toString('HH:mm').' '.$this->translate('by').' '.$this->post->getAuthor()->firstName ?></p>
|
||||
<div class="content"><?=$this->post->content ?></div>
|
||||
<div class="content"><?= $hl->replaceCodeblock($this->post->content) ?></div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
|
@ -28,9 +28,9 @@ class ProfileController extends Fiktiv_Controller_Action
|
|||
));
|
||||
|
||||
$options = array(
|
||||
User::AVATAR_NONE => 'Ingen avatar',
|
||||
User::AVATAR_FIKTIV => 'Egen avatar',
|
||||
User::AVATAR_GRVTAR => 'Gravatar'
|
||||
1 => 'Ingen avatar',
|
||||
2 => 'Egen avatar',
|
||||
3 => 'Gravatar'
|
||||
);
|
||||
$form->addElement('select', 'avatar', array(
|
||||
'label' => 'u:avatar type',
|
||||
|
|
@ -82,7 +82,8 @@ class ProfileController extends Fiktiv_Controller_Action
|
|||
$form->addDisplayGroup(
|
||||
array(
|
||||
'password',
|
||||
'passwordConfirm'
|
||||
'passwordConfirm',
|
||||
'save'
|
||||
),
|
||||
'partThree',
|
||||
array(
|
||||
|
|
@ -90,19 +91,16 @@ class ProfileController extends Fiktiv_Controller_Action
|
|||
)
|
||||
);
|
||||
|
||||
$form->addDisplayGroup(
|
||||
array(
|
||||
'save'
|
||||
),
|
||||
'partThree'
|
||||
);
|
||||
|
||||
|
||||
$user = Zend_Auth::getInstance()->getIdentity();
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$user = $auth->getIdentity();
|
||||
|
||||
|
||||
if ($this->_request->isPost()) {
|
||||
|
||||
$users = new ModelUser();
|
||||
$userRow = $users->find($user->id)->current();
|
||||
|
||||
$data = $this->_request->getPost();
|
||||
|
||||
if ($data['password'] !== $data['passwordConfirm'] || empty($data['password'])) {
|
||||
|
|
@ -113,22 +111,27 @@ class ProfileController extends Fiktiv_Controller_Action
|
|||
|
||||
} else {
|
||||
|
||||
if ($user->setPassword($data['password']))
|
||||
$this->view->messages = 'Lösenordet är ändrat!';
|
||||
//if ($users->setPassword($user->id, $data['password']))
|
||||
// $this->view->messages = 'Lösenordet är ändrat!';
|
||||
|
||||
unset($data['password']);
|
||||
}
|
||||
|
||||
|
||||
unset($data['password']);
|
||||
unset($data['passwordConfirm']);
|
||||
unset($data['save']);
|
||||
|
||||
|
||||
$user->setAttribs($data);
|
||||
$user->save();
|
||||
$userRow->setFromArray($data);
|
||||
$userRow->save();
|
||||
|
||||
// Update auth session
|
||||
$user = (object) array_merge((array)$user, $userRow->toArray());
|
||||
unset($user->salt);
|
||||
unset($user->password);
|
||||
$auth->getStorage()->write($user);
|
||||
}
|
||||
|
||||
$form->populate($user->toArray());
|
||||
$form->populate((array)$user);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,16 @@
|
|||
</span>
|
||||
|
||||
<span class="float-right">
|
||||
<?php
|
||||
|
||||
$obj = new Zend_Http_UserAgent();
|
||||
echo $obj->getDevice()->getBrowser();
|
||||
echo ' ';
|
||||
echo implode('.', array_slice(explode('.', $obj->getDevice()->getBrowserVersion()), 0, 2));
|
||||
|
||||
|
||||
?>
|
||||
<br />
|
||||
<a href="<?=$this->url(array('action' => 'about'),'default-default') ?>#cookies"><?=$this->translate('u:cookies')?></a> -
|
||||
<a href="<?=$this->url(array('action' => 'about'),'default-default') ?>#about"><?=$this->translate('uw:about')?></a>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ class Fiktiv_Controller_Plugin_Language extends Zend_Controller_Plugin_Abstract
|
|||
'en' => 'en_US'
|
||||
);
|
||||
|
||||
Zend_Registry::set('Zend_Locale', new Zend_Locale($lookup[$lang]));
|
||||
|
||||
$database = $bootstrap->getResource('database');
|
||||
$database->query("SET lc_time_names = ?;", $lookup[$lang]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,11 +37,10 @@ class Fiktiv_Highlighter {
|
|||
|
||||
foreach ($code[1] as $key => $lang) {
|
||||
$c = str_replace('<br>', "\n",html_entity_decode($code[2][$key], ENT_COMPAT,'UTF-8'));
|
||||
$block = str_replace($code[2][$key], html_entity_decode($this->highlight($c, $lang), ENT_COMPAT, 'UTF-8'), $block);
|
||||
$block = str_replace($code[2][$key], $this->highlight($c, $lang), $block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@
|
|||
defined('APPLICATION_PATH') ||
|
||||
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
|
||||
|
||||
defined('APPLICATION_EXTERNAL') ||
|
||||
define('APPLICATION_EXTERNAL', realpath(dirname(__FILE__) . '/../external'));
|
||||
|
||||
defined('APPLICATION_ENV') ||
|
||||
define('APPLICATION_ENV',(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
define('APPLICATION_ENV',(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
|
||||
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
APPLICATION_PATH . '/../library',
|
||||
|
|
@ -21,4 +24,4 @@ $application = new Zend_Application(
|
|||
);
|
||||
|
||||
$application->bootstrap()
|
||||
->run();
|
||||
->run();
|
||||
|
|
|
|||
BIN
public/js/nicEdit/nicCode/icons/code.png
Normal file
BIN
public/js/nicEdit/nicCode/icons/code.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 389 B |
61
public/js/nicEdit/nicCode/nicCode.js
Normal file
61
public/js/nicEdit/nicCode/nicCode.js
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* nicExample
|
||||
* @description: An example button plugin for nicEdit
|
||||
* @requires: nicCore, nicPane, nicAdvancedButton
|
||||
* @author: Brian Kirchoff
|
||||
* @version: 0.9.0
|
||||
*/
|
||||
|
||||
/* START CONFIG */
|
||||
var nicExampleOptions = {
|
||||
buttons : {
|
||||
'example' : {name : __('Some alt text for the button'), type : 'nicEditorExampleButton'}
|
||||
}/* NICEDIT_REMOVE_START */,iconFiles : {'example' : '/fiktivkod/js/nicEdit/nicCode/icons/code.png'}/* NICEDIT_REMOVE_END */
|
||||
};
|
||||
/* END CONFIG */
|
||||
|
||||
|
||||
|
||||
function insertAtCursor(myField, myValue) {
|
||||
//IE support
|
||||
if (document.selection) {
|
||||
myField.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = myValue;
|
||||
} else if (myField.selectionStart || myField.selectionStart == 0) {
|
||||
var startPos = myField.selectionStart;
|
||||
var endPos = myField.selectionEnd;
|
||||
myField.value = myField.value.substring(0, startPos)
|
||||
+ myValue
|
||||
+ myField.value.substring(endPos, myField.value.length);
|
||||
} else {
|
||||
myField.value += myValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var nicEditorExampleButton = nicEditorButton.extend({
|
||||
mouseClick : function() {
|
||||
var editor = nicEditors.findEditor('content');
|
||||
var lang = prompt('Language?');
|
||||
|
||||
var userSelection;
|
||||
if (window.getSelection) {
|
||||
userSelection = window.getSelection();
|
||||
} else if (document.selection) { // should come last; Opera!
|
||||
userSelection = document.selection.createRange();
|
||||
}
|
||||
|
||||
var pos = userSelection.anchorOffset;
|
||||
|
||||
var content = editor.getContent();
|
||||
|
||||
//editor.setContent(content + '<code lang="' + lang + '"></code><p></p>');
|
||||
|
||||
// calling the function
|
||||
insertAtCursor(document.getElementById('content'), 'test');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
nicEditors.registerPlugin(nicPlugin,nicExampleOptions);
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Reference in a new issue