Changeset 45
- Timestamp:
- 07/17/07 17:24:45 (18 months ago)
- Location:
- trunk/app
- Files:
-
- 2 added
- 14 modified
-
controllers/entries_controller.php (modified) (5 diffs)
-
controllers/subjects_controller.php (modified) (1 diff)
-
controllers/users_controller.php (modified) (2 diffs)
-
views/elements/subjects.thtml (modified) (1 diff)
-
views/entries/admin_add.thtml (modified) (2 diffs)
-
views/entries/admin_edit.thtml (modified) (1 diff)
-
views/entries/admin_listing.thtml (modified) (2 diffs)
-
views/helpers/gags.php (modified) (4 diffs)
-
views/layouts/admin.thtml (modified) (1 diff)
-
views/layouts/default.thtml (modified) (1 diff)
-
views/layouts/portal.thtml (modified) (2 diffs)
-
views/news/admin_add.thtml (modified) (1 diff)
-
views/news/admin_edit.thtml (modified) (1 diff)
-
views/subjects/qs.thtml (added)
-
webroot/css/ControlPanel.css (modified) (1 diff)
-
webroot/img/static/subjects.png (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/entries_controller.php
r43 r45 12 12 class EntriesController extends AppController { 13 13 14 public $helpers = array('Ajax', 'Form', 'Fck' );14 public $helpers = array('Ajax', 'Form', 'Fck', 'Gags'); 15 15 16 public $components = array('Edublog', 'Portal', 'Search' );16 public $components = array('Edublog', 'Portal', 'Search', 'Mypagination'); 17 17 18 18 public function results($string) … … 70 70 $this->Sanitize->paranoid($this->data["Entry"]["title"]); //Hopefully this is enough 71 71 72 if ($this->Entry->save($this->data["Entry"])) 73 { 74 $this->msgFlash('Story has been added', '/admin/entries/listing'); 75 } 76 else 77 { 72 if ($this->Entry->save($this->data["Entry"])) 73 { 74 if ( $this->data["Entry"]["end"] == 1 ) // edition ends 75 { 76 $this->msgFlash('Story has been added', '/admin/entries/listing'); 77 } 78 else //edition continue 79 { $id = $this->Entry->getLastInsertID(); 80 $this->msgFlash('Story has been added', '/admin/entries/edit/'.$id); 81 } 82 } 83 else 84 { 78 85 $this->flash('Database error!', '/admin/entries/listing'); 79 }80 86 } 81 } 87 } 88 } 82 89 83 90 public function admin_start($order = null) … … 98 105 } 99 106 100 public function admin_listing($order = null) 101 { 107 public function admin_listing($page=1, $order = null) 108 { 109 $order = ($order == null) ? 'Entry.id DESC': 'Entry.'.$order; 102 110 103 111 $this->layout = 'admin'; 104 112 113 //pagination 114 $total_rows = $this->Entry->findCount(array("Entry.user_id"=>$this->othAuth->user('id'))); 115 116 $lmt = 25; // limit news 117 118 $targetpage = "/admin/entries/listing/"; 119 120 $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 121 122 $this->set('pagination', $pagination); 123 105 124 $conditions = array("Entry.user_id"=>$this->othAuth->user('id')); 106 125 107 $data = $this->Entry->findAll($conditions, $order); 126 $fields = null; 127 128 $offset = (($page * $lmt) - $lmt); 129 130 $limit = $lmt . " OFFSET " . $offset; 131 132 $data = $this->Entry->findAll($conditions, $fields, $order, $limit); 108 133 109 134 $this->set('data', $data); 110 111 135 } 112 136 … … 117 141 $this->set('subjects', $this->Entry->Subject->generateList()); 118 142 119 if (empty($this->data ))143 if (empty($this->data["Entry"])) 120 144 { 121 145 $this->Post->id = $id; … … 126 150 if ($this->Entry->save($this->data['Entry'])) 127 151 { 128 $this->msgFlash('The story has been updated.', '/admin/entries/listing'); 152 if ( $this->data["Entry"]["end"] == 1 ) 153 { 154 $this->redirect('/admin/entries/listing'); 155 } 156 else 157 { 158 $this->msgFlash('Entry has been updated','/admin/entries/edit/'.$this->data['Entry']['id']); 159 } 129 160 } 130 161 } -
trunk/app/controllers/subjects_controller.php
r22 r45 13 13 14 14 public $components = array('Portal'); 15 16 public function display() 17 { 18 $this->layout = 'ajax'; 19 20 $conditions = null; 21 22 $fields = array("Subject.id", "Subject.title", "Subject.code"); 23 24 $order = "Subject.title"; 25 26 $limit = null; 27 28 $this->set('data', $this->Subject->findAll($conditions, $fields, $order, $limit)); 29 30 $this->render('qs', 'ajax'); 31 32 } 15 33 16 34 public function admin_listing() -
trunk/app/controllers/users_controller.php
r44 r45 20 20 class UsersController extends AppController 21 21 { 22 public $helpers = array('Ajax', 'Form', 'User', 'Fck' );22 public $helpers = array('Ajax', 'Form', 'User', 'Fck', 'Gags'); 23 23 24 24 public $components = array('Security', 'Edublog', 'Portal', 'Email', 'Adds', 'Mypagination'); … … 466 466 467 467 /** === ADMIN SECTION ==***/ 468 468 // change user status actived/no actived 469 public function admin_change($id, $status) 470 { 471 $this->data['User']['active'] = ($status == 0 ) ? 1 : 0; 472 473 $this->data['User']['id'] = $id; 474 475 if ($this->User->save($this->data)) 476 { 477 $this->msgFlash('User status changed', '/admin/users/listing/'); 478 } 479 else 480 { 481 $this->flash('Problem!!', '/admi/users/listing/'); 482 } 483 } 484 469 485 /*** DELETE **/ 470 486 public function delete($id) -
trunk/app/views/elements/subjects.thtml
r1 r45 1 <div id="categories">Subjects</div>2 3 <div id="list_categories">4 5 1 <?php 6 //var_dump($subjects); 7 8 foreach ($subjects as $key => $val) { 9 //echo "key es " . $key . " y val es " . $val["Subject"] . "<br />"; 10 echo ' <a href="/subjects/show/'.$val["Subject"]["id"].'"> '. $val["Subject"]["title"] . '</a> <b>|</b> '; 11 } 2 echo '<div style="text-align:center;margin:15px auto 15px auto;">'; 3 echo $ajax->link($html->image("static/subjects.png", array("alt"=>"Subjects", "title"=>"Subjects", "style"=>"border:1px solid #fff")), '/subjects/display', array("update" => "qn", 4 "loading"=>"Element.show('loading3');", "complete"=>"Element.hide('loading3');Effect.Appear('updater')"), 5 null, false); 6 echo "</div>"; 7 8 echo '<div id="loading3" style="display: none;">'; 9 echo $html->image("static/loading.gif", array("alt"=>"Loading")); 10 echo '</div>'; 11 12 echo $ajax->div('qn', array("style"=>"padding:3px")); 13 echo $ajax->divEnd('qn'); 12 14 ?> 13 14 </div>15 -
trunk/app/views/entries/admin_add.thtml
r36 r45 5 5 <?php echo $html->addCrumb('Entries', '/admin/entries/listing'); ?> 6 6 <?php echo $html->getCrumbs(' / '); ?> 7 <?php echo $html->formTag('/admin/entries/add/','post' , array("onsubmit"=>"return validateEntry()")); ?>7 <?php echo $html->formTag('/admin/entries/add/','post'); ?> 8 8 <?php echo $html->hiddenTag('Entry/user_id', $othAuth->user('id')) ?> 9 9 <fieldset> … … 42 42 <?php echo $form->labelTag( 'Entry/status', 'Published:' );?> 43 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> 44 </td><td> 45 <?php echo $form->labelTag( 'Entry/discution', 'Comments allowed:' );?> 46 <?php echo $html->checkbox('Entry/discution', null, array("value"=>1)); ?> 47 </td> 48 <td> 49 <?php echo $form->labelTag( 'Entry/end', 'Finish edition:' );?><br /> 50 <?php echo $html->checkbox('Entry/end', null, array("value" => 1)); ?> 51 </td> 52 </tr> 48 53 49 54 <tr><td colspan="3"> -
trunk/app/views/entries/admin_edit.thtml
r14 r45 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 7 8 <fieldset> 9 <legend>Edit Entry</legend> 10 10 11 <?php echo $html->formTag('/entries/edit/','post'); ?> 11 <table style="margin:0 auto 0 auto;"> 12 <tr><td> 13 <?php echo $html->formTag('/admin/entries/edit/','post'); ?> 12 14 <?php echo $html->hiddenTag('Entry/user_id', $othAuth->user('id')) ?> 13 15 <?php echo $html->hiddenTag('Entry/id') ?> 14 16 15 <fieldset>16 17 <?php echo $form->labelTag( 'Entry/title', 'Title' );?><br /> 17 18 <?php echo $html->input('Entry/title', array("size" => 40, "maxlength" => 50, "class"=>"formas")); ?> 18 19 <?php echo $html->tagErrorMsg('Entry/title', 'Title is required.'); ?> 19 <br /><br /> 20 21 <p><?php echo $form->labelTag( 'Entry/category_id', 'Category' );?> 22 <br /> 23 <?php 24 /*$html->selectTag( 25 $fieldName, 26 $optionElements, 27 $selected = null, 28 $selectAttr = array(), 29 $optionAttr = null, 30 $showEmpty = true, 31 $return = false 32 selectTag ($fieldName, $optionElements, $selected=null, $selectAttr=array(), $optionAttr=null, $showEmpty=true, $return=false) 33 */ 34 echo $html->selectTag('Entry/category_id', $categories); ?> 35 </p> 36 37 <p><?php echo $form->labelTag( 'Entry/Body', 'Body:' );?><br /> 38 <?php echo $html->textarea('Entry/body', array("class"=>"formas", "cols"=>80, "rows"=>45)) ?> 39 <?php echo $fck->load('Entry/body', 'Karamelo'); ?> 40 <?php echo $html->tagErrorMsg('Entry/body', 'Body is required.'); ?> 41 <br /> 42 </p> 43 44 <p><?php echo $form->labelTag( 'Entry/status', 'Published:' );?><br /> 45 <?php echo $html->checkbox('Entry/status'); ?> 46 <br /></p> 47 48 <p><?php echo $form->labelTag( 'Entry/disc', 'Comments allowed:' );?><br /> 49 <?php echo $html->checkbox('Entry/disc'); ?> 50 <br /></p> 51 52 <br /> 53 <?php echo $html->submit('Add', array("class"=>"b_formas")) ?> 20 </td> 21 <td> 22 <?php echo $form->labelTag('Entry/subject_id', 'Subject:' );?> 23 <?php echo $html->selectTag('Entry/subject_id', $subjects); ?> 24 </td> 25 <td> 26 <?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> 27 </td> 28 </tr> 29 <tr> 30 <td colspan="3"> 31 <?php echo $form->labelTag( 'Entry/Body', 'Body:' );?><br /> 32 <?php echo $html->textarea('Entry/body', array("class"=>"formas", "cols"=>80, "rows"=>45)) ?> 33 <?php echo $fck->load('Entry/body', 'Karamelo'); ?> 34 <?php echo $html->tagErrorMsg('Entry/body', 'Body is required.'); ?> 35 </td></tr> 36 <tr> 37 <td> 38 <?php echo $form->labelTag( 'Entry/status', 'Published:' );?><br /> 39 <?php echo $html->checkbox('Entry/status', null, array("value" => 1)); ?> 40 </td> 41 <td> 42 <?php echo $form->labelTag( 'Entry/discution', 'Comments allowed:' );?><br /> 43 <?php echo $html->checkbox('Entry/discution', null, array("value" => 1)); ?> 44 </td> 45 <td> 46 <?php echo $form->labelTag( 'Entry/end', 'Finish edition:' );?><br /> 47 <?php echo $html->checkbox('Entry/end', null, array("value" => 1)); ?> 48 </td> 49 </tr> 50 <tr> 51 <td colspan="3"> 52 <?php echo $html->submit('Save') ?> 53 </form> 54 </td> 55 </tr> 56 </table> 57 54 58 </fieldset> 55 </form>56 </div> -
trunk/app/views/entries/admin_listing.thtml
r20 r45 1 <script type="text/javascript"> 2 window.onload = timedMsg; 3 </script> 4 <?php $session->flash(); ?> 1 5 2 <?php echo $html->addCrumb('Control Tools', '/admin/ /entries/start'); ?>6 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?> 3 7 4 8 <?php echo $html->getCrumbs(' / '); ?> … … 8 12 <p><?php echo $html->link($html->image('actions/new.png', array("alt"=>"Add entry", "title"=>"Add entry")), '/admin/entries/add', null, false, false) ?></p> 9 13 14 <table class="tbadmin"> 10 15 <?php 11 16 //die(print_r($data)); 12 17 13 foreach ($data as $key => $val) { 14 echo '<p><a href="/admin/entries/edit/'.$data[$key]['Entry']['id'].'">Edit</a> '; 15 echo $data[$key]['Entry']['title']; 16 echo ' <a href="/admin/entries/delete/'.$data[$key]['Entry']['id'].'">Delete</a></p><hr />'; 18 $th = array ('Edit', 'Title', 'Status', 'Delete'); 19 echo $html->tableHeaders($th); 20 foreach ($data as $val) { 21 $tr = array ( 22 $gags->sendEdit($val['Entry']['id'], 'entries'), 23 $val['Entry']['title'], 24 $gags->setStatus($val['Entry']['status']), 25 $gags->confirmDel($val['Entry']['id'], 'entries') 26 ); 27 28 echo $html->tableCells($tr, array("class"=>"altRow", "onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='altRow'"), 29 array('class'=>'evenRow',"onmouseover"=>"this.className='highlight'", "onmouseout"=>"this.className='evenRow'")); 17 30 } 18 ?> 31 ?> 32 </table> 33 34 <?php echo $pagination; ?> -
trunk/app/views/helpers/gags.php
r22 r45 12 12 public $helpers = array('Html', 'Ajax'); 13 13 14 public function confirmDel($id, $controller) { 14 public function confirmDel($id, $controller) 15 { 15 16 16 17 $strB = $this->Html->formTag('/admin/'.$controller.'/delete/'.$id.'/', 'post', array("onsubmit"=>"return confirm('Are you sure to delete?')")); … … 21 22 } 22 23 23 public function sendEdit($id, $controller) { 24 public function sendEdit($id, $controller) 25 { 24 26 25 27 $strB = $this->Html->formTag('/admin/'.$controller.'/edit/'.$id, 'post'); … … 30 32 } 31 33 32 public function setStatus($s) { 34 public function setStatus($s) 35 { 33 36 34 $status = ( $s == 1 ) ? 'Publi cado' : 'En preparación';37 $status = ( $s == 1 ) ? 'Published' : 'Draft'; 35 38 36 39 return $status; … … 45 48 } 46 49 47 public function googleAds($page = 1, $position = 'vertical') {48 49 switch ($page)50 {51 case 1:52 $div = '<div style="float:left;margin-right:20px;">';53 break;54 case 2:55 $div = '<div style="float:center;width:50%;margin-left:120px;padding:6px;">';56 break;57 case 3:58 $div = '<div style="width:100%;padding:0;text-align:center">';59 break;60 default:61 $div = '<div style="float:left;margin-right:20px;">';62 break;63 64 }65 66 if (substr($_SERVER['REMOTE_ADDR'], 0, 7) == '132.248')67 {68 return '';69 }70 71 if ($position == 'vertical')72 {73 $Ads = $div .74 '<script type="text/javascript"><!--75 google_ad_client = "pub-0016482957997855";76 google_ad_width = 336;77 google_ad_height = 280;78 google_ad_format = "336x280_as";79 google_ad_type = "text_image";80 google_ad_channel = "";81 google_color_border = "FFFFFF";82 google_color_bg = "FFFFFF";83 google_color_link = "FC6500";84 google_color_text = "000000";85 google_color_url = "FC6500";86 //--></script>87 <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">88 </script></div>';89 }90 else91 {92 $Ads = $div .93 '<script type="text/javascript"><!--94 google_ad_client = "pub-0016482957997855";95 google_ad_width = 468;96 google_ad_height = 55;97 google_ad_format = "468x60_as";98 google_ad_type = "text_image";99 //2007-05-26: Linux100 google_ad_channel = "9033725822";101 google_color_border = "FFFFFF";102 google_color_bg = "FFFFFF";103 google_color_link = "FC6500";104 google_color_text = "000000";105 google_color_url = "FC6500";106 //-->107 </script>108 <script type="text/javascript"109 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">110 </script>';111 }112 113 return $Ads;114 }115 50 } -
trunk/app/views/layouts/admin.thtml
r15 r45 19 19 Logged in as <strong><?php echo $othAuth->user('username'); ?></strong> | 20 20 <strong><a href="/"><?php echo $_SERVER['SERVER_NAME']; ?></a></strong> 21 <a href="/ users/edit/<?php echo $othAuth->user('id'); ?>">My Account</a> |21 <a href="/admin/users/edit/<?php echo $othAuth->user('id'); ?>">My Account</a> | 22 22 <a href="/users/logout">Logout</a> 23 23 </div> -
trunk/app/views/layouts/default.thtml
r41 r45 22 22 <body> 23 23 <div style="margin:60px auto 60px auto;padding:17px;border:1px dotted gray;text-align:center;width:400px;background-color: #fff"> 24 <a href="/"><img src="http://trac.mononeurona.org/chilpotle-logo.png" alt="Chipotle Software" title="Chipotle Software" /></a><br /> 24 <a href="http://trac.mononeurona.org"><img src="http://trac.mononeurona.org/chilpotle-logo.png" alt="Chipotle Software" title="Chipotle Software" /></a> 25 <br /> 25 26 <?php echo $content_for_layout; ?> 26 27 <br /> -
trunk/app/views/layouts/portal.thtml
r43 r45 31 31 <tr><td colspan="3" id="toplinks"> 32 32 <?php 33 if ( $othAuth->sessionValid() ) { 33 if ( $othAuth->sessionValid() ) 34 { 34 35 echo '<a href="/admin/entries/start" title="Admin">Admin</a> | '; 35 36 echo '<a href="/users/logout" title="Logout">Logout</a> | '; 36 } else { 37 } 38 else 39 { 37 40 echo '<a id="logindiv" href="#" onclick="javascript:mod(\'logindiv\', 1, \'\')">Login</a> | '; 38 41 } … … 105 108 106 109 <?php echo $this->renderElement('poll', $Element["Poll"]); ?> 110 111 <?php echo $this->renderElement('subjects'); ?> 107 112 </td> 108 113 </tr> -
trunk/app/views/news/admin_add.thtml
r29 r45 4 4 <?php echo $javascript->link('fckeditor/fckeditor'); ?> 5 5 6 <?php echo $html->addCrumb('Control Tools', '/admin/entries/ index'); ?>6 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?> 7 7 <?php echo $html->addCrumb('News', '/admin/news/listing'); ?> 8 8 <?php echo $html->getCrumbs(' / '); ?> -
trunk/app/views/news/admin_edit.thtml
r29 r45 7 7 <?php $session->flash(); ?> 8 8 9 <?php echo $html->addCrumb('Control Tools', '/admin/entries/ index'); ?>9 <?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?> 10 10 <?php echo $html->addCrumb('News', '/admin/news/listing'); ?> 11 11 <?php echo $html->getCrumbs(' / '); ?> -
trunk/app/webroot/css/ControlPanel.css
r1 r45 30 30 31 31 #table_header{padding:3px;text-align:center;background-color:#c0c0c0;font-weight:bold;margin-bottom:6px;} 32 33 .tbadmin {width:80%;margin:5px auto 5px auto;border-collapse:collapse;} 34 .altRow {background-color:#f1ffff;} 35 .evenRow{background-color:#fff;} 36 .highlight{background-color:#e9f9ff;border:1px solid orange;} 37 32 38 33 39 .main_tabula td {text-align:center;padding:6px}
