Skip to content

Commit

Permalink
batch of fixes: (missing files) Supplier delete fixed, gallery delete…
Browse files Browse the repository at this point in the history
… fixed, general delete message improvements, gallery titl names maxed to 255 from 20 and plenty more.
  • Loading branch information
root committed May 17, 2009
1 parent d0e147e commit d2c09c1
Show file tree
Hide file tree
Showing 23 changed files with 311 additions and 222 deletions.
7 changes: 6 additions & 1 deletion UPGRADE
Expand Up @@ -4,11 +4,16 @@ UPGRADE
Remember to always run these steps in order. They are ordered intentionally to either
minimise or totally remove downtime during upgrade.

14/05/09 - v0.9.2 to edge
17/05/09 - v0.9.2 to edge
---------------------------

1. Run the following MySQL.

ALTER TABLE galleries

MODIFY `slug` varchar(255) collate utf8_unicode_ci NOT NULL default '',
MODIFY `title` varchar(255) collate utf8_unicode_ci NOT NULL default '';

ALTER TABLE pages

MODIFY `slug` varchar(60) collate utf8_unicode_ci NOT NULL default '',
Expand Down
38 changes: 19 additions & 19 deletions application/assets/css/boxes.css
@@ -1,18 +1,18 @@
/* STANDARD DIV STYLING
Most boxes inherit properties from the generic box style.
---------------------------------------------------------------------- */

/* generic box with no colour or dimensions set */

