Changeset 36
- Timestamp:
- 07/16/07 17:29:03 (18 months ago)
- Location:
- trunk/app
- Files:
-
- 13 modified
-
config/sql/karamelo.sql (modified) (2 diffs)
-
controllers/components/adds.php (modified) (1 diff)
-
controllers/entries_controller.php (modified) (4 diffs)
-
controllers/images_controller.php (modified) (8 diffs)
-
controllers/news_controller.php (modified) (1 diff)
-
models/entry.php (modified) (1 diff)
-
models/subject.php (modified) (2 diffs)
-
views/entries/admin_add.thtml (modified) (1 diff)
-
views/helpers/fck.php (modified) (3 diffs)
-
views/layouts/popup.thtml (modified) (1 diff)
-
views/news/display.thtml (modified) (2 diffs)
-
views/subjects/admin_add.thtml (modified) (1 diff)
-
views/subjects/admin_listing.thtml (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/karamelo.sql
r27 r36 833 833 INSERT INTO categories (title, user_id) VALUES ('Book Review', 1); 834 834 835 -- Sections blogs 836 CREATE TABLE themeblogs ( 837 id serial PRIMARY KEY, 838 title varchar(110) NOT NULL, 839 user_id int NOT NULL REFERENCES users(id) ON DELETE CASCADE 840 ); 841 835 842 -- entries in the users blogs 836 843 CREATE TABLE entries ( … … 838 845 title varchar(50) NOT NULL, 839 846 body text NOT NULL, 840 category_id int REFERENCES categories (id) ON DELETE CASCADE,847 subject_id int REFERENCES subjects (id) ON DELETE CASCADE, 841 848 created timestamp(0) with time zone DEFAULT now() NOT NULL, 842 849 status int NOT NULL DEFAULT 0, 843 user_id int REFERENCES users (id) ON DELETE CASCADE,850 user_id int REFERENCES users(id) ON DELETE CASCADE, 844 851 disc int NOT NULL DEFAULT 0 -- discution, Activ/Desactiv 1/0 845 852 ); -
trunk/app/controllers/components/adds.php
r1 r36 32 32 return substr($password, 0, $length); 33 33 } 34 //handle images 35 public function get_extension($imagetype) 36 { 37 38 if ( empty($imagetype) ) 39 { 40 return false; 41 } 42 43 switch($imagetype) 44 { 45 case 'image/bmp': return '.bmp'; 46 case 'image/cis-cod': return '.cod'; 47 case 'image/gif': return '.gif'; 48 case 'image/ief': return '.ief'; 49 case 'image/jpeg': return '.jpg'; 50 case 'image/pipeg': return '.jfif'; 51 case 'image/tiff': return '.tif'; 52 case 'image/x-cmu-raster': return '.ras'; 53 case 'image/x-cmx': return '.cmx'; 54 case 'image/x-icon': return '.ico'; 55 case 'image/x-portable-anymap': return '.pnm'; 56 case 'image/x-portable-bitmap': return '.pbm'; 57 case 'image/x-portable-graymap': return '.pgm'; 58 case 'image/x-portable-pixmap': return '.ppm'; 59 case 'image/x-rgb': return '.rgb'; 60 case 'image/x-xbitmap': return '.xbm'; 61 case 'image/x-xpixmap': return '.xpm'; 62 case 'image/x-xwindowdump': return '.xwd'; 63 case 'image/png': return '.png'; 64 case 'image/x-jps': return '.jps'; 65 case 'image/x-freehand': return '.fh'; 66 default: return false; 67 } 68 } 34 69 35 70 //validate email format and hosting address -
trunk/app/controllers/entries_controller.php
r34 r36 18 18 public function results($string) 19 19 { 20 $this->layout = 'portal'; 20 21 21 $conditions = array("Entry.body"=>$string);22 $conditions = array("Entry.body"=>$string); 22 23 23 $data = $this->Entry->findAll($conditions, $order); 24 25 $this->set('data', $data); 24 $this->set('data', $this->Entry->findAll($conditions, $order)); 26 25 } 27 26 28 27 public function rss($user_id) 29 28 { 30 31 29 $this->layout = 'rss'; 32 30 33 31 $conditions = array("Entry.status"=>1, "Entry.user_id"=>$user_id); 34 32 35 $fields = array("id", "title", "body", "created", " category_id", "user_id");33 $fields = array("id", "title", "body", "created", "subject_id", "user_id"); 36 34 37 35 $data = $this->Entry->findAll($conditions, $fields, "Entry.created", 10, false, 2); … … 57 55 } 58 56 57 /** ==== ADMIN SECTION ====*/ 58 59 59 public function admin_add() 60 60 { 61 61 62 62 $this->layout = 'admin'; 63 // adds new blog entries 64 if ( empty($this->data) ) 65 { 66 67 $this->set('categories', $this->Entry->Category->generateList()); 68 69 $conditions = array("Entry.user_id" => $this->othAuth->user('id')); 70 71 $fields = array("id", "title", "body", "disc", "created", "status"); 72 73 $data = $this->Entry->findAll($conditions, $fields, null, null, null, 1); 74 75 $this->set('data', $data); 76 77 //$this->render(); 78 } 63 64 if ( empty($this->data["Entry"]) ) 65 { 66 $this->set('subjects', $this->Entry->Subject->generateList(null,'title')); 67 } 79 68 else 80 {69 { 81 70 82 71 $this->Sanitize = new Sanitize; … … 92 81 $this->flash('Database error!', '/admin/entries/listing'); 93 82 } 94 }83 } 95 84 } 96 /** === ADMIN SECTION */ 97 85 98 86 public function admin_start($order = null) 99 87 { … … 107 95 108 96 $conditions = null; 109 $fields = array("id", "title", "body", " category_id");97 $fields = array("id", "title", "body", "subject_id"); 110 98 $data = $this->Entry->findAll( $conditions, $fields, $order, null, null, true ); 111 99 -
trunk/app/controllers/images_controller.php
r31 r36 1 1 <?php 2 /* *2 /* 3 3 * Karamelo E-Learning Platform 4 4 * Manuel Montoya 2002-2007 5 5 * Chipotle Software 6 * GPL v3manuel<at>mononeurona.org6 * GPL manuel<at>mononeurona.org 7 7 */ 8 8 … … 13 13 class ImagesController extends AppController 14 14 { 15 public $helpers = array('Ajax', 'Form', 'User', 'Gags'); 16 17 public $components = array('Security', 'Mypagination'); 18 19 public function admin_listing() 15 public $helpers = array('Html', 'Javascript', 'Ajax', 'Form', 'User'); 16 17 public $components = array('Security', 'Adds'); 18 19 public function index($id = null) 20 { 21 $this->pageTitle = 'View Active Users'; 22 $this->set('data', $this->User->findAll()); 23 $this->set('color', 'blue'); 24 } 25 26 public function admin_listing($set = null) 20 27 { 21 $this->layout = 'admin'; 22 28 if ($set == null) 29 { 30 $this->layout = 'admin'; 31 $limit = 30; 32 $this->set('set', null); 33 } else { 34 $this->layout = 'popup'; 35 $limit = 15; 36 $this->set('set', true); 37 } 23 38 $this->pageTitle = 'Your Images'; 24 39 … … 29 44 $order = "Image.id DESC"; 30 45 31 $data = $this->Image->findAll($conditions, $fields, $order, null, null, 1);46 $data = $this->Image->findAll($conditions, $fields, $order, $limit); 32 47 33 48 $this->set('data', $data); 34 }35 36 public function admin_listview()37 {38 $this->layout = 'popup';39 40 $this->pageTitle = 'Your Images';41 42 $conditions = array("user_id"=>$this->othAuth->user('id'));43 44 $fields = array("id", "file", "user_id");45 46 $order = "Image.id DESC";47 48 $limit = 20;49 50 $data = $this->Image->findAll($conditions, $fields, $order, null, null, 1);51 52 $this->set('data', $data);53 54 $this->set('listview', true);55 49 } 56 50 … … 89 83 90 84 $maxfilesize = 2097152; /** 2MB max size */ 85 86 $this->Sanitize = new Sanitize; 87 88 $this->Sanitize->cleanArray($this->data); 91 89 92 90 $imgfile_name = $this->data['Image']['file']['name']; … … 108 106 /** delete uploaded file */ 109 107 unlink($imgfile); 110 die($this->flash($ErrMsg,'/admin/images/listing/') ); 108 $this->flash($ErrMsg,'/admin/images/listing/'); 109 exit(); 111 110 } 112 111 113 112 if ( $imgfile_size > $maxfilesize) 114 113 { 115 $ErrMsg = "<h1>ERROR</h1> The image is too big.<br>";114 $ErrMsg = "<h1>ERROR</h1> The image is too big.<br>"; 116 115 $ErrMsg .= "<p>Bigger than 2.0 MB <br><br>"; 117 116 $ErrMsg .= "Current size: " . $imgfile_size ."</p>\n"; … … 119 118 /** delete uploaded file */ 120 119 unlink($imgfile); 121 die( $this->flash($ErrMsg,'/images/listing/') ); 122 } 123 124 $field = "id"; 125 126 $conditions = array("user_id" => $this->othAuth->user('id')); 127 128 $order = "Image.id DESC"; 129 130 $current_id = $this->Image->field($field, $conditions, $order); 120 $this->flash($ErrMsg,'/admin/images/listing/'); 121 exit(); 122 } 123 124 $current_id = $this->Image->field("id", array("Image.id"=>"> 0"), "Image.id DESC"); 131 125 132 126 $next_id = ($current_id + 1); 133 127 134 $extension = $this-> get_extension($type);128 $extension = $this->Adds->get_extension($type); 135 129 136 130 $Name = $this->othAuth->user('username') . "_" . $next_id . $extension; … … 140 134 $final_filename = str_replace(" ", "_", $Name); 141 135 142 $newfile = $uploaddir . "/" . $final_filename;136 $newfile = $uploaddir . "/" . $final_filename; 143 137 144 138 /** do extra security check to prevent malicious abuse */ … … 155 149 } 156 150 151 /*** Create thumb***/ 152 if ( $type != 'avatar') 153 { 154 $this->createThumb($final_filename); 155 } 157 156 /** Database stuff **/ 158 157 159 $this->data['Image']['file'] = $final_filename; 158 $this->data['Image']['file'] = $final_filename; 159 $this->data['Image']['user_id'] = $this->othAuth->user('id'); 160 160 161 161 if ($this->Image->save($this->data)) 162 { 163 $this->redirect($this->data['Image']['return']); 164 } 165 162 { 163 $this->redirect($this->data['Image']['return']); 164 exit(); 165 } 166 166 167 /** delete the temporary uploaded file **/ 167 168 unlink($imgfile); 168 169 169 } 170 170 } 171 171 172 protected function get_extension($imagetype) { 173 174 if ( empty($imagetype) ) 175 { 176 return false; 177 } 178 179 switch($imagetype) 180 { 181 case 'image/bmp': return '.bmp'; 182 case 'image/cis-cod': return '.cod'; 183 case 'image/gif': return '.gif'; 184 case 'image/ief': return '.ief'; 185 case 'image/jpeg': return '.jpg'; 186 case 'image/pipeg': return '.jfif'; 187 case 'image/tiff': return '.tif'; 188 case 'image/x-cmu-raster': return '.ras'; 189 case 'image/x-cmx': return '.cmx'; 190 case 'image/x-icon': return '.ico'; 191 case 'image/x-portable-anymap': return '.pnm'; 192 case 'image/x-portable-bitmap': return '.pbm'; 193 case 'image/x-portable-graymap': return '.pgm'; 194 case 'image/x-portable-pixmap': return '.ppm'; 195 case 'image/x-rgb': return '.rgb'; 196 case 'image/x-xbitmap': return '.xbm'; 197 case 'image/x-xpixmap': return '.xpm'; 198 case 'image/x-xwindowdump': return '.xwd'; 199 case 'image/png': return '.png'; 200 case 'image/x-jps': return '.jps'; 201 case 'image/x-freehand': return '.fh'; 202 default: return false; 203 } 172 /*** DELETE **/ 173 public function admin_delete($id) 174 { 175 $file = $this->Image->field("Image.file", array("Image.id"=>$id)); 176 177 $this->Image->del($id); 178 179 /** delete image and thumb **/ 180 unlink("../webroot/img/imgusers/" . $file); 181 unlink("../webroot/img/imgusers/thumbs/" . $file); 182 $this->redirect($this->data['Image']['return']); 204 183 } 205 184 206 /*** DELETE **/ 207 public function admin_delete($id, $imgfile) 185 protected function createThumb($file) 208 186 { 209 $this->Image->del($id); 210 211 /** delete the uploaded file **/ 212 $uploaddir = "../webroot/img/imgusers/"; 213 unlink($uploaddir . $imgfile); 214 $this->flash('The image has been deleted.', '/admin/images/listing'); 187 188 $imgfile = "../webroot/img/imgusers/" . $file; // system path 189 190 //exit($imgfile); 191 $thumb_img = "../webroot/img/imgusers/thumbs/" . $file; // system path 192 193 $new_w = 100; //new width 194 195 /** only resize if the image is larger than 250 x 200 */ 196 197 $image_stats = getimagesize($imgfile); // return array 198 199 $imagewidth = $image_stats[0]; 200 201 $imageheight = $image_stats[1]; 202 203 $img_type = $image_stats[2]; // 1 = GIF, 2 = JPG, 3 = PNG 204 205 $ratio = ($imagewidth / $new_w); 206 207 $new_h = round($imageheight / $ratio); 208 209 /*** Save bandwidth! generate thumbs **/ 210 if (!file_exists($thumb_img)) // thumb already exist?? 211 { 212 switch ($img_type) 213 { 214 case 1; 215 216 $src_img = imagecreatefromgif($imgfile); 217 218 $dst_img = imagecreatetruecolor($new_w, $new_h); 219 220 imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h, $imagewidth, $imageheight); 221 222 imagegif($dst_img, $thumb_img, "100"); 223 break; 224 225 case 2; 226 227 $src_img = imagecreatefromjpeg($imgfile); 228 229 $dst_img = imagecreatetruecolor($new_w, $new_h); 230 231 imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h, $imagewidth, $imageheight); 232 233 imagejpeg($dst_img, $thumb_img, "100"); 234 break; 235 236 case 3; 237 $dst_img = imagecreatetruecolor($new_w, $new_h); 238 239 $src_img = ImageCreateFrompng($imgfile); 240 241 imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h, $imagewidth, $imageheight); 242 243 imagepng($dst_img, $thumb_img); 244 break; 245 } 246 } 215 247 } 216 217 248 } 218 249 ?> -
trunk/app/controllers/news_controller.php
r35 r36 244 244 245 245 public function category($id = null, $order=null) 246 { 246 { 247 $this->layout = 'portal'; 248 247 249 if ($id != null) 248 250 { -
trunk/app/models/entry.php
r1 r36 5 5 { 6 6 // Its always good practice to include this variable. 7 public $name = 'Entry'; 8 public $belongsTo = 'User, Category'; 7 8 public $belongsTo = 'User, Subject'; 9 9 10 public $hasMany = 'Comment'; 10 11 11 12 12 public $validate = array( -
trunk/app/models/subject.php
r15 r36 9 9 class Subject extends AppModel 10 10 { 11 // Its always good practice to include this variable.12 public $name = 'Subject';13 11 14 12 public $hasMany = array('Vclassroom' => … … 32 30 'finderQuery' => '' 33 31 ), 34 ' News' =>35 array('className' => ' News',32 'Entry' => 33 array('className' => 'Entry', 36 34 'conditions' => null, 37 35 'order' => null, -
trunk/app/views/entries/admin_add.thtml
r14 r36 2 2 <?php echo $javascript->link('fckeditor/fckeditor'); ?> 3 3 4 <div class="spaced"> 5 6 <?php echo $html->addCrumb('Control Tools', '/entries/index'); ?> 7 <?php echo $html->addCrumb('Entries', '/entries/listing'); ?> 4 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?> 5 <?php echo $html->addCrumb('Entries', '/admin/entries/listing'); ?> 8 6 <?php echo $html->getCrumbs(' / '); ?> 9 10 <?php echo $html->formTag('/entries/add/','post', array("onsubmit"=>"return validateEntry()")); ?> 11 7 <?php echo $html->formTag('/admin/entries/add/','post', array("onsubmit"=>"return validateEntry()")); ?> 12 8 <?php echo $html->hiddenTag('Entry/user_id', $othAuth->user('id')) ?> 13 9 <fieldset> 14 10 <legend>New Entry</legend> 15 <?php echo $form->labelTag( 'Entry/title', 'Title' );?><br /> 16 <?php echo $html->input('Entry/title', array("size" => 40, "maxlength" => 50)); ?> 11 12 <table style="margin:0 auto 0 auto;"> 13 <tr><td> 14 15 <?php echo $form->labelTag( 'Entry/title', 'Title:' );?><br /> 16 <?php echo $html->input('Entry/title', array("size" => 50, "maxlength" => 50)); ?> 17 17 <?php echo $html->tagErrorMsg('Entry/title', 'Title is required.'); ?> 18 < br /><br />18 </td> 19 19 20 <p><?php echo $form->labelTag( 'Entry/category_id', 'Category' );?> 21 <br /> 22 <?php 23 /*$html->selectTag( 24 $fieldName, 25 $optionElements, 26 $selected = null, 27 $selectAttr = array(), 28 $optionAttr = null, 29 $showEmpty = true, 30 $return = false 31 selectTag ($fieldName, $optionElements, $selected=null, $selectAttr=array(), $optionAttr=null, $showEmpty=true, $return=false) 32 */ 33 echo $html->selectTag('Entry/category_id', $categories, null, $html->tagValue('Entry/category_id'), array("class"=>"formas"), false, false); 20 <td> 21 <?php echo $form->labelTag( 'Entry/subject_id', 'Subject:' );?><br /> 22 <?php 23 echo $html->selectTag('Entry/subject_id', $subjects, null, $html->tagValue('Entry/subject_id'), null, false, false); 34 24 35 echo $html->link($html->image('static/add.png', array("alt"=>"Add category", "title"=>"Add category")), '#', array("onclick"=>"javascript:window.open('/categories/listing', 'blank', 'toolbar=no, scrollbars=yes,width=350,height=500')"), null, false);25 /* echo $html->link($html->image('static/add.png', array("alt"=>"Add category", "title"=>"Add category")), '#', array("onclick"=>"javascript:window.open('/admin/categories/listing', 'blank', 'toolbar=no, scrollbars=yes,width=350,height=500')"), null, false);*/ 36 26 ?> 37 </ p>27 </td> 38 28 39 <p style="text-align:right;"> 40 <?php echo $html->link($html->image('admin/myimages.jpg', array("alt"=>"My Images", "title"=>"My Images")), '#', array("onclick"=>"javascript:window.open('/images/listview', 'blank', 'toolbar=no, scrollbars=yes,width=700,height=500')"), null, false) ?></p> 41 <p> 29 <td> 30 <?php echo $html->link($html->image('admin/myimages.jpg', array("alt"=>"My Images", "title"=>"My Images")), '#', array("onclick"=>"javascript:window.open('/admin/images/listing/set', 'blank', 'toolbar=no, scrollbars=yes,width=700,height=500')"), null, false) ?></p> 31 </td> 32 </tr> 33 <tr><td colspan="3"> 42 34 <?php echo $form->labelTag( 'Entry/Body', 'Body:' );?><br /> 43 <?php echo $html->textarea('Entry/body', array("class"=>"formas", "cols"=>80, "rows"=> 45)) ?>35 <?php echo $html->textarea('Entry/body', array("class"=>"formas", "cols"=>80, "rows"=>55)) ?> 44 36 <?php echo $fck->load('Entry/body', 'Karamelo'); ?> 45 37 <?php echo $html->tagErrorMsg('Entry/body', 'Body is required.'); ?> 46 <br /> 47 </p> 38 </td></tr> 48 39 49 <p><?php echo $form->labelTag( 'Entry/status', 'Published:' );?><br /> 50 <?php echo $html->checkbox('Entry/status'); ?> 51 <br /></p> 40 <tr> 41 <td> 42 <?php echo $form->labelTag( 'Entry/status', 'Published:' );?> 43 <?php echo $html->checkbox('Entry/status', null, array("value"=>1)); ?> 44 </td><td colspan="2"> 45 <?php echo $form->labelTag( 'Entry/disc', 'Comments allowed:' );?> 46 <?php echo $html->checkbox('Entry/disc', null, array("value"=>1)); ?> 47 </td></tr> 52 48 53 <p><?php echo $form->labelTag( 'Entry/disc', 'Comments allowed:' );?><br /> 54 <?php echo $html->checkbox('Entry/disc'); ?> 55 <br /></p> 56 57 <br /> 49 <tr><td colspan="3"> 58 50 <?php echo $html->submit('Add'); ?> 51 </td></tr> 52 </table> 53 59 54 </fieldset> 60 55 </form> 61 </div> -
trunk/app/views/helpers/fck.php
r1 r36 2 2 class FckHelper extends Helper 3 3 { 4 public function load($id, $toolbar = 'Karamelo', $width = 700 ) {4 public function load($id, $toolbar = 'Karamelo', $width = 700, $height = 450) { 5 5 6 6 $did = ''; … … 17 17 bFCKeditor_$did.ToolbarSet = '$toolbar'; 18 18 bFCKeditor_$did.Width = $width; 19 bFCKeditor_$did.Height = 350;19 bFCKeditor_$did.Height = $height; 20 20 bFCKeditor_$did.Skin = 'silver'; 21 21 bFCKeditor_$did.ReplaceTextarea(); … … 26 26 } 27 27 } 28 ?> 28 ?> -
trunk/app/views/layouts/popup.thtml
r1 r36 5 5 <head> 6 6 <title>Karamelo: Control Panel</title> 7 <? 7 <?php 8 8 if (isset($javascript)): 9 9 echo $html->charsetTag('utf-8'); -
trunk/app/views/news/display.thtml
r35 r36 1 <div id="cintillo">Noticias</div>
