Save Page edition
@return \Zend\View\Model\JsonModel
425453
public function saveEditionAction()
	{
		$idPage = $this->params()->fromRoute('idPage', $this->params()->fromQuery('idPage', ''));
		$translator = $this->serviceLocator->get('translator');
		
		$eventDatas = array('idPage' => $idPage);
		$this->getEventManager()->trigger('meliscms_page_saveedition_start', null, $eventDatas);
		
		$container = new Container('meliscms');
		if (empty($idPage))
		{
			$result = array(
    				'success' => 0,
    				'errors' => array(array('empty' => $translator->translate('tr_meliscms_form_common_errors_Empty datas')))
    		);
		}
		else
		{
		    // Resave XML of the page
			if (!empty($container['content-pages'][$idPage]))
			{

				// Create the new XML
				$newXmlContent = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
				$newXmlContent .= '<document type="MelisCMS" author="MelisTechnology" version="2.0">' . "\n";
				foreach ($container['content-pages'][$idPage] as $namePlugin => $pluginEntries)
				{
                    if($namePlugin != 'private:melisPluginSettings') {
                        foreach ($pluginEntries as $idEntry => $valueEntry) {
                            $newXmlContent .= "\t" . $valueEntry . "\n";
                        }
                    }
				}
				$newXmlContent .= '</document>';
				
				// Save the result
                $melisPageSavedTable = $this->getServiceLocator()->get('MelisEngineTablePageSaved');
				$melisPageSavedTable->save(array('page_content' => $newXmlContent), $idPage);
				
			}	

			$result = array(
					'success' => 1,
					'errors' => array(),
			);
		}

		$this->getEventManager()->trigger('meliscms_page_saveedition_end', null, $result);
		
		return new JsonModel($result);
	}
225578
protected function saveJson()
    {
        $this->swagger->saveAs($this->docsFile);

        $security = new SecurityDefinitions();
        $security->generate($this->docsFile);

        return $this;
    }
299105
public function saveAction()
	{
		if( config( 'shop.authorize', true ) ) {
			$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
		}

		$cntl = $this->createAdmin();

		if( ( $html = $cntl->save() ) == '' ) {
			return $cntl->getView()->response();
		}

		return $this->getHtml( $html );
	}
1123400
public function save()
    {
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");
        $aRDFaDeliveries = (array) \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("ardfadeliveries");

        // Delete old mappings
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sOxIdParameter = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("oxid");
        $sSql = "DELETE FROM oxobject2delivery WHERE oxdeliveryid = '{$sOxIdParameter}' AND OXTYPE = 'rdfadeliveryset'";
        $oDb->execute($sSql);

        // Save new mappings
        foreach ($aRDFaDeliveries as $sDelivery) {
            $oMapping = oxNew(\OxidEsales\Eshop\Core\Model\BaseModel::class);
            $oMapping->init("oxobject2delivery");
            $oMapping->assign($aParams);
            $oMapping->oxobject2delivery__oxobjectid = new \OxidEsales\Eshop\Core\Field($sDelivery);
            $oMapping->save();
        }
    }
940722
public function saveinnlang()
    {
        $sOxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        $oObj = oxNew(\OxidEsales\Eshop\Application\Model\SelectList::class);

        if ($sOxId != "-1") {
            $oObj->loadInLang($this->_iEditLang, $sOxId);
        } else {
            $aParams['oxselectlist__oxid'] = null;
        }

        //Disable editing for derived items
        if ($oObj->isDerived()) {
            return;
        }

        parent::save();

        //$aParams = $oObj->ConvertNameArray2Idx( $aParams);
        $oObj->setLanguage(0);
        $oObj->assign($aParams);

        // apply new language
        $oObj->setLanguage(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("new_lang"));
        $oObj->save();

        // set oxid if inserted
        $this->setEditObjectId($oObj->getId());
    }
