Exemplo n.º 1
0
 public function handleCreate()
 {
     //$user_id = Auth::id();
     $data = Input::all();
     $rules = array('layout_title' => 'required|Unique:layouts', 'author' => 'required');
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $layout = new Layout();
         $layout->layout_title = Input::get('title');
         $layout->author = Input::get('author');
         $layout->description = Input::get('description');
         $layout->css_src = Input::get('css_src');
         $layout->js_src = Input::get('js_src');
         $layout->navigation = Input::get('navigation');
         $layout->footer = Input::get('footer');
         $layout->full_layout = Input::get('full_layout');
         $layout->published_by = Auth::id();
         $layout->updated_by = Auth::id();
         if (Input::get('save_layout')) {
             $layout->save();
             return Redirect::action('AdminLayoutController@index')->with('flash_edit_success', 'Hurray!You have created a Layout');
         } elseif (Input::get('continue_layout')) {
             $layout->save();
             return Redirect::action('AdminLayoutController@edit', $layout->id)->with('flash_edit_success', 'Hurray!Your updated information are saved,You can continue work...');
         } else {
             return Redirect::action('AdminLayoutController@index')->with('flash_dlt_success', 'OH!Sorry! I can not make a Layout in this time');
         }
     } else {
         return Redirect::back()->withInput()->withErrors($validator);
     }
 }
 public function createDevice($buildingid, $roomid)
 {
     $data = Input::all();
     $layout = new Layout();
     $layout->roomid = $roomid;
     $layout->device = $data['device'];
     $layout->name = '';
     $layout->save();
 }
Exemplo n.º 3
0
 public function install($id)
 {
     $dir = FROG_ROOT . '/public/themes/' . $id . '/';
     $files = $this->scan_directory_recursively($dir, 'php');
     $data = array();
     $data['name'] = $id;
     // Layouts
     $layouts = array();
     $l = array();
     // Snippets
     $snippets = array();
     $s = array();
     foreach ($files as $file) {
         switch ($file['name']) {
             case 'layouts':
                 foreach ($file['content'] as $layout) {
                     $layouts[] = $layout['name'];
                     $l['name'] = Themr::theme_name($layout['name']);
                     $l['content_type'] = 'text/html';
                     $l['content'] = file_get_contents($layout['path']);
                     $layout = new Layout($l);
                     if (!$layout->save()) {
                         Flash::set('error', __('Layout has not been added. Name must be unique!'));
                     }
                 }
                 break;
             case 'snippets':
                 foreach ($file['content'] as $snippet) {
                     $snippets[] = $snippet['name'];
                     $s['name'] = $snippet['name'];
                     $s['filter_id'] = '';
                     $s['content'] = file_get_contents($snippet['path']);
                     $snippet = new Snippet($s);
                     if (!$snippet->save()) {
                         Flash::set('error', __('Snippet has not been added. Name must be unique!'));
                     }
                 }
                 break;
         }
     }
     // Serialize Layout and Snippet names
     $data['layout'] = serialize($layouts);
     $data['snippet'] = serialize($snippets);
     // Get Current Theme Info
     $theme_info = Themr::findTheme($id);
     // Save into Themr database table
     $theme = new Themr($data);
     if (!$theme->save()) {
         Flash::set('error', __('Theme has not been added. Name must be unique!'));
         redirect(get_url('plugin/themr'));
     } else {
         Flash::set('success', __('Theme <b>:name</b> has been added!', array(':name' => $theme_info['name'])));
         redirect(get_url('plugin/themr'));
     }
 }
Exemplo n.º 4
0
 /**
  * 录入
  *
  */
 public function actionCreate($id)
 {
     parent::_acl('layout_create');
     $model = new Layout();
     if (isset($_POST['Layout'])) {
         $model->attributes = $_POST['Layout'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入房屋布局,ID:' . $model->id));
             $this->redirect(array('index', 'id' => $model->house_id));
         }
     }
     $this->render('create', array('model' => $model, 'house_id' => $id));
 }
Exemplo n.º 5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $this->addToolbar();
     $model = new Layout();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Layout'])) {
         $model->attributes = $_POST['Layout'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('form', array('model' => $model));
 }
