/*!
Insert front page
325693
function insertFrontpage( $params, $text )
    {
        $this->saveState();
        $closeObject = false;
        if ( $this->FrontpageID == null )
        {
            $this->ezInsertMode(1,1,'before');
            $this->ezNewPage();
            $this->FrontpageID = $this->currentPage;
        }
        else if( $this->currentPage != $this->FrontpageID )
        {
            $this->reopenObject( $this->FrontpageID );
            $closeObject = true;
        }

        $fontSize = $this->fontSize();

        $text = $this->fixWhitespace( $text );
        $this->setXOffset( 0 );

        Cezpdf::ezText( $text, $params['size'], array( 'justification' => $params['justification'],
                                                       'top_margin' => $params['top_margin'] ) );

        $this->setFontSize( $fontSize );

        if ( $closeObject )
        {
            $this->closeObject();
        }
        $this->restoreState();
    }
1296901
function launchAddInclude(evSrc) {

        var pageId = evSrc.getAttribute('data-target-page-id');
        var region = evSrc.getAttribute('data-target-region');
        
        window.parent.postMessage({
            name: 'add-include',
            pageId: pageId,
            regionName: region
        }, window.location.origin);
    }
1335489
def insert(self, i, tab_index):
        """"""
        _id = id(self.editor.tabs.widget(tab_index))
        self.history.insert(i, _id)
809069
function ezInsertMode( $status = 1, $pageNum = 1, $pos = 'before' )
    {
        // puts the document into insert mode. new pages are inserted until this is re-called with status=0
        // by default pages wil be inserted at the start of the document
        switch ( $status )
        {
            case '1':
                if ( isset( $this->ezPages[$pageNum] ) )
                {
                    $this->ez['insertMode'] = 1;
                    $this->ez['insertOptions'] = array( 'id' => $this->ezPages[$pageNum],
                                                        'pos' => $pos );
                } break;
            case '0':
                $this->ez['insertMode'] = 0;
                break;
        }
    }
1116882
function add ($title, $text, $menu, $footer, $lang, $id=null)
    {
        global $config;
        $this->title=$title;
        $this->content=$text;
        if (isset($id)) {
            $query = sprintf(
                file_get_contents("sql/addPageID.sql"),
                mysql_real_escape_string($title),
                mysql_real_escape_string($text), mysql_real_escape_string($menu),
                mysql_real_escape_string($footer), $lang, $id
            );
        } else {
            $query = sprintf(
                file_get_contents("sql/addPage.sql"),
                mysql_real_escape_string($title),
                mysql_real_escape_string($text), mysql_real_escape_string($menu),
                mysql_real_escape_string($footer), $lang
            );
        }
        $config->connexionBdd->requete($query);
    }
841560
private function insert()
    {
        Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '()');

        $plugins = Eresus_Plugin_Registry::getInstance();
        $files = arg('files');
        if ($files && is_array($files))
        {
            foreach ($files as $plugin => $install)
            {
                if ($install)
                {
                    try
                    {
                        $plugins->install($plugin);
                    }
                    catch (DomainException $e)
                    {
                        Eresus_Kernel::app()->getPage()->addErrorMessage($e->getMessage());
                    }
                }
            }

        }
        HttpResponse::redirect('admin.php?mod=plgmgr');
    }
9679
function renderPrev($tag = '&lt;&lt;') {
        if ($this->total_rows == 0)
            return FALSE;
         
        if ($this->page > 1) {
            //return ' <a href="' . $this->php_self . '?page=' . ($this->page - 1) . '&' . $this->append . '">' . $tag . '</a>';
            $pageno = $this->page - 1;
            return " <a href='javascript:void(0);' OnClick='getdata( $pageno )' title='Anterior'>$tag</a> ";
        } else {
            return " $tag ";
        }
    }
330118
public function front()
    {
        $pageId        = isset($this->pluginFrontConfig['pageIdFolder']) ? $this->pluginFrontConfig['pageIdFolder'] : 1;
        $listofpages   = [];
        $viewVariables = [];

        if($pageId) {

            // Getting the Subpages from MelisFrontNavigator
            $treeSrv = $this->getServiceLocator()->get('MelisEngineTree');
            $pages = $treeSrv->getPageChildren($pageId, 1);

            foreach ($pages as $key => $val)
            {
                /**
                 * Page content has a values of XML type
                 * so need to parse to make the content of the page easy to manage
                 *
                 * $xmlValues will handle the result of parsing
                 * this will return array
                 */
                $parser = xml_parser_create();
                xml_parse_into_struct($parser, $val->page_content, $xmlValues);
                xml_parser_free($parser);

                // This process will get only the Page content with the tags of MELISTAGS and has a Tag Id
                $pageContent = array();

                foreach ($xmlValues as $xKey => $xVal)
                {
                    if ($xVal['tag'] = 'MELISTAG')
                    {
                        if (!empty($xVal['attributes']['ID']))
                        {
                            if (!empty($xVal['value'])) {
                                // Adding the content tag using the tag Id with its value
                                $pageContent[$xVal['attributes']['ID']] = $xVal['value'];
                            }
                        }
                    }
                }

                $val->page_tags = $pageContent;

                array_push($listofpages, $val);
            }

            // Create an array with the variables that will be available in the view
            $viewVariables = array(
                'pageIdFolder' => $pageId,
                'pluginId' => $this->pluginFrontConfig['id'],
                'listofpages' => $listofpages
            );

        }

        // return the variable array and let the view be created
        return $viewVariables;
    }
