This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 
<?php 

/**
 * @package Users
 * @author Tony Trupp <[email protected]>
 * @copyright  Copyright (c) 2003-2009 Concrete5. (http://www.concrete5.org)
 * @license    http://www.concrete5.org/license/     MIT License
 *
 */
 

class Concrete5_Model_LayoutPreset extends Object{
    
    protected $lpID=0;
    protected $lpName='';
    protected $layoutID=0;
     
    public function getLayoutPresetID(){ return $this->lpID; }
    public function getLayoutPresetName(){ return $this->lpName; }
    public function getLayoutID(){ return $this->layoutID; }
    public function getLayoutObject() { return Layout::getById($this->layoutID); }   
    
    static public function getList() {
        $db = Loader::db();
        $r = $db->Execute('select lp.* FROM LayoutPresets AS lp, Layouts AS l WHERE lp.layoutID=l.layoutID order by lpName asc');
        $presets = array();
        while ($row = $r->FetchRow()) {
            $layoutPreset = new LayoutPreset();
            $layoutPreset->setPropertiesFromArray($row);
            $presets[] = $layoutPreset;
        }
        return $presets;
    }
    
    public static function getByID($lpID) { 
        $db = Loader::db();
        $r = $db->GetRow('SELECT lp.* FROM LayoutPresets AS lp, Layouts AS l WHERE lp.layoutID=l.layoutID AND lp.lpID  = '.intval($lpID));
        if(is_array($r) && intval($r['lpID']) ) {
            $layoutPreset = new LayoutPreset(); 
            $layoutPreset->setPropertiesFromArray($r);
            return $layoutPreset;
        } 
        return false; 
    }
    
    //Removes a preset. Does NOT remove the associated rule
    public function delete() {
        $db = Loader::db();
        $db->Execute('delete from LayoutPresets where lpID = '.intval($this->lpID) );
    }    
    
    public function add($lpName, $layout) {
        $db = Loader::db();
        $db->Execute('insert into LayoutPresets (lpName, layoutID) values (?, ?)', array( $lpName, $layout->getLayoutID() )  ); 
    } 
}