public function loadThumbnails()
 {
     /**
      * @var $cx \Cx\Core\Core\Controller\Cx
      */
     $pdo = $this->cx->getDb()->getPdoConnection();
     $sth = $pdo->query('SELECT id,name, size,  100 as quality, CONCAT(".thumb_",name) as value FROM  `' . DBPREFIX . 'settings_thumbnail`');
     self::$thumbnails = $sth->fetchAll();
 }
 /**
  * Get a component controller object
  * 
  * @param string $name  component name
  * @return \Cx\Core\Core\Model\Entity\SystemComponentController 
  * The requested component controller or null if no such component exists
  */
 public function getComponent($name)
 {
     if (empty($name)) {
         return null;
     }
     $componentRepo = $this->cx->getDb()->getEntityManager()->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent');
     $component = $componentRepo->findOneBy(array('name' => $name));
     if (!$component) {
         return null;
     }
     return $component->getSystemComponentController();
 }
 /**
  * Do something before resolving is done
  *
  * @param \Cx\Core\Routing\Url                      $request    The URL object for this request
  */
 public function preResolve(\Cx\Core\Routing\Url $request)
 {
     if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_BACKEND) {
         $sessionObj = $this->getSession();
         $sessionObj->cmsSessionStatusUpdate('backend');
     }
 }
Exemplo n.º 4
0
 protected function initDefaultCategoryImage()
 {
     $this->defaultCategoryImage['src'] = \Cx\Core\Core\Controller\Cx::instanciate()->getClassLoader()->getWebFilePath(\Cx\Core\Core\Controller\Cx::instanciate()->getModuleFolderName() . '/Downloads/View/Media/no_picture.gif');
     $imageSize = getimagesize(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBasePath() . $this->defaultCategoryImage['src']);
     $this->defaultCategoryImage['width'] = $imageSize[0];
     $this->defaultCategoryImage['height'] = $imageSize[1];
 }
 private function __construct()
 {
     global $objInit;
     $backOrFrontend = $objInit->mode;
     // TODO: Unused
     //        global $objFWUser;
     //        $langId;
     if ($backOrFrontend == "frontend") {
         $langId = $objInit->getFrontendLangId();
     } else {
         //backend
         $langId = $objInit->getBackendLangId();
     }
     $langCode = FWLanguage::getLanguageCodeById($langId);
     $this->setVariable(array('path' => ASCMS_PATH_OFFSET . '/' . $langCode . '/', 'basePath' => ASCMS_PATH_OFFSET . '/', 'cadminPath' => \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteBackendPath() . '/', 'mode' => $objInit->mode, 'language' => $langCode, 'csrf' => \Cx\Core\Csrf\Controller\Csrf::code()), 'contrexx');
     //let i18n set it's variables
     $i18n = new ContrexxJavascriptI18n($langCode);
     $i18n->variablesTo($this);
     //determine the correct jquery ui css' path.
     //the user might have overridden the default css in the theme, so look out for this too.
     $jQUiCssPath = 'themes/' . $objInit->getCurrentThemesPath() . '/jquery-ui.css';
     //customized css would be here
     if ($objInit->mode != 'frontend' || !file_exists(ASCMS_DOCUMENT_ROOT . '/' . $jQUiCssPath)) {
         //use standard css
         $jQUiCssPath = 'lib/javascript/jquery/ui/css/jquery-ui.css';
     }
     $this->setVariable(array('jQueryUiCss' => $jQUiCssPath), 'contrexx-ui');
 }
Exemplo n.º 6
0
 /**
  * Test the subdirectory check in the filesystem class
  */
 public function testSubdirectoryCheck()
 {
     $cx = Cx::instanciate();
     $this->assertTrue(MediaSourceManager::isSubdirectory($cx->getWebsitePath() . '/images', 'files/'));
     $this->assertFalse(MediaSourceManager::isSubdirectory($cx->getWebsitePath() . '/media', 'files/'));
     $this->assertFalse(MediaSourceManager::isSubdirectory($cx->getWebsitePath() . '/images', 'media5/'));
 }
Exemplo n.º 7
0
 /**
  * Get the requested Page.
  *
  * @access  public
  */
 public function getPage()
 {
     $_GET['act'] = empty($_GET['act']) ? '' : $_GET['act'];
     switch ($_GET['act']) {
         case 'lostpw':
             $this->showPasswordLost();
             break;
         case 'resetpw':
             $this->showPasswordReset();
             break;
         case 'verify':
             $this->verifyUserAccount();
             break;
         case 'captcha':
             $this->getCaptcha();
             break;
         default:
             $this->showLogin();
             break;
     }
     $this->objTemplate->setVariable('CONTREXX_CHARSET', CONTREXX_CHARSET);
     $endcode = $this->objTemplate->get();
     // replace links from before contrexx 3
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $ls = new \LinkSanitizer($cx, $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . '/', $endcode);
     $endcode = $ls->replace();
     echo $endcode;
     exit;
 }