Exemplo n.º 6
0
 function _add()
 {
     $data = $_POST['layout'];
     Flash::set('post_data', (object) $data);
     $layout = new Layout($data);
     if (!$layout->save()) {
         Flash::set('error', __('Layout has not been added. Name must be unique!'));
         redirect(get_url('layout/add'));
     } else {
         Flash::set('success', __('Layout has been added!'));
         Observer::notify('layout_after_add', $layout);
     }
     // save and quit or save and continue editing?
     if (isset($_POST['commit'])) {
         redirect(get_url('layout'));
     } else {
         redirect(get_url('layout/edit/' . $layout->id));
     }
 }
 function _add()
 {
     $data = $_POST['layout'];
     Flash::set('post_data', (object) $data);
     // CSRF checks
     if (isset($_POST['csrf_token'])) {
         $csrf_token = $_POST['csrf_token'];
         if (!SecureToken::validateToken($csrf_token, BASE_URL . 'layout/add')) {
             Flash::set('error', __('Invalid CSRF token found!'));
             redirect(get_url('layout/add'));
         }
     } else {
         Flash::set('error', __('No CSRF token found!'));
         redirect(get_url('layout/add'));
     }
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a name!'));
         redirect(get_url('layout/add'));
     }
     if (empty($data['content_type'])) {
         Flash::set('error', __('You have to specify a content-type!'));
         redirect(get_url('layout/add'));
     }
     $layout = new Layout($data);
     if (!$layout->save()) {
         Flash::set('error', __('Layout has not been added. Name must be unique!'));
         redirect(get_url('layout/add'));
     } else {
         Flash::set('success', __('Layout has been added!'));
         Observer::notify('layout_after_add', $layout);
     }
     // save and quit or save and continue editing?
     if (isset($_POST['commit'])) {
         redirect(get_url('layout'));
     } else {
         redirect(get_url('layout/edit/' . $layout->id));
     }
 }
Exemplo n.º 8
0
 /**
  * Displays form for attaching a module to the provied
  * layout name.
  *
  * @param string $name
  * @param array $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     $this->setTitle(t('Attach new module'));
     $this->setOutputType(self::_OT_CONFIG);
     if (!$this->_acl->check('content_layout_attach_module')) {
         throw new Module_NoPermission();
     }
     /**
      * Create the layout object and get all sectors from the theme of
      * the site type of this layout
      */
     $layout = new Layout(substr($name, 0, -7));
     $siteType = substr($layout->getName(), 0, strpos($layout->getName(), '-'));
     $theme = new Theme($this->_config->get('theme/' . $siteType . '_default'));
     // Build the form with validation
     $form = new View_form('attach/attach.html', 'content_layout');
     $form->action($this->_router->makeUrl('content_layout', 'attach', $layout->getName()));
     $form->addElement('content_layout/module', null, t('Module'), new Validator_InArray(Module::getModules()));
     $form->addElement('content_layout/sector', null, t('Sector'), new Validator_InArray(array_keys($theme->getSectors())));
     if ($form->hasInput() && $form->isValid()) {
         $fd = $form->getValues('content_layout');
         // Attach the new module to the correct sector
         try {
             $cntrlrId = $layout->addController($fd['sector'], array('mod' => $fd['module']));
             if ($layout->save()) {
                 $this->_event->success(t('Successfully added module'));
                 return zula_redirect($this->_router->makeUrl('content_layout', 'edit', $layout->getName(), null, array('id' => $cntrlrId)));
             } else {
                 $this->_event->error(t('Unable to save content layout file'));
             }
         } catch (Theme_SectorNoExist $e) {
             $this->_event->error(sprintf(t('Unable to attach module. Sector "%s" does not exist'), $fd['sector']));
         }
     }
     // Assign additional data
     $form->assign(array('SECTORS' => $theme->getSectors(), 'LAYOUT' => $layout->getName()));
     return $form->getOutput();
 }
