本文整理汇总了PHP中Layout::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Layout::save方法的具体用法?PHP Layout::save怎么用?PHP Layout::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layout
的用法示例。
在下文中一共展示了Layout::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleCreate
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);
}
}
示例2: createDevice
public function createDevice($buildingid, $roomid)
{
$data = Input::all();
$layout = new Layout();
$layout->roomid = $roomid;
$layout->device = $data['device'];
$layout->name = '';
$layout->save();
}
示例3: install
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'));
}
}
示例4: actionCreate
/**
* 录入
*
*/
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));
}
示例5: actionCreate
/**
* 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));
}
示例6: Layout
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));
}
}
示例7: redirect
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));
}
}
示例8: __call
/**
* 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();
}
示例9: addAreaLayout
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();
}
示例10: redirect
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));
}
}
示例11: simpan
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");
}
}
示例12: upgradeTo_260_alpha1
/**
* 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';
}
}
示例13: install
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();
}
示例14: detachCntrlr
/**
* 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'));
}
}
示例15: indexSection
/**
* 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();
}