Exemplo n.º 8
0
 function __construct($path)
 {
     $this->cx = \Cx\Core\Core\Controller\Cx::instanciate();
     if (!$path) {
         throw new \InvalidArgumentException("Path shouldn't be empty: Given: " . $path);
     }
     $this->rootPath = rtrim($path, '/');
 }
 /**
  * Constructor
  */
 function __construct($name)
 {
     $this->imagePath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesMediaDirPath() . '/';
     $this->imageWebPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesMediaDirWebPath() . '/';
     parent::__construct('.', $name);
     parent::getFrontendLanguages();
     parent::getSettings();
 }
Exemplo n.º 10
0
 function getContainer()
 {
     $path = $this->cx->getCodeBaseCoreModulePath() . '/Uploader/View/Template/Backend/Uploader' . $this->options['uploader-type'] . '.html';
     $template = new Sigma();
     $template->loadTemplateFile($path);
     $template->setVariable(array('UPLOADER_ID' => $this->id, 'UPLOADER_CODE' => file_get_contents($this->cx->getCodeBaseCoreModulePath() . '/Uploader/View/Template/Backend/Uploader.html')));
     return $template->get();
 }
Exemplo n.º 11
0
 protected function renderElement($title, $level, $hasChilds, $lang, $path, $current, $page)
 {
     $width = $level * 25;
     $spacer = "<img src='" . ASCMS_CORE_MODULE_FOLDER . "/Sitemap/View/Media/spacer.gif' width='{$width}' height='12' alt='' />";
     $linkTarget = $page->getLinkTarget();
     $this->template->setVariable(array('STYLE' => self::cssPrefix . '_' . $level, 'SPACER' => $spacer, 'NAME' => $title, 'TARGET' => empty($linkTarget) ? '_self' : $linkTarget, 'URL' => \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . $this->virtualLanguageDirectory . $path));
     $this->template->parse('sitemap');
 }
 /**
  * postInit
  *
  * @param \Cx\Core\Core\Controller\Cx $cx
  *
  * @return null
  */
 public function postInit(\Cx\Core\Core\Controller\Cx $cx)
 {
     $componentController = $this->getComponent('MultiSite');
     if (!$componentController) {
         return;
     }
     \Cx\Core\Setting\Controller\Setting::init('MultiSite', 'config', 'FileSystem');
     if (\Cx\Core\Setting\Controller\Setting::getValue('mode', 'MultiSite') != \Cx\Core_Modules\MultiSite\Controller\ComponentController::MODE_WEBSITE) {
         return;
     }
     $updateFile = $cx->getWebsiteTempPath() . '/Update/' . \Cx\Core_Modules\Update\Model\Repository\DeltaRepository::PENDING_DB_UPDATES_YML;
     if (!file_exists($updateFile)) {
         return;
     }
     $componentController->setCustomerPanelDomainAsMainDomain();
     $updateController = $this->getController('Update');
     $updateController->applyDelta();
 }
 /**
  * Constructor
  */
 function __construct($name)
 {
     global $_ARRAYLANG, $_CORELANG, $objTemplate, $_CONFIG;
     $this->act = !empty($_GET['act']) ? $_GET['act'] : '';
     $this->limit = $_CONFIG['corePagingLimit'];
     $this->offset = !empty($_GET['pos']) ? $_GET['pos'] : 0;
     parent::__construct(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseModulePath() . '/MediaDir/View/Template/Backend', $name);
     parent::getFrontendLanguages();
 }
Exemplo n.º 14
0
 /**
  * Do something before resolving is done
  * 
  * @param \Cx\Core\Routing\Url                      $request    The URL object for this request
  */
 public function preResolve(\Cx\Core\Routing\Url $request)
 {
     global $sessionObj;
     if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_BACKEND) {
         if (empty($sessionObj)) {
             $sessionObj = \cmsSession::getInstance();
         }
         $_SESSION->cmsSessionStatusUpdate('backend');
     }
 }
Exemplo n.º 15
0
 /**
  * PHP5 constructor
  *
  * @global array
  * @global array
  * @global HTML_Teplate_Sigma
  */
 function __construct()
 {
     global $_ARRAYLANG, $_CORELANG, $objTemplate;
     $this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_MODULE_PATH . '/Market/View/Template/Backend');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
     $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE);
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $this->mediaPath = $cx->getWebsiteMediaMarketPath() . '/';
     $this->mediaWebPath = $cx->getWebsiteMediaMarketWebPath() . '/';
     $this->settings = $this->getSettings();
 }
