Skip to content

Commit

Permalink
Merge pull request #4 from dignajar/master
Browse files Browse the repository at this point in the history
New merge
  • Loading branch information
clickwork-git committed Oct 6, 2015
2 parents 247e2d2 + a1bfc15 commit d6590b3
Show file tree
Hide file tree
Showing 50 changed files with 972 additions and 456 deletions.
5 changes: 5 additions & 0 deletions admin/controllers/edit-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ function deleteUser($args, $deleteContent=false)
return false;
}

// The editors cannot delete users.
if($Login->role()!=='admin') {
return false;
}

if($deleteContent) {
$dbPosts->deletePostsByUser($args['username']);
}
Expand Down
24 changes: 11 additions & 13 deletions admin/views/edit-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<li><a href="#email"><?php $Language->p('Email') ?></a></li>
<li><a href="#password"><?php $Language->p('Password') ?></a></li>

<?php if($_user['username']!=='admin') { ?>
<?php if($_user['username']=='admin') { ?>
<li><a href="#delete"><?php $Language->p('Delete') ?></a></li>
<?php } ?>
</ul>
Expand All @@ -18,9 +18,7 @@

<div id="profile">
<form method="post" action="" class="forms">

<input type="hidden" id="jstoken" name="token" value="<?php $Security->printToken() ?>">
<input type="hidden" name="edit-user" value="true">
<input type="hidden" name="username" value="<?php echo $_user['username'] ?>">

<label>
Expand Down Expand Up @@ -50,7 +48,7 @@

<?php } ?>

<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="user-profile">
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="edit-user">
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn"><?php $Language->p('Cancel') ?></a>
</form>
</div>
Expand All @@ -61,7 +59,7 @@

<div id="email">
<form method="post" action="" class="forms">
<input type="hidden" name="edit-user" value="true">
<input type="hidden" id="jstoken" name="token" value="<?php $Security->printToken() ?>">
<input type="hidden" name="username" value="<?php echo $_user['username'] ?>">

<label>
Expand All @@ -70,7 +68,7 @@
<div class="forms-desc"><?php $Language->p('email-will-not-be-publicly-displayed') ?></div>
</label>

<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="user-email">
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="edit-user">
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn"><?php $Language->p('Cancel') ?></a>
</form>
</div>
Expand All @@ -81,7 +79,7 @@

<div id="password">
<form method="post" action="" class="forms">
<input type="hidden" name="change-password" value="true">
<input type="hidden" id="jstoken" name="token" value="<?php $Security->printToken() ?>">
<input type="hidden" name="username" value="<?php echo $_user['username'] ?>">

<label>
Expand All @@ -94,28 +92,28 @@
<input type="password" name="confirm-password" class="width-50">
</label>

<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="user-password">
<input type="submit" class="btn btn-blue" value="<?php $Language->p('Save') ?>" name="change-password">
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn"><?php $Language->p('Cancel') ?></a>
</form>
</div>

<!-- ===================================== -->
<!-- Delete -->
<!-- ===================================== -->
<?php if($_user['username']!=='admin') { ?>
<?php if($_user['username']=='admin') { ?>

<div id="delete">

<form method="post" action="" class="forms">
<input type="hidden" name="delete-user-all" value="true">
<input type="hidden" id="jstoken" name="token" value="<?php $Security->printToken() ?>">
<input type="hidden" name="username" value="<?php echo $_user['username'] ?>">
<p><input type="submit" class="btn btn-blue" value="<?php $Language->p('Delete the user and all its posts') ?>"></p>
<p><input type="submit" name="delete-user-all" class="btn btn-blue" value="<?php $Language->p('Delete the user and all its posts') ?>"></p>
</form>

<form method="post" action="" class="forms">
<input type="hidden" name="delete-user-associate" value="true">
<input type="hidden" id="jstoken" name="token" value="<?php $Security->printToken() ?>">
<input type="hidden" name="username" value="<?php echo $_user['username'] ?>">
<p><input type="submit" class="btn btn-blue" value="<?php $Language->p('Delete the user and associate its posts to admin user') ?>"></p>
<p><input type="submit" name="delete-user-associate" class="btn btn-blue" value="<?php $Language->p('Delete the user and associate its posts to admin user') ?>"></p>
</form>

<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn"><?php $Language->p('Cancel') ?></a>
Expand Down
15 changes: 15 additions & 0 deletions admin/views/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@
<div class="forms-desc"><?php $Language->p('the-url-of-your-site') ?></div>
</label>

<h4><?php $Language->p('Command Line Mode') ?></h4>

<label for="cliMode">
<?php $Language->p('Cli Mode') ?>
<select name="cliMode" class="width-50">
<?php
$htmlOptions = array('true'=>'Enabled', 'false'=>'Disabled');
foreach($htmlOptions as $value=>$text) {
echo '<option value="'.$value.'"'.( ($Site->cliMode()===$value)?' selected="selected"':'').'>'.$text.'</option>';
}
?>
</select>
<div class="forms-desc"><?php $Language->p('enable-the-command-line-mode-if-you-add-edit') ?></div>
</label>

<h4><?php $Language->p('URL Filters') ?></h4>

<label>
Expand Down
4 changes: 4 additions & 0 deletions kernel/boot/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@
// PHP paths with dependency
define('PATH_THEME', PATH_ROOT.'themes/'.$Site->theme().'/');
define('PATH_THEME_PHP', PATH_THEME.'php'.DS);
define('PATH_THEME_CSS', PATH_THEME.'css'.DS);
define('PATH_THEME_JS', PATH_THEME.'js'.DS);
define('PATH_THEME_IMG', PATH_THEME.'img'.DS);
define('PATH_THEME_LANG', PATH_THEME.'languages'.DS);

// Objects with dependency
$Language = new dbLanguage( $Site->locale() );
Expand Down
13 changes: 8 additions & 5 deletions kernel/dbpages.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ public function regenerateCli()
}
}