871454
public function editAction() {
		$configForm = $this->getForm();
        /* @var $request \Zend\Http\Request */
        $request = $this->getRequest();
		
        if ($request->isPost()) {
			$data = $request->getPost();
			$configForm->setData($data);
			if ($configForm->isValid()) {
				$configData = $configForm->getData();
				$flatConfig = $this->flattenConfig($configData['config'], $this->getConfigPrefix());
				$this->saveConfig($flatConfig);
				
				$this->flashMessenger()->addSuccessMessage($this->getTranslator()->translate('Configuration successfully saved'));
				return $this->_redirectToIndex();
			}
        } else {
			$configForm->setData($this->getConfig());
		}
		
		$view = new ViewModel(array('title' => $this->getEditTitle(), 'configForm' => $configForm));
		$view->setTemplate('xelax-site-config/site-config/edit.phtml');
		return $view;
	}
605479
public function saveinnlang()
    {
        parent::save();

        $soxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        if (isset($aParams['oxcontents__oxloadid'])) {
            $aParams['oxcontents__oxloadid'] = $this->_prepareIdent($aParams['oxcontents__oxloadid']);
        }

        // checkbox handling
        if (!isset($aParams['oxcontents__oxactive'])) {
            $aParams['oxcontents__oxactive'] = 0;
        }

        $oContent = oxNew(\OxidEsales\Eshop\Application\Model\Content::class);

        if ($soxId != "-1") {
            $oContent->loadInLang($this->_iEditLang, $soxId);
        } else {
            $aParams['oxcontents__oxid'] = null;
        }

        $oContent->setLanguage(0);
        $oContent->assign($aParams);

        // apply new language
        $oContent->setLanguage(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("new_lang"));
        $oContent->save();

        // set oxid if inserted
        $this->setEditObjectId($oContent->getId());
    }
69582
public function save()
    {

        $fields = array_except($this->attributes, ["_index", "_type", "_id", "_score"]);

        if ($this->exists()) {

            // Update the current document

            $this->newQuery()->id($this->getID())->update($fields);

        } else {

            // Check if model key exists in items

            if (array_key_exists("_id", $this->attributes)) {
                $created = $this->newQuery()->id($this->attributes["_id"])->insert($fields);
                $this->_id = $this->attributes["_id"];
            } else {
                $created = $this->newQuery()->insert($fields);
                $this->_id = $created->_id;
            }

            $this->setConnection($this->getConnection());
            $this->setIndex($created->_index);

            // Match earlier versions

            $this->_index = $created->_index;
            $this->_type = $this->type;

            $this->exists = true;
        }

        return $this;
    }
996281
public function editionOkAction()
    {
        $lng = \Cmf\Language\Factory::get($this);
        HelperFactory::getMessageBox()->addSuccessMessage($lng[self::MSG_EDITION_OK]);

        return $this->forward('default');
    }
459330
public function create()
	{
		$arrNodes = false;

		if ($this->insideRoot)
		{
			$objContent = \ContentModel::findById($this->data->pid);

			$rootId = Controller::getRootPageId($objContent->ptable, $objContent->pid);

			if (null !== $rootId)
			{
				$objPage = \PageModel::findWithDetails($rootId);

				if ($this->insideLang || empty($objPage->domain))
				{
					$arrNodes = array($rootId);
				}
				else
				{
					$arrNodes = (array) \PageModel::findByDns($objPage->domain)->fetchEach('id');
				}
			}
		}
		
		if ($this->multiArticle)
		{
			$this->generateDCA('multiArticle', array
			(
				'inputType' => 'articleTree',
				'label'		=> array($this->label, $this->description),
				'eval'		=> array
				(
					'multiple'		=>	true,				
					'fieldType'		=>	'checkbox', 
					'orderField'	=>	$this->virtualFieldName('orderArticle'),
					'mandatory'		=> ($this->mandatory) ? true : false, 
					'rootNodes'		=>	$arrNodes,
					'tl_class'		=> 'clr'
				),
				'load_callback'		=> array
				(
					array('tl_content_contentblocks', 'prepareOrderPageValue'),
				),
				'save_callback'		=> array
				(
					array('tl_content_contentblocks', 'saveOrderPageValue'),
				),
			));
		}
		else
		{
			$this->generateDCA('singleArticle', array
			(
				'inputType' => 'articleTree',
				'label'		=> array($this->label, $this->description),
				'eval'		=> array
				(
					'fieldType'		=>	'radio', 
					'mandatory'		=> ($this->mandatory) ? true : false, 
					'rootNodes'		=>	$arrNodes,
					'tl_class'		=> 'clr'
				),
			));
		}
	}