Exemplo n.º 16
0
 protected function initDefaultCategoryImage()
 {
     $this->defaultCategoryImage['src'] = ASCMS_DOWNLOADS_IMAGES_WEB_PATH . '/no_picture.gif';
     if (file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . $this->defaultCategoryImage['src'])) {
         $imageSize = getimagesize(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . $this->defaultCategoryImage['src']);
     } else {
         $imageSize = getimagesize(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseDocumentRootPath() . $this->defaultCategoryImage['src']);
     }
     $this->defaultCategoryImage['width'] = $imageSize[0];
     $this->defaultCategoryImage['height'] = $imageSize[1];
 }
Exemplo n.º 17
0
 /**
  * Returns the created path by the given array.
  *
  * @param   array   $matches
  * @return  string  created path
  */
 private function getPath($matches)
 {
     // The Shop JS Cart escapes pathes because he loads it via JavaScript.
     // For this reason, we replace escaped slashes by slashes.
     $matches[\LinkSanitizer::FILE_PATH] = str_replace('\\/', '/', $matches[\LinkSanitizer::FILE_PATH]);
     $testPath = explode('?', $matches[\LinkSanitizer::FILE_PATH], 2);
     if ($testPath[0] == 'index.php' || $testPath[0] == '' || $testPath[0] == './') {
         $ret = ASCMS_INSTANCE_OFFSET;
         if (\Env::get('cx')->getMode() == \Cx\Core\Core\Controller\Cx::MODE_BACKEND) {
             $ret .= \Cx\Core\Core\Controller\Cx::instanciate()->getBackendFolderName();
         }
         $ret .= '/';
         if (isset($testPath[1])) {
             $args = preg_split('/&(amp;)?/', $testPath[1]);
             $params = array();
             foreach ($args as $arg) {
                 $split = explode('=', $arg, 2);
                 $params[$split[0]] = $split[1];
             }
             // frontend case
             if (isset($params['section'])) {
                 $cmd = '';
                 if (isset($params['cmd'])) {
                     $cmd = $params['cmd'];
                     unset($params['cmd']);
                 }
                 $ret = \Cx\Core\Routing\Url::fromModuleAndCmd($params['section'], $cmd);
                 unset($params['section']);
                 // backend case
             } else {
                 if (isset($params['cmd'])) {
                     $ret .= $params['cmd'];
                     unset($params['cmd']);
                     if (isset($params['act'])) {
                         $ret .= '/' . $params['act'];
                         unset($params['act']);
                     }
                 }
             }
             if (count($params)) {
                 $ret .= '?' . http_build_query($params);
             }
         }
         return $matches[\LinkSanitizer::ATTRIBUTE_AND_OPEN_QUOTE] . $ret . $matches[\LinkSanitizer::CLOSE_QUOTE];
     } else {
         if ($this->fileExists(ASCMS_DOCUMENT_ROOT . '/' . $matches[\LinkSanitizer::FILE_PATH])) {
             // this is an existing file, do not add virtual language dir
             return $matches[\LinkSanitizer::ATTRIBUTE_AND_OPEN_QUOTE] . ASCMS_INSTANCE_OFFSET . '/' . $matches[\LinkSanitizer::FILE_PATH] . $matches[\LinkSanitizer::CLOSE_QUOTE];
         } else {
             // this is a link to a page, add virtual language dir
             return $matches[\LinkSanitizer::ATTRIBUTE_AND_OPEN_QUOTE] . $this->offset . $matches[\LinkSanitizer::FILE_PATH] . $matches[\LinkSanitizer::CLOSE_QUOTE];
         }
     }
 }
Exemplo n.º 18
0
 /**
  * @param string $buttonName
  *
  * @return string
  */
 function getXHtml($buttonName = "Upload")
 {
     $path = $this->cx->getCodeBaseCoreModulePath() . '/Uploader/View/Template/Backend/Uploader' . $this->options['uploader-type'] . '.html';
     $template = new Sigma();
     $template->loadTemplateFile($path);
     $template->setVariable(array('UPLOADER_ID' => $this->id, 'UPLOADER_CODE' => file_get_contents($this->cx->getCodeBaseCoreModulePath() . '/Uploader/View/Template/Backend/Uploader.html')));
     if ($this->options['uploader-type'] == self::UPLOADER_TYPE_INLINE) {
         $this->addClass('uploader-button-hidden');
     }
     return '<button ' . $this->getOptionsString() . ' disabled>' . $buttonName . '</button>' . $template->get();
 }
