AddSiteForm action to add a new site
17499
public function doAddSite() {
		$site = $this->owner->getNewItem('new-' . Site::class .'-0', false);
		$site->write();

		return $this->owner->redirect(
			singleton(CMSPageEditController::class)->Link("show/$site->ID")
		);
	}
696368
public function submitForm(array &$form, FormStateInterface $form_state)
    {
        $site    = &$form_state->getTemporaryValue('site');
        $values  = &$form_state->getValues();

        /** @var $site Site */
        $site->title          = $values['title'];
        $site->title_admin    = $values['title_admin'];
        $site->http_redirects = $values['http_redirects'];
        $site->replacement_of = $values['replacement_of'];
        $site->http_host      = $values['http_host'];
        $site->allowed_protocols = $values['allowed_protocols'];
        $site->theme          = $values['theme'];
        $attributes = $form_state->getValue('attributes', []);
        foreach ($attributes as $name => $attribute) {
            $site->setAttribute($name, $attribute);
        }

        $this->manager->getStorage()->save($site);
        drupal_set_message($this->t("Site modifications have been saved"));

        $this->dispatcher->dispatch('site:update', new SiteEvent($site, $this->currentUser()->uid));

        $form_state->setRedirect('admin/dashboard/site/' . $site->id);
    }
1041442
public void addSite(String siteKey) {
		ValueMap gv = new ValueMap(siteKey);
		if (!this.valueMaps.contains(gv)) {
			this.valueMaps.add(gv);
		}
	}
365576
def add(self, action):
        """"""
        self._state_machine.transition_to_add()
        self._actions.append(action)
524193
public function onSiteClone(SiteCloneEvent $event)
    {
        $source = $event->getTemplateSite();
        $target = $event->getSite();

        // First copy node layouts
        $this
            ->database
            ->query(
                "
                INSERT INTO {layout} (site_id, nid, region)
                SELECT
                    :target, usn.nid, ul.region
                FROM {layout} ul
                JOIN {ucms_site_node} usn ON
                    ul.nid = usn.nid
                    AND usn.site_id = :target
                WHERE
                    ul.site_id = :source
                    AND NOT EXISTS (
                        SELECT 1
                        FROM {layout} s_ul
                        WHERE
                            s_ul.nid = ul.nid
                            AND s_ul.site_id = :target3
                    )
            ",
                [
                    ':target'  => $target->getId(),
                    ':target2' => $target->getId(),
                    ':source'  => $source->getId(),
                    ':target3' => $target->getId(),
                ]
            )
        ;

        // Then duplicate layout data
        $this
            ->database
            ->query(
                "
                INSERT INTO {layout_data}
                    (layout_id, item_type, item_id, style, position, options)
                SELECT
                    target_ul.id,
                    uld.item_type,
                    uld.item_id,
                    uld.style,
                    uld.position,
                    uld.options
                FROM {layout} source_ul
                JOIN {layout_data} uld ON
                    source_ul.id = uld.layout_id
                    AND source_ul.site_id = :source
                JOIN {node} n ON n.nid = uld.nid
                JOIN {layout} target_ul ON
                    target_ul.nid = source_ul.nid
                    AND target_ul.site_id = :target
                WHERE
                    (n.status = 1 OR n.is_global = 0)
            ",
                [
                    ':source' => $source->getId(),
                    ':target' => $target->getId(),
                ]
            )
        ;
    }
436526
def insertSite(self, businput):
        
        conn = self.dbi.connection()
        tran = conn.begin()
        try:
            siteobj = { # FIXME: unused?
                "site_name" : businput["site_name"]
            }
            businput["site_id"] = self.sm.increment(conn, "SEQ_SI", tran)
            self.sitein.execute(conn, businput, tran)
            tran.commit()
        except Exception as ex:
            if (str(ex).lower().find("unique constraint") != -1 or
                str(ex).lower().find("duplicate") != -1):
                # already exists, lets fetch the ID
                self.logger.warning("Ignoring unique constraint violation")
                self.logger.warning(ex)
            else:
                if tran:
                    tran.rollback()
                self.logger.exception(ex)
                raise
        finally:
            if tran:
                tran.close()
            if conn:
                conn.close()