1022849
function save()
    {
        $dt = '';
        if (isset($_POST['dt'])) {
            $dt = base64_decode($_POST['dt']);
            $dt = utf8_encode($dt);
            $dt = json_decode($dt);
        }

        if (isset($dt->content)) {
            $media =    isset($dt->media) ? $dt->media : '{}';
            $category = isset($dt->category) ? $dt->category : 1;
            $link =     isset($dt->link) ? $dt->link : '';
            $tags =     isset($dt->tags) ? $dt->tags : '';
            $status =   isset($dt->status) ? $dt->status : 'R';

            $title =    isset($dt->title) ? $dt->title : 'Sem Título';
            $destaque = isset($dt->destaque) ? $dt->destaque : 'Nenhum destaque ...';

            $uID = isset($dt->info->user) ? $dt->info->user : 0;
            $aID = isset($dt->info->article) ? $dt->info->article : 0;

            $article = new Model\Article($aID);

            $article->set('author', $uID);
            $article->set('category', $category);
            $article->set('pubdate', date('Y-m-d H:i:s'));
            $article->set('editdate', date('Y-m-d H:i:s'));

            $article->set('link', $link);
            $article->set('tags', $tags);
            $article->set('status', $status);
            $article->set('media', json_encode($media));
            
            $article->set('title', $title);
            $article->set('content', str_replace(["--", "..."], ["&mdash;", "&hellip;"], $dt->content));
            $article->set('resume', $destaque);

            //Gravando...
            $article->save();

            //Send to client
            $this->send(['status'=>'ok', 'id'=>$article->get('id'), 'link'=>$article->get('link')]);
        }
        $this->sendError();
    }
900447
public void savePreviousImplementedVersion(Page page, Integer version) {
        String value = version != null ? String.valueOf(version) : null;
        ContentEntityObject entityObject = getContentEntityManager().getById(page.getId());
        getContentPropertyManager().setStringProperty(entityObject, PREVIOUS_IMPLEMENTED_VERSION, value);
    }