Exemplo n.º 19
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $folderPath = $cx->getWebsiteTempPath() . '/Update';
     if (!file_exists($folderPath)) {
         \Cx\Lib\FileSystem\FileSystem::make_folder($folderPath);
     }
     if (!file_exists($folderPath . '/' . self::PENDING_DB_UPDATES_YML)) {
         \Cx\Lib\FileSystem\FileSystem::copy_file($cx->getCodeBaseCoreModulePath() . '/Update/Data/' . self::PENDING_DB_UPDATES_YML, $folderPath . '/' . self::PENDING_DB_UPDATES_YML);
     }
     parent::__construct($folderPath . '/' . self::PENDING_DB_UPDATES_YML);
 }
Exemplo n.º 20
0
 /**
  * @param $params
  */
 public function removeFile($params)
 {
     \Env::get('init')->loadLanguageData('MediaBrowser');
     $path = !empty($params['get']['path']) ? contrexx_input2raw($params['get']['path']) : null;
     $filename = !empty($params['post']['file']['datainfo']['name']) ? contrexx_input2raw($params['post']['file']['datainfo']['name']) : null;
     if ($filename && $path) {
         $pathArray = explode('/', $path);
         // Shift off the first element of the array to get the media type.
         $mediaType = array_shift($pathArray);
         $strPath = '/' . join('/', $pathArray);
         $this->setMessage($this->cx->getMediaSourceManager()->getMediaType($mediaType)->getFileSystem()->removeFile(new \Cx\Core\MediaSource\Model\Entity\LocalFile($strPath . $filename)));
     }
 }
Exemplo n.º 21
0
 /**
  * @param String $name
  *
  * @return array
  * @throws ParserException
  */
 public function retrieve($name)
 {
     $file = file_get_contents(\Cx\Core\Core\Controller\Cx::instanciate()->getClassLoader()->getFilePath($this->path . '/' . $name . '/options/options.yml'));
     if ($file) {
         try {
             $yaml = new Parser();
             return $yaml->parse($file);
         } catch (ParserException $e) {
             preg_match("/line (?P<line>[0-9]+)/", $e->getMessage(), $matches);
             throw new ParserException($e->getMessage(), $matches['line']);
         }
     } else {
         throw new ParserException("File" . $this->path . '/' . $name . '/options/options.yml not found');
     }
 }
 /**
  * Clears a cache page
  * @param string $urlPattern Drop all pages that match the pattern, for exact format, make educated guesses
  * @param string $domain Domain name to drop cache page of
  * @param int $port Port to drop cache page of
  */
 protected function clearCachePageForDomainAndPort($urlPattern, $domain, $port)
 {
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $strCachePath = $cx->getWebsiteCachePath() . '/';
     $glob = null;
     if ($urlPattern == '*') {
         $glob = $strCachePath . '*';
     }
     if (!$glob) {
         $searchParts = $cx->getComponent('Cache')->getCacheFileNameSearchPartsFromUrl($urlPattern);
         $glob = $strCachePath . $cx->getComponent('Cache')->getCacheFileNameFromUrl($urlPattern, false) . '*' . implode('', $searchParts) . '*';
     }
     if ($glob !== null) {
         $fileNames = glob($glob);
         foreach ($fileNames as $fileName) {
             if (!preg_match('#/[0-9a-f]{32}((_[plutgc][a-z0-9]+)+)?$#', $fileName)) {
                 continue;
             }
             try {
                 $file = new \Cx\Lib\FileSystem\File($fileName);
                 $file->delete();
             } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
             }
         }
         return;
     }
     $cacheFile = $cx->getComponent('Cache')->getCacheFileNameFromUrl($urlPattern);
     try {
         $file = new \Cx\Lib\FileSystem\File($strCachePath . $cacheFile);
         $file->delete();
     } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
     }
     // make sure HTTP and HTTPS files are dropped
     if (substr($urlPattern, 0, 5) == 'https') {
         $urlPattern = 'http' . substr($urlPattern, 5);
     } else {
         if (substr($urlPattern, 0, 4) == 'http') {
             $urlPattern = 'https' . substr($urlPattern, 4);
         }
     }
     $cacheFile = md5($urlPattern);
     try {
         $file = new \Cx\Lib\FileSystem\File($strCachePath . $cacheFile);
         $file->delete();
     } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
     }
 }
