当前位置: 首页>>代码示例>>PHP>>正文


PHP PageModel::save方法代码示例

本文整理汇总了PHP中PageModel::save方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::save方法的具体用法?PHP PageModel::save怎么用?PHP PageModel::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PageModel的用法示例。


在下文中一共展示了PageModel::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: page_model_test

function page_model_test($delete)
{
    include_once "adventure_model.php";
    $page = new PageModel("Sample Page Text" . rand(0, 100000), AdventureModel::first()->id, "images/test.png");
    $page->save();
    $page->print_fields();
    $page->set("page_text", "Updated Page Text");
    $page->save();
    $page->print_fields();
    if ($delete) {
        $page->delete();
    }
    $pm = PageModel::find(PageModel::last()->id);
    $pm->print_fields();
    PageModel::find(999);
}
开发者ID:spencerbartz,项目名称:horrie_international,代码行数:16,代码来源:page_model.php

示例2: updateDisableRules

 /**
  * Update any disable rules associated with this response.
  */
 private function updateDisableRules()
 {
     if (!isset($this->parent)) {
         $this->parent = new QuestionModel(array('questionID' => $this->responseRow->questionID, 'depth' => 'question'));
     }
     $question = $this->parent;
     foreach ($question->prompts as $prompt) {
         foreach ($prompt['rules'] as $rule) {
             if ($prompt['promptID'] == $this->responseText) {
                 if ($rule->enabled != 'Y') {
                     $rule->enabled = 'Y';
                     $rule->save();
                     if (preg_match('/.+Page$/', $rule->type)) {
                         $page = new PageModel(array('pageID' => $rule->targetID, 'depth' => 'question'));
                         $page->save();
                     } elseif (preg_match('/.+Section$/', $rule->type)) {
                         $section = new SectionModel(array('sectionID' => $rule->targetID, 'depth' => 'question'));
                         $section->save();
                     } elseif (preg_match('/.+Question$/', $rule->type)) {
                         $question = new QuestionModel(array('questionID' => $rule->targetID, 'depth' => 'question'));
                         $question->save();
                     }
                 }
             } else {
                 if ($rule->enabled != 'N') {
                     $rule->enabled = 'N';
                     $rule->save();
                     if (preg_match('/.+Page$/', $rule->type)) {
                         $page = new PageModel(array('pageID' => $rule->targetID, 'depth' => 'question'));
                         $page->save();
                     } elseif (preg_match('/.+Section$/', $rule->type)) {
                         $section = new SectionModel(array('sectionID' => $rule->targetID, 'depth' => 'question'));
                         $section->save();
                     } elseif (preg_match('/.+Question$/', $rule->type)) {
                         $question = new QuestionModel(array('questionID' => $rule->targetID, 'depth' => 'question'));
                         $question->save();
                     }
                 }
             }
         }
     }
 }
开发者ID:humansky,项目名称:qframe,代码行数:45,代码来源:ResponseModel.php

示例3: approveSaveAction

 public function approveSaveAction()
 {
     try {
         if ($this->_hasParam('approvals')) {
             $page = new PageModel(array('pageID' => $this->_getParam('id'), 'depth' => 'response'));
             $comments = $this->_getParam('comments');
             foreach ($this->_getParam('approvals') as $questionID => $state) {
                 $question = $page->getQuestion(intval($questionID));
                 if ($question === null) {
                     throw new Exception('Invalid attempt to approve a non-existent question or question on another page');
                 }
                 $response = $question->getResponse();
                 if ($response->requiresAdditionalInfo() && !$response->hasAdditionalInfo()) {
                     throw new Exception('Invalid attempt to approve a response that requires additional information with none provided');
                 }
                 $response->state = intval($state);
                 if (array_key_exists($questionID, $comments)) {
                     if ($comments[$questionID] === '') {
                         $response->approverComments = null;
                     } else {
                         $response->approverComments = $comments[$questionID];
                     }
                 }
                 $response->save();
                 foreach ($question->children as $child) {
                     $response = $child->getResponse();
                     $response->state = intval($state);
                     $response->save();
                 }
             }
             $page->save();
             $instance = new InstanceModel(array('instanceID' => $page->instanceID, 'depth' => 'page'));
             $instance->save();
         }
     } catch (Exception $e) {
         $this->view->error = $e->getMessage();
     }
     $this->view->setRenderLayout(false);
 }
开发者ID:humansky,项目名称:qframe,代码行数:39,代码来源:PageController.php

