get page setup information from any section of a Word document.

$param string $filename.
$param string $sectionid.

@return Object of page setup information.
@throws Exception
336095
public function getPageSetup($sectionid = '')
    {
        if ($sectionid == '')
            throw new Exception('No Section Id specified');

        $strURI = Product::$baseProductUri . '/words/' . $this->getFileName() . '/sections/'.$sectionid.'/pageSetup';
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'GET','');

        $json = json_decode($responseStream);

        if ($json->Code == 200) {
            return $json->PageSetup;
        }
        
        AsposeApp::getLogger()->warning('Error occured, http 200 code was not found.', array(
            'json-code' => $json->Code,
        ));
        return false;
    }
735022
def sectionByID(self, sectionID):
        
        if not self._sectionsByID or sectionID not in self._sectionsByID:
            self.sections()
        return self._sectionsByID[sectionID]
492266
public static function get_page_contents($pageid) {

        $params = self::validate_parameters(self::get_page_contents_parameters(),
                                            array(
                                                'pageid' => $pageid
                                            )
            );
        $warnings = array();

        // Get wiki page.
        if (!$page = wiki_get_page($params['pageid'])) {
            throw new moodle_exception('incorrectpageid', 'wiki');
        }

        // Get wiki instance.
        if (!$wiki = wiki_get_wiki_from_pageid($params['pageid'])) {
            throw new moodle_exception('incorrectwikiid', 'wiki');
        }

        // Permission validation.
        $cm = get_coursemodule_from_instance('wiki', $wiki->id, $wiki->course);
        $context = context_module::instance($cm->id);
        self::validate_context($context);

        // Check if user can view this wiki.
        if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
            throw new moodle_exception('incorrectsubwikiid', 'wiki');
        }
        if (!wiki_user_can_view($subwiki, $wiki)) {
            throw new moodle_exception('cannotviewpage', 'wiki');
        }

        $returnedpage = array();
        $returnedpage['id'] = $page->id;
        $returnedpage['wikiid'] = $wiki->id;
        $returnedpage['subwikiid'] = $page->subwikiid;
        $returnedpage['groupid'] = $subwiki->groupid;
        $returnedpage['userid'] = $subwiki->userid;
        $returnedpage['title'] = $page->title;
        $returnedpage['tags'] = \core_tag\external\util::get_item_tags('mod_wiki', 'wiki_pages', $page->id);

        // Refresh page cached content if needed.
        if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
            if ($content = wiki_refresh_cachedcontent($page)) {
                $page = $content['page'];
            }
        }

        list($returnedpage['cachedcontent'], $returnedpage['contentformat']) = external_format_text(
                            $page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
        $returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);

        // Get page version.
        $version = wiki_get_current_version($page->id);
        if (!empty($version)) {
            $returnedpage['version'] = $version->version;
        }

        $result = array();
        $result['page'] = $returnedpage;
        $result['warnings'] = $warnings;
        return $result;
    }
769101
public Element getById(Element id, String childName) throws Exception {
	  return getById(doc.getDocumentElement(), id, childName);
  }
337938
protected static function createDocumentWrapper($html, $contentType = null, $documentID = null) 
    {
        if (function_exists('domxml_open_mem')) {
            throw new Exception("Old PHP4 DOM XML extension detected. phpQuery won't work until this extension is enabled.");
        }
        //        $id = $documentID
        //            ? $documentID
        //            : md5(microtime());
        $document = null;
        if ($html instanceof DOMDOCUMENT) {
            if (self::getDocumentID($html)) {
                // document already exists in phpQuery::$documents, make a copy
                $document = clone $html;
            } else {
                // new document, add it to phpQuery::$documents
                $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID);
            }
        } else {
            $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID);
        }
        //        $wrapper->id = $id;
        // bind document
        phpQuery::$documents[$wrapper->id] = $wrapper;
        // remember last loaded document
        phpQuery::selectDocument($wrapper->id);
        return $wrapper->id;
    }
95946
public function getFileContent($fileName)
    {
        $result = $this->zip->getFromName($fileName);
        if ($result === false)
            throw new Exception('Could not get file information: '.$result);
        return $result;
    }