1130195
function newPage($insert = 0, $id = 0, $pos = 'after')
    {
        // if there is a state saved, then go up the stack closing them
        // then on the new page, re-open them with the right setings

        if ($this->nStateStack) {
            for ($i = $this->nStateStack; $i >= 1; $i--) {
                $this->restoreState($i);
            }
        }

        $this->numObj++;

        if ($insert) {
            // the id from the ezPdf class is the id of the contents of the page, not the page object itself
            // query that object to find the parent
            $rid = $this->objects[$id]['onPage'];
            $opt = array('rid' => $rid, 'pos' => $pos);
            $this->o_page($this->numObj, 'new', $opt);
        } else {
            $this->o_page($this->numObj, 'new');
        }

        // if there is a stack saved, then put that onto the page
        if ($this->nStateStack) {
            for ($i = 1; $i <= $this->nStateStack; $i++) {
                $this->saveState($i);
            }
        }

        // and if there has been a stroke or fill color set, then transfer them
        if (isset($this->currentColor)) {
            $this->setColor($this->currentColor, true);
        }

        if (isset($this->currentStrokeColor)) {
            $this->setStrokeColor($this->currentStrokeColor, true);
        }

        // if there is a line style set, then put this in too
        if (mb_strlen($this->currentLineStyle, '8bit')) {
            $this->addContent("\n$this->currentLineStyle");
        }

        // the call to the o_page object set currentContents to the present page, so this can be returned as the page id
        return $this->currentContents;
    }
1176261
function insertTextScript(text) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.text = text;
    insertHeaderNode(script);
    return script;
}
1051134
function startTagBeforeHtml(p, token) {
    if (token.tagName === $.HTML) {
        p._insertElement(token, NS.HTML);
        p.insertionMode = BEFORE_HEAD_MODE;
    }

    else
        tokenBeforeHtml(p, token);
}
73499
public function onOutputFrontendTemplate($buffer)
    {
        if (null !== ($rootPage = PageModel::findByPk($GLOBALS['objPage']->rootId)) && $rootPage->cookiebar_enable) {
            $generator = new CookiebarGenerator();
            $cookiebar = $generator->createTemplate($rootPage->row())->parse();

            if ('before_wrapper' === $rootPage->cookiebar_placement) {
                $buffer = str_replace('<div id="wrapper">', $cookiebar.'<div id="wrapper">', $buffer);
            } else {
                $buffer = str_replace('</body>', $cookiebar.'</body>', $buffer);
            }
        }

        return $buffer;
    }
185774
function insertArticle(summary, article, level) {
    article = SummaryArticle(article);
    level = is.string(level)? level : level.getLevel();

    var parent = summary.getParent(level);
    if (!parent) {
        return summary;
    }

    // Find the index to insert at
    var articles = parent.getArticles();
    var index = getLeafIndex(level);

    // Insert the article at the right index
    articles = articles.insert(index, article);

    // Reindex the level from here
    parent = parent.set('articles', articles);
    parent = indexArticleLevels(parent);

    return mergeAtLevel(summary, parent.getLevel(), parent);
}
316937
function Render_First($anchor=true)
	{
	global $PHP_SELF;
		if ($anchor) {
	?>
		<a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a> &nbsp;
	<?php
		} else {
			print "$this->first &nbsp; ";
		}
	}
