protected function expandReferences(Workflow $workflow, AbstractRevision $revision, array $references)
 {
     $referenceObjs = array();
     $factory = new ReferenceFactory($workflow, $revision->getRevisionType(), $revision->getCollectionId());
     foreach ($references as $ref) {
         $referenceObjs[] = $factory->{$ref['factoryMethod']}($ref['refType'], $ref['value']);
     }
     return $referenceObjs;
 }
 /**
  * Cache key for last revision
  *
  * @param AbstractRevision $revision
  * @return string
  */
 protected function getLastRevCacheKey(AbstractRevision $revision)
 {
     return $revision->getCollectionId()->getAlphadecimal() . '-' . $revision->getRevisionType() . '-last-rev';
 }
 /**
  * @param AbstractRevision $obj
  * @return string[]
  */
 public static function toStorageRow($obj)
 {
     return array('rev_id' => $obj->revId->getAlphadecimal(), 'rev_user_id' => $obj->user->id, 'rev_user_ip' => $obj->user->ip, 'rev_user_wiki' => $obj->user->wiki, 'rev_parent_id' => $obj->prevRevision ? $obj->prevRevision->getAlphadecimal() : null, 'rev_change_type' => $obj->changeType, 'rev_type' => $obj->getRevisionType(), 'rev_type_id' => $obj->getCollectionId()->getAlphadecimal(), 'rev_content' => $obj->content, 'rev_content_url' => $obj->contentUrl, 'rev_flags' => implode(',', $obj->flags), 'rev_mod_state' => $obj->moderationState, 'rev_mod_user_id' => $obj->moderatedBy ? $obj->moderatedBy->id : null, 'rev_mod_user_ip' => $obj->moderatedBy ? $obj->moderatedBy->ip : null, 'rev_mod_user_wiki' => $obj->moderatedBy ? $obj->moderatedBy->wiki : null, 'rev_mod_timestamp' => $obj->moderationTimestamp, 'rev_mod_reason' => $obj->moderatedReason, 'rev_last_edit_id' => $obj->lastEditId ? $obj->lastEditId->getAlphadecimal() : null, 'rev_edit_user_id' => $obj->lastEditUser ? $obj->lastEditUser->id : null, 'rev_edit_user_ip' => $obj->lastEditUser ? $obj->lastEditUser->ip : null, 'rev_edit_user_wiki' => $obj->lastEditUser ? $obj->lastEditUser->wiki : null, 'rev_content_length' => $obj->contentLength, 'rev_previous_content_length' => $obj->previousContentLength);
 }
 public function isComparable(AbstractRevision $cur, AbstractRevision $prev)
 {
     if ($cur->getRevisionType() == $prev->getRevisionType()) {
         return $cur->getCollectionId()->equals($prev->getCollectionId());
     } else {
         return false;
     }
 }
 /**
  * Compares the references contained within $revision against those stored for
  * that revision.  Returns the differences.
  *
  * @param Workflow $workflow
  * @param AbstractRevision $revision
  * @param PostRevision|null $root
  * @return array Two nested arrays, first the references that were added and
  *  second the references that were removed.
  */
 protected function calculateChangesFromExisting(Workflow $workflow, AbstractRevision $revision, PostRevision $root = null)
 {
     $prevReferences = $this->getExistingReferences($revision->getRevisionType(), $revision->getCollectionId());
     $references = $this->getReferencesFromRevisionContent($workflow, $revision, $root);
     return $this->referencesDifference($prevReferences, $references);
 }
 /**
  * @todo Move this to AbstractBlock and use for summary/header/etc.
  * @param AbstractRevision $revision
  * @return Message
  */
 protected function getDisallowedErrorMessage(AbstractRevision $revision)
 {
     if (in_array($this->action, array('moderate-topic', 'moderate-post'))) {
         /*
          * When failing to moderate an already moderated action (like
          * undo), show the more general "you have insufficient
          * permissions for this action" message, rather than the
          * specialized "this topic is <hidden|deleted|suppressed>" msg.
          */
         return $this->context->msg('flow-error-not-allowed');
     }
     $state = $revision->getModerationState();
     // display simple message
     // i18n messages:
     //  flow-error-not-allowed-hide,
     //  flow-error-not-allowed-reply-to-hide-topic
     //  flow-error-not-allowed-delete
     //  flow-error-not-allowed-reply-to-delete-topic
     //  flow-error-not-allowed-suppress
     //  flow-error-not-allowed-reply-to-suppress-topic
     if ($revision instanceof PostRevision) {
         $type = $revision->isTopicTitle() ? 'topic' : 'post';
     } else {
         $type = $revision->getRevisionType();
     }
     // Show a snippet of the relevant log entry if available.
     if (\LogPage::isLogType($state)) {
         // check if user has sufficient permissions to see log
         $logPage = new \LogPage($state);
         if ($this->context->getUser()->isAllowed($logPage->getRestriction())) {
             // LogEventsList::showLogExtract will write to OutputPage, but we
             // actually just want that text, to write it ourselves wherever we want,
             // so let's create an OutputPage object to then get the content from.
             $rc = new \RequestContext();
             $output = $rc->getOutput();
             // get log extract
             $entries = \LogEventsList::showLogExtract($output, array($state), $this->workflow->getArticleTitle()->getPrefixedText(), '', array('lim' => 10, 'showIfEmpty' => false, 'msgKey' => array(array("flow-error-not-allowed-{$this->action}-to-{$state}-{$type}", "flow-error-not-allowed-{$state}-extract"))));
             // check if there were any log extracts
             if ($entries) {
                 $message = new \RawMessage('$1');
                 return $message->rawParams($output->getHTML());
             }
         }
     }
     return $this->context->msg(array("flow-error-not-allowed-{$this->action}-to-{$state}-{$type}", "flow-error-not-allowed-{$state}", "flow-error-not-allowed"));
 }