Exemplo n.º 1
0
 /**
  * @test Profiler::In
  * @test Profiler::Out
  *
  * @since 1.9
  */
 public function testInOut()
 {
     Profiler::reset();
     $this->assertInstanceOf('\\ProfilerStub', Profiler::In('Lala'));
     $this->assertInstanceOf('\\ProfilerStub', Profiler::Out('Lala'));
     $this->assertInstanceOf('\\ProfilerStub', Profiler::In('Lila', true));
     $this->assertInstanceOf('\\ProfilerStub', Profiler::Out('Lila', true));
 }
Exemplo n.º 2
0
 /**
  * @see SpecialPage::execute
  */
 public function execute($param)
 {
     Profiler::In(__METHOD__);
     $out = $this->getOutput();
     $out->setPageTitle($this->msg('properties')->text());
     $page = new PropertiesQueryPage($this->getStore(), $this->getSettings());
     $page->setContext($this->getContext());
     list($limit, $offset) = $this->getLimitOffset();
     $page->doQuery($offset, $limit, $this->getRequest()->getVal('property'));
     // Ensure locally collected output data is pushed to the output!
     SMWOutputs::commitToOutputPage($out);
     Profiler::Out(__METHOD__);
 }
Exemplo n.º 3
0
 /**
  * Prepare and update the OutputPage property
  *
  * Factbox content is either retrived from a CacheStore or re-parsed from
  * the Factbox object
  *
  * Altered content is tracked using the revision Id, getLatestRevID() only
  * changes after a content modification has occurred.
  *
  * Cached content is stored in an associative array following:
  * { 'revId' => $revisionId, 'text' => (...) }
  *
  * @since 1.9
  *
  * @param ParserOutput $parserOutput
  */
 public function process(ParserOutput $parserOutput)
 {
     Profiler::In(__METHOD__);
     $title = $this->outputPage->getTitle();
     $revId = $this->getRevisionId($title);
     $resultMapper = $this->newResultMapper($title->getArticleID());
     $content = $resultMapper->fetchFromCache();
     if ($this->cacheIsAvailableFor($revId, $content)) {
         $this->isCached = true;
         $this->outputPage->mSMWFactboxText = $content['text'];
     } else {
         $this->isCached = false;
         $text = $this->rebuild($title, $parserOutput, $this->outputPage->getContext());
         $resultMapper->recache(array('revId' => $revId, 'text' => $text));
         $this->outputPage->mSMWFactboxText = $text;
     }
     Profiler::Out(__METHOD__);
 }
Exemplo n.º 4
0
 /**
  * Renders table content for a given SMWSemanticData object
  *
  * @since 1.9
  *
  * @param SMWSemanticData $semanticData
  */
 protected function getTableContent(SemanticData $semanticData)
 {
     Profiler::In(__METHOD__);
     // Do exclude some tags from processing otherwise the display
     // can become distorted due to unresolved/open tags (see Bug 23185)
     $excluded = array('table', 'tr', 'th', 'td', 'dl', 'dd', 'ul', 'li', 'ol', 'b', 'sup', 'sub');
     $attributes = array();
     foreach ($semanticData->getProperties() as $propertyDi) {
         $propertyDv = $this->dataValueFactory->newDataItemValue($propertyDi, null);
         if (!$propertyDi->isShown()) {
             // showing this is not desired, hide
             continue;
         } elseif ($propertyDi->isUserDefined()) {
             // User defined property (@note the preg_replace is a slight
             // hack to ensure that the left column does not get too narrow)
             $propertyDv->setCaption(preg_replace('/[ ]/u', ' ', $propertyDv->getWikiValue(), 2));
             $attributes['property'] = array('class' => 'smwpropname');
             $attributes['values'] = array('class' => 'smwprops');
         } elseif ($propertyDv->isVisible()) {
             // Predefined property
             $attributes['property'] = array('class' => 'smwspecname');
             $attributes['values'] = array('class' => 'smwspecs');
         } else {
             // predefined, internal property
             // @codeCoverageIgnoreStart
             continue;
             // @codeCoverageIgnoreEnd
         }
         $valuesHtml = array();
         foreach ($semanticData->getPropertyValues($propertyDi) as $dataItem) {
             $dataValue = $this->dataValueFactory->newDataItemValue($dataItem, $propertyDi);
             $dataValue->setServiceLinksRenderState(false);
             if ($dataValue->isValid()) {
                 $valuesHtml[] = Sanitizer::removeHTMLtags($dataValue->getLongWikiText(true), null, array(), array(), $excluded) . $dataValue->getInfolinkText(SMW_OUTPUT_WIKI);
             }
         }
         // Invoke table content
         $this->tableBuilder->addCell($propertyDv->getShortWikiText(true), $attributes['property']);
         $this->tableBuilder->addCell($this->messageBuilder->listToCommaSeparatedText($valuesHtml), $attributes['values']);
         $this->tableBuilder->addRow();
     }
     Profiler::Out(__METHOD__);
 }