Exemplo n.º 23
0
 public function getDetailPage()
 {
     global $_ARRAYLANG, $objDatabase;
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $file = str_replace($cx->getWebsiteOffsetPath(), '', $_GET["path"]) . $_GET["file"];
     $objResult = $objDatabase->Execute("SELECT `id`, `file`, `source`, `hash`, `check`, `expiration_date` FROM " . DBPREFIX . "module_filesharing WHERE `source` = '" . contrexx_raw2db($file) . "'");
     $existing = $objResult !== false && $objResult->RecordCount() > 0;
     if ($_GET["switch"]) {
         if ($existing) {
             $objDatabase->Execute("DELETE FROM " . DBPREFIX . "module_filesharing WHERE `source` = '" . contrexx_raw2db($file) . "'");
         } else {
             $hash = FileSharingLib::createHash();
             $check = FileSharingLib::createCheck($hash);
             $source = str_replace($cx->getWebsiteOffsetPath(), '', $_GET["path"]) . $_GET["file"];
             $objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_filesharing (`file`, `source`, `hash`, `check`) VALUES ('" . contrexx_raw2db($source) . "', '" . contrexx_raw2db($source) . "', '" . contrexx_raw2db($hash) . "', '" . contrexx_raw2db($check) . "')");
         }
         $existing = !$existing;
     }
     if ($existing) {
         $this->_objTpl->setVariable(array('FILE_STATUS' => $_ARRAYLANG["TXT_FILESHARING_SHARED"], 'FILE_STATUS_SWITCH' => $_ARRAYLANG["TXT_FILESHARING_STOP_SHARING"], 'FILE_STATUS_SWITCH_HREF' => 'index.php?cmd=Media&amp;archive=FileSharing&amp;act=filesharing&amp;path=' . $_GET["path"] . '&amp;file=' . $_GET["file"] . '&amp;switch=1'));
         $this->_objTpl->touchBlock('shared');
     } else {
         $this->_objTpl->setVariable(array('FILE_STATUS' => $_ARRAYLANG["TXT_FILESHARING_NOT_SHARED"], 'FILE_STATUS_SWITCH' => $_ARRAYLANG["TXT_FILESHARING_START_SHARING"], 'FILE_STATUS_SWITCH_HREF' => 'index.php?cmd=Media&amp;archive=FileSharing&amp;act=filesharing&amp;path=' . $_GET["path"] . '&amp;file=' . $_GET["file"] . '&amp;switch=1'));
         $this->_objTpl->hideBlock('shared');
     }
     if ($_POST["shareFiles"]) {
         $emails = array();
         foreach (preg_split('/[;,\\s]+/', $_POST["email"]) as $email) {
             if (\FWValidator::isEmail($email)) {
                 $emails[] = contrexx_input2raw($email);
             }
         }
         if (count($emails) > 0) {
             FileSharingLib::sendMail($objResult->fields["id"], $_POST["subject"], $emails, $_POST["message"]);
         }
     } elseif ($_POST["saveExpiration"]) {
         if ($_POST["expiration"]) {
             $objDatabase->Execute("UPDATE " . DBPREFIX . "module_filesharing SET `expiration_date` = NULL WHERE `id` = " . $objResult->fields["id"]);
         } else {
             $objDatabase->Execute("UPDATE " . DBPREFIX . "module_filesharing SET `expiration_date` = '" . date('Y-m-d H:i:s', strtotime($_POST["expirationDate"])) . "' WHERE `id` = " . $objResult->fields["id"]);
         }
     }
     $objResult = $objDatabase->Execute("SELECT `id`, `hash`, `check`, `expiration_date` FROM " . DBPREFIX . "module_filesharing WHERE `source` = '" . contrexx_raw2db($file) . "'");
     $this->_objTpl->setVariable(array('FORM_ACTION' => 'index.php?cmd=Media&amp;archive=FileSharing&amp;act=filesharing&amp;path=' . $_GET["path"] . '&amp;file=' . $_GET["file"], 'FORM_METHOD' => 'POST', 'FILESHARING_INFO' => $_ARRAYLANG['TXT_FILESHARING_INFO'], 'FILESHARING_LINK_BACK_HREF' => 'index.php?cmd=Media&amp;archive=FileSharing&amp;path=' . $_GET["path"], 'FILESHARING_LINK_BACK' => $_ARRAYLANG['TXT_FILESHARING_LINK_BACK'], 'FILESHARING_DOWNLOAD_LINK' => $_ARRAYLANG['TXT_FILESHARING_DOWNLOAD_LINK'], 'FILE_DOWNLOAD_LINK_HREF' => FileSharingLib::getDownloadLink($objResult->fields["id"]), 'FILE_DELETE_LINK_HREF' => FileSharingLib::getDeleteLink($objResult->fields["id"]), 'FILESHARING_DELETE_LINK' => $_ARRAYLANG['TXT_FILESHARING_DELETE_LINK'], 'FILESHARING_STATUS' => $_ARRAYLANG['TXT_FILESHARING_STATUS'], 'FILESHARING_EXPIRATION' => $_ARRAYLANG['TXT_FILESHARING_EXPIRATION'], 'FILESHARING_NEVER' => $_ARRAYLANG['TXT_FILESHARING_NEVER'], 'FILESHARING_EXPIRATION_CHECKED' => htmlentities($objResult->fields["expiration_date"] == NULL ? 'checked="checked"' : '', ENT_QUOTES, CONTREXX_CHARSET), 'FILESHARING_EXPIRATION_DATE' => htmlentities($objResult->fields["expiration_date"] != NULL ? date('d.m.Y H:i', strtotime($objResult->fields["expiration_date"])) : date('d.m.Y H:i', time() + 3600 * 24 * 7), ENT_QUOTES, CONTREXX_CHARSET), 'FILESHARING_SEND_MAIL' => $_ARRAYLANG['TXT_FILESHARING_SEND_MAIL'], 'FILESHARING_EMAIL' => $_ARRAYLANG["TXT_FILESHARING_EMAIL"], 'FILESHARING_EMAIL_INFO' => $_ARRAYLANG["TXT_FILESHARING_EMAIL_INFO"], 'FILESHARING_SUBJECT' => $_ARRAYLANG["TXT_FILESHARING_SUBJECT"], 'FILESHARING_SUBJECT_INFO' => $_ARRAYLANG["TXT_FILESHARING_SUBJECT_INFO"], 'FILESHARING_MESSAGE' => $_ARRAYLANG["TXT_FILESHARING_MESSAGE"], 'FILESHARING_MESSAGE_INFO' => $_ARRAYLANG["TXT_FILESHARING_MESSAGE_INFO"], 'FILESHARING_SEND' => $_ARRAYLANG["TXT_FILESHARING_SEND"], 'FILESHARING_SAVE' => $_ARRAYLANG["TXT_FILESHARING_SAVE"], 'TXT_CORE_MAILTEMPLATE_NOTE_TO' => $_ARRAYLANG['TXT_CORE_MAILTEMPLATE_NOTE_TO']));
 }
