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


PHP PageModel::delete方法代码示例

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


在下文中一共展示了PageModel::delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _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::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。