Exemplo n.º 9
0
	public function addAreaLayout($area, $layout, $addToPosition='bottom' ) {  
		$db = Loader::db();
		
		//get max layout name number, for fixed autonaming of layouts 
		$vals = array( intval($this->cID), $this->getVersionID(), $area->getAreaHandle() );
		$sql = 'SELECT MAX(areaNameNumber) FROM CollectionVersionAreaLayouts WHERE cID=? AND cvID=? AND arHandle=?';
		$nextNumber = intval($db->getOne($sql,$vals))+1;  
		
		if($addToPosition=='top'){  
			$position=-1; 
		}else{ 
		
			//does the main area already have blocks in it? 
			//$areaBlocks = $area->getAreaBlocksArray($this); 
			$areaBlocks = $this->getBlocks( $area->getAreaHandle() );
			
			//then copy those blocks from that area into a newly created 1x1 layout, so it can be above out new layout 
			if( count($areaBlocks) ){  
			
				//creat new 1x1 layout to hold existing parent area blocks
				//Loader::model('layout'); 
				$placeHolderLayout = new Layout( array('rows'=>1,'columns'=>1) );  
				$placeHolderLayout->save( $this );  
				$vals = array( $this->getCollectionID(), $this->getVersionID(), $area->getAreaHandle(), $placeHolderLayout->getLayoutID(), $nextNumber, 10000 );
				$sql = 'INSERT INTO CollectionVersionAreaLayouts ( cID, cvID, arHandle, layoutID, areaNameNumber, position ) values (?, ?, ?, ?, ?, ?)';
				$db->query($sql,$vals);	 
				
				//add parent area blocks to this new layout
				$placeHolderLayout->setAreaObj($area);
				$placeHolderLayout->setAreaNameNumber($nextNumber);   
				$placeHolderLayoutAreaHandle = $placeHolderLayout->getCellAreaHandle(1);
				//foreach($areaBlocks as $b){ 
					//$newBlock=$b->duplicate($this); 
					//$newBlock->move($this, $placeHolderLayoutArea); 
					//$newBlock->refreshCacheAll(); 
					//$b->delete();
					//$b->move($this, $placeHolderLayoutArea); 
					//$b->refreshCacheAll(); 
					
				//} 
				$v = array( $placeHolderLayoutAreaHandle, $this->getCollectionID(), $this->getVersionID(), $area->getAreaHandle() );
				$db->Execute('update CollectionVersionBlocks set arHandle=? WHERE cID=? AND cvID=? AND arHandle=?', $v);				
				
				$nextNumber++; 
			}
			
			$position=10001; 
		}
		
		
		$vals = array( $this->getCollectionID(), $this->getVersionID(), $area->getAreaHandle(), $layout->getLayoutID(), $nextNumber, $position );
		$sql = 'INSERT INTO CollectionVersionAreaLayouts ( cID, cvID, arHandle, layoutID, areaNameNumber, position ) values (?, ?, ?, ?, ?, ?)';
		$db->query($sql,$vals);	
		
		$layout->setAreaNameNumber($nextNumber);
		
		$this->refreshCache();
	}
Exemplo n.º 10
0
 function _add()
 {
     $data = $_POST['layout'];
     Flash::set('post_data', (object) $data);
     if (empty($data['name'])) {
         Flash::set('error', __('You have to specify a name!'));
         redirect(get_url('layout/add'));
     }
     if (empty($data['content_type'])) {
         Flash::set('error', __('You have to specify a content-type!'));
         redirect(get_url('layout/add'));
     }
     $layout = new Layout($data);
     if (!$layout->save()) {
         Flash::set('error', __('Layout has not been added. Name must be unique!'));
         redirect(get_url('layout/add'));
     } else {
         Flash::set('success', __('Layout has been added!'));
     }
     // save and quit or save and continue editing?
     if (isset($_POST['commit'])) {
         redirect(get_url('layout'));
     } else {
         redirect(get_url('layout/edit/' . $layout->id));
     }
 }
Exemplo n.º 11
0
 function simpan()
 {
     //        pr($_POST);
     $succ = 0;
     $id = tin($_POST['id']);
     $val = tin($_POST['val']);
     $l = new Layout();
     $l->getByID($id);
     if ($l->layout_file != "") {
         $l->layout_file = $val;
         $l->load = 1;
         $succ = $l->save();
     } else {
         $l1 = new Layout();
         $l1->layout_id = $id;
         $l1->layout_file = $val;
         $succ = $l1->save();
     }
     if ($succ) {
         echo Lang::t("Success");
     } else {
         echo Lang::t("Failed");
     }
 }