Exemplo n.º 24
0
 public static function get($prop)
 {
     switch ($prop) {
         case 'em':
             return \Cx\Core\Core\Controller\Cx::instanciate()->getDb()->getEntityManager();
             break;
         case 'cx':
             if (!isset(self::$props[$prop]) && class_exists('\\Cx\\Core\\Core\\Controller\\Cx')) {
                 return \Cx\Core\Core\Controller\Cx::instanciate();
             }
         default:
             if (isset(self::$props[$prop])) {
                 return self::$props[$prop];
             }
             break;
     }
     return null;
 }
Exemplo n.º 25
0
 private function __construct($config)
 {
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $sessionObj = $cx->getComponent('Session')->getSession();
     // TODO: move to basic configuration screen (/cadmin/index.php?cmd=settings)
     $captchaConfig = array('ReCaptcha' => array('domains' => array('localhost' => array('public_key' => '6LeiusgSAAAAACPI2stz_Qh2fVC1reRUxJuqzf7h', 'private_key' => '6LeiusgSAAAAAABv3CW65svwgRMqFfTiC5NTOzOh'))));
     $config['coreCaptchaLib'] = '';
     $config['coreCaptchaLibConfig'] = json_encode($captchaConfig);
     switch ($config['coreCaptchaLib']) {
         case 'ReCaptcha':
             $this->objCaptcha = new ReCaptcha($config);
             break;
         case 'contrexx':
         default:
             $this->objCaptcha = new ContrexxCaptcha($config);
             break;
     }
 }
 /**
  * Loads the systemComponent using the doctrine entity manager for the existing SystemComponentController and adds it to the repository
  * @param array $preLoadedComponents An array containing the preloaded components
  */
 public function setPreLoadedComponents($preLoadedComponents)
 {
     foreach ($preLoadedComponents as $componentName => $preLoadedComponent) {
         // get systemComponent by name
         $systemComponent = parent::findOneBy(array('name' => $componentName));
         // set systemComponent on existing systemComponentController
         $preLoadedComponent->setSystemComponent($systemComponent);
         // add yaml directory
         $yamlDir = $this->cx->getClassLoader()->getFilePath($preLoadedComponent->getDirectory(false) . '/Model/Yaml');
         if (file_exists($yamlDir)) {
             $this->cx->getDb()->addSchemaFileDirectories(array($yamlDir));
         }
         // store the systemComponent with its now loaded id as key to the array of loaded components
         $this->loadedComponents[$preLoadedComponent->getId()] = $preLoadedComponent;
         // Add JSON adapter
         \Cx\Core\Json\JsonData::addAdapter($preLoadedComponent->getControllersAccessableByJson(), $preLoadedComponent->getNamespace() . '\\Controller');
     }
 }
