Adds a new version to the page.

If the current version is embargoed then the new version is also embargoed.
If the current version is published then the new version becomes a draft.
514870
public function addVersion(array $attrs = []): PageVersionInterface
    {
        if ($oldVersion = $this->getCurrentVersion()) {
            $attrs += $oldVersion->toArray();
        }

        // Chunk type and ID fields shouldn't be copied.
        unset($attrs[PageVersion::ATTR_CHUNK_TYPE]);
        unset($attrs[PageVersion::ATTR_CHUNK_ID]);
        unset($attrs[PageVersion::ATTR_RESTORED_FROM]);

        $newVersion = new PageVersion($attrs);
        $newVersion->setPage($this);

        /*
         * Only make the new version a draft if the old version is published.
         * When a new page is created we set the edited_at time to make the first version published
         */
        if ($oldVersion->isPublished()) {
            $newVersion->makeDraft();
        }

        $newVersion->save();

        $this->setCurrentVersion($newVersion);

        return $this->getCurrentVersion();
    }
1024680
public void add(final long version) {
        versionWindow[versionWriteHead++] = version;
        if (versionWriteHead == versionWindow.length) {
            versionWriteHead = 0;
        }
        versionsStored++;
    }
957145
def _update_release_content(self, release, content):
        """"""
        if release.body:
            new_body = []
            current_parser = None
            is_start_line = False
            for parser in self.parsers:
                parser.replaced = False

            # update existing sections
            for line in release.body.splitlines():

                if current_parser:
                    if current_parser._is_end_line(current_parser._process_line(line)):
                        parser_content = current_parser.render()
                        if parser_content:
                            # replace existing section with new content
                            new_body.append(parser_content + "\r\n")
                        current_parser = None

                for parser in self.parsers:
                    if (
                        parser._render_header().strip()
                        == parser._process_line(line).strip()
                    ):
                        parser.replaced = True
                        current_parser = parser
                        is_start_line = True
                        break
                    else:
                        is_start_line = False

                if is_start_line:
                    continue
                if current_parser:
                    continue
                else:
                    # preserve existing sections
                    new_body.append(line.strip())

            # catch section without end line
            if current_parser:
                new_body.append(current_parser.render())

            # add new sections at bottom
            for parser in self.parsers:
                parser_content = parser.render()
                if parser_content and not parser.replaced:
                    new_body.append(parser_content + "\r\n")

            content = u"\r\n".join(new_body)

        return content
1034705
function(newProps) {
        if (this.getInitialState) {
            if (this.getInitialProps) {
                newProps = this.getInitialProps(newProps) || {};
            }
            var newState = this.getInitialState(newProps);
            this.replaceState(newState);
            return;
        }

        if (!this.__newProps) {
            updateManager.queueWidgetUpdate(this);
        }

        this.__newProps = newProps;
    }
1172343
private static BsonDocument withNewVersion(
      final BsonDocument document,
      final BsonDocument newVersion
  ) {
    final BsonDocument newDocument = BsonUtils.copyOfDocument(document);
    newDocument.put(DOCUMENT_VERSION_FIELD, newVersion);
    return newDocument;
  }
1104972
public function upgradeBookInformation() {

		// Metadata

		$meta_post = $this->getMetaPost();
		if ( ! $meta_post ) {
			return; // Do nothing
		}

		$metadata = $this->getMetaPostMetadata();
		$compare = $this->getDeprecatedComparisonTable( 'metadata' );

		foreach ( $metadata as $meta_key => $meta_value ) {
			$new_meta_key = ( isset( $compare[ $meta_key ] ) ) ? $compare[ $meta_key ] : false;
			if ( $new_meta_key ) {
				$meta_id = $this->getMidByKey( $meta_post->ID, $meta_key );
				if ( $meta_id ) {
					if ( isset( $this->upgradeCheckboxes[ $meta_key ] ) ) {
						$meta_value = 'on';
					} elseif ( is_array( $meta_value ) ) {
						$meta_value = array_values( $meta_value );
						$meta_value = array_pop( $meta_value );
					}

					// Overrides
					if ( 'pb_language' === $new_meta_key ) {
						$meta_value = substr( strtolower( $meta_value ), 0, 2 );
					}
					if ( 'pb_publication_date' === $new_meta_key ) {
						$meta_value = strtotime( $meta_value );
					}

					// Update the original $meta_key to the $new_meta_key
					update_metadata_by_mid( 'post', $meta_id, $meta_value, $new_meta_key );
				}
			}
		}
		// Force title change
		update_metadata( 'post', $meta_post->ID, 'pb_title', get_bloginfo( 'name' ) );
	}