707817
function(item, tableRow) {
				tableRow.className += "treeTableRow addsitesTableRow"; //$NON-NLS-0$
				
				var siteConfigCol = document.createElement("td"); //$NON-NLS-0$
				siteConfigCol.id = tableRow.id + "col1"; //$NON-NLS-0$
				var actionCol = document.createElement("td"); //$NON-NLS-0$
				actionCol.id = tableRow.id + "col4"; //$NON-NLS-0$
				
				// Site config column
				var href = mSiteUtils.generateEditSiteHref(item);
				var nameLink = document.createElement("a"); //$NON-NLS-0$
				nameLink.href = href;
				siteConfigCol.appendChild(nameLink);
				nameLink.textContent = item.Name;
				
				var statusField = document.createElement("span"); //$NON-NLS-0$
				statusField.style.padding = "0 10px 0 10px"; //$NON-NLS-0$
				siteConfigCol.appendChild(statusField);
				
				// Status, URL columns
				var status = item.HostingStatus;
				if (typeof status === "object") { //$NON-NLS-0$
					if (status.Status === "started") { //$NON-NLS-0$
						statusField.appendChild(document.createTextNode(messages["Started"]));
						var link = document.createElement("a"); //$NON-NLS-0$
						link.href = status.URL;
						link.textContent = status.URL;
						siteConfigCol.appendChild(link);
					} else {
						var statusString = status.Status.substring(0,1).toUpperCase() + status.Status.substring(1);
						statusField.appendChild(document.createTextNode(statusString));
					}
				} else {
					statusField.appendChild(document.createTextNode(messages["Unknown"]));
				}
				
				// Action column
				var actionsWrapper = document.createElement("span"); //$NON-NLS-0$
				actionsWrapper.id = tableRow.id + "actionswrapper"; //$NON-NLS-0$
				actionsWrapper.classList.add("sectionTableItemActions"); //$NON-NLS-0$
				actionCol.appendChild(actionsWrapper);
				var options = this._options;
				var userData = {
					startCallback: options.startCallback,
					stopCallback: options.stopCallback,
					deleteCallback: options.deleteCallback,
					errorCallback: function(err) {
						options.serviceRegistry.getService('orion.page.message').setProgressResult(err); //$NON-NLS-0$
					}
				};
				this._commandService.renderCommands(options.actionScopeId, actionsWrapper, item, null /*handler*/, "tool", userData); //$NON-NLS-0$

				tableRow.appendChild(siteConfigCol);
				tableRow.appendChild(actionCol);
			}
328829
private void createAddContactSubForm() {
		add(new WHeading(HeadingLevel.H3, "Add a new contact"));

		WButton addBtn = new WButton("Add");
		addBtn.setAction(new Action() {
			@Override
			public void execute(final ActionEvent event) {
				addNewContact();
			}
		});
		addBtn.setImage("/image/address-book-new.png");
		newNameField.setDefaultSubmitButton(addBtn);

		WContainer container = new WContainer();
		container.add(newNameField);
		container.add(addBtn);

		WFieldLayout layout = new WFieldLayout();
		add(layout);
		layout.addField("New contact name", container);
		add(new WAjaxControl(addBtn, new AjaxTarget[]{repeater, newNameField}));
	}
65628
function ReportSiteAction(Site $site, Enums\Action $action)
    {
        $logItem = $this->CreateLogItem(Enums\ObjectType::Site(), $action);       
        if (!$action->Equals(Enums\Action::Delete()))
        {
            $logSite = new LogSite();
            $logSite->SetLogItem($logItem);
            $logSite->SetSite($site);
            $logSite->Save();
        }
    }
1341395
def _set_data(self, action):
        
        if action == 'siteinfo':
            self._set_siteinfo()
        elif action == 'sitematrix':
            self._set_sitematrix()
        elif action == 'sitevisitors':
            self._set_sitevisitors()
