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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class Concrete5_Controller_Dashboard_Pages_Types_Composer extends DashboardBaseController {

    protected $ct = false;
    
    protected function verify($ctID = false) {
        $cap = Loader::helper('concrete/dashboard');
        $ct = false;
        if ($ctID > 0) {
            $ct = CollectionType::getByID($ctID);
        }
        
        if ($cap->canAccessComposer() && is_object($ct)) {
            $this->set('ct', $ct);
            $this->ct = $ct;
        } else {
            $this->redirect("/dashboard/pages/types");
        }
    }
    
    public function save_content_items($ctID = false) {
        $this->verify($ctID);
        $items = array();
        foreach($this->post('item') as $item) {
            $obj = new stdClass;
            if (substr($item, 0, 3) == 'bID') {
                $obj->bID = substr($item, 3);
            } else {
                $obj->akID = substr($item, 4);
            }
            $items[] = $obj;
        }
        $this->ct->saveComposerContentItemOrder($items);
        exit;
    }
    
    public function view($ctID = false, $action = false) { 
        $this->verify($ctID);
        $this->set('contentitems', $this->ct->getComposerContentItems());
        $this->set('disableThirdLevelNav', true);
        if ($action == 'updated') {
            $this->set('message', t('Composer settings updated.'));
        }
    }   
    
    public function save() {
        $this->verify($this->post('ctID'));
        if ($this->post('ctIncludeInComposer')) {
            switch($this->post('ctComposerPublishPageMethod')) {
                case 'PARENT':
                    $page = Page::getByID($this->post('ctComposerPublishPageParentID'));
                    if($page->isError()) {
                        $this->error->add(t('Parent page not selected'));
                    } else {
                        $this->ct->saveComposerPublishTargetPage($page);
                    }
                    break;
                case 'PAGE_TYPE':
                    $ct = CollectionType::getByID($this->post('ctComposerPublishPageTypeID'));
                    $this->ct->saveComposerPublishTargetPageType($ct);
                    break;
                default:
                    $this->ct->saveComposerPublishTargetAll();                  
                    break;
            }
            if(!$this->error->has()) {
                $this->ct->saveComposerAttributeKeys($this->post('composerAKID'));
                $this->redirect('/dashboard/pages/types/composer', 'view', $this->ct->getCollectionTypeID(), 'updated');
            } else {
                $this->view($this->ct->getCollectionTypeID());
            }
        } else {
            $this->ct->resetComposerData();
            $this->redirect("/dashboard/pages/types", "clear_composer");
        }
    }
    
}