754920
public function actionCreatePage()
    {
        $this->menuFlush();
        $model = new Nav();
        $fromDraft = $this->postArg('use_draft');
        $parentNavId = $this->postArg('parent_nav_id');
        $navContainerId = $this->postArg('nav_container_id');
        
        if (!empty($parentNavId)) {
            $navContainerId = Nav::findOne($parentNavId)->nav_container_id;
        }
        
        if (!empty($fromDraft)) {
            $create = $model->createPageFromDraft($parentNavId, $navContainerId, $this->postArg('lang_id'), $this->postArg('title'), $this->postArg('alias'), $this->postArg('description'), $this->postArg('from_draft_id'), $this->postArg('is_draft'));
        } else {
            $create = $model->createPage($parentNavId, $navContainerId, $this->postArg('lang_id'), $this->postArg('title'), $this->postArg('alias'), $this->postArg('layout_id'), $this->postArg('description'), $this->postArg('is_draft'));
        }
        
        if (is_array($create)) {
            Yii::$app->response->statusCode = 422;
        }
        
        return $create;
    }
253188
protected function submitAddPage()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->validateComponent('page');
        $this->addPage();
    }
1225208
public void addAddVersion(String source, String name, String value, Confidence confidence) {
        addVersion.add(new Evidence(source, name, value, confidence));
    }
29875
def commit(self, overlay=True):
        
        CheckParent(self.page)              # doc may have died meanwhile
        self.totalcont += self.text_cont

        if not fitz_py2:                    # need bytes if Python > 2
            self.totalcont = bytes(self.totalcont, "utf-8")

        # make /Contents object with dummy stream
        xref = TOOLS._insert_contents(self.page, b" ", overlay)
        # update it with potential compression
        self.doc._updateStream(xref, self.totalcont)

        self.lastPoint  = None         # clean up ...
        self.rect       = None         #
        self.draw_cont  = ""           # for possible ...
        self.text_cont  = ""           # ...
        self.totalcont  = ""           # re-use
        return
89131
public static void add() {

        String current = System.getProperties().getProperty(HANDLER_PKGS, "");
        if (current.length() > 0) {
            if (current.contains(PKG)) {
                return;
            }
            current = current + "|";
        }
        System.getProperties().put(HANDLER_PKGS, current + PKG);

    }
773970
public function isOnDraft()
    {
        $id = $this->owner->ID ?: $this->owner->OldID;
        if (!$id) {
            return false;
        }
        if (!$this->hasStages()) {
            return true;
        }

        $draftVersion = static::get_versionnumber_by_stage($this->owner, Versioned::DRAFT, $id);
        return (bool)$draftVersion;
    }
474309
def can_publish(self):
        
        with self.published_context():
            published = self.one(
                Q._uid == self._uid,
                projection={'revision': True}
                )

        if not published:
            return True

        with self.draft_context():
            draft = self.one(Q._uid == self._uid, projection={'revision': True})

        return draft.revision > published.revision
1314429
def new_revision(self, *fields):
        """"""

        # Ensure this document is a draft
        if not self._id:
            assert g.get('draft'), \
                    'Only draft documents can be assigned new revisions'
        else:
            with self.draft_context():
                assert self.count(Q._id == self._id) == 1, \
                        'Only draft documents can be assigned new revisions'

        # Set the revision
        if len(fields) > 0:
           fields.append('revision')

        self.revision = datetime.now()

        # Update the document
        self.upsert(*fields)
1173652
def delete(self, version):
        
        # Shouldn't be able to delete live or draft version
        if version.state != version.DRAFT and \
                      version.state != version.PUBLISHED:
            version.delete()
            message = "%s version deleted." % version.date_published
            return self.write_message(message=message)