Exemplo n.º 12
0
    /**
     * Upgrades to 2.6.0-alpha1 (2.5.60)
     *
     * @return bool|string
     */
    protected function upgradeTo_260_alpha1()
    {
        switch ($this->version) {
            case '2.5.0':
            case '2.5.1':
            case '2.5.2':
            case '2.5.3':
            case '2.5.4':
            case '2.5.5':
            case '2.5.6':
            case '2.5.50':
                foreach (array('main', 'admin') as $siteType) {
                    $layout = new Layout($siteType . '-default');
                    $sc = $layout->getControllers('SC');
                    $sc = array_shift($sc);
                    $layout->detachController($sc['id']);
                    $layout->save();
                    // Create the new FPSC (FrontPage Sector Content) layout
                    $layout = new Layout('fpsc-' . $siteType);
                    $layout->addController('SC', $sc, $sc['id']);
                    $layout->save();
                }
            case '2.5.51':
                $this->sqlFile('2.6.0-alpha1/2.5.52.sql');
            case '2.5.52':
                $this->sqlFile('2.6.0-alpha1/2.5.53.sql');
            case '2.5.53':
                $this->_config_sql->add('media/wm_position', 'bl');
            case '2.5.54':
                /**
                 * Update the ACL resources for the page changes (#247)
                 */
                $this->sqlFile('2.6.0-alpha1/2.5.55.sql');
                $addRoles = $editRoles = $manageRoles = array();
                foreach ($this->_acl->getAllRoles() as $role) {
                    if ($this->_acl->check('page_delete', $role['id'])) {
                        $editRoles[] = $role['name'];
                        $manageRoles[] = $role['name'];
                    } else {
                        if ($this->_acl->check('page_edit', $role['id'])) {
                            $editRoles[] = $role['name'];
                        }
                    }
                    if ($this->_acl->check('page_add', $role['id'])) {
                        $addRoles[] = $role['name'];
                    }
                }
                // Add in the new resources
                $query = $this->_sql->query('SELECT SUBSTRING(name, 11) AS pid FROM {PREFIX}acl_resources
													WHERE name LIKE "page-view_%"');
                foreach ($query->fetchAll(PDO::FETCH_COLUMN) as $pid) {
                    $this->_acl->allowOnly('page-edit_' . $pid, $editRoles);
                    $this->_acl->allowOnly('page-manage_' . $pid, $manageRoles);
                }
                $this->_acl->deleteResource(array('page_add', 'page_edit', 'page_delete'));
                $this->_acl->allowOnly('page_manage', $addRoles);
            case '2.5.55':
                $this->sqlFile('2.6.0-alpha1/2.5.56.sql');
            case '2.5.56':
            default:
                return '2.5.60';
        }
    }
Exemplo n.º 13
0
 function install()
 {
     $CI =& get_instance();
     $CI->load->dbforge();
     // loading objects;
     $CI->config->load('objects');
     $tables = $CI->config->item('objects');
     $tables_keys = array_keys($tables);
     foreach ($tables_keys as $item) {
         $CI->dbforge->add_field($tables[$item]);
         $CI->dbforge->create_table($item);
         $CI->db->query("ALTER TABLE `" . $item . "` ADD COLUMN `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (`id`)");
     }
     $CI->load->library('datamapper');
     //adding the default section
     $index = new Section();
     $index->parent_section = 0;
     $index->sort = 0;
     $index->save();
     // adding the default content Layouts
     $before_page = new Layout();
     $before_page->sub_section = intval(TRUE);
     $before_page->cell = 0;
     $before_page->sort = 0;
     $before_page->parent_section = $index->id;
     $before_page->info = 'BEFORE_PAGE_LOCKED';
     $before_page->save();
     $page_head = new Layout();
     $page_head->sub_section = intval(TRUE);
     $page_head->cell = 0;
     $page_head->sort = 0;
     $page_head->parent_section = $index->id;
     $page_head->info = 'PAGE_HEAD_LOCKED';
     $page_head->save();
     $page_body = new Layout();
     $page_body->sub_section = intval(TRUE);
     $page_body->cell = 0;
     $page_body->sort = 0;
     $page_body->parent_section = $index->id;
     $page_body->info = 'PAGE_BODY_LOCKED';
     $page_body->save();
     $after_page = new Layout();
     $after_page->sub_section = intval(TRUE);
     $after_page->cell = 0;
     $after_page->sort = 0;
     $after_page->parent_section = $index->id;
     $after_page->info = 'AFTER_PAGE_LOCKED';
     $after_page->save();
     $default_layout = new Layout();
     $default_layout->path = 'layout/default.php';
     $default_layout->parent_content = 3;
     $default_layout->parent_section = 1;
     $default_layout->subsection = 0;
     $default_layout->cell = 0;
     $default_layout->sort = 0;
     $default_layout->save();
 }
Exemplo n.º 14
0
 /**
  * Attempts to detach/remove a controller from the sector map for the
  * correct site type. Done by controller ID. If the site type does not
  * exist then it will not attempt to detach the controller.
  *
  * @return bool
  */
 protected function detachCntrlr()
 {
     try {
         $layout = new Layout($this->_input->post('content_layout_name'));
         $resources = array();
         $delCount = 0;
         foreach ($this->_input->post('controller_ids') as $cntrlrId) {
             try {
                 $layout->detachController($cntrlrId);
                 ++$delCount;
                 // Store resource IDs to delete
                 $resources[] = 'layout_controller_' . $cntrlrId;
             } catch (Layout_ControllerNoExist $e) {
                 $this->_event->error(sprintf(t('Unable to detach module ID "%d" as it does not exist'), $cntrlrId));
             }
         }
         if ($layout->save()) {
             // Remove ACL resources if needed
             if (!empty($resources)) {
                 foreach ($resources as $tmpResource) {
                     try {
                         $this->_acl->deleteResource($tmpResource);
                     } catch (Acl_ResourceNoExist $e) {
                         $this->_log->message('Content layout unable to remove ACL Resource "' . $tmpResource . '"', Log::L_INFO);
                     }
                 }
             }
             if ($delCount > 0) {
                 $this->_event->success(t('Detached selected modules'));
             }
         } else {
             $this->_event->error(t('Unable to save layout, ensure file is writable'));
         }
     } catch (Input_KeyNoExist $e) {
         $this->_event->error(t('No modules selected'));
     }
 }
Exemplo n.º 15
0
 /**
  * Allows the user to configure the module that is attached to a
  * sector. This, however, currently depends on JavaScript enabled.
  *
  * @return string
  */
 public function indexSection($layoutName = null)
 {
     $this->setTitle(t('Edit module'));
     $this->setOutputType(self::_OT_CONFIG);
     // Check permission and if a layout has been provided
     if (!$this->_acl->check('content_layout_config_module')) {
         throw new Module_NoPermission();
     } else {
         if ($layoutName === null) {
             $this->_event->error(t('Unable to edit attached module, no layout given'));
             return zula_redirect($this->_router->makeUrl('content_layout'));
         }
     }
     // Get correct cntrlr ID that is to be edited
     try {
         $cntrlrId = $this->_router->getArgument('id');
     } catch (Router_ArgNoExist $e) {
         try {
             $cntrlrId = $this->_input->post('content_layout/cid');
         } catch (Input_KeyNoExist $e) {
             $this->_event->error(t('Unable to edit attached module, no ID given'));
             return zula_redirect($this->_router->makeUrl('content_layout'));
         }
     }
     // Create the correct layout and ensure cntrlr exists
     $layout = new Layout($layoutName);
     try {
         $cntrlr = $layout->getControllerDetails($cntrlrId);
         $module = new Module($cntrlr['mod']);
         $this->setTitle(sprintf(t('Configure attached module "%1$s"'), $module->title));
         if (!isset($cntrlr['config']['clDescription'])) {
             $cntrlr['config']['clDescription'] = '';
         }
     } catch (Layout_ControllerNoExist $e) {
         $this->_event->error(sprintf(t('Unable to edit controller "%1$d" as it does not exist'), $cntrlrId));
         return zula_redirect($this->_router->makeUrl('content_layout', 'manage', $layoutName));
     } catch (Module_NoExist $e) {
         $this->_event->error(sprintf(t('Unable to edit attached module "%1$s" as it does not exist'), $cntrlr['mod']));
         return zula_redirect($this->_router->makeUrl('content_layout', 'manage', $layoutName));
     }
     /**
      * Prepare form validation
      */
     $form = new View_form('edit/module.html', $this->getDetail('name'), false);
     $form->addElement('content_layout/config/displayTitle', $cntrlr['config']['displayTitle'], t('Display Title'), new Validator_InArray(array('true', 'false', 'custom')));
     $form->addElement('content_layout/config/customTitle', $cntrlr['config']['customTitle'], t('Custom title'), new Validator_Length(0, 255));
     $form->addElement('content_layout/config/htmlWrapClass', $cntrlr['config']['htmlWrapClass'], t('HTML class'), new Validator_Length(0, 500), $cntrlr['sector'] != 'SC');
     $form->addElement('content_layout/config/clDescription', $cntrlr['config']['clDescription'], t('Description'), new Validator_Length(0, 255), $cntrlr['sector'] != 'SC');
     $form->addElement('content_layout/cntrlr', null, t('Controller'), new Validator_Alphanumeric('_-.!+'));
     $form->addElement('content_layout/section', null, t('Section'), new Validator_Alphanumeric('_-.!+'));
     $form->addElement('content_layout/config', null, t('Config'), new Validator_Is('array'), false);
     if ($form->hasInput() && $form->isValid()) {
         $fd = $form->getValues('content_layout');
         try {
             $layout->editController($cntrlr['id'], array('con' => $fd['cntrlr'], 'sec' => $fd['section'], 'order' => $cntrlr['order'], 'config' => isset($fd['config']) ? $fd['config'] : array()));
             try {
                 $roles = $this->_input->post('acl_resources/layout_controller_' . $cntrlr['id']);
             } catch (Input_ValueNoExist $e) {
                 $roles = array();
             }
             $this->_acl->allowOnly('layout_controller_' . $cntrlr['id'], $roles);
             if ($layout->save()) {
                 $this->_event->success(sprintf(t('Configured attached module ID "%d"'), $cntrlr['id']));
             } else {
                 $this->_event->error(t('Unable to save layout, ensure file is writable'));
             }
         } catch (Layout_ControllerNoExist $e) {
             $this->_event->error(sprintf(t('Unable to edit attached module ID "%d" as it does not exist'), $cntrlr['id']));
         } catch (Theme_SectorMapNotWriteable $e) {
             $this->_event->error(sprintf(t('Unable to edit module in sector map: $s'), $e->getMessage()));
         }
         // Redirect back to correct location, FPSC layouts go back to index
         $url = new Router_Url('content_layout');
         $url->siteType($this->_router->getSiteType());
         if (strpos($layoutName, 'fpsc-') === 0) {
             $url->queryArgs(array('type' => substr($layoutName, 5)));
         } else {
             $url->controller('manage')->section($layoutName);
         }
         return zula_redirect($url);
     }
     /**
      * Gets all displays modes that this module offers, the current display
      * mode being used - once done start building up the form.
      */
     $displayModes = Hooks::notifyAll($module->name . '_display_modes');
     $currentMode = Hooks::notifyAll($module->name . '_resolve_mode', $cntrlr['con'], $cntrlr['sec'], $cntrlr['config']);
     $this->addAsset('js/edit.js');
     $form->assign(array('CID' => $cntrlr['id'], 'LAYOUT_NAME' => $layoutName, 'SECTOR' => $cntrlr['sector'], 'MODULE' => $module->getDetails(), 'DISPLAY_MODES' => empty($displayModes) ? array('default' => t('Default')) : $displayModes, 'CURRENT_MODE' => empty($currentMode) ? 'default' : $currentMode[0]));
     $jsConfig = array_merge($cntrlr, $cntrlr['config']);
     unset($jsConfig['config']);
     $form->assignHtml(array('JS_CONFIG' => zula_array_js_string($jsConfig), 'ACL_FORM' => $this->_acl->buildForm(array(t('View attached module') => 'layout_controller_' . $cntrlr['id']))));
     return $form->getOutput();
 }
Exemplo n.º 16
0
         if (!$layoutPreset && !$layout->isUniqueToCollectionVersion($nvc) || $_POST['layoutPresetAction'] == 'create_new_preset' || $_POST['layoutPresetAction'] == 'save_as_custom') {
             $updateLayoutId = 1;
             $layout->layoutID = 0;
         }
         $layout->save($nvc);
         //if($oldLayoutId) $nvc->updateAreaLayoutId($area, $oldLayoutId, $layout->layoutID);
     } else {
         //this may be triggered when there are two quick requests to the server, and the change has already been saved
         $skipLayoutSave = 1;
         //throw new Exception(t('Access Denied: Invalid Layout'));
     }
 } else {
     //new layout
     $layout = new Layout($params);
     $position = $_REQUEST['add_to_position'] == 'top' ? 'top' : 'bottom';
     $layout->save($nvc);
     //$nvc->addAreaLayout($area, $layout, $position);
 }
 //are we adding a new layout to an area, or updating an existing one?
 $cvalID = intval($_REQUEST['cvalID']);
 if ($skipLayoutSave) {
     //see above
 } elseif ($cvalID) {
     //get the cval of the record that corresponds to this version & area
     $vals = array($nvc->getCollectionID(), $nvc->getVersionID(), $_GET['arHandle'], intval($_REQUEST['layoutID']));
     $cvalID = intval($db->getOne('SELECT cvalID FROM CollectionVersionAreaLayouts WHERE cID=? AND cvID=? AND arHandle=? AND layoutID=? ', $vals));
     if ($updateLayoutId) {
         $nvc->updateAreaLayoutId($cvalID, $layout->layoutID);
     }
 } else {
     $nvc->addAreaLayout($area, $layout, $position);
Exemplo n.º 17
0
 /**
  * Provides ability to add a new content layout. The user will
  * be redirect to the page, as if they had gone 'Edit' on the
  * layout once it has been created.
  *
  * @return string
  */
 public function addSection()
 {
     $this->setTitle(t('Add new layout'));
     $this->setOutputType(self::_OT_CONFIG);
     try {
         $cloner = $this->_router->getArgument('clone');
         $cloner = new Layout($cloner);
         if ($cloner->exists()) {
             $cloneName = $cloner->getName();
             $cloneRegex = $cloner->getRegex();
             $this->setTitle(sprintf(t('Clone layout "%1$s"'), $cloneName));
         } else {
             throw new Exception();
         }
     } catch (Exception $e) {
         $cloneName = null;
         $cloneRegex = null;
     }
     // Build and check form
     $form = new View_Form('index/form_layout.html', 'content_layout');
     $form->action($this->_router->makeUrl('content_layout', 'index', 'add'));
     $form->addElement('content_layout/name', null, t('Name'), array(new Validator_Alphanumeric('-'), new Validator_Length(2, 225)));
     $form->addElement('content_layout/regex', $cloneRegex, t('URL/Regex'), new Validator_Length(2, 255));
     $form->addElement('content_layout/site_type', $this->_router->getDefaultSiteType(), t('Site type'), new Validator_InArray($this->_router->getSiteTypes()));
     $form->addElement('content_layout/clone', $cloneName, t('Clone'), array(new Validator_Alphanumeric('-'), new Validator_Length(0, 225)));
     if ($form->hasInput() && $form->isValid()) {
         $fd = $form->getValues('content_layout');
         // Check if we are cloning a layout
         if ($fd['clone']) {
             $layout = new Layout($fd['clone']);
             $layout->setName($fd['site_type'] . '-' . $fd['name']);
         } else {
             $layout = new Layout($fd['site_type'] . '-' . $fd['name']);
         }
         $layout->setRegex($fd['regex']);
         $path = $this->_zula->getDir('config') . '/layouts/' . $layout->getName() . '.xml';
         if ($layout->save($path)) {
             $this->_event->success(t('Added new content layout'));
             return zula_redirect($this->_router->makeUrl('content_layout', 'manage', $layout->getName()));
         }
         $this->_event->error(t('Unable to save content layout'));
     }
     return $form->getOutput();
 }