690891
private void addServer(CmsSiteMatcher matcher, CmsSite site) {

        Map<CmsSiteMatcher, CmsSite> siteMatcherSites = new HashMap<CmsSiteMatcher, CmsSite>(m_siteMatcherSites);
        siteMatcherSites.put(matcher, site);
        setSiteMatcherSites(siteMatcherSites);
    }
1347619
public function actionAdd() 
	{
		$model=new OmmuPages;

		// Uncomment the following line if AJAX validation is needed
		$this->performAjaxValidation($model);

		if(isset($_POST['OmmuPages'])) {
			$model->attributes=$_POST['OmmuPages'];
			
			if($model->save()) {
				Yii::app()->user->setFlash('success', Yii::t('phrase', 'Pages success created.'));
				$this->redirect(array('manage'));
			}
		}

		$this->pageTitle = Yii::t('phrase', 'Add Page');
		$this->pageDescription = '';
		$this->pageMeta = '';
		$this->render('admin_add', array(
			'model'=>$model,
		));
	}
725050
function createSite() {
  function app(page) { app.handle(page); }
  mixin(app, EventEmitter.prototype, false);
  mixin(app, proto, false);
  app.init();
  return app;
}
1199746
private function generateNewPart(): void
    {
        if ($this->buffer) {
            $this->closeSitemap();
        }

        $this->bufferUrlCount = 0;
        $this->bufferSize = 0;
        ++$this->bufferPart;

        if (!is_writable($this->folder)) {
            throw new \RuntimeException(sprintf('Unable to write to folder: %s', $this->folder));
        }

        $filename = sprintf($this->pattern, $this->bufferPart);

        $this->buffer = fopen($this->folder.'/'.$filename, 'w');

        $this->bufferSize += fwrite($this->buffer, '<?xml version="1.0" encoding="UTF-8"?>'."\n".'<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'.$this->getHeaderByFlag().'>'."\n");
    }
550964
def site(self, action):
        
        query = None
        viewdays = 7
        hostpath = self.uri + self.endpoint

        if action == 'siteinfo':
            query = hostpath + (
                '?action=query'
                '&meta=siteinfo|siteviews'
                '&siprop=general|statistics'
                '&list=mostviewed&pvimlimit=max')
            query += '&pvisdays=%d' % viewdays  # meta=siteviews
            self.set_status('query', 'siteinfo|siteviews|mostviewed')
        elif action == 'sitematrix':
            query = hostpath + '?action=sitematrix'
            self.set_status('sitematrix', 'all')
        elif action == 'sitevisitors':
            query = hostpath + (
                '?action=query'
                '&meta=siteviews&pvismetric=uniques')
            query += '&pvisdays=%d' % viewdays  # meta=siteviews
            self.set_status('query', 'siteviews:uniques')

        if not query:
            raise ValueError("Could not form query")

        query += '&format=json&formatversion=2'

        return query
108412
public function submitForm(array &$form, FormStateInterface $form_state)
    {
        $node   = $form_state->getTemporaryValue('node');
        $action = $form_state->getValue('action');
        $siteId = $form_state->getValue('site');

        $options = [];
        if (isset($_GET['destination'])) {
            $options['query']['destination'] = $_GET['destination'];
            unset($_GET['destination']);
        }

        switch ($action) {

            case 'duplicate':
                list($path, $options) = $this->siteManager->getUrlGenerator()->getRouteAndParams($siteId, 'node/' . $node->id(). '/clone', $options);
                drupal_set_message($this->t("You can now edit this node on this site, it will be automatically duplicated."));
                break;

            default:
                $path = 'node/' . $node->id() . '/edit';
                drupal_set_message($this->t("You are now editing the global content for all sites."));
                break;
        }

        $form_state->setRedirect($path, $options);
    }
505848
private function AddSitemapActiveField()
    {
        $name = 'SitemapActive';
        $field = new Checkbox($name);
        if (!$this->site->Exists() || $this->site->GetSitemapActive())
        {
            $field->SetChecked();
        }
        $this->AddField($field);
    }