Changeset 45

Show
Ignore:
Timestamp:
07/17/07 17:24:45 (18 months ago)
Author:
aarkerio
Message:

Subjects list on front end

Location:
trunk/app
Files:
2 added
14 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/entries_controller.php

    r43 r45  
    1212class EntriesController extends AppController { 
    1313    
    14    public $helpers       = array('Ajax', 'Form', 'Fck'); 
     14   public $helpers       = array('Ajax', 'Form', 'Fck', 'Gags'); 
    1515    
    16    public $components    = array('Edublog', 'Portal', 'Search'); 
     16   public $components    = array('Edublog', 'Portal', 'Search', 'Mypagination'); 
    1717    
    1818   public function results($string)  
     
    7070    $this->Sanitize->paranoid($this->data["Entry"]["title"]); //Hopefully this is enough 
    7171     
    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    { 
    7885            $this->flash('Database error!', '/admin/entries/listing'); 
    79       } 
    8086    } 
    81   } 
     87   } 
     88 } 
    8289  
    8390  public function admin_start($order = null) 
     
    98105  } 
    99106   
    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; 
    102110        
    103111       $this->layout    = 'admin'; 
    104112        
     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        
    105124       $conditions = array("Entry.user_id"=>$this->othAuth->user('id')); 
    106125        
    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); 
    108133        
    109134       $this->set('data', $data); 
    110         
    111135  } 
    112136   
     
    117141     $this->set('subjects', $this->Entry->Subject->generateList()); 
    118142      
    119      if (empty($this->data)) 
     143     if (empty($this->data["Entry"])) 
    120144     { 
    121145         $this->Post->id = $id; 
     
    126150         if ($this->Entry->save($this->data['Entry'])) 
    127151         { 
    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             } 
    129160         } 
    130161     } 
  • trunk/app/controllers/subjects_controller.php

    r22 r45  
    1313    
    1414   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   } 
    1533    
    1634   public function admin_listing() 
  • trunk/app/controllers/users_controller.php

    r44 r45  
    2020class UsersController extends AppController 
    2121{ 
    22     public $helpers          = array('Ajax', 'Form', 'User', 'Fck'); 
     22    public $helpers          = array('Ajax', 'Form', 'User', 'Fck', 'Gags'); 
    2323     
    2424    public $components       = array('Security', 'Edublog', 'Portal', 'Email', 'Adds', 'Mypagination'); 
     
    466466   
    467467  /** === 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 
    469485  /*** DELETE  **/  
    470486  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  
    51<?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'); 
    1214?> 
    13  
    14 </div> 
    15  
  • trunk/app/views/entries/admin_add.thtml

    r36 r45  
    55<?php echo $html->addCrumb('Entries', '/admin/entries/listing'); ?>  
    66<?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'); ?> 
    88<?php echo $html->hiddenTag('Entry/user_id', $othAuth->user('id')) ?> 
    99<fieldset> 
     
    4242       <?php echo $form->labelTag( 'Entry/status', 'Published:' );?> 
    4343       <?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> 
    4853   
    4954  <tr><td colspan="3"> 
  • trunk/app/views/entries/admin_edit.thtml

    r14 r45  
    22<?php echo $javascript->link('fckeditor/fckeditor'); ?>  
    33 
    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'); ?>  
    86<?php echo $html->getCrumbs(' / '); ?> 
    97 
     8<fieldset> 
     9<legend>Edit Entry</legend> 
    1010 
    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'); ?> 
    1214<?php echo $html->hiddenTag('Entry/user_id', $othAuth->user('id')) ?> 
    1315<?php echo $html->hiddenTag('Entry/id') ?> 
    1416 
    15 <fieldset> 
    1617  <?php echo $form->labelTag( 'Entry/title', 'Title' );?><br />  
    1718  <?php echo $html->input('Entry/title', array("size" => 40, "maxlength" => 50, "class"=>"formas")); ?> 
    1819  <?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 
    5458</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(); ?> 
    15 
    2 <?php echo $html->addCrumb('Control Tools', '/admin//entries/start'); ?>  
     6<?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>  
    37 
    48<?php echo $html->getCrumbs(' / '); ?> 
     
    812<p><?php echo $html->link($html->image('actions/new.png', array("alt"=>"Add entry", "title"=>"Add entry")), '/admin/entries/add', null, false, false) ?></p> 
    913 
     14<table class="tbadmin"> 
    1015<?php 
    1116//die(print_r($data)); 
    1217 
    13 foreach ($data as $key => $val) { 
    14       echo '<p><a href="/admin/entries/edit/'.$data[$key]['Entry']['id'].'">Edit</a>&nbsp;&nbsp;'; 
    15       echo $data[$key]['Entry']['title']; 
    16       echo '&nbsp;&nbsp;<a href="/admin/entries/delete/'.$data[$key]['Entry']['id'].'">Delete</a></p><hr />'; 
     18$th = array ('Edit', 'Title', 'Status', 'Delete'); 
     19echo $html->tableHeaders($th);   
     20foreach ($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'"));  
    1730} 
    18 ?>  
     31?> 
     32</table> 
     33 
     34<?php echo $pagination; ?> 
  • trunk/app/views/helpers/gags.php

    r22 r45  
    1212   public  $helpers = array('Html', 'Ajax'); 
    1313    
    14    public function confirmDel($id, $controller) { 
     14   public function confirmDel($id, $controller)  
     15   { 
    1516         
    1617        $strB  = $this->Html->formTag('/admin/'.$controller.'/delete/'.$id.'/', 'post', array("onsubmit"=>"return confirm('Are you sure to delete?')")); 
     
    2122   } 
    2223    
    23    public function sendEdit($id, $controller) { 
     24   public function sendEdit($id, $controller)  
     25   { 
    2426         
    2527        $strB  = $this->Html->formTag('/admin/'.$controller.'/edit/'.$id, 'post'); 
     
    3032   } 
    3133    
    32    public function setStatus($s) { 
     34   public function setStatus($s)  
     35   { 
    3336            
    34            $status = ( $s == 1 ) ? 'Publicado' : 'En preparaci&oacute;n'; 
     37           $status = ( $s == 1 ) ? 'Published' : 'Draft'; 
    3538            
    3639           return $status; 
     
    4548 } 
    4649 
    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    else 
    91    { 
    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: Linux 
    100 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   }  
    11550} 
  • trunk/app/views/layouts/admin.thtml

    r15 r45  
    1919     Logged in as <strong><?php echo $othAuth->user('username'); ?></strong> | 
    2020     <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> | 
    2222       <a href="/users/logout">Logout</a>     
    2323   </div> 
  • trunk/app/views/layouts/default.thtml

    r41 r45  
    2222<body> 
    2323<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 /> 
    2526   <?php echo $content_for_layout; ?> 
    2627   <br /> 
  • trunk/app/views/layouts/portal.thtml

    r43 r45  
    3131<tr><td colspan="3" id="toplinks"> 
    3232<?php  
    33 if ( $othAuth->sessionValid() ) {  
     33if ( $othAuth->sessionValid() )  
     34{  
    3435    echo '<a href="/admin/entries/start" title="Admin">Admin</a> | '; 
    3536    echo '<a href="/users/logout" title="Logout">Logout</a> | '; 
    36 } else { 
     37}  
     38else  
     39{ 
    3740    echo '<a id="logindiv" href="#" onclick="javascript:mod(\'logindiv\', 1, \'\')">Login</a> | '; 
    3841} 
     
    105108        
    106109       <?php echo  $this->renderElement('poll',       $Element["Poll"]); ?> 
     110        
     111       <?php echo $this->renderElement('subjects'); ?> 
    107112</td> 
    108113</tr> 
  • trunk/app/views/news/admin_add.thtml

    r29 r45  
    44<?php echo $javascript->link('fckeditor/fckeditor'); ?>  
    55 
    6 <?php echo $html->addCrumb('Control Tools', '/admin/entries/index'); ?>  
     6<?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>  
    77<?php echo $html->addCrumb('News', '/admin/news/listing'); ?>  
    88<?php echo $html->getCrumbs(' / '); ?> 
  • trunk/app/views/news/admin_edit.thtml

    r29 r45  
    77<?php $session->flash(); ?> 
    88 
    9 <?php echo $html->addCrumb('Control Tools', '/admin/entries/index'); ?>  
     9<?php echo $html->addCrumb('Control Tools', '/admin/entries/start'); ?>  
    1010<?php echo $html->addCrumb('News', '/admin/news/listing'); ?>  
    1111<?php echo $html->getCrumbs(' / '); ?> 
  • trunk/app/webroot/css/ControlPanel.css

    r1 r45  
    3030 
    3131#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 
    3238 
    3339.main_tabula td {text-align:center;padding:6px}