$fields['status'] = CLI_STATUS;
$fields['date'] = Date::current(DB_DATE_FORMAT);
$fields['username'] = 'admin';

//$tmpPaths = glob(PATH_PAGES.'*', GLOB_ONLYDIR);
$tmpPaths = Filesystem::listDirectories(PATH_PAGES);
foreach($tmpPaths as $directory)
Expand Down Expand Up @@ -364,7 +360,14 @@ public function regenerateCli()

foreach($newPaths as $key=>$value)
{
if(!isset($this->db[$key])) {
if(!isset($this->db[$key]))
{
// Default values for the new pages.
$fields['status'] = CLI_STATUS;
$fields['date'] = Date::current(DB_DATE_FORMAT);
$fields['username'] = 'admin';

// Create the entry for the new page.
$this->db[$key] = $fields;
}

Expand Down
64 changes: 63 additions & 1 deletion kernel/helpers/text.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,65 @@

class Text {

private static $specialChars = array(
// Latin
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'AE', 'Ç'=>'C',
'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I',
'Ð'=>'D', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ő'=>'O',
'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ű'=>'U', 'Ý'=>'Y', 'Þ'=>'TH',
'ß'=>'ss',
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'ae', 'ç'=>'c',
'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i',
'ð'=>'d', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ő'=>'o',
'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ü'=>'u', 'ű'=>'u', 'ý'=>'y', 'þ'=>'th',
'ÿ'=>'y',
// Latin symbols
'©'=>'(c)',
// Greek
'Α'=>'A', 'Β'=>'B', 'Γ'=>'G', 'Δ'=>'D', 'Ε'=>'E', 'Ζ'=>'Z', 'Η'=>'H', 'Θ'=>'8',
'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>'u', 'Ž'=>'Z',
'ā'=>'a', 'č'=>'c', 'ē'=>'e', 'ģ'=>'g', 'ī'=>'i', 'ķ'=>'k', 'ļ'=>'l', 'ņ'=>'n',
'š'=>'s', 'ū'=>'u', 'ž'=>'z'
);

public static function addSlashes($string, $begin=true, $end=true)
{
if($begin) {
Expand Down Expand Up @@ -54,6 +113,9 @@ public static function randomText($length)

public static function cleanUrl($string, $separator='-')
{
// Transliterate characters to ASCII
$string = str_replace(array_keys(self::$specialChars), self::$specialChars, $string);

if(function_exists('iconv')) {
$string = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
}
Expand Down Expand Up @@ -90,7 +152,7 @@ public static function firstCharUp($string, $encoding='UTF-8')
{
$strlen = mb_strlen($string, $encoding);
$firstChar = mb_substr($string, 0, 1, $encoding);
$then = mb_substr($string, 1, $strlen - 1, $encoding);
$then = mb_substr($string, 1, $strlen - 1, $encoding);

return mb_strtoupper($firstChar, $encoding).$then;
}
Expand Down

0 comments on commit d6590b3

Please sign in to comment.