612000
public function savePostData($pageVersion, $pagePost, $pageLangPost, $pageGroupsPost, $pageInfoOther = [])
    {
        /*
         * Post data fixes
         */
        foreach ($pagePost as $k => $pagePostField) {
            if (is_array($pagePostField) && array_key_exists('exists', $pagePostField)) {
                $pagePost[$k] = array_key_exists('select', $pagePostField) ? $pagePostField['select'] : 0;
            }
        }
        if (array_key_exists('live_start', $pagePost)) {
            $pagePost['live_start'] = DateTimeHelper::jQueryToMysql($pagePost['live_start']) ?: null;
        }
        if (array_key_exists('live_end', $pagePost)) {
            $pagePost['live_end'] = DateTimeHelper::jQueryToMysql($pagePost['live_end']) ?: null;
        }
        foreach ($pageInfoOther as $k => $pageInfoOtherField) {
            if (is_array($pageInfoOtherField) && array_key_exists('exists', $pageInfoOtherField) && array_key_exists('select', $pageInfoOtherField)) {
                $pageInfoOther[$k] = $pageInfoOtherField['select'];
            }
        }

        /*
         * Overwrite default/existing data with posted data
         */
        $pageDefaults = array_merge([
            'template' => 0,
            'parent' => 0,
            'child_template' => 0,
            'order' => 0,
            'group_container' => 0,
            'group_container_url_priority' => 0,
            'canonical_parent' => 0,
            'link' => 0,
            'live' => 0,
            'sitemap' => 1,
            'live_start'=> null,
            'live_end' => null
        ], $this->getAttributes());
        foreach ($pageDefaults as $pageAttribute => $pageDefault) {
            $setAttributeValue = array_key_exists($pageAttribute, $pagePost) ? $pagePost[$pageAttribute] : $pageDefault;
            if (in_array($pageAttribute, ['template'])) { // don't directly update to page, only to page version
                $pageVersion->$pageAttribute = $setAttributeValue;
            } else {
                $this->$pageAttribute = $setAttributeValue;
            }
        }

        if (!$this->pageCurrentLang) {
            $this->setRelation('pageCurrentLang', ($d = $this->pageDefaultLang) ? $d->replicate() : new PageLang);
            unset($this->pageCurrentLang->language_id);
        }
        $pageLang = $this->pageLang();
        $pageLangDefaults = array_merge([
            'language_id' => Language::current(),
            'url' => '',
            'name' => '',
            'live_version' => 1
        ], $pageLang->getAttributes());
        foreach ($pageLangDefaults as $pageLangAttribute => $pageLangDefault) {
            $pageLang->$pageLangAttribute = array_key_exists($pageLangAttribute, $pageLangPost) ? $pageLangPost[$pageLangAttribute] : $pageLangDefault;
        }

        /*
         * Check page parent exists if set and page limit is not hit
         */
        $parent = static::find($this->parent);
        if ($this->parent > 0 && !$parent) {
            return false;
        }
        if (!$this->id && !$this->link && static::at_limit($this->parent == -1)) {
            return false;
        }

        /*
         * Check page name/url set and does not conflict
         */
        $pageLang->url = trim($pageLang->url);
        if (!$this->link) {
            $pageLang->url = strtolower(str_replace(['/', ' '], '-', $pageLang->url));
            if (preg_match('#^[-]+$#', $pageLang->url)) {
                $pageLang->url = '';
            }
            if ($pageLang->url == '' && !$this->parent) {
                $pageLang->url = '/';
            }
            $siblings = [];
            foreach ($pageGroupsPost as $pageGroupId => $checkedVal) {
                $pageGroup = PageGroup::preload($pageGroupId);
                $siblings = array_merge($pageGroup->exists ? $pageGroup->itemPageIds() : [], $siblings);
            }
            if ($this->parent >= 0) {
                $siblings = array_merge(static::getChildPageIds($this->parent), $siblings);
            }
            $siblings = array_unique($siblings);
        }
        if (!$pageLang->name) {
            FormMessage::add('page_info_lang[name]', 'page name required');
        }
        if (!$pageLang->url) {
            FormMessage::add('page_info_lang[url]', 'page url required');
        }
        if (!empty($siblings)) {
            $same_level = PageLang::where('url', '=', $pageLang->url)->whereIn('page_id', $siblings);
            $same_level = $this->id ? $same_level->where('page_id', '!=', $this->id) : $same_level;
            if (!$same_level->get()->isEmpty()) {
                FormMessage::add('page_info_lang[url]', 'url in use by another page!');
                $pageLang->url = '';
            }
        }
        if (!$pageLang->name || !$pageLang->url) {
            return false;
        }

        /*
         * If adding a page as a group container, create container / check exists
         */
        if ($this->group_container == -1) {
            $groupContainer = new PageGroup;
            $groupContainer->name = $pageLang->name;
            $groupContainer->item_name = 'Page';
            $groupContainer->default_template = 0;
            $groupContainer->save();
            $this->group_container = $groupContainer->id;
        } elseif ($this->group_container) {
            $groupContainer = PageGroup::preload($this->group_container);
            if (!$groupContainer->exists || ($pageDefaults['group_container'] != $this->group_container && !$groupContainer->canEditItems())) {
                $this->group_container = 0;
            }
        }

        /*
         * Check if page info can be updated (based on publishing auth action, or allowed if new page)
         */
        $authPageIdCheck = $this->id ?: ($this->parent > 0 ? $this->parent : 0);
        $canPublish = (config('coaster::admin.publishing') > 0 && Auth::action('pages.version-publish', ['page_id' => $authPageIdCheck])) || (config('coaster::admin.publishing') == 0 && Auth::action('pages.edit', ['page_id' => $authPageIdCheck]));
        $canPublish = $canPublish || (isset($groupContainer) && ((config('coaster::admin.publishing') > 0 && $groupContainer->canPublishItems()) || (config('coaster::admin.publishing') == 0 && $groupContainer->canEditItems())));
        $willPublish = !$this->id || $canPublish;

        /*
         * Check and save page changes
         */
        $newPage = !$this->id;
        if ($willPublish) {
            // if new page set as last ordered page
            if ($this->parent >= 0 && !$this->id) {
                $lastSibling = static::where('parent', '=', $this->parent)->orderBy('order', 'desc')->first();
                $this->order = $lastSibling ? $lastSibling->order + 1 : 1;
            }

            // if new page publish template
            $this->template = $this->id ? $this->template: $pageVersion->template;
            // if link remove live template
            $this->template = $this->link ? 0 : $this->template;

            // set page live between but no dates set set as hidden, or if can't publish set as hidden
            $this->live = ($this->live == 2 && is_null($this->live_end) && is_null($this->live_start)) ? 0 : $this->live;
            $this->live = $canPublish ? $this->live : 0;

            // save page data
            $this->save();
            $pageLang->page_id = $this->id;
            $pageLang->save();
        }
        $pageVersion->page_id = $this->id;
        $pageVersion->save();

        /*
         * Update title block to the page name is new page
         */
        if ($newPage && $titleBlock = Block::where('name', '=', config('coaster::admin.title_block'))->first()) {
            $titleBlock->setVersionId($pageVersion->version_id)->setPageId($this->id)->getTypeObject()->save($pageLang->name);
            PageSearchData::updateText(strip_tags($pageLang->name), 0, $this->id);
        }

        /*
         * Save Page Groups
         */
        $currentGroupIds = $this->groupIds();
        $newGroupIds = array_keys($pageGroupsPost);
        PageGroupPage::where('page_id', '=', $this->id)->whereIn('group_id', array_diff($currentGroupIds, $newGroupIds))->delete();
        foreach (array_diff($newGroupIds, $currentGroupIds) as $addGroupId) {
            $this->groups()->attach($addGroupId);
        }
        $this->groupIds(true); // clear old groups as data may be used again in page info view

        /*
         * Save other page info
         */
        if ($willPublish && Auth::action('menus')) {
            MenuItem::set_page_menus($this->id, array_key_exists('menus', $pageInfoOther) ? $pageInfoOther['menus'] : []);
        }

        if ($canPublish && array_key_exists('beacons', $pageInfoOther) && Auth::action('themes.beacons-update')) {
            BlockBeacon::updatePage($this->id, $pageInfoOther['beacons']);
        }

        return true;
    }
