Skip to content

Commit

Permalink
Merge pull request anchorcms#99 from chrillemeter/dev
Browse files Browse the repository at this point in the history
Dev branch updates
  • Loading branch information
Kieron Wilson committed Apr 7, 2012
2 parents 69c3fa5 + d770f26 commit 2829a92
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 7 deletions.
54 changes: 54 additions & 0 deletions config.default.php
Expand Up @@ -46,6 +46,60 @@
'detail' => false,
'log' => false
),

//Foreign characters
'foreign_characters' => array(
'/ä|æ|ǽ/' => 'ae',
'/ö|œ/' => 'oe',
'/ü/' => 'ue',
'/Ä/' => 'Ae',
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/' => 'A',
'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª/' => 'a',
'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
'/ç|ć|ĉ|ċ|č/' => 'c',
'/Ð|Ď|Đ/' => 'D',
'/ð|ď|đ/' => 'd',
'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E',
'/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e',
'/Ĝ|Ğ|Ġ|Ģ/' => 'G',
'/ĝ|ğ|ġ|ģ/' => 'g',
'/Ĥ|Ħ/' => 'H',
'/ĥ|ħ/' => 'h',
'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/' => 'I',
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/' => 'i',
'/Ĵ/' => 'J',
'/ĵ/' => 'j',
'/Ķ/' => 'K',
'/ķ/' => 'k',
'/Ĺ|Ļ|Ľ|Ŀ|Ł/' => 'L',
'/ĺ|ļ|ľ|ŀ|ł/' => 'l',
'/Ñ|Ń|Ņ|Ň/' => 'N',
'/ñ|ń|ņ|ň|ʼn/' => 'n',
'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/' => 'O',
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/' => 'o',
'/Ŕ|Ŗ|Ř/' => 'R',
'/ŕ|ŗ|ř/' => 'r',
'/Ś|Ŝ|Ş|Š/' => 'S',
'/ś|ŝ|ş|š|ſ/' => 's',
'/Ţ|Ť|Ŧ/' => 'T',
'/ţ|ť|ŧ/' => 't',
'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/' => 'U',
'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/' => 'u',
'/Ý|Ÿ|Ŷ/' => 'Y',
'/ý|ÿ|ŷ/' => 'y',
'/Ŵ/' => 'W',
'/ŵ/' => 'w',
'/Ź|Ż|Ž/' => 'Z',
'/ź|ż|ž/' => 'z',
'/Æ|Ǽ/' => 'AE',
'/ß/'=> 'ss',
'/IJ/' => 'IJ',
'/ij/' => 'ij',
'/Œ/' => 'OE',
'/ƒ/' => 'f'
),

// Show database profile
'debug' => false
Expand Down
6 changes: 3 additions & 3 deletions system/admin/theme/posts/edit.php
Expand Up @@ -32,14 +32,14 @@

<p>
<label for="created"><?php echo __('posts.date', 'Date'); ?>:</label>
<input type="date" id="created" autocomplete="off" name="created" value="<?php echo Input::post('created', date('jS M Y, h:i', strtotime($article->created))); ?>">
<input type="date" id="created" autocomplete="off" name="created" value="<?php echo Input::post('created', date('jS M Y, h:i', $article->created)); ?>">

<em><?php echo __('posts.date_explain', 'The date your post will be published. Uses <code><a href="http://php.net/manual/en/function.strtotime.php">strtotime()</a></code>.'); ?></em>
</p>

<p>
<label for="slug"><?php echo __('posts.slug', 'Slug'); ?>:</label>
<input type="url" id="slug" autocomplete="off" name="slug" value="<?php echo Input::post('slug', $article->slug); ?>">
<input type="text" id="slug" autocomplete="off" name="slug" value="<?php echo Input::post('slug', $article->slug); ?>">

<em><?php echo __('posts.slug_explain', 'The slug for your post.'); ?></em>
</p>
Expand Down Expand Up @@ -67,7 +67,7 @@
'published' => __('posts.published', 'published')
) as $value => $status): ?>
<?php $selected = (Input::post('status', $article->status) == $value) ? ' selected' : ''; ?>
<option value="<?php echo $status; ?>"<?php echo $selected; ?>>
<option value="<?php echo $value; ?>"<?php echo $selected; ?>>
<?php echo $status; ?>
</option>
<?php endforeach; ?>
Expand Down
29 changes: 25 additions & 4 deletions system/classes/posts.php
Expand Up @@ -3,6 +3,30 @@
class Posts {

private static function slug($str) {

$foreign_chars = Config::get('foreign_characters');

$trans = array(
'#&\#\d+?;#i' => '',
'#&\S+?;#i' => '',
'#\s+#i' => '-',
'#[^a-z0-9\-\._]#i' => '',
'#-+#i' => '-',
'#^-#i' => '-',
'#\.+$#i' => '',
'#_#i' => '-'
);

// Merging both arrays with characters.
$foreign_chars = array_merge($foreign_chars, $trans);

// Replaceing foreign characters
$str = preg_replace(array_keys($foreign_chars), array_values($foreign_chars),$str);

return trim(stripcslashes(strtolower($str)));
}

/*private static function slug($str) {
// current locale
$locale = setlocale(LC_ALL, 0);
Expand All @@ -19,7 +43,7 @@ private static function slug($str) {
setlocale(LC_ALL, $locale);
return $str;
}
}*/

public static function extend($post) {
if(is_array($post)) {
Expand Down Expand Up @@ -261,9 +285,6 @@ public static function update($id) {
var_dump($post['created']);

$post['created'] = strtotime($post['created']);

var_dump($post['created']);
exit;

if($post['created'] === false) {
$errors[] = Lang::line('posts.invalid_date', 'Please enter a valid date');
Expand Down

0 comments on commit 2829a92

Please sign in to comment.