680260
public function getPage()
    {
        if (null === $this->site || null === $this->layout || null === $this->title) {
            $this->reset();
            throw new \Exception("Required data missing");
        }

        $page = new Page($this->uid);
        $page->setTitle($this->title);
        $page->setSite($this->site);

        if (null !== $this->parent) {
            $page->setParent($this->insureParentIsSection($this->parent));
        }

        $page->setLayout($this->layout, $this->itemToPushInMainZone);

        if (null !== $this->url) {
            $page->setUrl($this->url);
        }

        if (null !== $this->redirect) {
            $page->setRedirect($this->redirect);
        }

        if (null !== $this->target) {
            $page->setTarget($this->target);
        }

        if (null !== $this->altTitle) {
            $page->setAltTitle($this->altTitle);
        }

        if (null !== $this->state) {
            $page->setState($this->state);
        }

        if (null !== $this->publishedAt) {
            $page->setPublishing($this->publishedAt);
        }

        if (null !== $this->createdAt) {
            $page->setCreated($this->createdAt);
        }

        if (null !== $this->archiving) {
            $page->setArchiving($this->archiving);
        }

        $pageContentSet = $page->getContentSet();
        $this->updateContentRevision($pageContentSet);
        while ($column = $pageContentSet->next()) {
            $this->updateContentRevision($column);
        }

        if (0 < count($this->elements)) {
            foreach ($this->elements as $e) {
                $column = $pageContentSet->item($e['content_set_position']);
                if ($e['set_main_node']) {
                    $e['content']->setMainNode($page);
                }

                $column->push($e['content']);
            }

            $pageContentSet->rewind();
        }

        $this->doPersistIfValid($page);

        $this->reset();

        return $page;
    }
229449
public function getUrl()
	{
		throw new \Exception('Dont use me bro.');

		$url = null;

		switch ($this->getResource()) {

			case self::RESOURCE_PAGE:
				$pageData = $this->getPage();

				if ( ! is_null($pageData)) {
					$url = $this->getPageFullPath($pageData);
				}
				break;

			case self::RESOURCE_FILE:
				$file = $this->getFile();

				if ($file instanceof File) {
					$fs = ObjectRepository::getFileStorage($this);
					$url = $fs->getWebPath($file);
				}

				break;

			case self::RESOURCE_LINK:
			case self::RESOURCE_EMAIL:
				$url = $this->getHref();
				break;

//			case self::RESOURCE_RELATIVE_PAGE:
//				$page = $this->getPage();
//
//				if (is_null($page)) {
//					$this->log()->warn("No page ID set or found for relative link #", $this->getId());
//					throw new ResourceNotFoundException("Invalid redirect");
//				}
//
//				$pageChildren = $page->getPublicChildren();
//
//				if ( ! $pageChildren->isEmpty()) {
//					$type = $this->getHref();
//					$relativeChild = null;
//
//					if ($type == self::RELATIVE_FIRST) {
//						$relativeChild = $pageChildren->first();
//					} else {
//						$relativeChild = $pageChildren->last();
//					}
//
//					$url = $this->getPageFullPath($relativeChild);
//				} else {
//					//throw new ResourceNotFoundException('Valid relative redirect child was not found');
//					return null;
//				}
//				break;

			default:
				$this->log()->warn("Unrecognized resource for supra html markup link tag, data: $this");
		}

		return $url;
	}
242655
public function getSection($sectionName)
    {
        if (!$this->hasSection($sectionName))
        {
            throw new InvalidDataException(sprintf('Section "%s" does not exists!', $sectionName));
        }

        return $this->sections[$sectionName];
    }
298548
public GetDocumentResponse getDocument(String documentId) {
        GetDocumentRequest request = new GetDocumentRequest();
        request.setDocumentId(documentId);
        return this.getDocument(request);
    }