Exemplo n.º 27
0
 /**
  * PHP5 constructor
  *
  * @global     object    $objTemplate
  * @global    array    $_ARRAYLANG
  */
 function __construct()
 {
     global $objTemplate, $_ARRAYLANG, $objInit;
     $this->objTpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Cache/View/Template/Backend');
     $langData = $objInit->loadLanguageData('Cache');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->objTpl);
     $this->objTpl->setErrorHandling(PEAR_ERROR_DIE);
     $this->arrSettings = $this->getSettings();
     $this->objSettings = new \Cx\Core\Config\Controller\Config();
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     if (is_dir($cx->getWebsiteCachePath())) {
         if (is_writable($cx->getWebsiteCachePath())) {
             $this->strCachePath = $cx->getWebsiteCachePath() . '/';
         } else {
             $objTemplate->SetVariable('CONTENT_STATUS_MESSAGE', $_ARRAYLANG['TXT_CACHE_ERR_NOTWRITABLE'] . $cx->getWebsiteCachePath());
         }
     } else {
         $objTemplate->SetVariable('CONTENT_STATUS_MESSAGE', $_ARRAYLANG['TXT_CACHE_ERR_NOTEXIST'] . $cx->getWebsiteCachePath());
     }
     parent::__construct();
 }
Exemplo n.º 28
0
 /**
  * Returns the smallest thumbnail for a file.
  *
  * @param $filename
  *
  * @return string Thumbnail Name
  */
 public function getThumbnailFilename($filename)
 {
     // legacy fallback for older calls.
     if (preg_match('/\\.thumb$/', $filename)) {
         return $filename;
     }
     if (!file_exists($filename) && !file_exists($this->cx->getWebsitePath() . '/' . ltrim($filename, '/'))) {
         return $filename . '.thumb';
     }
     $webpath = pathinfo($filename, PATHINFO_DIRNAME);
     if (!file_exists($filename)) {
         $filename = $this->cx->getWebsitePath() . $filename;
     }
     if (file_exists($filename) && MediaSourceManager::isSubdirectory($this->cx->getWebsitePath(), $filename)) {
         $this->createThumbnailFromPath($filename);
     }
     $extension = pathinfo($filename, PATHINFO_EXTENSION);
     $filename = pathinfo($filename, PATHINFO_FILENAME);
     $this->getThumbnails();
     $thumbnailType = $this->thumbnails[0];
     $thumbnail = preg_replace('/\\.' . lcfirst($extension) . '$/', $thumbnailType['value'] . '.' . lcfirst($extension), $webpath . '/' . $filename . '.' . $extension);
     return $thumbnail;
 }
 /**
  * Searches the content and returns an array that is built as needed by the search module.
  *
  * @param string $searchTerm
  *
  * @return array
  */
 public function searchResultsForSearchModule($searchTerm)
 {
     $em = \Env::get('cx')->getDb()->getEntityManager();
     $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     // only list results in case the associated page of the module is active
     $page = $pageRepo->findOneBy(array('module' => 'MediaDir', 'lang' => FRONTEND_LANG_ID, 'type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION));
     //If page is not exists or page is inactive then return empty result
     if (!$page || !$page->isActive()) {
         return array();
     }
     //get the config site values
     \Cx\Core\Setting\Controller\Setting::init('Config', 'site', 'Yaml');
     $coreListProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config');
     $searchVisibleContentOnly = \Cx\Core\Setting\Controller\Setting::getValue('searchVisibleContentOnly', 'Config');
     //get the config otherConfigurations value
     \Cx\Core\Setting\Controller\Setting::init('Config', 'otherConfigurations', 'Yaml');
     $searchDescriptionLength = \Cx\Core\Setting\Controller\Setting::getValue('searchDescriptionLength', 'Config');
     $hasPageAccess = true;
     $isNotVisible = $searchVisibleContentOnly == 'on' && !$page->isVisible();
     if ($coreListProtectedPages == 'off' && $page->isFrontendProtected()) {
         $hasPageAccess = \Permission::checkAccess($page->getFrontendAccessId(), 'dynamic', true);
     }
     //If the page is invisible and frontend access is denied then return empty result
     if ($isNotVisible || !$hasPageAccess) {
         return array();
     }
     //get the media directory entry by the search term
     $entries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($this->moduleName);
     $entries->getEntries(null, null, null, $searchTerm);
     //if no entries found then return empty result
     if (empty($entries->arrEntries)) {
         return array();
     }
     $results = array();
     $formEntries = array();
     $defaultEntries = null;
     $objForm = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, $this->moduleName);
     $numOfEntries = intval($entries->arrSettings['settingsPagingNumEntries']);
     foreach ($entries->arrEntries as $entry) {
         $pageUrlResult = null;
         $entryForm = $objForm->arrForms[$entry['entryFormId']];
         //Get the entry's link url
         //check the entry's form detail view exists if not,
         //check the entry's form overview exists if not,
         //check the default overview exists if not, dont show the corresponding entry in entry
         switch (true) {
             case $entries->checkPageCmd('detail' . $entry['entryFormId']):
                 $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, 'detail' . $entry['entryFormId'], FRONTEND_LANG_ID, array('eid' => $entry['entryId']));
                 break;
             case $pageCmdExists = $entries->checkPageCmd($entryForm['formCmd']):
             case $entries->checkPageCmd(''):
                 if ($pageCmdExists && !isset($formEntries[$entryForm['formCmd']])) {
                     $formEntries[$entryForm['formCmd']] = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName);
                     $formEntries[$entryForm['formCmd']]->getEntries(null, null, null, null, null, null, 1, null, 'n', null, null, $entryForm['formId']);
                 }
                 if (!$pageCmdExists && !isset($defaultEntries)) {
                     $defaultEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName);
                     $defaultEntries->getEntries();
                 }
                 //get entry's form overview / default page paging position
                 $entriesPerPage = $numOfEntries;
                 if ($pageCmdExists) {
                     $entriesPerPage = !empty($entryForm['formEntriesPerPage']) ? $entryForm['formEntriesPerPage'] : $numOfEntries;
                 }
                 $pageCmd = $pageCmdExists ? $entryForm['formCmd'] : '';
                 $entryKeys = $pageCmdExists ? array_keys($formEntries[$entryForm['formCmd']]->arrEntries) : array_keys($defaultEntries->arrEntries);
                 $entryPos = array_search($entry['entryId'], $entryKeys);
                 $position = floor($entryPos / $entriesPerPage);
                 $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, $pageCmd, FRONTEND_LANG_ID, array('pos' => $position * $entriesPerPage));
                 break;
             default:
                 break;
         }
         //If page url is empty then dont show it in the result
         if (!$pageUrlResult) {
             continue;
         }
         //Get the search results title and content from the form context field 'title' and 'content'
         $title = current($entry['entryFields']);
         $content = '';
         $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName);
         $inputFields = $objInputfields->getInputfields();
         foreach ($inputFields as $arrInputfield) {
             $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : '';
             if (!in_array($contextType, array('title', 'content'))) {
                 continue;
             }
             $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : '';
             $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType);
             try {
                 $objInputfield = safeNew($strInputfieldClass, $this->moduleName);
                 $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null;
                 $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus);
                 if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) {
                     $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[(BLOCK_[A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']);
                     \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage());
                 }
             } catch (\Exception $e) {
                 \DBG::log($e->getMessage());
                 continue;
             }
             $inputFieldValue = $arrInputfieldContent[$this->moduleConstVar . '_INPUTFIELD_VALUE'];
             if (empty($inputFieldValue)) {
                 continue;
             }
             if ($contextType == 'title') {
                 $title = $inputFieldValue;
             } elseif ($contextType == 'content') {
                 $content = \Cx\Core_Modules\Search\Controller\Search::shortenSearchContent($inputFieldValue, $searchDescriptionLength);
             }
         }
         $results[] = array('Score' => 100, 'Title' => html_entity_decode(contrexx_strip_tags($title), ENT_QUOTES, CONTREXX_CHARSET), 'Content' => $content, 'Link' => $pageUrlResult->toString());
     }
     return $results;
 }
    function getJavascriptCheck()
    {
        $fieldName = $this->moduleNameLC . "Inputfield_";
        if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_BACKEND) {
            $hiddenField = "value_hidden = false";
        } else {
            $hiddenField = "value_hidden = document.getElementById('" . $fieldName . "' + field + '_0_hidden').value;";
        }
        $strJavascriptCheck = <<<EOF

            case 'file':
                value = document.getElementById('{$fieldName}' + field + '_0').value;
                {$hiddenField}
                if (value == "" && value_hidden == "" && isRequiredGlobal(inputFields[field][1], value)) {
                    isOk = false;
                    document.getElementById('{$fieldName}' + field + '_0').style.border = "#ff0000 1px solid";
                } else {
                    document.getElementById('{$fieldName}' + field + '_0').style.borderColor = '';
                }
                break;

EOF;
        return $strJavascriptCheck;
    }