Exemplo n.º 5
0
 /**
  * @since 1.9
  *
  * @return DIProperty[]
  */
 protected function getProperties($res)
 {
     Profiler::In(__METHOD__);
     $result = array();
     foreach ($res as $row) {
         try {
             $property = new DIProperty($row->smw_title);
         } catch (InvalidPropertyException $e) {
             $property = new SMWDIError(new Message('smw_noproperty', array($row->smw_title)));
         }
         $result[] = array($property, $row->count);
     }
     Profiler::Out(__METHOD__);
     return $result;
 }
 protected function fetchFromParser()
 {
     Profiler::In(__METHOD__);
     if ($this->getRevision() === null) {
         return $this->msgForNullRevision();
     }
     $this->parserOutput = $this->parser->parse($this->getRevision()->getText(), $this->getTitle(), $this->makeParserOptions(), true, true, $this->getRevision()->getID());
     Profiler::Out(__METHOD__);
     return $this;
 }
 /**
  * Executes and outputs results for available concepts
  *
  * @since 1.9
  *
  * @param array $param
  */
 public function execute($param)
 {
     Profiler::In(__METHOD__);
     $this->getOutput()->setPageTitle($this->msg('concepts')->text());
     $from = $this->getRequest()->getVal('from', '');
     $until = $this->getRequest()->getVal('until', '');
     $limit = $this->getRequest()->getVal('limit', 50);
     $diWikiPages = $this->getResults($limit, $from, $until);
     $diWikiPages = $until !== '' ? array_reverse($diWikiPages) : $diWikiPages;
     $this->getOutput()->addHTML($this->getHtml($diWikiPages, $limit, $from, $until));
     Profiler::Out(__METHOD__);
 }
Exemplo n.º 8
0
 /**
  * Generates list of involved subjects
  *
  * @since 1.9
  *
  * @param DIProperty $property
  */
 protected function dispatchUpdateForProperty(DIProperty $property)
 {
     Profiler::In(__METHOD__, true);
     $this->addUpdateJobsForProperties(array($property));
     // Hook deprecated with SMW 1.9 and will vanish with SMW 1.11
     wfRunHooks('smwUpdatePropertySubjects', array(&$this->jobs));
     // Hook since 1.9
     wfRunHooks('SMW::Job::updatePropertyJobs', array(&$this->jobs, $property));
     $this->addUpdateJobsForPropertyWithTypeError();
     $this->addUpdateJobsFromSerializedData();
     Profiler::Out(__METHOD__, true);
     return $this;
 }
Exemplo n.º 9
0
 /**
  * @param $spos start index
  */
 protected function refreshData($spos)
 {
     Profiler::In();
     $run = $this->hasParameter('run') ? $this->getParameter('run') : 1;
     $prog = ApplicationFactory::getInstance()->getStore()->refreshData($spos, 20, $this->getNamespace($run));
     if ($spos > 0) {
         $this->createNextJob(array('spos' => $spos, 'prog' => $prog, 'rc' => $this->getParameter('rc'), 'run' => $run));
     } elseif ($this->getParameter('rc') > $run) {
         // do another run from the beginning
         $this->createNextJob(array('spos' => 1, 'prog' => 0, 'rc' => $this->getParameter('rc'), 'run' => $run + 1));
     }
     Profiler::Out();
     return true;
 }
Exemplo n.º 10
0
 /**
  * This factory method returns a data value object from a given property,
  * value string. It is intended to be used on user input to allow to
  * turn a property and value string into a data value object.
  *
  * @since 1.9
  *
  * @param string $propertyName property string
  * @param string $valueString user value string
  * @param mixed $caption user-defined caption
  * @param SMWDIWikiPage|null $contextPage context for parsing the value string
  *
  * @return DataValue
  */
 public function newPropertyValue($propertyName, $valueString, $caption = false, DIWikiPage $contextPage = null)
 {
     // Enforce upper case for the first character on annotations that are used
     // within the property namespace in order to avoid confusion when
     // $wgCapitalLinks setting is disabled
     if ($contextPage !== null && $contextPage->getNamespace() === SMW_NS_PROPERTY) {
         $propertyName = ucfirst($propertyName);
     }
     $propertyDV = SMWPropertyValue::makeUserProperty($propertyName);
     if (!$propertyDV->isValid()) {
         return $propertyDV;
     }
     if (!$propertyDV->canUse()) {
         return new ErrorValue($propertyDV->getPropertyTypeID(), wfMessage('smw-datavalue-property-restricted-use', $propertyName)->inContentLanguage()->text(), $valueString, $caption);
     }
     $propertyDI = $propertyDV->getDataItem();
     if ($propertyDI instanceof SMWDIError) {
         Profiler::Out(__METHOD__, true);
         return $propertyDV;
     }
     if ($propertyDI instanceof DIProperty && !$propertyDI->isInverse()) {
         $dataValue = $this->newPropertyObjectValue($propertyDI, $valueString, $caption, $contextPage);
     } elseif ($propertyDI instanceof DIProperty && $propertyDI->isInverse()) {
         $dataValue = new ErrorValue($propertyDV->getPropertyTypeID(), wfMessage('smw_noinvannot')->inContentLanguage()->text(), $valueString, $caption);
     } else {
         $dataValue = new ErrorValue($propertyDV->getPropertyTypeID(), wfMessage('smw-property-name-invalid', $propertyName)->inContentLanguage()->text(), $valueString, $caption);
     }
     if ($dataValue->isValid() && !$dataValue->canUse()) {
         $dataValue = new ErrorValue($propertyDV->getPropertyTypeID(), wfMessage('smw-datavalue-restricted-use', implode(',', $datavalue->getErrors()))->inContentLanguage()->text(), $valueString, $caption);
     }
     return $dataValue;
 }
Exemplo n.º 11
0
 private function doRealUpdate()
 {
     Profiler::In();
     $this->store->setUpdateJobsEnabledState($this->updateJobsEnabledState);
     if ($this->processSemantics) {
         $this->store->updateData($this->semanticData);
     } else {
         $this->store->clearData($this->semanticData->getSubject());
     }
     Profiler::Out();
     return true;
 }