Skip to content

Instantly share code, notes, and snippets.

@webuilder240
Last active August 29, 2015 14:09
Show Gist options
  • Save webuilder240/fdd86cc7d70daa13d252 to your computer and use it in GitHub Desktop.
Save webuilder240/fdd86cc7d70daa13d252 to your computer and use it in GitHub Desktop.
<?php
/**
* Application level View Helper
*
* This file is application-wide helper file. You can put all
* application-wide helper-related methods here.
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Helper
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('Helper', 'View');
/**
* Application helper
*
* Add your application-wide methods in the class below, your helpers
* will inherit them.
*
* @package app.View.Helper
*/
class SplHelper extends Helper {
public $helpers = ['Markdown.Markdown','Html'];
public function date_format($datetime)
{
$format = 'Y/n/j H:i';
return date($format,strtotime($datetime));
}
public function Ellipsis($string, $limit = 30)
{
$string = $this->Markdown->transform($string);
$remove_tags_string = strip_tags($string);
$tmp = mb_substr($remove_tags_string,0,$limit);
if (mb_strlen($remove_tags_string) > $limit) {
$tmp.=' ...';
}
return h($tmp);
}
public function echoPost($content)
{
// <pre>を取り除くいて、
$content = $this->Markdown->transform($content);
return "<div id='spl_content_area'>{$content}</div>";
}
public function archiveLink($archive)
{
$link_text = "{$archive['Archive']['year']} / {$archive['Archive']['month']} ({$archive['Archive']['count']})";
$text = $this->Html->link($link_text,[
'controller' => '/',
'?' => [
'month' => $archive['Archive']['year'] . $archive['Archive']['month']
]
]);
return $text;
}
public function syntaxHighlighterLoad()
{
echo $this->Html->css('vendor/syntaxhighlighter/shCore');
echo $this->Html->css('vendor/syntaxhighlighter/shThemeDefault');
echo $this->Html->script('vendor/syntaxhighlighter/shCore');
echo $this->Html->script('vendor/syntaxhighlighter/shAutoloader');
echo $this->Html->script('vendor/syntaxhighlighter/shAllload');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment