Deliver the admin navigation bar via ajax.

@param null $page_id

@return Response
346720
public function adminNavbarAction(Request $request, $page_id = null)
    {
        if ($page_id) {

            /** @var \Networking\InitCmsBundle\Entity\PageManager $pageManager */
            $pageManager = $this->container->get('networking_init_cms.page_manager');
            $page = $pageManager->find($page_id);
            $request->attributes->set('_content', $page);
        }
        $response = $this->render(
            '@NetworkingInitCms/Admin/esi_admin_navbar.html.twig',
            ['admin_pool' => $this->getAdminPool()]
        );

        // set the shared max age - which also marks the response as public
        $response->setSharedMaxAge(10);

        return $response;
    }
269075
public static function getChildPagesCount($page_id = null)
    {
        if (is_null($page_id)) {
            return null;
        }

        $children = PageManager::fetch(false, array('id'), array(
            sprintf('parent = %d', $page_id)
        ));
        $count = count($children);

        if ($count > 0) {
            foreach ($children as $c) {
                $count += self::getChildPagesCount($c['id']);
            }
        }

        return $count;
    }
1245721
protected function getAdminPageHook() {
		global $pagenow, $typenow, $plugin_page;

		$page_hook = '';
		if ( isset( $plugin_page ) ) {
			if ( ! empty( $typenow ) ) {
				$the_parent = $pagenow . '?post_type=' . $typenow;
			} else {
				$the_parent = $pagenow;
			}

			$page_hook = get_plugin_page_hook( $plugin_page, $the_parent );
		}

		return $page_hook;
	}
247424
private void doUpdateDevelopMode() throws PageException {

	admin.updateMode(getBoolObject("admin", action, "mode"));
	store();
	adminSync.broadcast(attributes, config);
    }
1168464
public function actionView ($id)
		{
			$page = Page::find()->where([ 'id' => $id ])->orWhere([ 'guid' => $id ])->one();
			if ($page === null)
			{
				Yii::$app->notification->errorToSession(Yii::tr('Given page does not exist.', [], 'page'));
				$this->redirect(Url::toRoute([ '/page/index' ]));
			}
			$this->setTitle(Yii::tr('View page', [], 'page'));
			$this->data('page', $page);
			$this->data('useMenu', $this->module->useMenu);
			$this->_tpl = '@pageViews/view';
		}
34453
public function getPageLayout($pageId, $pageThemeId = null)
    {
        $sections = $templateSections = [];
        $error    = '';
        $details  = [];

        /** @var $pageModel \PageBuilder\Model\PageModel */
        $pageModel = $this->getServiceLocator()->get('pagebuilder\model\page');

        /** @var $themeModel \PageBuilder\Model\BaseModel */
        $themeModel = $this->getServiceLocator()->get('pagebuilder\model\theme');

        /** @var $templateModel \PageBuilder\Model\BaseModel */
        $templateModel = $this->getServiceLocator()->get('pagebuilder\model\template');

        /** @var $page \PageBuilder\Entity\Page */
        if ($page = $pageModel->getRepository()->find($pageId)) {

            $details = [
                'id'          => $page->getId(),
                'title'       => $page->getTitle(),
                'description' => $page->getDescription(),
                'template'    => $page->getTemplate() ? $page->getTemplate()->getTitle() : '',
                'layout'      => '',
                'pageTheme'   => '',
                'themeId'     => '',
                'layoutType'  => 'Custom Layout',
                'parent'      => $page->getParent() ? $page->getParent()->getTitle() : '',

            ];
        }
        $themeId = $pageTheme = null;
        if ($pageThemeId) {
            /** @var $pageThemeModel \PageBuilder\Model\BaseModel */
            $pageThemeModel = $this->getServiceLocator()->get('pagebuilder\model\pageTheme');
            $pageTheme      = $pageThemeModel->findObject($pageThemeId);
            $themeId        = $pageTheme->getId();
        }

        if ($themeId and $pageTheme) {
            $details['themeId'] = $themeId;

            $details['layout']    = $pageTheme->getLayout();
            $details['pageTheme'] = $pageTheme->getId();

            /** @var $temp \PageBuilder\Entity\Template */
            if ($temp = $page->getTemplate()) {
                $sections = $temp->getTemplateSections()->toArray();
            } elseif ($temp = $page->getParent()->getTemplate()) {
                $sections = $temp->getTemplateSections()->toArray();
            }
        }
        /** @var $section \PageBuilder\Entity\Join\TemplateSection */
        foreach ($sections as $section) {
            $slug                    = $section->getSectionId()->getSlug();
            $templateSections[$slug] = [
                'title'  => $section->getSectionId()->getTitle(),
                'status' => $section->getIsActive() ? 1 : 0,
                'class'  => $section->getIsActive() ? '' : 'in-active',
            ];
        }

        if ($themeData = $themeModel->getRepository()->findAll()) {
            /** @var $theme \PageBuilder\Entity\Theme */
            foreach ($themeData as $theme) {
                $details['themes'][$theme->getId()] = $theme->toArray();
            }
        } else {
            $details['themes'] = [];
        }

        /** @var $templateModel \PageBuilder\Model\TemplateModel */
        $templates  = $templateModel->listTemplates();
        $components = $this->getServiceLocator()->get('pagebuilder\model\component')->listItemsByTitle();

        /** @var $widgetUtil \PageBuilder\Util\Widget */
        $widgetUtil = $this->getServiceLocator()->get('util\widget');

        $widgetList = $widgetUtil->getWidgetList();
        $urlHelper  = $this->getServiceLocator()->get('ViewHelperManager')->get('url');

        $return = [
            'error'     => $error,
            'page'      => $details,
            'editUrl'   => $pageThemeId
                ? $urlHelper('builder\theme', ['id' => $pageThemeId])
                : $urlHelper(
                    'builder', ['id' => $pageId]
                ),
            'sections'  => $templateSections,
            'title'     => 'Layout Manager - ' . ($page ? $page->getTitle() : ''),
            'widgets'   => [
                'title' => 'Widgets',
                'items' => $widgetUtil->getRegistry(),
                'total' => count($widgetUtil->getRegistry()),
                'list'  => $widgetList,
                'id'    => PageBuilder::LAYOUT_WIDGET,
            ],
            'assets'    => [
                PageBuilder::LAYOUT_USER_DEFINED => [
                    'title' => 'User Defined',
                    'items' => $components,
                ],
            ],
            'templates' => [
                'title' => 'Templates',
                'items' => $templates,
            ],
            'tags'      => $this->_getTaglist(),
        ];

        return $return;
    }
968020
public function postAdmin(Request $request, Page $page)
    {
        $this->authorize('editAdmin', $page);

        $page
            ->setInternalName($request->input('internal_name'))
            ->setAddPageBehaviour($request->input('add_behaviour'))
            ->setChildAddPageBehaviour($request->input('child_add_behaviour'))
            ->setDisableDelete($request->has('disable_delete'));

        PageFacade::save($page);
    }
1016946
public function retrieveEmployeeRole($role_id)
    {
        list($response, $statusCode, $httpHeader) = $this->retrieveEmployeeRoleWithHttpInfo ($role_id);
        return $response; 
    }
434799
public function __async_priority($navID = 0, $direction = 1, $parentId = 0)
    {
        /** @var CMSNav $data */
        $data = null;
        $response = array('status' => 0);

        if (dbQuery('\samson\cms\web\navigation\CMSNav')->id($navID)->first($data)) {
            $data->priority($direction);
            $response['status'] = 1;
        }

        // return Ajax response
        return $this->__async_tree($parentId);
    }
751356
public function resolvePageLayout($pageId, $themeId = null)
    {
        /** @var $site \PageBuilder\Entity\Site */
        /** @var $parent \PageBuilder\Entity\Page */
        /** @var $page \PageBuilder\Entity\Page */
        /** @var $templateObj \PageBuilder\Entity\Template */
        /** @var PageModel $pageModel */

        $layout    = [];
        $pageModel = $this->getServiceLocator()->get('pagebuilder\model\page');
        $page      = $pageModel->getMainPageById($pageId);

        if ($page['layout']) {
            return $page['layout'];
        } elseif ($page['parentId']) {
            $parentPage = $pageModel->getMainPageById($page['parentId']);
            if ($parentPage['layout']) {
                return $parentPage['layout'];
            }
        }

        if (is_object($page) and $templateObj = $page->getTemplate()) {
            if ($layout = $templateObj->getLayout()) {
                return $layout;
            }
        }

        //get the sites default template's layout
        if ($site = $this->getServiceLocator()->get('active\site')) {
            if ($templateObj = $site->getDefaultTemplate()) {
                return $templateObj->getLayout();
            }
        }

        return $layout;
    }
1332551
public function actionManage($page=null) 
	{
		$pageTitle = Yii::t('phrase', 'Page Views');
		if($page != null) {
			$data = OmmuPages::model()->findByPk($page);
			$pageTitle = Yii::t('phrase', 'Page Views: $page_title', array ('$page_title'=>$data->title->message));
		}
		
		$model=new OmmuPageViews('search');
		$model->unsetAttributes();	// clear any default values
		if(isset($_GET['OmmuPageViews'])) {
			$model->attributes=$_GET['OmmuPageViews'];
		}

		$columns = $model->getGridColumn($this->gridColumnTemp());

		$this->pageTitle = $pageTitle;
		$this->pageDescription = '';
		$this->pageMeta = '';
		$this->render('admin_manage', array(
			'model'=>$model,
			'columns' => $columns,
		));
	}
518386
public function listByPageAction($page_id) {
        $em = $this->getDoctrine()->getManager();

        $entities = $em->getRepository('FlowcodePageBundle:Block')->findBy(array("page" => $page_id));
        $page = $em->getRepository('FlowcodePageBundle:Page')->find($page_id);

        return array(
            'page' => $page,
            'entities' => $entities,
        );
    }
967565
protected function updatePost( $post_id, $status ) {

		$post = get_post( $post_id, 'ARRAY_A' );
		if ( empty( $post ) ) {
			return;
		}

		global $wpdb;
		$menu_order = $wpdb->get_var(
			$wpdb->prepare(
				"SELECT MAX(menu_order) FROM {$wpdb->posts} WHERE post_type = %s AND post_parent = %d AND ID != %d ",
				$post['post_type'],
				$post['post_parent'],
				$post_id
			)
		);
		if ( $menu_order !== null ) {
			$post['menu_order'] = $menu_order + 1;
		}

		$post['post_status'] = $status;

		wp_update_post( $post );
	}
333133
public function findOrganizationPage($organizationId, $pageId)
    {
        list($response) = $this->findOrganizationPageWithHttpInfo($organizationId, $pageId);
        return $response;
    }
132681
public function getLastVersion($page_id)
	{
		$qb = $this->createQueryBuilder('p');
		
		$qb->where('p.original=:page_id')
			->orderBy('p.createdAt', 'DESC')
			->setParameter(':page_id', $page_id);
		
		$result = $qb->getQuery()->setMaxResults(1)->getResult();

		if ( is_null($result) ) {
			$qb2 = $this->createQueryBuilder('p');
			$qb2->where('p.id=:page_id')->setParameter(':page_id', $page_id);
			
			$result = $qb->getQuery()->getResult();
		}
		
		return $result[0];
	}
963542
public function revoke_admin($admin_id)
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $payload  = ['cmd' => 'revoke-admin', 'admin' => $admin_id];
        $response = $this->exec_curl('/api/s/' . $this->site . '/cmd/sitemgr', $payload);

        return $this->process_response_boolean($response);
    }
350701
protected function setPage($page_id)
    {
        $this->data_page = $this->page->get($page_id);

        if (empty($this->data_page)) {
            $this->outputHttpStatus(404);
        }

        $this->controlAccessPage();
        $this->preparePage($this->data_page);
    }