.box {
position: relative;
height: 1%;
padding: 0 0.79em;
margin: 0 0 0.79em 0;
text-align:left;
}
.box h3, .box h4, .box h5, .box h6 {
font-size: 1.3em;
/* STANDARD DIV STYLING
Most boxes inherit properties from the generic box style.
---------------------------------------------------------------------- */

/* generic box with no colour or dimensions set */

.box {
position: relative;
height: 1%;
padding: 0 0.79em;
margin: 0 0 0.79em 0;
text-align:left;
}
.box h3, .box h4, .box h5, .box h6 {
font-size: 1.3em;
}

.width-full { width:100% !important; }
Expand All @@ -22,10 +22,10 @@
.width-third { width:33% !important; }
.width-quater { width:25% !important; }

.width-5 { width:5em !important; }
.width-7 { width:7em !important; }
.width-10 { width:10em !important; }
.width-15 { width:10em !important; }
.width-5 { width:5em !important; }
.width-7 { width:7em !important; }
.width-10 { width:10em !important; }
.width-15 { width:15em !important; }
.width-20 { width:20em !important; }
.width-22 { width:22em !important; }
.width-25 { width:25em !important; }
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion application/modules/categories/views/admin/form.php
Expand Up @@ -7,6 +7,12 @@

<?= form_open($this->uri->uri_string()); ?>

<div class="field"> <label for="title">Title</label> <?= form_input('title', $category->title, 'class="text"'); ?></div><? $this->load->view('admin/layout_fragments/table_buttons', array('buttons' => array('save', 'cancel') )); ?>
<div class="field">
<label for="title">Title</label>
<?= form_input('title', $category->title, 'class="text"'); ?>
<span class="required-icon tooltip">Required</span>
</div>

<? $this->load->view('admin/layout_fragments/table_buttons', array('buttons' => array('save', 'cancel') )); ?>

<?= form_close(); ?>
182 changes: 117 additions & 65 deletions application/modules/galleries/controllers/admin.php
Expand Up @@ -39,7 +39,7 @@ function create() {
$this->data->galleries = $tree;

$this->load->library('validation');
$rules['title'] = 'trim|required|callback__createCheckTitle';
$rules['title'] = 'trim|required|max_length[255]|callback__createCheckTitle';
$rules['description'] = 'trim|required';
$rules['parent'] = 'trim|numeric';
$this->validation->set_rules($rules);
Expand Down Expand Up @@ -88,11 +88,11 @@ function create() {
}

// Admin: Edit a Gallery
function edit($slug = '') {

$this->data->gallery = $this->galleries_m->getGallery($slug);
function edit($slug = '')
{
$gallery = $this->galleries_m->getGallery($slug);

if (empty($slug) or !$this->data->gallery)
if (empty($slug) or !$gallery)
{
redirect('admin/galleries/index');
}
Expand All @@ -106,18 +106,21 @@ function edit($slug = '') {

$this->load->library('validation');
$rules['id'] = '';
$rules['title'] = 'trim|required';
$rules['title'] = 'trim|required|max_length[255]';
$rules['description'] = 'trim|required';
$rules['parent'] = 'trim|numeric';
$this->validation->set_rules($rules);
$this->validation->set_fields();

foreach(array_keys($rules) as $field) {
foreach(array_keys($rules) as $field)
{
if(isset($_POST[$field]))
$this->data->gallery->$field = $this->validation->$field;
{
$gallery->$field = $this->validation->$field;
}
}

$spaw_cfg = array('name'=>'description', 'content'=>$this->data->gallery->description);
$spaw_cfg = array('name'=>'description', 'content' => $gallery->description);
$this->load->library('spaw', $spaw_cfg);
// setting directories for a SPAW editor instance:
$this->spaw->setConfigItem(
Expand All @@ -142,62 +145,61 @@ function edit($slug = '') {
SPAW_CFG_TRANSFER_SECURE
);

if ($this->validation->run()) {
if ($this->galleries_m->updateGallery($_POST, $slug)) {
$this->session->set_flashdata(array('success'=>'Your gallery was saved.'));
if ($this->validation->run())
{
if ($this->galleries_m->updateGallery($_POST, $slug))
{
$this->session->set_flashdata('success', 'The gallery "' . $gallery->title . '" was saved.');
} else {
$this->session->set_flashdata(array('error'=>'An error occurred.'));
$this->session->set_flashdata('error', 'An error occurred.');
}
redirect('admin/galleries');
}

$this->data->gallery =& $gallery;
$this->layout->create('admin/form', $this->data);

}

// Admin: Delete a Gallery
function delete($slug = '') {
// Delete one
if($slug)
function delete($slug = '')
{
// An ID was passed in the URL, lets delete that
$slugs_array = ($slug > 0) ? array($slug) : $this->input->post('action_to');

if(empty($slugs_array))
{
$this->session->set_flashdata('error', 'You need to select one or more galleries to delete.');
redirect('admin/galleries/index');
}

$deleted = 0;
foreach ($slugs_array as $slug)
{
if($this->_delete_directory(APPPATH.'assets/img/galleries/'.$slug))
{
if($this->galleries_m->deleteGallery($slug))
{
$this->session->set_flashdata('success', 'Gallery '.$slug.' successfully deleted.');
} else {
$deleted++;
}

else
{
$this->session->set_flashdata('error', 'Error occurred while trying to delete gallery '.$slug);
}
} else {
$this->session->set_flashdata('error', 'Unable to delete dir '.$slug);
}
} else {
// Delete multiple
if(isset($_POST['delete']))

else
{
$deleted = 0;
$to_delete = 0;
foreach ($this->input->post('delete') as $slug => $value)
{
if($this->_delete_directory(APPPATH.'assets/img/galleries/'.$slug))
{
if($this->galleries_m->deleteGallery($slug))
{
$deleted++;
} else {
$this->session->set_flashdata('error', 'Error occurred while trying to delete gallery '.$slug);
}
} else {
$this->session->set_flashdata('error', 'Unable to delete dir '.$slug);
}
$to_delete++;
}
if( $deleted > 0 ) $this->session->set_flashdata('success', $deleted.' galleries out of '.$to_delete.' successfully deleted.');
} else {
$this->session->set_flashdata('error', 'You need to select galleries first.');
$this->session->set_flashdata('error', 'Unable to delete dir '.$slug);
}
}


if( $deleted > 0 )
{
$this->session->set_flashdata('success', $deleted.' galleries out of '.count($slugs_array).' successfully deleted.');
}

redirect('admin/galleries/index');
}

Expand Down Expand Up @@ -227,23 +229,22 @@ function _delete_directory($dirname)

return true;
}

// Admin: Delete Gallery Photos
function deletephoto() {
if (!$this->input->post('btnDelete')) redirect('admin/galleries/index');
foreach ($this->input->post('delete') as $photos => $value) {
$this->galleries_m->deleteGalleryPhoto($photos);
}
redirect('admin/galleries/index');
return;
}

// Admin: Upload a photo
function upload($slug = '') {
function manage($slug = '') {

if (empty($slug)) exit('admin/galleries/index');
if (empty($slug)) redirect('admin/galleries/index');

$this->load->library('validation');
$this->data->gallery = $this->galleries_m->getGallery($slug);
$this->data->photos = $this->galleries_m->getPhotos($slug);

$this->layout->create('admin/manage', $this->data);
}


function upload($slug = '')
{
$this->load->library('validation');
$rules['userfile'] = 'trim';
$rules['description'] = 'trim|required';
$this->validation->set_rules($rules);
Expand All @@ -255,22 +256,73 @@ function upload($slug = '') {
$upload_cfg['overwrite'] = TRUE;
$this->load->library('upload', $upload_cfg);

if (($this->validation->run()) && ($this->upload->do_upload())) {
if (($this->validation->run()) && ($this->upload->do_upload()))
{
$image = $this->upload->data();
$this->galleries_m->addPhoto($image, $slug, $this->input->post('description'));

if( $this->galleries_m->addPhoto($image, $slug, $this->input->post('description')) )
{
$this->session->set_flashdata('success', 'Image "'.$image['file_name'].'" uploaded successfully.');
}

else
{
$this->session->set_flashdata('error', 'An error occurred uploading the image "'.$image['file_name'].'".');
}
}

$this->data->photos = $this->galleries_m->getPhotos($slug);

$this->layout->create('admin/upload', $this->data);
redirect('admin/galleries/manage/'.$slug);

}

// Admin: Delete Gallery Photos
function delete_photo($id = 0)
{
$gallery = $this->input->post('gallery');

$ids_array = ( $id > 0 ) ? array($id) : $this->input->post('action_to');

if(empty($ids_array))
{
$this->session->set_flashdata('error', 'You need to select one or more photos to delete.');
}

else
{
$deleted = 0;
foreach ($ids_array as $photo_id)
{
if($this->galleries_m->deleteGalleryPhoto($photo_id))
{
$deleted++;
}
}

if($deleted > 0)
{
$this->session->set_flashdata('success', 'Deleted '.$deleted.' image(s) successfully.');
}

else
{
$this->session->set_flashdata('notice', 'No images were deleted.');
}
}

redirect('admin/galleries/manage/'.$gallery);
}

// Callback: from create()
function _createTitleCheck($title = '') {
if ($this->galleries_m->checkTitle($title)) {
function _createTitleCheck($title = '')
{
if ($this->galleries_m->checkTitle($title))
{
$this->validation->set_message('_createTitleCheck', 'A gallery with this name already exists.');
return FALSE;
} else {
}

else
{
return TRUE;
}
}
Expand Down
1 change: 1 addition & 0 deletions application/modules/galleries/models/galleries_m.php
Expand Up @@ -23,6 +23,7 @@ function addPhoto($image = array(), $gallery_slug = '', $description) {
'gallery_slug'=>$gallery_slug,
'description'=>$description,
'updated_on'=>now()));
return $this->db->insert_id();
}

function checkTitle($title = '') {
Expand Down
3 changes: 2 additions & 1 deletion application/modules/galleries/views/admin/form.php
Expand Up @@ -9,7 +9,8 @@

<div class="field">
<label for="title">Title</label>
<input type="text" id="title" name="title" maxlength="100" value="<?= $gallery->title; ?>" class="text" />
<input type="text" id="title" name="title" maxlength="255" value="<?= $gallery->title; ?>" class="text" />
<span class="required-icon tooltip">Required</span>
</div>

<div class="field width-two-thirds">
Expand Down
2 changes: 1 addition & 1 deletion application/modules/galleries/views/admin/index.php
Expand Up @@ -30,8 +30,8 @@
<td><?=$gallery->num_photos;?></td>
<td><?=date('M d, Y', $gallery->updated_on);?></td>
<td><?= anchor('galleries/' . $gallery->slug, 'View', 'target="_blank"') . ' | ' .
anchor('admin/galleries/manage/' . $gallery->slug, 'Manage') . ' | ' .
anchor('admin/galleries/edit/' . $gallery->slug, 'Edit') . ' | ' .
anchor('admin/galleries/upload/' . $gallery->slug, 'Upload') . ' | ' .
anchor('admin/galleries/delete/' . $gallery->slug, 'Delete', array('class'=>'confirm')); ?>
</td>
</tr>
Expand Down

0 comments on commit d2c09c1

Please sign in to comment.