533947
def publish(ctx, test=False, force=False, draft=False):
    

    previous_version = get_previous_version(ctx)
    current_version = parver.Version.parse(metadata["version"])

    if current_version <= previous_version and not force:
        error_message = (
            f"current version ({current_version!s}) is <= to previous version "
            f"({previous_version!s}), use 'package.version' to update current version"
        )
        report.error(ctx, "publish", error_message)
        raise ValueError(error_message)

    report.info(ctx, "publish", f"publishing project {ctx.metadata['name']!r}")
    report.warning(
        ctx,
        "publish",
        f"drafting publish for project {ctx.metadata['name']!r} (has no effect)",
    )

    commit_message = f"Release {current_version!s}"
    report.info(ctx, "publish", f"git commiting release {commit_message!r}")
    git_commit_command = f"git commit -asm {commit_message!r}"
    if not draft:
        ctx.run(git_commit_command)

    tag_content = get_tag_content(ctx).replace('"', '\\"')
    git_tag_command = (
        f'git tag -a "v{current_version!s}" -m '
        f'"Version {current_version!s}\n\n{tag_content}"'
    )
    report.info(
        ctx, "publish", f"git tagging commit as release for version {current_version!s}"
    )
    if not draft:
        ctx.run(git_tag_command)

    artifact_paths = [f"{_.as_posix()!r}" for _ in get_artifact_paths(ctx)]
    for artifact_path in artifact_paths:
        report.debug(ctx, "publish", f"publishing artifact {artifact_path}")
    publish_command = f"twine upload {' '.join(artifact_paths)}"
    if test:
        publish_command += " --repository 'https://test.pypi.org/legacy/'"

    # get user to confirm publish
    try:
        input(
            report._get_text(
                ctx,
                "success",
                "publish",
                "about to publish, [Enter] to continue, [Ctrl-C] to abort: ",
            )
        )

        while True:
            (username, password) = get_username_password(
                ctx, "PyPi Username: ", "PyPi Password: "
            )
            # TODO: check if username and password are valid before tyring to post
            report.info(ctx, "publish", f"publishing project {ctx.metadata['name']!s}")
            if not draft:
                publish_command += f" -u {username!r} -p {password!r}"
                publish_result = ctx.run(publish_command, warn=True)
                if publish_result.exited:
                    report.error(
                        ctx,
                        "publish",
                        f"failed to publish {ctx.metadata['name']!s} (retrying)",
                    )
                    continue
            break

        git_push_command = "git push --tags"
        report.info(ctx, "publish", f"pushing git tags")
        if not draft:
            ctx.run(git_push_command)
    except KeyboardInterrupt:
        print()
        report.error(ctx, "publish", "aborting publish!")
        git_remove_tag_command = f"git tag -d {current_version!s}"
        report.warn(ctx, "publish", "removing git tags")
        if not draft:
            ctx.run(git_remove_tag_command)
        git_reset_command = f"git reset --soft HEAD^"
        report.warn(ctx, "publish", "softly reseting commit")
        if not draft:
            ctx.run(git_reset_command)
322850
public function addMenuWordpress()
    {
        if ($this->isHideMenu()) {

            add_submenu_page(
                null,
                $this->getName(),
                $this->getName(),
                $this->getCapability(),
                $this->getSlug(),
                [MocaBonita::getInstance(), 'sendContent']
            );

        } elseif ($this->isMainMenu()) {

            add_menu_page(
                $this->getName(),
                $this->getName(),
                $this->getCapability(),
                $this->getSlug(),
                [MocaBonita::getInstance(), 'sendContent'],
                $this->getDashicon(),
                $this->getMenuPosition()
            );

        } elseif ($this->isSubMenu()) {

            add_submenu_page(
                $this->getParentPage()->getSlug(),
                $this->getName(),
                $this->getName(),
                $this->getCapability(),
                $this->getSlug(),
                [MocaBonita::getInstance(), 'sendContent']
            );

            if ($this->getParentPage()->isRemovePageSubmenu()) {
                remove_submenu_page($this->getParentPage()->getSlug(), $this->getParentPage()->getSlug());
                $this->getParentPage()->setRemovePageSubmenu(false);
            }
        }

    }