/** * Instantiates the class object * * @return NgSymfonyToolsApiContentConverter */ public static function instance() { if (self::$instance === null) { $serviceContainer = ezpKernel::instance()->getServiceContainer(); self::$instance = new self($serviceContainer->get('ezpublish.api.repository')); } return self::$instance; }
/** * Constructor */ public function __construct() { $serviceContainer = ezpKernel::instance()->getServiceContainer(); $this->searchHandler = $serviceContainer->get('ezpublish.spi.search'); $this->persistenceHandler = $serviceContainer->get('ezpublish.api.persistence_handler'); $this->repository = $serviceContainer->get('ezpublish.api.repository'); $this->searchEngine = $serviceContainer->getParameter('search_engine'); }
/** * Constructor */ public function __construct() { $serviceContainer = ezpKernel::instance()->getServiceContainer(); $this->searchHandler = $serviceContainer->get('ezpublish.spi.search'); $this->persistenceHandler = $serviceContainer->get('ezpublish.api.persistence_handler'); $this->repository = $serviceContainer->get('ezpublish.api.repository'); $this->iniConfig = eZINI::instance('ezplatformsearch.ini'); }
public function __construct(ezpKernelHandler $kernelHandler) { /** * PHP 5.3.3 is our hard requirement */ if (version_compare(PHP_VERSION, '5.3.3') < 0) { echo "<h1>Unsupported PHP version " . PHP_VERSION . "</h1>", "<p>eZ Publish 5.x does not run with PHP version lower than 5.3.</p>", "<p>For more information about supported software please visit ", "<a href=\"http://ez.no/\" >us, eZ Systems, on http://ez.no</a>. See you there :-)</p>"; exit; } $this->kernelHandler = $kernelHandler; self::$instance = $this; }
/** * Renders the given URI with Symfony stack * * @param string|\Symfony\Component\HttpKernel\Controller\ControllerReference $uri * @param array $options * * @return string */ public static function renderUri($uri, $options = array()) { $serviceContainer = ezpKernel::instance()->getServiceContainer(); $fragmentHandler = $serviceContainer->get('fragment.handler'); $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; unset($options['strategy']); try { return $fragmentHandler->render($uri, $strategy, $options); } catch (InvalidArgumentException $e) { throw new InvalidArgumentException("The URI {$uri->controller} couldn't be rendered", 0, $e); } }
/** * Executes the template operator * * @param eZTemplate $tpl * @param string $operatorName * @param mixed $operatorParameters * @param string $rootNamespace * @param string $currentNamespace * @param mixed $operatorValue * @param array $namedParameters * @param mixed $placement */ function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement) { if (!is_string($namedParameters['name']) && empty($namedParameters['name'])) { $tpl->error($operatorName, "{$operatorName} parameter 'name' must be a non empty string.", $placement); return; } $templateName = $namedParameters['name']; if ($namedParameters['parameters'] !== null && !is_array($namedParameters['parameters'])) { $tpl->error($operatorName, "{$operatorName} parameter 'parameters' must be a hash array.", $placement); return; } $templateParameters = $namedParameters['parameters'] !== null ? $namedParameters['parameters'] : array(); $apiContentConverter = NgSymfonyToolsApiContentConverter::instance(); foreach ($templateParameters as $parameterName => $parameterValue) { $templateParameters[$parameterName] = $apiContentConverter->convert($parameterValue); } $serviceContainer = ezpKernel::instance()->getServiceContainer(); $templatingEngine = $serviceContainer->get('templating'); $operatorValue = $templatingEngine->render($templateName, $templateParameters); }
public static function getGroupedClasses() { /** @var ContainerInterface $container */ $container = ezpKernel::instance()->getServiceContainer(); $params = $container->getParameter('kaliop_class_select'); $classInclude = $classExclude = $groupInclude = $groupExclude = false; $cgparams = array(); if (!empty($params['classes']['include'])) { $classInclude = true; $cgparams = $params['classes']['include']; } elseif (!empty($params['classes']['exclude'])) { $classExclude = true; $cgparams = $params['classes']['exclude']; } elseif (!empty($params['class_groups']['include'])) { $groupInclude = true; $cgparams = $params['class_groups']['include']; } elseif (!empty($params['class_groups']['exclude'])) { $groupExclude = true; $cgparams = $params['class_groups']['exclude']; } $groups = eZContentClassGroup::fetchList(false, true); $return = array(); $count = 0; foreach ($groups as $group) { if ($groupInclude and (in_array($group->attribute('id'), $cgparams) or in_array($group->attribute('name'), $cgparams)) or !$groupInclude and $groupExclude and (!in_array($group->attribute('id'), $cgparams) or !in_array($group->attribute('name'), $cgparams)) or !$groupInclude and !$groupExclude) { $array = array('name' => $group->attribute('name'), 'classes' => array()); $count++; $classes = eZContentClassClassGroup::fetchClassList(0, $group->attribute('id'), true); foreach ($classes as $class) { if ($classInclude and (in_array($class->attribute('id'), $cgparams) or in_array($class->attribute('identifier'), $cgparams)) or !$classInclude and $classExclude and (!in_array($class->attribute('id'), $cgparams) or !in_array($class->attribute('identifier'), $cgparams)) or !$classInclude and !$classExclude) { $array['classes'][] = array('identifier' => $class->attribute('identifier'), 'name' => $class->attribute('name')); $count++; } } $return[] = $array; } } return array('result' => array('groups' => $return, 'total' => $count)); }
/** * Starts the publishing process for the linked version. After publishing, * the child process is terminated. * * @return false|int false if the fork fails, the pid of the child process * after the fork */ public function publish() { $contentObjectId = $this->version()->attribute('contentobject_id'); $contentObjectVersion = $this->version()->attribute('version'); // $processObject = ezpContentPublishingProcess::fetchByContentObjectVersion( $contentObjectId, $contentObjectVersion ); $this->setStatus(self::STATUS_WORKING, true, "beginning publishing"); // prepare the cluster file handler for the fork eZClusterFileHandler::preFork(); $pid = pcntl_fork(); // force the DB connection closed $db = eZDB::instance(); $db->close(); $db = null; eZDB::setInstance(null); // Force the new stack DB connection closed as well try { $kernel = ezpKernel::instance(); if ($kernel->hasServiceContainer()) { $serviceContainer = $kernel->getServiceContainer(); $dbHandler = $serviceContainer->get('ezpublish.connection'); $factory = $serviceContainer->get('ezpublish.api.storage_engine.legacy.dbhandler.factory'); $dbHandler->setDbHandler($factory->buildLegacyDbHandler()->getDbHandler()); } } catch (LogicException $e) { // we just ignore this, since it means that we are running in a pure legacy context } // Force the cluster DB connection closed if the cluster handler is DB based $cluster = eZClusterFileHandler::instance(); // error, cancel if ($pid == -1) { $this->setStatus(self::STATUS_PENDING, true, "pcntl_fork() failed"); return false; } else { if ($pid) { return $pid; } } // child process try { $myPid = getmypid(); pcntl_signal(SIGCHLD, SIG_IGN); $this->setAttribute('pid', $myPid); $this->setAttribute('started', time()); $this->store(array('pid', 'started')); // login the version's creator to make sure publishing happens as if ran synchronously $creatorId = $this->version()->attribute('creator_id'); $creator = eZUser::fetch($creatorId); eZUser::setCurrentlyLoggedInUser($creator, $creatorId); unset($creator, $creatorId); $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectId, 'version' => $contentObjectVersion)); // Statuses other than CONTINUE require special handling if ($operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) { if ($operationResult['status'] == eZModuleOperationInfo::STATUS_HALTED) { // deferred to crontab if (strpos($operationResult['result']['content'], 'Deffered to cron') !== false) { $processStatus = self::STATUS_DEFERRED; } else { $processStatus = self::STATUS_UNKNOWN; } } else { $processStatus = self::STATUS_UNKNOWN; } } else { $processStatus = self::STATUS_FINISHED; } // mark the process as completed $this->setAttribute('pid', 0); $this->setStatus($processStatus, false, "publishing operation finished"); $this->setAttribute('finished', time()); $this->store(array('status', 'finished', 'pid')); // Call the postProcessing hook ezpContentPublishingQueue::signals()->emit('postHandling', $contentObjectId, $contentObjectVersion, $processStatus); } catch (eZDBException $e) { $this->reset("database error: " . $e->getMessage()); } // generate static cache $ini = eZINI::instance(); if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') { $staticCacheHandlerClassName = $ini->variable('ContentSettings', 'StaticCacheHandler'); $staticCacheHandlerClassName::executeActions(); } eZScript::instance()->shutdown(); exit; }
/** * Returns the URL for provided route and parameters * * @param string $name * @param array $parameters * @param bool $schemeRelative * * @return string */ public static function getUrl($name, $parameters = array(), $schemeRelative = false) { $serviceContainer = ezpKernel::instance()->getServiceContainer(); return $serviceContainer->get('router')->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL); }
<?php $Module = $Params['Module']; $nodeID = (int) $Params['node_id']; $container = ezpKernel::instance()->getServiceContainer(); $htmlpdfapi = $container->get('netgen_html_pdf_api'); $ezcontent = $container->get('ez_content'); $html = $ezcontent->viewLocation($nodeID, 'full')->getContent(); $params = array('html' => $html); /** @var \Guzzle\Http\Message\Response $pdfFile */ $pdfFile = $htmlpdfapi->generateFromHTML($params); header('Content-Type: application/pdf'); header('Content-Disposition: attachment;filename=' . $nodeID . '.pdf'); echo $pdfFile->getBody(true); eZExecution::cleanExit();