SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Orchika Usage Source Code #1

    I finally finished my framework. Here's the blog controller I made ("I made it in a screencast which I'll upload soon too")

    But tell me what you think of the code and if you can see yourself using it.

    2 intro screencasts:
    http://www.2shared.com/file/3498843/.../Intro_1_.html
    http://www.2shared.com/file/3498854/...iguration.html

    blog screencast:
    http://www.2shared.com/file/3498900/46e416bd/blog.html

    FINAL source code:

    PHP Code:
    <?php

    class BlogSection extends Section {
        public function 
    Open() {
            
    $this->Load('Posts');
            
    $this->Load('Users');
            
    $this->Set('status'$this->Auth->IsConnected());
        }
        
        public function 
    AddPage() {
            if(!
    $this->Auth->IsConnected()) {
                return;
            }
            if(
    $this->Form->Sent) {
                
    $this->Form->Validate->Fill('title');
                if(
    $this->Form->IsValid) {
                    
    $this->Posts->Insert($this->Form->All());
                    
    aEnvironment::Redirect(PageLink('Blog''Show'));
                }
                
    $this->Form->Reload();
            }
        }
        
        public function 
    DeletePage($id) {
            if(!
    aVar::IsNumeric($id))
                throw new 
    Exception('ID parameter has to be a valid integer.');
            if(!
    $this->Auth->IsConnected())
                throw new 
    Exception('You have to be authenticated in order to delete.');
            
    $this->Posts->DeleteByPrimary($id);
            
    aEnvironment::Redirect(PageLink('Blog/Show'));
        }
        
        public function 
    ShowPage() {
            
    $this->Set('posts'$this->Posts->All());
        }
        
        public function 
    CommentsPage($id) {
            if(!
    aVar::IsNumeric($id))
                throw new 
    Exception('ID parameter has to be a valid integer.');
            
            if(
    $this->Form->Sent) {
                
    $this->Form->Validate->Fill('body');
                if(
    $this->Form->IsValid) {
                    
    $this->Load('Comments');
                    
    $this->Form->Set('post_id'$id);
                    
    $this->Comments->Insert($this->Form->All());
                }
            }
            
            
    $post $this->Posts->Primary($id);
            
    $this->Set('post'$post[0]);
        }
        
        public function 
    AuthPage($logout) {
            if(
    $logout == 'Logout') {
                
    $this->Auth->Disconnect();
            }
            
            if(
    $this->Form->Sent) {
                
    $this->Form->Validate->Fill('name, password');
                if(
    $this->Form->IsValid) {
                    
    $user $this->Users->Where('name'$this->Form->Get('name'));
                    if(
    aArray::Length($user) < 1) {
                        
    $this->Set('bad''name');
                        return;
                    }
                    if(
    $user[0]['password'] == $this->Form->Get('password')) {
                        
    $this->Auth->Set('name'$user[0]['name']);
                        
    $this->Auth->Connect();
                        
    $this->Set('bad''success');
                        return;
                    }
                    
    $this->Set('bad''password');
                }
                
    $this->Form->Reload();
            }
        }
    }
    Last edited by CoderMaya; Jun 25, 2008 at 19:01.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •