Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions application/controllers/images.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,39 @@ public function save_image($img_id){
/**
* upload image - called from redactor
*/
public function post_upload(){
public function post_upload()
{

$model = $this->model;


$rules = array(
'image' => 'required|mimes:jpg|max:1000',
'name' => ''
);

// jiggle the uploaded data into the format we'd like
$uploaded_img = Input::file('image');

$img = array();
$img['name'] = $uploaded_img['name'][0];
$img['type'] = $uploaded_img['type'][0];
$img['tmp_name'] = $uploaded_img['tmp_name'][0];
$img['error'] = $uploaded_img['error'][0];
$img['size'] = $uploaded_img['size'][0];

$uploaded_input = array();
$uploaded_input['image'] = $img;

if(!$model::is_valid($rules)){
if (!$model::is_valid($rules, $uploaded_input)) {
return static::json(array('error'=>'invalid input','errors'=> $model::$validation->errors->all()), 422);
}

$img = Input::file('image');
if(isset( $img['error']) && $img['error'] === 0){
$name = explode('.',$img['name']);
if (isset($img['error']) && $img['error'] === 0) {
$name = explode('.', $img['name']);
array_pop($name);
$name = implode('.',$name);
}else{
$name = implode('.', $name);
} else {
return static::json(array('error'=>'invalid input'), 422);
}

Expand All @@ -159,20 +173,22 @@ public function post_upload(){
$new->name = $name;
$new->height = $size[1];
$new->width = $size[0];
$new->populate_from_input();

// FIXME - why was this even unsetting the image element??
$new->populate_from_input($uploaded_input);

$new->save();

$img = Input::file('image');
if(isset( $img['error']) && $img['error'] === 0){
if(!$this->save_image($new->id)){

if (isset($img['error']) && $img['error'] === 0) {
if (!$this->save_image($new->id)) {
$new->raw_delete();
}
}else{
} else {
$new->raw_delete();
}

return static::json(API::get_data_single('image',$new->id));
return static::json(API::get_data_single('image', $new->id));
}

/**
Expand Down
43 changes: 41 additions & 2 deletions application/models/image.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,60 @@
<?php
class Image extends SimpleData
{
/**
* Validation object once it has been created.
*/
public static $validation = null;

public static $table = 'images';

public static $rules = array(
'name' => 'required',
'image' => 'mimes:jpg|max:1000'
);

public function populate_from_input()
//FIXME because clearly this is terrible - cfc
/**
* Validates input for Field. Overrides parent method
*
* @param array $input The input in Laravel input format.
* @param array $rules An array of Laravel validations which will overwrite the defaults for the class.
* @return $validaton The Laravel validation object.
*/
public static function is_valid($rules = null, $input = null)
{
if (!is_null($rules)) {
static::$rules = array_merge(static::$rules, $rules);
}

if (!$input) {
$input = Input::all();
}

static::$validation = Validator::make($input, static::$rules);

return static::$validation->passes();
}




/**
* Populates the model from Input or an array
*
* @param array $input
* @return void
*/
public function populate_from_input($input = null)
{
if (is_null(static::$validation))
{
throw new NoValidationException('No validation');
}

$input = Input::all();
if (!$input) {
$input = Input::all();
}

// Remove _wysihtml5_mode entirely.
unset($input['image']);
Expand Down
2 changes: 1 addition & 1 deletion application/models/simpledata.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static function clear_all_as_list_cache($year = false)
public function save()
{
$saved = $this->raw_save();

xdebug_break();
if ($saved)
{
static::clear_all_as_list_cache($this->year);
Expand Down
1 change: 1 addition & 0 deletions application/views/admin/inc/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</script>

<script src="<?php echo asset('js/redactor.js')?>"></script>
<script src="<?php echo asset('js/imagemanager.js')?>" type="text/javascript" charset="utf8"></script>
<script src="<?php echo asset('js/kent-texteditor.js')?>" type="text/javascript" charset="utf8"></script>

<!-- Additional js to make datatables & wysihtml5 work with bootstrap -->
Expand Down
2 changes: 1 addition & 1 deletion paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

$environments = array(
'local' => array('http://localhost*', '*.dev', '*.local', '*.local:9000', '192.168*', '*.vg'),
'local' => array('http://plant.test:8080*', '*.test:8080', '*.test', '*.dev', '*.local', '*.local:9000', '192.168*', '*.vg'),
'test' => array('')
);

Expand Down
1,962 changes: 1,152 additions & 810 deletions public/css/redactor.css

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions public/css/redactor_kent.css
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
@font-face{font-family:Century Schoolbook;src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/CenturySchoolbook.eot);src:local("Century Schoolbook"),local("CenturySchoolbook"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/CenturySchoolbook.eot?#iefix) format("embedded-opentype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/CenturySchoolbook.woff2) format("woff2"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/CenturySchoolbook.woff) format("woff"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/CenturySchoolbook.ttf) format("truetype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/CenturySchoolbook.svg#CenturySchoolbook) format("svg");font-weight:400;font-style:normal}@font-face{font-family:ArialLight;src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-light-webfont.eot);src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-light-webfont.eot?#iefix) format("embedded-opentype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-light-webfont.woff) format("woff"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-light-webfont.ttf) format("truetype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-mtlight-webfont.svg#arial_mtmt_light) format("svg");font-weight:400;font-style:normal}@font-face{font-family:ArialLight;src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-lightitalic-webfont.eot);src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-lightitalic-webfont.eot?#iefix) format("embedded-opentype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-lightitalic-webfont.woff) format("woff"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-lightitalic-webfont.ttf) format("truetype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-lightitalic-webfont.svg#arial_mtlight_italic) format("svg");font-weight:400;font-style:italic}@font-face{font-family:ArialLight;src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-medium-webfont.eot);src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-medium-webfont.eot?#iefix) format("embedded-opentype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-medium-webfont.woff) format("woff"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-medium-webfont.ttf) format("truetype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-medium-webfont.svg#arial_mtmedium) format("svg");font-weight:700;font-style:normal}@font-face{font-family:ArialLight;src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-mediumitalic-webfont.eot);src:url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-mediumitalic-webfont.eot?#iefix) format("embedded-opentype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-mediumitalic-webfont.woff) format("woff"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-mediumitalic-webfont.ttf) format("truetype"),url(https://beta.kent.ac.uk/pantheon/kent-theme-assets/assets/fonts/arialmt/arialmt-mediumitalic-webfont.svg#arial_mtmedium_italic) format("svg");font-weight:700;font-style:italic}


.redactor-dropdown-box-format .redactor-dropdown-blockquote,
.redactor-dropdown-box-format .redactor-dropdown-pullquote{
.redactor-dropdown .redactor-dropdown-item-blockquote,
.redactor-dropdown .redactor-dropdown-item-pullquote{
font-family: "Century Schoolbook", Georgia, "Times New Roman", Times, serif;
font-size: 19px;
font-style: italic;
color: #05345C;
}
.redactor-dropdown-box-format .redactor-dropdown-pullquote span{
.redactor-dropdown .redactor-dropdown-item-pullquote span{
padding: 5px 0;
border-color:#05345C;
border-style: solid;
border-width: 1px 0;
}

.redactor-dropdown-box-format .redactor-dropdown-p{
.redactor-dropdown .redactor-dropdown-item-p{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size: 16px;
color: #171717;
}
.redactor-dropdown-box-format .redactor-dropdown-impact{
.redactor-dropdown .redactor-dropdown-item-impact{
font-family: "Century Schoolbook", Georgia, "Times New Roman", Times, serif;
font-size: 19px;
color: #937227;
}
.redactor-dropdown-box-format .redactor-dropdown-h2{
.redactor-dropdown .redactor-dropdown-item-h2{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size: 25.632px;
color: #05345C;
}
.redactor-dropdown-box-format .redactor-dropdown-h3{
.redactor-dropdown .redactor-dropdown-item-h3{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size:20.256px;
color: #05345C;
}
.redactor-dropdown-box-format .redactor-dropdown-h4{
.redactor-dropdown .redactor-dropdown-item-h4{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size:18px;
color: #05345C;
Expand All @@ -44,39 +44,39 @@
.redactor-box{
max-width: 725px;
}
.redactor-editor{
.redactor-styles{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size: 16px;
color: #171717;
line-height: 1.5;
}
.redactor-editor h2{
.redactor-styles h2{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size: 25.632px;
color: #05345C;
}
.redactor-editor h3{
.redactor-styles h3{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size:20.256px;
color: #05345C;
}
.redactor-editor h4{
.redactor-styles h4{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size:18px;
color: #05345C;
}

.redactor-editor a{
.redactor-styles a{
color: #005689;
text-decoration: none;
border-bottom: 1px solid #CCCCCC;
}

.redactor-editor a:hover {
.redactor-styles a:hover {
border-bottom: 1px solid #00263d;
}

.redactor-editor p.impact-statement{
.redactor-styles p.impact-statement{
font-size: 28.8px;
font-family: "Century Schoolbook", Georgia, "Times New Roman", Times, serif;
text-align: center;
Expand All @@ -85,7 +85,7 @@
}


.redactor-editor blockquote.simple{
.redactor-styles blockquote.simple{
padding: 16px;
font-family: "Century Schoolbook", Georgia, "Times New Roman", Times, serif;
font-size: 20.8px;
Expand All @@ -94,38 +94,38 @@
border:0;
}

.redactor-editor blockquote.simple:before{
.redactor-styles blockquote.simple:before{
font-size: 1.3em;
content: '\201C';
line-height: 16px;
line-height: calc(1rem);
}

.redactor-editor blockquote.simple:after{
.redactor-styles blockquote.simple:after{
font-size: 1.3em;
content: '\201D';
line-height: 16px;
line-height: 1rem;
line-height: calc(1rem);
}

.redactor-editor blockquote.pull-quote{
.redactor-styles blockquote.pull-quote{
border: 1px solid #05345C;
border-width: 1px 0;
padding: 2rem;
margin: 16px 0;
}

.redactor-editor figure{
.redactor-styles figure{
clear:both;
}
.redactor-editor figure:hover .media-wrap{
.redactor-styles figure:hover .media-wrap{
overflow: hidden;
}
.redactor-editor figure:hover img{
.redactor-styles figure:hover img{
filter: blur(3px);
}
.redactor-editor figure:hover .media-wrap:after{
.redactor-styles figure:hover .media-wrap:after{
content: "Edit";
display: block;
position: absolute;
Expand All @@ -137,15 +137,15 @@
pointer-events: none;
}

.redactor-editor figure .media-wrap img{
.redactor-styles figure .media-wrap img{
max-width: 100%;
height: auto;
}

.redactor-editor figure .media-wrap{
.redactor-styles figure .media-wrap{
position:relative;
}
.redactor-editor figure .attribution {
.redactor-styles figure .attribution {
position: absolute;
bottom: 0;
right: 0;
Expand All @@ -156,30 +156,30 @@
font-size: 0;
}

.redactor-editor figure figcaption{
.redactor-styles figure figcaption{
font-family: 'ArialLight', Arial, "Helvetica Neue", Helvetica, Tahoma, sans-serif;
font-size: .9rem;
color: #636c72;
font-style: normal;
}

.redactor-editor figure.figure-center{
.redactor-styles figure.figure-center{
display: block;
text-align: center;
margin:auto;
}

.redactor-editor figure.figure-right,
.redactor-editor figure.figure-pull-right{
.redactor-styles figure.figure-right,
.redactor-styles figure.figure-pull-right{
float:right;
clear:right;
max-width: 50%;
margin-left:2rem;
margin-bottom: 2rem;
}

.redactor-editor figure.figure-left,
.redactor-editor figure.figure-pull-left
.redactor-styles figure.figure-left,
.redactor-styles figure.figure-pull-left
{
float:left;
clear:left;
Expand Down Expand Up @@ -264,7 +264,7 @@
margin-bottom: 15px;
}

.img-picker .redactor-editor{
.img-picker .redactor-styles{
min-height: 20px !important;
height: 20px !important;
padding: 4px 6px;
Expand All @@ -273,7 +273,7 @@
overflow: hidden;
border: 1px solid #ccc;
}
.img-picker .redactor-editor p{
.img-picker .redactor-styles p{
margin:0;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
Expand Down
Loading