Assembla home | Assembla project page
 

Changeset 58

Show
Ignore:
Timestamp:
06/11/07 16:43:53 (1 year ago)
Author:
digitalspaghetti
Message:

Fixed WymEditor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branch/controllers/posts_controller.php

    r57 r58  
    66        // Set the default Paginate values       
    77        var $paginate = array('fields'=>array('Post.id', 'Post.title', 'Post.byline', 'Post.body', 'Post.comments_count' ,'Post.user_id', 'Post.stub' ,'Post.post_date' , 'Post.access_level', 'Post.frontpage' ,'Post.published' ,'User.id', 'User.username', 'Subject.id' ,'Subject.title'),'limit'=>10, 'order'=>array('Post.post_date'=>'DESC', 'Post.created' => 'DESC')); 
    8  
     8         
    99        function index() { 
    1010                // Increase recursion to get post tags and comments 
     
    107107        function admin_add() { 
    108108                if(!empty($this->data)) { 
     109                        $this->data['Post']['user_id'] = $this->othAuth->user('id'); 
    109110                        $this->cleanUpFields(); 
    110111                        $this->Post->create(); 
     
    116117                        } 
    117118                } 
    118                 $this->set('author_id', $this->othAuth->user('id')); 
    119119                $this->set('access_levels', $this->Group->generateList(null, 'Group.name ASC', null,'{n}.Group.level', '{n}.Group.name')); 
    120120                $this->set('subjects', $this->Post->Subject->generateList()); 
     
    130130                        if($this->Post->save($this->data)) { 
    131131                                $this->Session->setFlash('The Post saved'); 
    132                                 $this->redirect(array('action'=>'index'), null, true); 
     132                                //$this->redirect(array('action'=>'index'), null, true); 
     133                                pr($this->data); 
    133134                        } else { 
    134135                                $this->Session->setFlash('The Post could not be saved. Please, try again.'); 
  • branch/models/post.php

    r57 r58  
    1212                'subject_id' => VALID_NOT_EMPTY, 
    1313                'access_level' => VALID_NOT_EMPTY, 
    14                 'stub' => VALID_NOT_EMPTY, 
     14                /*'stub' => VALID_NOT_EMPTY,*/ 
    1515                'tags' => VALID_NOT_EMPTY, 
    1616                'published' => VALID_NOT_EMPTY, 
     
    6262                                                'insertQuery' => ''), 
    6363        ); 
     64         
     65        function beforeSave() 
     66    { 
     67        if (empty($this->id)) 
     68        { 
     69            $this->data[$this->name]['stub'] = $this->getUniqueUrl($this->data[$this->name]['title'], 'stub'); 
     70        } 
     71         
     72        return true; 
     73    }  
    6474} 
    6575?> 
  • branch/views/elements/js_include.ctp

    r57 r58  
    11<?php e($javascript->link('jquery'));?> 
    22<?php e($javascript->link('wymeditor/jquery.wymeditor'));?> 
     3<?php e($javascript->link('wymeditor/plugins/tidy/jquery.wymeditor.tidy'));?> 
     4<?php e($javascript->link('wymeditor/plugins/hovertools/jquery.wymeditor.hovertools'));?> 
    35<?php e($javascript->link('webrocket'));?> 
  • branch/views/posts/admin_add.ctp

    r57 r58  
    66                        <?php echo $form->input('title', array('class' => 'required'));?> 
    77                        <?php echo $form->input('byline', array('class' => 'required'));?> 
    8                         <?php echo $form->input('body', array('class' => 'required'));?> 
    9                         <?php echo $form->input('user_id', array('class' => 'required', 'value' => $author_id));?> 
     8                        <?php echo $form->input('body',array('class'=>'wymeditor'));?> 
    109                </fieldset> 
    1110                 
     
    1312                        <?php echo $form->input('subject_id', array('class' => 'required', 'options' => $subjects));?> 
    1413                        <?php echo $form->input('tags', array('class' => 'required', 'type'=>'text'));?>                                 
    15                         <?php echo $form->input('stub', array('class' => 'required'));?> 
    1614                </fieldset> 
    1715                 
     
    2422                </fieldset> 
    2523                                 
    26                 <?php echo $form->submit('Add');?> 
     24                <?php echo $form->submit('Add', array('class'=>'wymupdate'));?> 
    2725        </form> 
    2826</div> 
  • branch/views/posts/admin_edit.ctp

    r57 r58  
    77                        <?php echo $form->input('title', array('class' => 'required'));?> 
    88                        <?php echo $form->input('byline', array('class' => 'required'));?> 
    9                         <?php echo $form->input('body', array('class' => 'required'));?> 
     9                        <?php echo $form->input('body', array('class'=>'wymeditor'));?> 
    1010                        <?php echo $form->input('user_id', array('class' => 'required'));?> 
    1111                </fieldset> 
     
    2626                </fieldset> 
    2727                                 
    28                 <?php echo $form->submit('Add');?> 
     28                <?php echo $form->submit('Update', array('class'=>'wymupdate'));?> 
    2929                <li><?php echo $html->link('Delete', array('action'=>'delete', $html->tagValue('Post/id')), null, 'Are you sure you want to delete #' . $html->tagValue('Post/id')); ?> 
    3030        </form> 
  • branch/webroot/js/webrocket.js

    r57 r58  
    22 
    33$j(function() { 
    4     $j('#PostBody').wymeditor(); 
     4     
     5    $j(".wymeditor").wymeditor({ 
     6                 
     7        classesItems:[ 
     8                {name:"date", title:"PARA: Date", expr:"p"},  
     9                {name:"hidden-note", title:"PARA: Hidden note", expr:"p[@class!=\"important\"]"},  
     10                {name:"important", title:"PARA: Important", expr:"p[@class!=\"hidden-note\"]"},  
     11                {name:"border", title:"IMG: Border", expr:"img"},  
     12                {name:"special", title:"LIST: Special", expr:"ul, ol"}],  
     13                 
     14        editorStyles:[ 
     15                {name:".hidden-note", css:"color: #999; border: 2px solid #ccc;"},  
     16                {name:".border", css:"border: 4px solid #ccc;"},  
     17                {name:".date", css:"background-color: #ff9; border: 2px solid #ee9;"},  
     18                {name:".important", css:"color: red; font-weight: bold; border: 2px solid red;"},  
     19                {name:".special", css:"background-color: #fc9; border: 2px solid red;"}],  
     20                 
     21        dialogStyles:[ 
     22                {name:".hidden-note", css:"display: none;"},  
     23                {name:".border", css:"border: 1px solid #ccc;"},  
     24                {name:".date", css:"color: #ccf;"},  
     25                {name:".important", css:"color: red; font-weight: bold;"},  
     26                {name:".special", css:"color: green;"}],  
     27                 
     28        postInit:function (wym) { 
     29                wym.status("&nbsp;"); 
     30                var wymtidy = wym.tidy({sUrl:"/js/wymeditor/plugins/tidy/tidy.php", sButtonHtml:"<li class='wym_tools_tidy'><a name='CleanUp' href='#' style='background-image: url(/js/wymeditor/plugins/tidy/wand.png)'>Clean up HTML</a></li>"}); 
     31                wymtidy.init();wym.hovertools();}, postInitDialog:function (wym, wdw) {var body = wdw.document.body;var sSelectLink = "<div class='row row-indent'><select class='wym_select_link'><option selected value='WYMeditor http://www.wymeditor.org/'>WYMeditor</option><option value='SourceForge http://www.sourceforge.net/'>SourceForge</option><option value='GNU http://www.gnu.org/'>GNU</option></select><input class='wym_choose' type='button' value='{Choose}' /></div>"; 
     32                $j(body).filter(".wym_dialog_link").find("fieldset").eq(0).prepend(wym.replaceStrings(sSelectLink)); 
     33                $j(body).find(".wym_choose").click(function () {var sVal = $j(body).find(".wym_select_link").val(); 
     34                $j(body).find(".wym_href").val(sVal.substring(sVal.lastIndexOf(" ") + 1)); 
     35                $j(body).find(".wym_title").val(sVal.substr(0, sVal.lastIndexOf(" ")));});} 
     36        }); 
     37         
     38        $j(".wymsubmit").click(function () {alert($j(this).siblings(".wymeditor").val());}); 
     39         
    540        $j("ul.mytreemenu").Treeview({speed: "slow", collapsed: true}); 
    641});