122616
public function boot() {

		// Filter the front page template.
		add_filter( 'frontpage_template_hierarchy',  [ $this, 'frontPage' ], 5 );

		// Filter the single, page, and attachment templates.
		add_filter( 'single_template_hierarchy',     [ $this, 'single' ], 5 );
		add_filter( 'page_template_hierarchy',       [ $this, 'single' ], 5 );
		add_filter( 'attachment_template_hierarchy', [ $this, 'single' ], 5 );

		// Filter taxonomy templates.
		add_filter( 'taxonomy_template_hierarchy', [ $this, 'taxonomy' ], 5 );
		add_filter( 'category_template_hierarchy', [ $this, 'taxonomy' ], 5 );
		add_filter( 'tag_template_hierarchy',      [ $this, 'taxonomy' ], 5 );

		// Filter the author template.
		add_filter( 'author_template_hierarchy', [ $this, 'author' ], 5 );

		// Filter the date template.
		add_filter( 'date_template_hierarchy', [ $this, 'date' ], 5 );

		// System for capturing the template hierarchy.
		foreach ( $this->types as $type ) {

			// Capture the template hierarchy for each type.
			add_filter( "{$type}_template_hierarchy", [ $this, 'templateHierarchy' ], PHP_INT_MAX );

			// Capture the located template.
			add_filter( "{$type}_template", [ $this, 'template' ], PHP_INT_MAX );
		}

		// Re-add the located template.
		add_filter( 'template_include', [ $this, 'templateInclude' ], PHP_INT_MAX );
	}
213624
function create()
    {
        $content = $this->loadContentTypes();
        $templates = $this->loadTemplates();
        restoreRequest();
        $form = array (
            'name' => 'createPage',
            'caption' => strAdd,
            'width' => '600px',
            'fields' => array (
                array ('type' => 'hidden','name'=>'owner','value'=>arg('owner', 'int')),
                array ('type' => 'hidden','name'=>'action', 'value'=>'insert'),
                array ('type' => 'edit','name' => 'name','label' => admPagesName,'width' => '150px',
                    'maxlength' => '32', 'pattern'=>'/^[a-z0-9_]+$/i', 'errormsg'=>admPagesNameInvalid),
                array ('type' => 'edit','name' => 'title','label' => admPagesTitle,'width' => '100%',
                    'pattern'=>'/.+/', 'errormsg'=>admPagesTitleInvalid),
                array ('type' => 'edit','name' => 'caption','label' => admPagesCaption,'width' => '100%',
                    'maxlength' => '64', 'pattern'=>'/.+/', 'errormsg'=>admPagesCaptionInvalid),
                array ('type' => 'edit','name' => 'hint','label' => admPagesHint,'width' => '100%'),
                array ('type' => 'edit','name' => 'description','label' => admPagesDescription,
                    'width' => '100%'),
                array ('type' => 'edit','name' => 'keywords','label' => admPagesKeywords,'width' => '100%'),
                array ('type' => 'select','name' => 'template','label' => admPagesTemplate,
                    'items' => $templates[0], 'values' => $templates[1], 'default'=>pageTemplateDefault),
                array ('type' => 'select','name' => 'type','label' => admPagesContentType,
                    'items' => $content[0], 'values' => $content[1], 'default'=>contentTypeDefault),
                array ('type' => 'checkbox','name' => 'active','label' => admPagesActive, 'default'=>true),
                array ('type' => 'checkbox','name' => 'visible','label' => admPagesVisible,
                    'default'=>true),
                array ('type' => 'select','name' => 'access','label' => admAccessLevel,'access' => ADMIN,
                    'values'=>array(ADMIN,EDITOR,USER,GUEST),
                    'items' => array (ACCESSLEVEL2,ACCESSLEVEL3,ACCESSLEVEL4,ACCESSLEVEL5),
                    'default' => GUEST),
                array ('type' => 'edit','name' => 'position','label' => admPosition,'access' => ADMIN,
                    'width' => '4em','maxlength' => '5'),
                array ('type' => 'memo','name' => 'options','label' => admPagesOptions,'height' => '5')
            ),
            'buttons' => array('ok', 'cancel'),
        );

        /** @var TAdminUI $page */
        $page = Eresus_Kernel::app()->getPage();
        $result = $page->renderForm($form, Eresus_CMS::getLegacyKernel()->request['arg']);
        return $result;
    }
524213
function _insertInList($list, $element, position, $relativeElement) {
        // Determine where to insert. Default is LAST.
        var inserted = false;
        if (position) {

            // Adjust relative position for menu section positions since $relativeElement
            // has already been resolved by _getRelativeMenuItem() to a menuItem
            if (position === FIRST_IN_SECTION) {
                position = BEFORE;
            } else if (position === LAST_IN_SECTION) {
                position = AFTER;
            }

            if (position === FIRST) {
                $list.prepend($element);
                inserted = true;
            } else if ($relativeElement && $relativeElement.length > 0) {
                if (position === AFTER) {
                    $relativeElement.after($element);
                    inserted = true;
                } else if (position === BEFORE) {
                    $relativeElement.before($element);
                    inserted = true;
                }
            }
        }

        // Default to LAST
        if (!inserted) {
            $list.append($element);
        }
    }