public function process($currentXml) { if (!array_key_exists('toFile', $this->elementAttributes)) { webServiceError('&error-process-serialize-no-with-file;'); } $toFile = $this->elementAttributes['toFile']; $configFilenamesPath = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'custom-filenames.php'; include_once $configFilenamesPath; $toFile = replaceCustomFilenamePlaceholders($toFile, $this->depthArray); $destinationFilename = processDepthTemplate($toFile, $this->depthArray); $destinationPath = $this->contentDirectory . DIRECTORY_SEPARATOR . $destinationFilename; file_put_contents($destinationPath, $currentXml); return $currentXml; }
function generatePath($path) { $destinationFilename = processDepthTemplate($path, $this->depthArray); $destinationPath = $this->contentDirectory . DIRECTORY_SEPARATOR . $destinationFilename; return $destinationPath; }
/** handles pipeline loop process */ function processAPipelineLevel(&$pipelineStages, $currentXml, $pipelineDirectory, $contentDirectory, $previewDirectory, $pipelineSettings, $loopDepth = '', $depthArray = null) { $foreachIndex = null; foreach ($pipelineStages as $key => $pipelineStage) { if (substr($key, 0, 2) != '__') { $elementAttributes =& $pipelineStage['__attributes']; if (!is_array($elementAttributes)) { webServiceError('&error-non-array;'); } if (!array_key_exists('process', $elementAttributes)) { webServiceError('&error-pipeline-lacks-process-attribute;'); } $foreachIndex++; if ($elementAttributes['process'] == 'Loop') { $depthArray[] = 'YouHaveAPipelineError-WrongDepthError'; $lastItemIndex = count($depthArray) - 1; $numberOfLoops = 0; if (array_key_exists('numberOfTimes', $elementAttributes)) { if (substr($elementAttributes['numberOfTimes'], 0, 11) == 'xpathCount:') { $xpathCountTemplate = substr($elementAttributes['numberOfTimes'], 11); $xpathCount = processDepthTemplate($xpathCountTemplate, $depthArray); if (strstr($xpathCount, '{') || strstr($xpathCount, 'YouHaveAPipelineError-WrongDepthError')) { webServiceError('&error-stepindex-parent;'); } $xsltString = file_get_contents(DOCVERT_DIR . 'core' . DIRECTORY_SEPARATOR . 'transform' . DIRECTORY_SEPARATOR . 'count-nodes.xsl-fragment'); $xsltString = str_replace('{{xpathCount}}', $xpathCount, $xsltString); $numberOfLoops = xsltTransformWithXsltString($currentXml, $xsltString); //displayXmlString($currentXml); } elseif (substr($elementAttributes['numberOfTimes'], 0, 10) == 'substring:') { $substring = substr($elementAttributes['numberOfTimes'], 10); $numberOfLoops = substr_count($currentXml, $substring); } elseif (substr($elementAttributes['numberOfTimes'], 0, 7) == 'number:') { $substring = substr($elementAttributes['numberOfTimes'], 7); $numberOfLoops = substr_count($currentXml, $substring); } else { webServiceError('&error-pipeline-number-of-times;'); } } else { webServiceError('&error-pipeline-needs-number-of-times-attribute;'); } for ($loopIndex = 1; $loopIndex <= $numberOfLoops; $loopIndex++) { $depthArray[$lastItemIndex] = $loopIndex; $newLoopDepth = $loopDepth; if ($newLoopDepth) { $newLoopDepth .= '-'; } $newLoopDepth .= $loopIndex; processAPipelineLevel($pipelineStage['__children'], $currentXml, $pipelineDirectory, $contentDirectory, $previewDirectory, $pipelineSettings, $newLoopDepth, $depthArray); } } else { $currentXml = processAPipelineStage($elementAttributes, $currentXml, $pipelineDirectory, $contentDirectory, $loopDepth, $depthArray, $previewDirectory, $pipelineSettings); } } } }