277594
public function assignSectionToContent($sectionId, $contentId)
    {
        try {
            return $this->innerGateway->assignSectionToContent($sectionId, $contentId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
703619
private void fetchByTitle(Title pTitle, boolean useExactTitle)
		throws WikiApiException
	{
		String searchString = pTitle.getPlainTitle();
		if (!useExactTitle) {
		    searchString = pTitle.getWikiStyleTitle();
		}

		Session session;
		session = this.wiki.__getHibernateSession();
		session.beginTransaction();
		Integer pageId = (Integer) session
				.createNativeQuery(
						"select pml.pageID from PageMapLine as pml where pml.name = :pagetitle LIMIT 1")
				.setParameter("pagetitle", searchString, StringType.INSTANCE).uniqueResult();
		session.getTransaction().commit();

        if (pageId == null) {
			throw new WikiPageNotFoundException("No page with name " + searchString + " was found.");
		}
		fetchByPageId(pageId);
        if (!this.isRedirect&&searchString != null&&!searchString.equals(getTitle().getRawTitleText())) {
                if(this.isRedirect){
                	//in case we already tried to re-retrieve the discussion page unsuccessfully,
                	//we have to give up here or we end up in an infinite loop.
                	
                	//reasons for this happening might be several entries in PageMapLine with the same name but different upper/lower case variants
                	//if the database does not allow case sensitive queries, then the API will always retrieve only the first result and if this is a redirect to a different writing variant, we are stuck in a loop.
                	//To fix this, either a case sensitive collation should be used or the API should be able to deal with set valued results and pick the correct one from the set.
                	//For now, we gracefully return without retrieving the Talk page for this article and throw an appropriate excption.
        			throw new WikiPageNotFoundException("No discussion page with name " + searchString + " could be retrieved. This is most likely due to multiple writing variants of the same page in the database");                	
                }else{
            		this.isRedirect = true;
                    /*
                     * WORKAROUND
                     * in our page is a redirect to a discussion page, we might not retrieve the target discussion page as expected but rather the article associated with the target discussion page
                     * we check this here and re-retrieve the correct page.
                     * this error should be avoided by keeping the namespace information in the database
                     * This fix has been provided by Shiri Dori-Hacohen and is discussed in the Google Group under https://groups.google.com/forum/#!topic/jwpl/2nlr55yp87I/discussion
                     */
                    if (searchString.startsWith(DISCUSSION_PREFIX) && !getTitle().getRawTitleText().startsWith(DISCUSSION_PREFIX)) {
                    	try {
                    		fetchByTitle(new Title(DISCUSSION_PREFIX + getTitle().getRawTitleText()), useExactTitle);
                    	} catch (WikiPageNotFoundException e) {
                    		throw new WikiPageNotFoundException("No page with name " + DISCUSSION_PREFIX + getTitle().getRawTitleText() + " was found.");
                    	}
                    }                	
                }
        }
	}
1170868
public function resolve_language_url($currentPageID, $sectionID)
    {
        $resolve = ['/'];
        $lang = Section::getByID((int) $sectionID);
        if (is_object($lang)) {
            $resolve = [$lang];
            $page = \Page::getByID((int) $currentPageID);
            if (!$page->isError()) {
                $relatedID = $lang->getTranslatedPageID($page);
                if ($relatedID) {
                    $pc = \Page::getByID($relatedID);
                    $resolve = [$pc];
                } elseif ($page->isGeneratedCollection()) {
                    $this->app->make('session')->set('multilingual_default_locale', $lang->getLocale());
                    $resolve = [$page];
                }
            }
        }

        return $this->app->make(ResolverManagerInterface::class)->resolve($resolve);
    }
1351837
public function getPagesWordCount()
    {
        try {
            $strURI = Product::$baseProductUri . "/pdf/" . $this->getFileName() . "/pages/wordCount";

            $signedURI = Utils::sign($strURI);

            $responseStream = Utils::processCommand($signedURI, "GET", "", "");

            $json = json_decode($responseStream);

            return $json->WordsPerPage->List;

        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }
493700
public int getDocId(String url) {
        synchronized (mutex) {
            OperationStatus result = null;
            DatabaseEntry value = new DatabaseEntry();
            try {
                DatabaseEntry key = new DatabaseEntry(url.getBytes());
                result = docIDsDB.get(null, key, value, null);

            } catch (RuntimeException e) {
                if (config.isHaltOnError()) {
                    throw e;
                } else {
                    logger.error("Exception thrown while getting DocID", e);
                    return -1;
                }
            }

            if ((result == OperationStatus.SUCCESS) && (value.getData().length > 0)) {
                return Util.byteArray2Int(value.getData());
            }

            return -1;
        }
    }
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;
    }
111088
public GetDocumentDownloadResponse getDocumentDownload(String documentId) {
        checkNotNull(documentId, "documentId should not be null.");
        GetDocumentDownloadRequest request = new GetDocumentDownloadRequest();
        request.setDocumentId(documentId);
        InternalRequest internalRequest = this.createRequest(HttpMethodName.GET, request, DOC, request.getDocumentId());
        internalRequest.addParameter("download", null);
        GetDocumentDownloadResponse response;
        try {
            response = this.invokeHttpClient(internalRequest, GetDocumentDownloadResponse.class);
        } finally {
            try {
                internalRequest.getContent().close();
            } catch (Exception e) {
                // ignore exception
            }
        }

        return response;
    }