586300
protected function createComponentPagePublish() : object
    {
        $control = $this->IPage_Publish->create();

        $control->onSave[] = function () use ($control)
        {
            $this->getComponent('pageSummaryModal')->redrawControl('pageSummary');

            $control->redrawControl('publish');

            $this->redrawPrinters(); // TODO: Remove dependency on Structure Module
        };

        return $control;
    }
727583
protected function getEditorOptions()
    {
        $this->editorOptions['element'] = new JsExpression('$("#' . $this->id . '")[0]');

        return Json::encode($this->editorOptions);
    }
787025
public function save()
    {
        parent::save();

        $soxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
        $oArticle->loadInLang($this->_iEditLang, $soxId);

        $oArticle->setLanguage(0);

        // checkbox handling
        if (!$oArticle->oxarticles__oxparentid->value && !isset($aParams['oxarticles__oxremindactive'])) {
            $aParams['oxarticles__oxremindactive'] = 0;
        }

        $oArticle->assign($aParams);

        //tells to article to save in different language
        $oArticle->setLanguage($this->_iEditLang);
        $oArticle = \OxidEsales\Eshop\Core\Registry::getUtilsFile()->processFiles($oArticle);

        $oArticle->resetRemindStatus();

        $oArticle->updateVariantsRemind();

        $oArticle->save();
    }
267758
public function save()
    {
        $soxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");
        $aParams['oxnewsletter__oxshopid'] = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId();

        $oNewsletter = oxNew(\OxidEsales\Eshop\Application\Model\Newsletter::class);
        if ($soxId != "-1") {
            $oNewsletter->load($soxId);
        } else {
            $aParams['oxnewsletter__oxid'] = null;
        }

        $oNewsletter->assign($aParams);
        $oNewsletter->save();

        // set oxid if inserted
        $this->setEditObjectId($oNewsletter->getId());
    }