示例4: page_unpublish

	/**
	 * Shortcut for unpublishing a page.
	 */
	public function page_unpublish() {
		$view    = $this->getView();
		$request = $this->getPageRequest();

		if(!\Core\user()->checkAccess('p:/core/pages/manage')){
			return View::ERROR_ACCESSDENIED;
		}

		$baseurl = $request->getParameter('baseurl');

		$page = new PageModel($baseurl);
		if(!$page->exists()){
			return View::ERROR_NOTFOUND;
		}

		if(!$request->isPost()){
			return View::ERROR_BADREQUEST;
		}

		// Is this page already un-published?
		if($page->get('published_status') == 'draft'){
			\Core\set_message('t:MESSAGE_ERROR_PAGE_ALREADY_UNPUBLISHED');
			\Core\go_back();
		}

		$page->set('published_status', 'draft');
		$page->save();

		\Core\set_message('t:MESSAGE_SUCCESS_PAGE_UNPUBLISHED');
		\Core\go_back();
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:34,代码来源:AdminController.php

示例5: _parsePages

	/**
	 * Internal function to parse and handle the configs in the component.xml file.
	 * This is used for installations and upgrades.
	 *
	 * @param boolean $install   Set to false to force uninstall/disable mode.
	 * @param int     $verbosity (default 0) 0: standard output, 1: real-time, 2: real-time verbose output.
	 *
	 * @return boolean | int
	 * @throws InstallerException
	 */
	public function _parsePages($install = true, $verbosity = 0) {
		$changes = array();

		$overallAction = $install ? 'Installing' : 'Uninstalling';

		Core\Utilities\Logger\write_debug($overallAction . ' pages for ' . $this->getName());

		// I need to get the schema definitions first.
		$node = $this->_xmlloader->getElement('pages');
		//$prefix = $node->getAttribute('prefix');

		// Now, get every table under this node.
		foreach ($node->getElementsByTagName('page') as $subnode) {
			/** @var DomElement $subnode */
			$baseurl = $subnode->getAttribute('baseurl');
			// Insert/Update the defaults for an entry in the database.
			// These are always global pages.
			$m = new PageModel(-1, $baseurl);

			if($verbosity == 2){
				CLI::PrintActionStart($overallAction . ' page ' . $baseurl);
			}

			// Hard-set pages get removed upon disabling.  They'll be recreated if re-enabled.
			if($install){
				// Just something to help the log.
				$action     = ($m->exists()) ? 'Updated' : 'Added';
				$admin      = $subnode->getAttribute('admin');
				$selectable = ($admin ? '0' : '1'); // Defaults
				$group      = ($admin ? $subnode->getAttribute('group') : '');
				if($subnode->getAttribute('selectable') !== ''){
					$selectable = $subnode->getAttribute('selectable');
				}
				$indexable = ($subnode->getAttribute('indexable') !== '') ? $subnode->getAttribute('indexable') : $selectable;
				$editurl = $subnode->getAttribute('editurl') ? $subnode->getAttribute('editurl') : '';
				$access = ($subnode->getAttribute('access')) ? $subnode->getAttribute('access') : null;

				// Do not "update" value, keep whatever the user set previously.
				if (!$m->get('rewriteurl')) {
					if ($subnode->getAttribute('rewriteurl')) $m->set('rewriteurl', $subnode->getAttribute('rewriteurl'));
					else $m->set('rewriteurl', $subnode->getAttribute('baseurl'));
				}
				// Do not "update" value, keep whatever the user set previously.
				if (!$m->get('title')) $m->set('title', $subnode->getAttribute('title'));

				if($access !== null){
					$m->set('access', $access);
				}

				// Do not update parent urls if the page already exists.
				if(!$m->exists()) $m->set('parenturl', $subnode->getAttribute('parenturl'));
				//$m->set('widget', $subnode->getAttribute('widget'));
				$m->set('admin', $admin);
				$m->set('admin_group', $group);
				$m->set('selectable', $selectable);
				$m->set('indexable', $indexable);
				$m->set('component', $this->getKeyName());
				$m->set('editurl', $editurl);
				if ($m->save()){
					$changes[] = $action . ' page [' . $baseurl . ']';
					if($verbosity == 2){
						CLI::PrintActionStatus(true);
					}
				}
				else{
					if($verbosity == 2){
						CLI::PrintActionStatus('skip');
					}
				}
			}
			else{
				$m->delete();
				$changes[] = 'Removed page [' . $subnode->getAttribute('baseurl') . ']';
				if($verbosity == 2){
					CLI::PrintActionStatus(true);
				}
			}
		}

		return ($changes > 0) ? $changes : false;
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:91,代码来源:Component_2_1.php


注:本文中的PageModel::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。