if ($create && !$remove && !$subtreeChildren) { // Attempt to create image alias variations $result = BCImageAlias::instance($scriptExecutionOptions)->createByObject($node->attribute('object'), $classes, $attributes, $imageAliases); } elseif ($create && !$remove && $subtreeChildren) { // Subtree fetch parameters for the ordering of child nodes fetched to be processed $subtreeParams = array('MainNodeOnly' => true, 'Depth' => 4, 'SortBy' => array('depth', true)); // Attempt to create image alias variations $result = BCImageAlias::instance($scriptExecutionOptions)->createByNodeSubtree($node, $subtreeParams, $classes, $attributes, $imageAliases); } elseif ($remove && !$create && !$subtreeChildren) { // Attempt to remove image alias variation files $result = BCImageAlias::instance($scriptExecutionOptions)->removeByObject($node->attribute('object'), $classes, $attributes, $imageAliases); } elseif ($remove && !$create && $subtreeChildren) { // Subtree fetch parameters for the ordering of child nodes fetched to be processed $subtreeParams = array('MainNodeOnly' => true, 'Depth' => 4, 'SortBy' => array('depth', true)); // Attempt to remove image alias variation files $result = BCImageAlias::instance($scriptExecutionOptions)->removeByNodeSubtree($node, $subtreeParams, $classes, $attributes, $imageAliases); } } } // Test for cases which do not operate by object if (!$objectID && !$nodeID) { // Perform operations for cases which do not operate by object if ($create && !$remove) { // Alert the user to what has happened if ($dry) { $footerMessage = "\nPretended to create " . $script->IterationIndex . " image alias variation image files. No image alias variation image files created!\n"; } else { $footerMessage = "\nGenerated " . $script->IterationIndex . " image alias variation image files. Image alias variation image files created!\n"; } } else { // Alert the user to what has happened
* Validate request to create content */ if (isset($parameters['node-id']) && $parameters['node-id'] != '' && is_string($parameters['node-id'])) { // Fetch the provided node $node = eZContentObjectTreeNode::fetch($parameters['node-id']); if (is_object($node)) { if ($parameters['children'] == true) { /** * Perform create subtree content requests */ $resultParameters = BCImageAlias::instance($executionOptions)->createByNodeSubtree($node, $parameters['subtree-params']); } else { /** * Perform create content requests */ $resultParameters = BCImageAlias::instance($executionOptions)->createByObject($node->attribute('object'), $parameters['subtree-params']); } if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'content/browse') === false) { $redirectUrl = $_SERVER['HTTP_REFERER']; } elseif ($node->hasAttribute('url_alias') && $node->attribute('url_alias') != '') { $redirectUrl = $node->attribute('url_alias'); $redirectUrlInstance = eZURI::instance($redirectUrl); $redirectUrlInstance->transformURI($redirectUrl, false, 'full'); } else { $redirectUrl = '/content/view/full/' . $node->attribute('node_id'); $redirectUrlInstance = eZURI::instance($redirectUrl); $redirectUrlInstance->transformURI($redirectUrl, false, 'full'); } if ($parameters['redirect'] != 'default') { //echo $redirectUrl; die(); $http->redirect($redirectUrl);
/** * Default constructor of the BCImageAlias class * * @param array $options Options used by the instance */ function BCImageAlias($options = false) { if (is_array($options)) { self::$ExecutionOptions = array_merge(self::$ExecutionOptions, $options); } }
/** * Workflow Event Type execute method */ function execute($process, $event) { /** * Fetch workflow process parameters */ $parameters = $process->attribute('parameter_list'); $objectID = $parameters['object_id']; $version = $parameters['version']; /** * Fetch workflow event execution settings */ $workflowEventRegenerateCreation = eZINI::instance('bcimagealias.ini')->variable('BCImageAliasSettings', 'WorkflowEventRegenerateAliasImageVariations') == 'enabled' ? true : false; $workflowEventTroubleshootCreation = eZINI::instance('bcimagealias.ini')->variable('BCImageAliasSettings', 'WorkflowEventTroubleshootAliasImageVariationCreation') == 'enabled' ? true : false; $workflowEventVerboseCreationLevel = eZINI::instance('bcimagealias.ini')->variable('BCImageAliasSettings', 'WorkflowEventTroubleshootAliasImageVariationCreationLevel') != '1' ? eZINI::instance('bcimagealias.ini')->variable('BCImageAliasSettings', 'WorkflowEventTroubleshootAliasImageVariationCreationLevel') : 1; $workflowEventCurrentSiteAccessCreation = eZINI::instance('bcimagealias.ini')->variable('BCImageAliasSettings', 'WorkflowEventCurrentSiteAccessAliasImageVariationCreation') == 'enabled' ? true : false; $workflowEventSubtreeImageAliasCreation = eZINI::instance('bcimagealias.ini')->variable('BCImageAliasSettings', 'WorkflowEventSubtreeImageAliasImageVariationCreation') == 'enabled' ? true : false; /** * BCImageAlias execution parameters */ $BCImageAliasExecutionParams = array('verbose' => false, 'verboseLevel' => 1, 'dry' => false, 'iterate' => false, 'regenerate' => $workflowEventRegenerateCreation, 'troubleshoot' => $workflowEventTroubleshootCreation, 'current-siteaccess' => $workflowEventCurrentSiteAccessCreation); /** * Optional debug output */ if ($BCImageAliasExecutionParams['troubleshoot'] == true) { echo "Workflow parameters: \n\n"; print_r($parameters); echo "\n\n"; } /** * Fetch content object */ $object = eZContentObject::fetch($objectID, $version); /** * Test for the rare chance we would not have been given an object. Terminate workflow event execution after writing debug error report */ if (!$object) { eZDebugSetting::writeError('extension-bcimagealias-create-image-alias-variations-workflow-on-non-object', $objectID, 'BCImageAliasCreateObjectImageVariationsType::execute'); return eZWorkflowEventType::STATUS_WORKFLOW_CANCELLED; } /** * Create image alias image variation image files by content object */ if ($workflowEventSubtreeImageAliasCreation) { $result = BCImageAlias::instance($BCImageAliasExecutionParams)->createByNodeSubtree($object->attribute('main_node')); } else { $result = BCImageAlias::instance($BCImageAliasExecutionParams)->createByObject($object); } /** * Optional debug output */ if ($BCImageAliasExecutionParams['troubleshoot'] == true) { die("\nTroubleshooting exection option enabled: Ending workflow event just before the end of it's execution to allow you to read related output.\n\n\n"); } /** * Test result for failure to create image aliases. Non-fatal workflow event execution result. Write debug error report just in case this is a problem */ if ($result == false) { eZDebugSetting::writeError('extension-bcimagealias-create-image-alias-variations-workflow-object-failure-to-create', $objectID, 'BCImageAliasCreateObjectImageVariationsType::execute'); } /** * Return default succesful workflow event status code, by default, regardless of results of execution, always. * Image alias image variation image files may not always need to be created. Also returning any other status * will result in problems with the succesfull and normal completion of the workflow event process */ return eZWorkflowType::STATUS_ACCEPTED; }