public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_CONFIG, $objNewsML, $arrMatches, $page_template, $themesPages, $cl;
     // Set NewsML messages
     if ($_CONFIG['feedNewsMLStatus'] == '1') {
         if (preg_match_all('/{NEWSML_([0-9A-Z_-]+)}/', \Env::get('cx')->getPage()->getContent(), $arrMatches)) {
             /** @ignore */
             if ($cl->loadFile(\Env::get('cx')->getCodeBaseModulePath() . '/Feed/Controller/NewsML.class.php')) {
                 $objNewsML = new NewsML();
                 $objNewsML->setNews($arrMatches[1], \Env::get('cx')->getPage()->getContent());
             }
         }
         if (preg_match_all('/{NEWSML_([0-9A-Z_-]+)}/', $page_template, $arrMatches)) {
             /** @ignore */
             if ($cl->loadFile(\Env::get('cx')->getCodeBaseModulePath() . '/Feed/Controller/NewsML.class.php')) {
                 $objNewsML = new NewsML();
                 $objNewsML->setNews($arrMatches[1], $page_template);
             }
         }
         if (preg_match_all('/{NEWSML_([0-9A-Z_-]+)}/', $themesPages['index'], $arrMatches)) {
             /** @ignore */
             if ($cl->loadFile(\Env::get('cx')->getCodeBaseModulePath() . '/Feed/Controller/NewsML.class.php')) {
                 $objNewsML = new NewsML();
                 $objNewsML->setNews($arrMatches[1], $themesPages['index']);
             }
         }
     }
 }
Beispiel #2
0
 function testGetAfterSet()
 {
     Env::set(Env::PROD);
     $this->assertEquals(Env::get(), Env::PROD);
     $this->assertTrue(Env::isProd());
     $this->assertFalse(Env::isTest());
 }
