/**
  * 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');
 }
 /**
  * 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');
 }
 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;
 }
Example #9
0
<?php

/**
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version //autogentag//
 * @package kernel
 */
// Set a default time zone if none is given to avoid "It is not safe to rely
// on the system's timezone settings" warnings. The time zone can be overriden
// in config.php or php.ini.
if (!ini_get("date.timezone")) {
    date_default_timezone_set("UTC");
}
ignore_user_abort(true);
error_reporting(E_ALL | E_STRICT);
require 'autoload.php';
$kernel = new ezpKernel(new ezpKernelWeb());
echo $kernel->run()->getContent();
 /**
  * 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);
 }
Example #11
0
 function initialize()
 {
     if (!ezpKernel::hasInstance()) {
         if (ob_get_length() != 0) {
             ob_end_clean();
         }
     }
     // Initialize text codec settings
     $this->updateTextCodecSettings();
     // Initialize debug settings
     $this->updateDebugSettings($this->UseDebugOutput);
     // Set the different permissions/settings.
     $ini = eZINI::instance();
     $iniFilePermission = $ini->variable('FileSettings', 'StorageFilePermissions');
     $iniDirPermission = $ini->variable('FileSettings', 'StorageDirPermissions');
     $iniVarDirectory = eZSys::cacheDirectory();
     eZCodePage::setPermissionSetting(array('file_permission' => octdec($iniFilePermission), 'dir_permission' => octdec($iniDirPermission), 'var_directory' => $iniVarDirectory));
     eZExecution::addCleanupHandler('eZDBCleanup');
     eZExecution::addFatalErrorHandler('eZFatalError');
     eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
     if ($this->UseExtensions) {
         // Check for extension
         eZExtension::activateExtensions('default');
         // Extension check end
     } else {
         if (!$this->isQuiet()) {
             $cli = eZCLI::instance();
             $cli->output("Notice: This script uses 'use-extensions' => false, meaning extension settings are not loaded!");
         }
     }
     $siteaccess = $this->SiteAccess;
     if ($siteaccess) {
         $access = array('name' => $siteaccess, 'type' => eZSiteAccess::TYPE_STATIC);
     } else {
         $ini = eZINI::instance();
         $siteaccess = $ini->variable('SiteSettings', 'DefaultAccess');
         $access = array('name' => $siteaccess, 'type' => eZSiteAccess::TYPE_DEFAULT);
     }
     $access = eZSiteAccess::change($access);
     if ($this->UseExtensions) {
         // Check for siteaccess extension
         eZExtension::activateExtensions('access');
         // Extension check end
     }
     // Now that all extensions are activated and siteaccess has been changed, reset
     // all eZINI instances as they may not take into account siteaccess specific settings.
     eZINI::resetAllInstances(false);
     // Set the global setting which is read by the session lib
     $GLOBALS['eZSiteBasics']['session-required'] = $this->UseSession;
     if ($this->UseSession) {
         $db = eZDB::instance();
         if ($db->isConnected()) {
             eZSession::start();
         } else {
             $this->setIsInitialized(false);
             $this->InitializationErrorMessage = 'database error: ' . $db->errorMessage();
             return;
         }
     }
     if ($this->User) {
         $userLogin = $this->User['login'];
         $userPassword = $this->User['password'];
         if ($userLogin and $userPassword) {
             $userID = eZUser::loginUser($userLogin, $userPassword);
             if (!$userID) {
                 $cli = eZCLI::instance();
                 if ($this->isLoud()) {
                     $cli->warning('Failed to login with user ' . $userLogin);
                 }
                 eZExecution::cleanup();
                 eZExecution::setCleanExit();
             }
         }
     }
     // Initialize module handling
     if ($this->UseModules) {
         $moduleRepositories = eZModule::activeModuleRepositories($this->UseExtensions);
         eZModule::setGlobalPathList($moduleRepositories);
     }
     $this->setIsInitialized(true);
 }
Example #12
0
<?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();
Example #13
0
<?php

/**
 * File containing the rest bootstrap
 *
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version //autogentag//
 * @package kernel
 */
require __DIR__ . '/autoload.php';
ignore_user_abort(true);
error_reporting(E_ALL | E_STRICT & E_DEPRECATED);
require 'autoload.php';
$kernel = new ezpKernel(new ezpKernelRest());
// mvc_tools will directly output the headers and content
$kernel->run();