/**
  * Marks all unreferenced element records as deleted with a recursion level of 99
  *
  * @return int Number of records deleted
  */
 public function markDeletedUnreferencedElementsRecords($markAsNegativeColPos = FALSE)
 {
     $pids = $this->sharedHelper->getPageIds();
     $allReferencedElementsArr = array();
     foreach ($pids as $pid) {
         $pageRecord = $this->sharedHelper->getPage($pid);
         if (!empty($pageRecord)) {
             $contentTree = $this->sharedHelper->getTemplavoilaAPIObj()->getContentTree('pages', $pageRecord, FALSE);
             $referencedElementsArrAsKeys = $contentTree['contentElementUsage'];
             if (!empty($referencedElementsArrAsKeys)) {
                 $referencedElementsArr = array_keys($referencedElementsArrAsKeys);
                 $allReferencedElementsArr = array_merge($allReferencedElementsArr, $referencedElementsArr);
             }
         }
     }
     $allReferencedElementsArr = array_unique($allReferencedElementsArr);
     $allRecordUids = $this->getUnreferencedElementsRecords($allReferencedElementsArr);
     $countRecords = count($allRecordUids);
     if ($markAsNegativeColPos) {
         $this->markNegativeColPos($allRecordUids);
     } else {
         $this->markDeleted($allRecordUids);
     }
     return $countRecords;
 }
 /**
  * converts flexform pointer string to local copy
  *
  * @param string $flexformPointerString
  * @return mixed
  */
 protected function convertFlexformPointerStringToLocalCopy($flexformPointerString)
 {
     $sourcePointer = $this->sharedHelper->getTemplavoilaAPIObj()->flexform_getPointerFromString($flexformPointerString);
     $contentUid = $this->sharedHelper->getTemplavoilaAPIObj()->copyElement($sourcePointer, $sourcePointer);
     $this->sharedHelper->getTemplavoilaAPIObj()->unlinkElement($sourcePointer);
     return $contentUid;
 }