Beispiel #3
0
 /**
  * Constructor
  * the class JsonLink handles, the link status whether the link is resolved or not.
  */
 public function __construct()
 {
     $this->em = \Env::get('em');
     if ($this->em) {
         $this->linkRepo = $this->em->getRepository('\\Cx\\Core_Modules\\LinkManager\\Model\\Entity\\Link');
     }
 }
 protected function preRender($lang)
 {
     if ($this->template->placeholderExists('LEVELS_FULL') || $this->template->placeholderExists('levels_full')) {
         $this->rootNode = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node')->getRoot();
     }
     $this->realPreRender($lang);
 }
 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('Contact');
     $mediaType = new MediaSource('attach', $_ARRAYLANG['TXT_CONTACT_UPLOADS'], array($this->cx->getWebsiteImagesAttachPath(), $this->cx->getWebsiteImagesAttachWebPath()));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
 /**
  * Constructor
  *
  * @param     ADONewConnection
  * @param     \Cx\Core\Html\Sigma
  * @param     string    $act
  * @param     object    $init
  * @global    array     Configuration
  */
 function __construct($act, $template, $db, $init)
 {
     parent::__construct($act, $template);
     $this->pageId = isset($_GET['id']) ? intval($_GET['id']) : 0;
     $this->cmd = $act;
     $this->defaultAct = 'showHistory';
     switch ($this->act) {
         case 'new':
         case 'updated':
         case 'unvalidated':
             $this->act = 'showHistory';
             break;
         case 'deleted':
             $this->act = 'showHistoryDeleted';
             break;
     }
     $this->em = \Env::get('em');
     $this->tpl = $template;
     $this->db = $db;
     $this->nodeRepo = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
     $this->pageRepo = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     $this->logRepo = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry');
     if (isset($_GET['pos'])) {
         $this->intPos = intval($_GET['pos']);
     }
     $this->tpl->setVariable(array('CONTENT_TITLE' => $this->strPageTitle, 'CONTENT_OK_MESSAGE' => $this->strOkMessage, 'CONTENT_STATUS_MESSAGE' => implode("<br />\n", $this->strErrMessage)));
     $this->setNavigation();
 }
 /**
  * @param Sigma $template
  */
 public function preFinalize(Sigma $template)
 {
     if (count($this->mediaBrowserInstances) == 0) {
         return;
     } else {
         global $_ARRAYLANG;
         /**
          * @var $init \InitCMS
          */
         $init = \Env::get('init');
         $init->loadLanguageData('MediaBrowser');
         foreach ($_ARRAYLANG as $key => $value) {
             if (preg_match("/TXT_FILEBROWSER_[A-Za-z0-9]+/", $key)) {
                 \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser');
             }
         }
         $thumbnailsTemplate = new Sigma();
         $thumbnailsTemplate->loadTemplateFile($this->cx->getCoreModuleFolderName() . '/MediaBrowser/View/Template/Thumbnails.html');
         $thumbnailsTemplate->setVariable('TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE', sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE']));
         foreach (UploaderConfiguration::getInstance()->getThumbnails() as $thumbnail) {
             $thumbnailsTemplate->setVariable(array('THUMBNAIL_NAME' => sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_' . strtoupper($thumbnail['name']) . '_SIZE'], $thumbnail['size']), 'THUMBNAIL_ID' => $thumbnail['id'], 'THUMBNAIL_SIZE' => $thumbnail['size']));
             $thumbnailsTemplate->parse('thumbnails');
         }
         \ContrexxJavascript::getInstance()->setVariable('thumbnails_template', $thumbnailsTemplate->get(), 'mediabrowser');
         \JS::activate('mediabrowser');
         \JS::registerJS('core_modules/MediaBrowser/View/Script/mediabrowser.js');
     }
 }
 /**
  * Initialize this interface
  * 
  * Loads all commands
  * @param \Cx\Core\Core\Controller\Cx $cx Cloudrexx main class
  */
 public function __construct($cx)
 {
     $this->cx = $cx;
     \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/Typing/Model/Entity/AutoBoxedObject.class.php');
     \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/Typing/Model/Entity/Primitives.class.php');
     $this->commands = array('db' => new DbCommand($this), 'import' => new ImportCommand($this), 'create' => new CreateCommand($this), 'uninstall' => new UninstallCommand($this), 'activate' => new ActivateCommand($this), 'deactivate' => new DeactivateCommand($this), 'move' => new MoveCommand($this), 'copy' => new CopyCommand($this), 'remove' => new RemoveCommand($this), 'test' => new TestCommand($this), 'export' => new ExportCommand($this));
 }
 public function showPrices()
 {
     global $_ARRAYLANG;
     $prices = $this->priceRepository->findAll();
     if (empty($prices)) {
         $prices = new \Cx\Modules\Pim\Model\Entity\Price();
     }
     $view = new \Cx\Core\Html\Controller\ViewGenerator($prices, array('header' => $_ARRAYLANG['TXT_MODULE_PIM_ACT_PRICE'], 'validate' => function ($formGenerator) {
         // this validation checks whether already a price for the currency and product exists
         $data = $formGenerator->getData()->toArray();
         $currency = $data['currency'];
         $product = $data['product'];
         $priceRepository = \Env::get('cx')->getDb()->getEntityManager()->getRepository('Cx\\Modules\\Pim\\Model\\Entity\\Price');
         $prices = $priceRepository->createQueryBuilder('p')->where('p.currency = ?1')->setParameter(1, $currency)->andWhere('p.product = ?2')->setParameter(2, $product);
         $prices = $prices->getQuery()->getResult();
         if (!empty($data['editid']) && count($prices) > 1) {
             return false;
         }
         if (empty($data['editid']) && count($prices) > 0) {
             return false;
         }
         return true;
     }, 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false)));
     $this->template->setVariable('PRICES_CONTENT', $view->render());
 }
 /**
  * Load your component.
  *
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_CORELANG, $subMenuTitle, $objTemplate;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             $objJobs = new Jobs(\Env::get('cx')->getPage()->getContent());
             \Env::get('cx')->getPage()->setContent($objJobs->getJobsPage());
             if ($page->getCmd() === 'details') {
                 $objJobs->getPageTitle(\Env::get('cx')->getPage()->getTitle());
                 \Env::get('cx')->getPage()->setTitle($objJobs->jobsTitle);
                 \Env::get('cx')->getPage()->setContentTitle($objJobs->jobsTitle);
                 \Env::get('cx')->getPage()->setMetaTitle($objJobs->jobsTitle);
             }
             break;
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
             $objTemplate = $this->cx->getTemplate();
             \Permission::checkAccess(148, 'static');
             $subMenuTitle = $_CORELANG['TXT_JOBS_MANAGER'];
             $objJobsManager = new JobsManager();
             $objJobsManager->getJobsPage();
             break;
         default:
             break;
     }
 }
 /**
  * Load your component.
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $objTemplate, $sessionObj;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             if (!isset($sessionObj) || !is_object($sessionObj)) {
                 $sessionObj = \cmsSession::getInstance();
             }
             $objLogin = new \Cx\Core_Modules\Login\Controller\Login(\Env::get('cx')->getPage()->getContent());
             $pageTitle = \Env::get('cx')->getPage()->getTitle();
             $pageMetaTitle = \Env::get('cx')->getPage()->getMetatitle();
             \Env::get('cx')->getPage()->setContent($objLogin->getContent($pageMetaTitle, $pageTitle));
             break;
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             if (\FWUser::getFWUserObject()->objUser->login(true)) {
                 \Cx\Core\Csrf\Controller\Csrf::header('location: index.php');
             }
             $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
             $objTemplate = $this->cx->getTemplate();
             $objLoginManager = new \Cx\Core_Modules\Login\Controller\LoginManager();
             $objLoginManager->getPage();
             break;
         default:
             break;
     }
 }
 private static function getClient()
 {
     if (!self::$_client) {
         self::$_client = new GuzzleHttp\Client(array('base_uri' => Env::get('github_api_url', 'https://api.github.com')));
     }
     return self::$_client;
 }
 /**
  * Do something after resolving is done
  *
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function postResolve(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $plainCmd, $cmd, $_CORELANG;
     // CSRF code needs to be even in the login form. otherwise, we
     // could not do a super-generic check later.. NOTE: do NOT move
     // this above the "new cmsSession" line!
     Csrf::add_code();
     // CSRF protection.
     // Note that we only do the check as long as there's no
     // cmd given; this is so we can reload the main screen if
     // the check has failed somehow.
     // fileBrowser is an exception, as it eats CSRF codes like
     // candy. We're doing \Cx\Core\Csrf\Controller\Csrf::check_code() in the relevant
     // parts in the module instead.
     // The CSRF code needn't to be checked in the login module
     // because the user isn't logged in at this point.
     // TODO: Why is upload excluded? The CSRF check doesn't take place in the upload module!
     if (!empty($plainCmd) && !empty($cmd) and !in_array($plainCmd, array('FileBrowser', 'Upload', 'Login', 'Home'))) {
         // Since language initialization in in the same hook as this
         // and we cannot define the order of module-processing,
         // we need to check if language is already initialized:
         if (!is_array($_CORELANG) || !count($_CORELANG)) {
             $objInit = \Env::get('init');
             $objInit->_initBackendLanguage();
             $_CORELANG = $objInit->loadLanguageData('core');
         }
         Csrf::check_code();
     }
 }
 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaBrowser');
     $mediaType = new MediaSource('files', $_ARRAYLANG['TXT_FILEBROWSER_FILES'], array($this->cx->getWebsiteImagesContentPath(), $this->cx->getWebsiteImagesContentWebPath()), array(), 1);
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
 public static function registerYamlSettingEventListener()
 {
     $evm = \Env::get('cx')->getEvents();
     $yamlSettingEventListener = new \Cx\Core\Config\Model\Event\YamlSettingEventListener();
     $evm->addModelListener(\Doctrine\ORM\Events::preUpdate, 'Cx\\Core\\Setting\\Model\\Entity\\YamlSetting', $yamlSettingEventListener);
     $evm->addModelListener('postFlush', 'Cx\\Core\\Setting\\Model\\Entity\\YamlSetting', $yamlSettingEventListener);
 }
Beispiel #16
0
 private function initialize($name)
 {
     $log_file = Env::get('log_path') . date('Y-m-d') . '.log';
     $log = new \Monolog\Logger($name);
     $log->pushHandler(new \Monolog\Handler\StreamHandler($log_file));
     self::$logger[$name] = $log;
 }
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaDir');
     $mediaType = new MediaSource('mediadir', $_ARRAYLANG['TXT_FILEBROWSER_MEDIADIR'], array($this->cx->getWebsiteImagesMediaDirPath(), $this->cx->getWebsiteImagesMediaDirWebPath()), array(153));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
 public function runTaskAction()
 {
     // load details
     $taskId = @$_GET['id'];
     $classMethod = @$_GET['method'];
     $mac = @$_GET['auth'];
     // verify hash
     $date = new \DateTime();
     $password = hash('sha256', $date->format('Y-m-d H:i:s') . $taskId . Env::get('auth_salt'));
     $expectedMac = hash_hmac('sha256', $classMethod, $password);
     // if hash is invalid, try again with a 1 second ago date
     if ($mac != $expectedMac) {
         $date = (new \DateTime())->sub(new \DateInterval("PT1S"));
         $password = hash('sha256', $date->format('Y-m-d H:i:s') . $taskId . Env::get('auth_salt'));
         $expectedMac = hash_hmac('sha256', $classMethod, $password);
     }
     if ($mac != $expectedMac) {
         throw new \Exception('Invalid auth token');
     }
     $classMethod = json_decode($classMethod);
     $class = $classMethod[0];
     $method = $classMethod[1];
     $obj = new $class();
     $obj->{$method}();
 }
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('Gallery');
     $mediaType = new MediaSource('gallery', $_ARRAYLANG['TXT_THUMBNAIL_GALLERY'], array($this->cx->getWebsiteImagesGalleryPath(), $this->cx->getWebsiteImagesGalleryWebPath(), array(12, 67)));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
Beispiel #20
0
    /**
     * Returns the group ids with access to front- or backend of a page
     * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get the group ids of
     * @param boolean $frontend True for frontend access groups, false for backend
     * @return mixed Array of group ids or false on error
     * @throws PageGuardException 
     */
    public function getAssignedGroupIds($page, $frontend)
    {
        if ($frontend && !$page->isFrontendProtected()) {
            return array();
        }
        if (!$frontend && !$page->isBackendProtected()) {
            return array();
        }
        try {
            $accessId = $this->getAccessId($page, $frontend);
        } catch (PageGuardException $e) {
            // the selected page is listed as protected but does not have an access id.
            // this is probably due to a db inconsistency, which we should be able to handle gracefully:
            $accessId = \Permission::createNewDynamicAccessId();
            if ($frontend && $accessId) {
                $page->setFrontendAccessId($accessId);
            } elseif (!$frontend && $accessId) {
                $page->setBackendAccessId($accessId);
            } else {
                // cannot create a new dynamic access id.
                throw new PageGuardException('This protected page doesn\'t have an access id associated with
it. Contrexx encountered an error while generating a new access id.');
            }
            Env::get('em')->persist($page);
            Env::get('em')->flush();
        }
        return \Permission::getGroupIdsForAccessId($accessId);
    }
 public function testDelete()
 {
     $objTransaction = new Transaction(\Env::get('db'));
     $arrInput = $this->getTestData();
     $arrInput['id'] = $objTransaction->add($arrInput['status'], $arrInput['invoice_number'], $arrInput['invoice_currency'], $arrInput['invoice_amount'], $arrInput['contact_title'], $arrInput['contact_forename'], $arrInput['contact_surname'], $arrInput['contact_company'], $arrInput['contact_street'], $arrInput['contact_postcode'], $arrInput['contact_place'], 204, $arrInput['contact_phone'], $arrInput['contact_email']);
     $objTransaction->delete($arrInput['id']);
     $this->assertFalse($objTransaction->get(array($arrInput['id'])));
 }
Beispiel #22
0
/**
 * Checks if a certain module, specified by param $moduleName, is installed.
 *
 * @param   string  $moduleName
 * @deprecated
 * @return  boolean
 */
function contrexx_isModuleInstalled($moduleName)
{
    static $objModuleChecker = NULL;
    if (!isset($objModuleChecker)) {
        $objModuleChecker = \Cx\Core\ModuleChecker::getInstance(\Env::get('em'), \Env::get('db'), \Env::get('ClassLoader'));
    }
    return $objModuleChecker->isModuleInstalled($moduleName);
}
Beispiel #23
0
 public static function getInstance()
 {
     static $objCaptcha = null;
     if (!isset($objCaptcha)) {
         $objCaptcha = new self(\Env::get('config'));
     }
     return $objCaptcha;
 }
Beispiel #24
0
 public function gen($controller, $method = 'index', $parameters = [])
 {
     $url = $controller . '/' . $method . '/';
     if (!empty($parameters)) {
         $url .= implode('/', $parameters);
     }
     return Env::get('base_href') . '/' . $url;
 }
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('MediaBrowser');
     $mediaType = new MediaSource('shop', $_ARRAYLANG['TXT_FILEBROWSER_SHOP'], array($this->cx->getWebsiteImagesShopPath(), $this->cx->getWebsiteImagesShopWebPath()));
     $mediaType->setAccessIds(array(13));
     $mediaBrowserConfiguration->addMediaType($mediaType);
 }
 public function getMainDomain()
 {
     $config = \Env::get('config');
     if (!empty($config['mainDomainId']) && isset($this->entities[$config['mainDomainId']])) {
         return $this->entities[$config['mainDomainId']];
     }
     $objDomain = $this->findBy(array('name' => $_SERVER['SERVER_NAME']));
     return $objDomain[0];
 }
 /**
  * Load your component.
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             $errorObj = new Error(\Env::get('cx')->getPage()->getContent());
             \Env::get('cx')->getPage()->setContent($errorObj->getErrorPage());
             break;
     }
 }
 /**
  * @param MediaSourceManager $mediaBrowserConfiguration
  */
 public function mediasourceLoad(MediaSourceManager $mediaBrowserConfiguration)
 {
     global $_ARRAYLANG;
     \Env::get('init')->loadLanguageData('Media');
     for ($i = 1; $i < 5; $i++) {
         $mediaType = new MediaSource('media' . $i, $_ARRAYLANG['TXT_MEDIA_ARCHIVE'] . ' ' . $i, array(call_user_func(array($this->cx, 'getWebsiteMediaarchive' . $i . 'Path')), call_user_func(array($this->cx, 'getWebsiteMediaarchive' . $i . 'WebPath'))), array(7, 39, 38));
         $mediaBrowserConfiguration->addMediaType($mediaType);
     }
 }
 public function __construct()
 {
     //this is a workaround for the error
     //"PDOException: You cannot serialize or unserialize PDO instances"
     //which appears since changing the charset to utf8 on doctrine config.
     parent::__construct();
     self::$cx = \Env::get('cx');
     $this->backupGlobals = false;
     $this->backupStaticAttributes = false;
 }
Beispiel #30
0
 /**
  * Constructor
  *
  */
 function __construct($langId = null)
 {
     global $_FRONTEND_LANGID;
     $this->em = \Env::get('em');
     if (!isset($langId)) {
         $langId = $_FRONTEND_LANGID;
     }
     $this->langId = $langId;
     $this->buildTree();
 }