Example #1
0
 /**
  *
  * @param mixed $object Array, instance of DataSet, instance of EntityBase, object
  * @param array $options component options
  * @throws ViewGeneratorException if there is any error in try catch statement
  */
 public function __construct($object, $options = array())
 {
     $this->componentOptions = $options;
     $this->viewId = static::$increment++;
     try {
         $cx = \Cx\Core\Core\Controller\Cx::instanciate();
         \JS::registerCSS($cx->getCoreFolderName() . '/Html/View/Style/Backend.css');
         $entityWithNS = preg_replace('/^\\\\/', '', $this->findEntityClass($object));
         // this is a temporary "workaround" for combined keys, see todo
         $entityClassMetadata = \Env::get('em')->getClassMetadata($entityWithNS);
         if (count($entityClassMetadata->getIdentifierFieldNames()) > 1) {
             throw new \Exception('Currently, view generator is not able to handle composite keys...');
         }
         $this->options = array();
         if (isset($options[$entityWithNS]) && is_array($options[$entityWithNS])) {
             $this->options = $options[$entityWithNS];
         } elseif ($entityWithNS == 'array' && isset($options['Cx\\Core_Modules\\Listing\\Model\\Entity\\DataSet']) && isset($options['Cx\\Core_Modules\\Listing\\Model\\Entity\\DataSet'][$object->getIdentifier()])) {
             $this->options = $options['Cx\\Core_Modules\\Listing\\Model\\Entity\\DataSet'][$object->getIdentifier()];
         }
         // If the options for this object are not set, we use the standard values from the component
         if (empty($this->options)) {
             $this->options = $options[''];
         }
         //initialize the row sorting functionality
         $this->getSortingOption($entityWithNS);
         if ((!isset($_POST['vg_increment_number']) || $_POST['vg_increment_number'] != $this->viewId) && (!isset($_GET['vg_increment_number']) || $_GET['vg_increment_number'] != $this->viewId)) {
             $vgIncrementNo = 'empty';
             if (isset($_POST['vg_increment_number'])) {
                 $vgIncrementNo = '#' . $_POST['vg_increment_number'];
             } else {
                 if (isset($_GET['vg_increment_number'])) {
                     $vgIncrementNo = '#' . $_GET['vg_increment_number'];
                 }
             }
             // do not make any changes to entities of other view generator instances!
             \DBG::msg('Omitting changes, my ID is #' . $this->viewId . ', supplied viewId was ' . $vgIncrementNo);
             return;
         }
         // execute add if entry is a doctrine entity (or execute callback if specified in configuration)
         // post add
         if (!empty($_GET['add']) && (!empty($this->options['functions']['add']) && $this->options['functions']['add'] != false) || !empty($this->options['functions']['allowAdd']) && $this->options['functions']['allowAdd'] != false) {
             $this->saveEntry($entityWithNS);
         }
         // execute edit if entry is a doctrine entity (or execute callback if specified in configuration)
         // post edit
         $editId = $this->getEntryId();
         if ($editId != 0 && (!empty($this->options['functions']['edit']) && $this->options['functions']['edit'] != false || !empty($this->options['functions']['allowEdit']) && $this->options['functions']['allowEdit'] != false)) {
             $this->saveEntry($entityWithNS);
         }
         // execute remove if entry is a doctrine entity (or execute callback if specified in configuration)
         // post remove
         $deleteId = !empty($_GET['deleteid']) ? contrexx_input2raw($_GET['deleteid']) : '';
         if ($deleteId != '' && (!empty($this->options['functions']['delete']) && $this->options['functions']['delete'] != false || !empty($this->options['functions']['allowDelete']) && $this->options['functions']['allowDelete'] != false)) {
             $this->removeEntry($entityWithNS);
         }
     } catch (\Exception $e) {
         \Message::add($e->getMessage());
         return;
     }
 }
 /**
  * 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 $subMenuTitle, $_CORELANG, $objTemplate;
     switch ($this->cx->getMode()) {
         case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
             $objKnowledge = new Knowledge(\Env::get('cx')->getPage()->getContent());
             \Env::get('cx')->getPage()->setContent($objKnowledge->getPage());
             if (!empty($objKnowledge->pageTitle)) {
                 \Env::get('cx')->getPage()->setTitle($objKnowledge->pageTitle);
                 \Env::get('cx')->getPage()->setContentTitle($objKnowledge->pageTitle);
                 \Env::get('cx')->getPage()->setMetaTitle($objKnowledge->pageTitle);
             }
             break;
         case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
             $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
             $objTemplate = $this->cx->getTemplate();
             if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory() . '/View/Style/backend.css'))) {
                 \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/backend.css', 1));
             }
             \Permission::checkAccess(129, 'static');
             $subMenuTitle = $_CORELANG['TXT_KNOWLEDGE'];
             $objKnowledge = new KnowledgeAdmin();
             $objKnowledge->getPage();
             break;
     }
 }
 /**
  * It displayes the import menu
  *
  * @return customer import screen
  */
 function showImport()
 {
     global $_ARRAYLANG, $objDatabase;
     \JS::activate('cx');
     \JS::activate('jqueryui');
     \JS::registerCSS('modules/Crm/View/Style/main.css');
     \JS::registerJS('modules/Crm/View/Script/contactexport.js');
     \JS::registerJS('lib/javascript/jquery.form.js');
     \JS::registerJS('lib/javascript/jquery.tmpl.min.js');
     \JS::registerJS('lib/javascript/jquery.base64.js');
     \JS::registerJS('lib/javascript/jquery.format.js');
     $objTpl = $this->_objTpl;
     $objTpl->addBlockfile('CRM_SETTINGS_FILE', 'settings_block', "module_{$this->moduleNameLC}_interface_import_options.html");
     $objTpl->setGlobalVariable(array('MODULE_NAME' => $this->moduleName));
     foreach ($this->_delimiter as $key => $value) {
         $objTpl->setVariable(array('CRM_DELIMITER_VALUE' => $key, 'CRM_DELIMITER_TITLE' => $_ARRAYLANG[$value['placeholder']]));
         $objTpl->parse('crm_delimiter');
     }
     foreach ($this->_enclosure as $key => $value) {
         $objTpl->setVariable(array('CRM_ENCLOSURE_VALUE' => $key, 'CRM_ENCLOSURE_TITLE' => $_ARRAYLANG[$value['placeholder']]));
         $objTpl->parse('crm_enclosure');
     }
     $options = array('upload-limit' => 1, 'id' => 'importUploader', 'style' => 'display:none;', 'allowed-extensions' => array('csv'));
     $uploaderCode = $this->initUploader('uploadFinished', 'importCallbackJs', '', '', $options);
     $redirectUrl = \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Crm&act=getImportFilename');
     $this->_objTpl->setVariable(array('COMBO_UPLOADER_CODE' => $uploaderCode, 'REDIRECT_URL' => $redirectUrl));
     $objTpl->setVariable(array('TXT_CRM_TITLE_IMPORT_CONTACTS' => $_ARRAYLANG['TXT_CRM_TITLE_IMPORT_CONTACTS'], 'TXT_CRM_IMPORT_HEADER' => $_ARRAYLANG['TXT_CRM_IMPORT_HEADER'], 'TXT_CRM_IMPORT_NOTE' => $_ARRAYLANG['TXT_CRM_IMPORT_NOTE'], 'TXT_CRM_IMPORT_NOTE_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_IMPORT_NOTE_DESCRIPTION'], 'TXT_CRM_CSV_SETTINGS' => $_ARRAYLANG['TXT_CRM_CSV_SETTINGS'], 'TXT_CRM_SKIP' => $_ARRAYLANG['TXT_CRM_SKIP'], 'TXT_CRM_OVERWRITE' => $_ARRAYLANG['TXT_CRM_OVERWRITE'], 'TXT_CRM_DUPLICATE' => $_ARRAYLANG['TXT_CRM_DUPLICATE'], 'TXT_CRM_CHOOSE_FILE' => $_ARRAYLANG['TXT_CRM_CHOOSE_FILE'], 'TXT_CRM_CSV_SEPARATOR' => $_ARRAYLANG['TXT_CRM_CSV_SEPARATOR'], 'TXT_CRM_CSV_ENCLOSURE' => $_ARRAYLANG['TXT_CRM_CSV_ENCLOSURE'], 'TXT_CRM_ON_DUPLICATES' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATES'], 'TXT_CRM_CHOOSE_CSV' => $_ARRAYLANG['TXT_CRM_CHOOSE_CSV'], 'TXT_CRM_ON_DUPLICATES_INFO' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATES_INFO'], 'TXT_CRM_ON_DUPLICATE_SKIP_INFO' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATE_SKIP_INFO'], 'TXT_CRM_ON_DUPLICATE_OVERWRITE_INFO' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATE_OVERWRITE_INFO'], 'TXT_CRM_ON_DUPLICATE_INFO' => $_ARRAYLANG['TXT_CRM_ON_DUPLICATE_INFO'], 'TXT_CRM_IGNORE_FIRST_ROW' => $_ARRAYLANG['TXT_CRM_IGNORE_FIRST_ROW'], 'TXT_CRM_CONTINUE' => $_ARRAYLANG['TXT_CRM_CONTINUE'], 'TXT_CRM_CANCEL' => $_ARRAYLANG['TXT_CRM_CANCEL'], 'TXT_CRM_VERIFY_FIELDS' => $_ARRAYLANG['TXT_CRM_VERIFY_FIELDS'], 'TXT_CRM_VERIFY_INFO' => $_ARRAYLANG['TXT_CRM_VERIFY_INFO'], 'TXT_CRM_FILE_COLUMN' => $_ARRAYLANG['TXT_CRM_FILE_COLUMN'], 'TXT_CRM_CORRESPONDING_FIELD' => $_ARRAYLANG['TXT_CRM_CORRESPONDING_FIELD'], 'TXT_CRM_CSV_VALUE' => $_ARRAYLANG['TXT_CRM_CSV_VALUE'], 'TXT_CRM_CHANGE' => $_ARRAYLANG['TXT_CRM_CHANGE'], 'TXT_CRM_LOADING' => $_ARRAYLANG['TXT_CRM_LOADING'], 'TXT_CRM_PREVIOUS_RECORD' => $_ARRAYLANG['TXT_CRM_PREVIOUS_RECORD'], 'TXT_CRM_NEXT_RECORD' => $_ARRAYLANG['TXT_CRM_NEXT_RECORD'], 'TXT_CRM_TITLE_SAVING_CONTACTS' => $_ARRAYLANG['TXT_CRM_TITLE_SAVING_CONTACTS'], 'TXT_CRM_INTERFACE_FINAL_INFO' => $_ARRAYLANG['TXT_CRM_INTERFACE_FINAL_INFO'], 'TXT_CRM_RECORD_DONE' => $_ARRAYLANG['TXT_CRM_RECORD_DONE'], 'TXT_CRM_RECORD_SKIPPED' => $_ARRAYLANG['TXT_CRM_RECORD_SKIPPED'], 'TXT_CRM_RECORD_IMPORT' => $_ARRAYLANG['TXT_CRM_RECORD_IMPORT'], 'TXT_CRM_RECORD_PROCESS' => $_ARRAYLANG['TXT_CRM_RECORD_PROCESS'], 'TXT_CRM_IMPORT_NAME' => $_ARRAYLANG['TXT_CRM_IMPORT_NAME'], 'TXT_CRM_EXPORT_NAME' => $_ARRAYLANG['TXT_CRM_EXPORT_NAME']));
 }
Example #4
0
 /**
  * Constructor    -> Create the menu and copy the template
  *
  * @global    array
  * @global    \Cx\Core\Html\Sigma
  * @global    InitCMS
  */
 function __construct()
 {
     global $_ARRAYLANG, $objTemplate, $objInit;
     $this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_MODULE_PATH . '/Gallery/View/Template/Backend');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
     $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE);
     \JS::registerCSS(substr(ASCMS_MODULE_FOLDER . '/Gallery/View/Style/main.css', 1));
     $this->intLangId = $objInit->userFrontendLangId;
     $this->strImagePath = ASCMS_GALLERY_PATH . '/';
     $this->strImageWebPath = ASCMS_GALLERY_WEB_PATH . '/';
     $this->strThumbnailPath = ASCMS_GALLERY_THUMBNAIL_PATH . '/';
     $this->strThumbnailWebPath = ASCMS_GALLERY_THUMBNAIL_WEB_PATH . '/';
     $this->strImportPath = ASCMS_GALLERY_IMPORT_PATH . '/';
     $this->importWebPath = ASCMS_GALLERY_IMPORT_WEB_PATH . '/';
     if (imagetypes() & IMG_GIF) {
         $this->boolGifEnabled = true;
     }
     if (imagetypes() & IMG_JPG) {
         $this->boolJpgEnabled = true;
     }
     if (imagetypes() & IMG_PNG) {
         $this->boolPngEnabled = true;
     }
     $this->getSettings();
     $this->checkImages();
     parent::__construct();
 }
 /**
  * Init the frontend editing.
  *
  * Register the javascripts and css files
  * Adds the used language variables to contrexx-js variables, so the toolbar has access to these variables
  *
  * @param ComponentController $componentController
  */
 public function initFrontendEditing(\Cx\Core_Modules\FrontendEditing\Controller\ComponentController $componentController)
 {
     global $_ARRAYLANG;
     // get necessary objects
     $objInit = \Env::get('init');
     $page = $this->cx->getPage();
     // add css and javascript file
     $jsFilesRoot = substr(ASCMS_CORE_MODULE_FOLDER . '/' . $componentController->getName() . '/View/Script', 1);
     \JS::registerCSS(substr(ASCMS_CORE_MODULE_FOLDER . '/' . $componentController->getName() . '/View/Style/Main.css', 1));
     \JS::registerJS($jsFilesRoot . '/Main.js');
     \JS::activate('cx');
     // not used for contrexx version 3.1
     //        \JS::registerJS($jsFilesRoot . '/CKEditorPlugins.js');
     // activate ckeditor
     \JS::activate('ckeditor');
     \JS::activate('jquery-cookie');
     // load language data
     $_ARRAYLANG = $objInit->loadLanguageData('FrontendEditing');
     $langVariables = array('TXT_FRONTEND_EDITING_SHOW_TOOLBAR' => $_ARRAYLANG['TXT_FRONTEND_EDITING_SHOW_TOOLBAR'], 'TXT_FRONTEND_EDITING_HIDE_TOOLBAR' => $_ARRAYLANG['TXT_FRONTEND_EDITING_HIDE_TOOLBAR'], 'TXT_FRONTEND_EDITING_PUBLISH' => $_ARRAYLANG['TXT_FRONTEND_EDITING_PUBLISH'], 'TXT_FRONTEND_EDITING_SUBMIT_FOR_RELEASE' => $_ARRAYLANG['TXT_FRONTEND_EDITING_SUBMIT_FOR_RELEASE'], 'TXT_FRONTEND_EDITING_REFUSE_RELEASE' => $_ARRAYLANG['TXT_FRONTEND_EDITING_REFUSE_RELEASE'], 'TXT_FRONTEND_EDITING_SAVE' => $_ARRAYLANG['TXT_FRONTEND_EDITING_SAVE'], 'TXT_FRONTEND_EDITING_EDIT' => $_ARRAYLANG['TXT_FRONTEND_EDITING_EDIT'], 'TXT_FRONTEND_EDITING_CANCEL_EDIT' => $_ARRAYLANG['TXT_FRONTEND_EDITING_CANCEL_EDIT'], 'TXT_FRONTEND_EDITING_FINISH_EDIT_MODE' => $_ARRAYLANG['TXT_FRONTEND_EDITING_FINISH_EDIT_MODE'], 'TXT_FRONTEND_EDITING_THE_DRAFT' => $_ARRAYLANG['TXT_FRONTEND_EDITING_THE_DRAFT'], 'TXT_FRONTEND_EDITING_SAVE_CURRENT_STATE' => $_ARRAYLANG['TXT_FRONTEND_EDITING_SAVE_CURRENT_STATE'], 'TXT_FRONTEND_EDITING_CONFIRM_BLOCK_SAVE' => $_ARRAYLANG['TXT_FRONTEND_EDITING_CONFIRM_BLOCK_SAVE'], 'TXT_FRONTEND_EDITING_MODULE_PAGE' => $_ARRAYLANG['TXT_FRONTEND_EDITING_MODULE_PAGE'], 'TXT_FRONTEND_EDITING_NO_TITLE_AND_CONTENT' => $_ARRAYLANG['TXT_FRONTEND_EDITING_NO_TITLE_AND_CONTENT'], 'TXT_FRONTEND_EDITING_CONFIRM_UNSAVED_EXIT' => $_ARRAYLANG['TXT_FRONTEND_EDITING_CONFIRM_UNSAVED_EXIT'], 'TXT_FRONTEND_EDITING_DRAFT' => $_ARRAYLANG['TXT_FRONTEND_EDITING_DRAFT'], 'TXT_FRONTEND_EDITING_PUBLISHED' => $_ARRAYLANG['TXT_FRONTEND_EDITING_PUBLISHED']);
     // add toolbar to html
     $this->prepareTemplate($componentController);
     // assign js variables
     $contrexxJavascript = \ContrexxJavascript::getInstance();
     $contrexxJavascript->setVariable('langVars', $langVariables, 'FrontendEditing');
     $contrexxJavascript->setVariable('pageId', $page->getId(), 'FrontendEditing');
     $contrexxJavascript->setVariable('hasPublishPermission', \Permission::checkAccess(78, 'static', true), 'FrontendEditing');
     $contrexxJavascript->setVariable('contentTemplates', $this->getCustomContentTemplates(), 'FrontendEditing');
     $contrexxJavascript->setVariable('defaultTemplate', $this->getDefaultTemplate(), 'FrontendEditing');
     $configPath = ASCMS_PATH_OFFSET . substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT));
     $contrexxJavascript->setVariable('configPath', $configPath . '?langId=' . FRONTEND_LANG_ID, 'FrontendEditing');
 }
 /**
  * @override
  */
 public function getXHtml()
 {
     global $_CORELANG;
     //JS / CSS dependencies
     \JS::activate('cx');
     \JS::registerJS('lib/javascript/swfobject.js');
     //        JS::registerJS('lib/javascript/deployJava.js');
     \JS::registerJS('core_modules/Upload/js/uploaders/combo/combo.js');
     \JS::registerCSS('core_modules/Upload/css/uploaders/combo/combo.css');
     \JS::registerJS('core_modules/Upload/js/uploaders/pl/plupload.full.js');
     \JS::registerJS('core_modules/Upload/js/uploaders/pl/jquery.plupload.queue.js');
     \JS::registerCSS('core_modules/Upload/css/uploaders/pl/plupload.queue.css');
     $formUploader = UploadFactory::getInstance()->newUploader('form', $this->uploadId);
     //i18n of uploader descriptions
     $formUploaderDescription = $_CORELANG['FORM_UPLOADER'];
     $plUploaderDescription = $_CORELANG['PL_UPLOADER'];
     $jumpUploaderDescription = $_CORELANG['JUMP_UPLOADER'];
     $alternativesCaption = $_CORELANG['OTHER_UPLOADERS'];
     //combuploader js config: available uploaders
     $uploaders = array("{type:'form',description:'" . $formUploaderDescription . "'}");
     if (in_array('Pl', $this->enabledUploaders)) {
         array_push($uploaders, "{type:'pl',description:'" . $plUploaderDescription . "'}");
     }
     if (in_array('Jump', $this->enabledUploaders)) {
         array_push($uploaders, "{type:'jump',description:'" . $jumpUploaderDescription . "'}");
     }
     $uploaders = '[' . join(',', $uploaders) . ']';
     $cmdOrSection = $this->isBackendRequest ? 'cmd' : 'section';
     $actOrCmd = $this->isBackendRequest ? 'act' : 'cmd';
     //from where the combouploader gets the code on an uploader switch
     $switchUrl;
     //from where the combouploader gets the response for finished uploads
     $responseUrl;
     if ($this->isBackendRequest) {
         $switchUrl = ASCMS_ADMIN_WEB_PATH . '/index.php?' . $cmdOrSection . '=Upload&' . $actOrCmd . '=ajaxUploaderCode';
         $responseUrl = ASCMS_ADMIN_WEB_PATH . '/index.php?' . $cmdOrSection . '=Upload&' . $actOrCmd . '=response';
     } else {
         $switchUrl = CONTREXX_SCRIPT_PATH . '?' . $cmdOrSection . '=Upload&' . $actOrCmd . '=ajaxUploaderCode';
         $responseUrl = CONTREXX_SCRIPT_PATH . '?' . $cmdOrSection . '=Upload&' . $actOrCmd . '=response';
     }
     $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders');
     $tpl->setErrorHandling(PEAR_ERROR_DIE);
     $tpl->loadTemplateFile('combo.html');
     $tpl->setVariable(array('CONFIG_UPLOADERS_JS' => $uploaders, 'RESPONSE_URL' => $responseUrl, 'UPLOAD_ID' => $this->uploadId, 'SWITCH_URL' => $switchUrl, 'OTHER_UPLOADERS_CAPTION' => $_CORELANG['OTHER_UPLOADERS'], 'TXT_CORE_UPLOAD_MORE' => $_CORELANG['TXT_CORE_UPLOAD_MORE'], 'TXT_CORE_FINISH_UPLOADING' => $_CORELANG['TXT_CORE_FINISH_UPLOADING'], 'TXT_CORE_FILES_UPLOADED' => $_CORELANG['TXT_CORE_FILES_UPLOADED'], 'TXT_CORE_FILES_NOT_UPLOADED' => $_CORELANG['TXT_CORE_FILES_NOT_UPLOADED']));
     $tpl->setVariable('UPLOADER_CODE', $formUploader->getXHtml());
     //see Uploader::handleInstanceBusiness
     $this->handleInstanceBusiness($tpl, 'cu');
     return $tpl->get();
 }
 public function getXHtml()
 {
     global $_CORELANG;
     \JS::registerCSS('core_modules/Upload/css/uploaders/exposedCombo/exposedCombo.css');
     \JS::registerJS('core_modules/Upload/js/uploaders/exposedCombo/exposedCombo.js');
     //back up instance name, we're going to set a temporary name for the combo uploader
     $instanceNameBak = $this->jsInstanceName;
     $this->jsInstanceName = 'exposedCombo_comboUploader_' . $this->uploadId;
     $comboXHtml = parent::getXHtml();
     $this->jsInstanceName = $instanceNameBak;
     $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders');
     $tpl->setErrorHandling(PEAR_ERROR_DIE);
     $tpl->loadTemplateFile('exposedCombo.html');
     $tpl->setVariable(array('COMBO_CODE' => $comboXHtml, 'DIALOG_TITLE' => $_CORELANG['UPLOAD_EXPOSED_DIALOG_TITLE']));
     //see Uploader::handleInstanceBusiness
     $this->handleInstanceBusiness($tpl, 'exposedCombo');
     return $tpl->get();
 }
 /**
  * This is called by the default ComponentController and does all the repeating work
  *
  * This creates a template of the page content and calls parsePage($template)
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Resolved page
  */
 public function getPage(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_ARRAYLANG;
     // init component template
     $componentTemplate = new \Cx\Core\Html\Sigma('.');
     $componentTemplate->setErrorHandling(PEAR_ERROR_DIE);
     $componentTemplate->setTemplate($page->getContent());
     // default css and js
     if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Style/Frontend.css'))) {
         \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Frontend.css', 1));
     }
     if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Script/Frontend.js'))) {
         \JS::registerJS(substr($this->getDirectory(false, true) . '/View/Script/Frontend.js', 1));
     }
     // parse page
     $componentTemplate->setGlobalVariable($_ARRAYLANG);
     $this->parsePage($componentTemplate, $page->getCmd());
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($componentTemplate);
     $page->setContent($componentTemplate->get());
 }
 /**
  * Use this to parse your backend page
  *
  * You will get the template located in /View/Template/{CMD}.html
  * You can access Cx class using $this->cx
  * To show messages, use \Message class
  * @param \Cx\Core\Html\Sigma $template Template for current CMD
  * @param array $cmd CMD separated by slashes
  */
 public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
 {
     global $_ARRAYLANG, $objInit;
     $objTpl = new \Cx\Core\Html\Sigma($this->getDirectory(true) . '/View/Template/Backend');
     //merge language
     $langData = $objInit->loadLanguageData('Pdf');
     $_ARRAYLANG = array_merge($_ARRAYLANG, $langData);
     $objTpl->setGlobalVariable($_ARRAYLANG);
     $objTpl->loadTemplatefile('Default.html');
     // Not an entity, parse overview or settings
     switch (current($cmd)) {
         default:
             // Parse entity view generation pages
             $entityClassName = $this->getNamespace() . '\\Model\\Entity\\PdfTemplate';
             $this->parseEntityClassPage($objTpl, $entityClassName, 'PdfTemplate');
             if ($objTpl->blockExists('overview')) {
                 $objTpl->touchBlock('overview');
             }
             break;
     }
     \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Backend.css', 1));
     $template->setVariable(array('CONTENT_TITLE' => $_ARRAYLANG['TXT_CORE_MODULE_PDF'], 'ADMIN_CONTENT' => $objTpl->get()));
 }
Example #10
0
 /**
  * Edit the task type
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 function editTaskType()
 {
     global $objDatabase, $_ARRAYLANG;
     \JS::activate("jquery");
     // Activate validation scripts
     \JS::registerCSS("lib/javascript/validationEngine/css/validationEngine.jquery.css");
     \JS::registerJS("lib/javascript/validationEngine/js/languages/jquery.validationEngine-en.js");
     \JS::registerJS("lib/javascript/validationEngine/js/jquery.validationEngine.js");
     \JS::registerCSS("lib/javascript/chosen/chosen.css");
     \JS::registerJS("lib/javascript/chosen/chosen.jquery.js");
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     if ($_POST['saveTaskType']) {
         $this->saveTaskTypes($id);
         $msg = "taskUpdated";
         \Cx\Core\Csrf\Controller\Csrf::header("Location:./index.php?cmd=" . $this->moduleName . "&act=settings&tpl=tasktypes&msg=" . base64_encode($msg));
         exit;
     }
     $objTpl = $this->_objTpl;
     $this->_pageTitle = $_ARRAYLANG['TXT_CRM_EDIT_TASK_TYPE'];
     $objTpl->addBlockfile('CRM_SETTINGS_FILE', 'settings_block', "module_{$this->moduleNameLC}_settings_edit_task_types.html");
     $this->getModifyTaskTypes($id);
     $objTpl->setVariable(array('TXT_CRM_ADD_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_EDIT_TASK_TYPE'], 'TXT_CRM_BACK1' => $_ARRAYLANG['TXT_CRM_BACK1'], 'CSRF_PARAM' => \Cx\Core\Csrf\Controller\Csrf::param(), 'TXT_BROWSE' => $_ARRAYLANG['TXT_BROWSE'], 'TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT' => $_ARRAYLANG['TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT']));
 }
 public function getFrameXHtml()
 {
     global $_CORELANG;
     if (!empty($_SESSION['upload']['handlers'][$this->uploadId]['singleFileMode'])) {
         \ContrexxJavascript::getInstance()->setVariable('restrictUpload2SingleFile', true, "upload/widget_{$this->uploadId}");
     }
     //JS / CSS dependencies
     \JS::activate('cx');
     \JS::registerCSS('core_modules/Upload/css/uploaders/form/formUploader.css');
     \JS::registerJS('core_modules/Upload/js/uploaders/form/formUploader.js');
     $uploadPath = $this->getUploadPath('form');
     $redirectUrl = '';
     if ($this->isBackendRequest) {
         $redirectUrl = ASCMS_ADMIN_WEB_PATH . '/index.php?cmd=Upload&act=formUploaderFrameFinished&uploadId=' . $this->uploadId;
     } else {
         $url = clone \Env::get('cx')->getRequest()->getUrl();
         $url->removeAllParams();
         $url->setParams(array('section' => 'Upload', 'cmd' => 'formUploaderFrameFinished', 'uploadId' => $this->uploadId));
         $redirectUrl = (string) $url;
     }
     $this->setRedirectUrl($redirectUrl);
     $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders');
     $tpl->setErrorHandling(PEAR_ERROR_DIE);
     $tpl->loadTemplateFile('formFrame.html');
     $tpl->setVariable('UPLOAD_URL', $uploadPath);
     $tpl->setVariable('INCLUDES', \JS::getCode());
     $tpl->setVariable('CXJS_INIT_JS', \ContrexxJavascript::getInstance()->initJs());
     $tpl->setVariable('UPLOAD_FORM_ADD', $_CORELANG['UPLOAD_FORM_ADD']);
     $tpl->setVariable('UPLOAD', $_CORELANG['UPLOAD']);
     $tpl->setVariable('UPLOAD_ID', $this->uploadId);
     $tpl->setVariable('MAX_FILE_SIZE', \FWSystem::getMaxUploadFileSize() - 1000);
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $ls = new \LinkSanitizer($cx, $cx->getCodeBaseOffsetPath(), $tpl->get());
     return $ls->replace();
 }
Example #12
0
 /**
  * add /edit of deals
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 function _modifyDeal()
 {
     global $objDatabase, $_ARRAYLANG;
     \JS::activate('cx');
     \JS::activate('jqueryui');
     \JS::registerCSS("modules/Crm/View/Style/main.css");
     \JS::registerCSS("modules/Crm/View/Style/contact.css");
     $redirect = $_REQUEST['redirect'] ? $_REQUEST['redirect'] : base64_encode('&act=deals');
     $objTpl = $this->_objTpl;
     $objTpl->loadTemplateFile("module_{$this->moduleNameLC}_deals_modify.html");
     $settings = $this->getSettings();
     $allowPm = $this->isPmInstalled && $settings['allow_pm'];
     $objTpl->setGlobalVariable(array('MODULE_NAME' => $this->moduleName, 'PM_MODULE_NAME' => $this->pm_moduleName));
     if ($allowPm) {
         //            include_once ASCMS_MODULE_PATH . '/pm/lib/pmLib.class.php';
         $objPmLib = new \PmLibrary();
     }
     $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
     $fields = array('title' => isset($_POST['title']) ? contrexx_input2raw($_POST['title']) : '', 'website' => isset($_POST['domain']) ? intval($_POST['domain']) : 0, 'customer' => isset($_REQUEST['customer']) ? (int) $_REQUEST['customer'] : 0, 'customer_contact' => isset($_POST['customer_contact']) ? (int) $_POST['customer_contact'] : 0, 'quoted_price' => isset($_POST['quoted_price']) ? (double) str_replace("'", '', $_POST['quoted_price']) : '', 'assigned_to' => isset($_POST['assigned_to']) ? (int) $_POST['assigned_to'] : \FWUser::getFWUserObject()->objUser->getId(), 'due_date' => isset($_POST['due_date']) ? contrexx_input2raw($_POST['due_date']) : date("Y-m-d"), 'description' => isset($_POST['description']) ? contrexx_input2raw($_POST['description']) : '', 'stage' => isset($_POST['dealsStage']) ? contrexx_input2raw($_POST['dealsStage']) : '');
     $projectFileds = array();
     if ($allowPm) {
         $projectFileds = array('invoice_type' => isset($_POST['invoiceType']) ? (int) $_POST['invoiceType'] : 3, 'project_type' => isset($_POST['project_type']) ? (int) $_POST['project_type'] : 0, 'project_status' => isset($_POST['status']) ? (int) $_POST['status'] : 0, 'priority' => isset($_POST['priority']) ? contrexx_input2raw($_POST['priority']) : 0, 'send_invoice' => isset($_POST['send-partial-invoice']) ? 1 : 0, 'hrs_offered' => isset($_POST['projectDuration']) ? (double) $_POST['projectDuration'] : '', 'quote_number' => isset($_POST['quoteNumber']) ? contrexx_input2raw($_POST['quoteNumber']) : '', 'bill_info' => isset($_POST['billing_info']) ? contrexx_input2raw($_POST['billing_info']) : '');
     }
     if (isset($_POST['save_deal'])) {
         if (true) {
             $fields['website'] = $this->_getDomainNameId($fields['website'], $fields['customer'], contrexx_input2raw($_POST['domainName']));
             if (!empty($id)) {
                 $query = \SQL::update("module_{$this->moduleNameLC}_deals", $fields, array('escape' => true)) . " WHERE `id` = {$id}";
             } else {
                 $query = \SQL::insert("module_{$this->moduleNameLC}_deals", $fields, array('escape' => true));
             }
             //print $query;
             $db = $objDatabase->Execute($query);
             $msg = empty($id) ? 'dealsAdded' : 'dealsUpdated';
             if (empty($id)) {
                 $id = $objDatabase->INSERT_ID();
             }
             $projectId = $objDatabase->getOne("SELECT project_id FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_deals` WHERE id = {$id}");
             if ($db) {
                 if ($allowPm) {
                     $saveProjects = array('name' => $fields['title'], 'quoteNumber' => $projectFileds['quote_number'], 'domain' => $fields['website'], 'customer_id' => $fields['customer'], 'project_type_id' => $projectFileds['project_type'], 'added_by' => \FWUser::getFWUserObject()->objUser->getId(), 'assigned_to' => $fields['assigned_to'], 'status' => $projectFileds['project_status'], 'priority' => $projectFileds['priority'], 'contact_id' => $fields['customer_contact'], 'quoted_price' => $fields['quoted_price'], 'projectDuration' => $projectFileds['hrs_offered'], 'billing_info' => $projectFileds['bill_info'], 'description' => $fields['description'], 'send_partial_invoice' => $projectFileds['send_invoice'], 'internal' => $projectFileds['invoice_type'], 'target_date' => isset($_POST['dueDate']) ? contrexx_input2raw($_POST['dueDate']) : date("Y-m-d"), 'billtype' => 1);
                     $projectId = $objPmLib->saveOppurtunityProject($saveProjects, $projectId);
                     if (isset($_FILES['documentUpload'])) {
                         $inputName = 'documentUpload';
                         $date = date('Y-m-d');
                         $docTitle = '';
                         $uploadedUserId = 0;
                         $objPmLib->uploadProjectDocument($inputName, $date, $projectId, $docTitle, $uploadedUserId);
                     }
                     // Update project id to the oppurtunity.
                     $objDatabase->Execute("UPDATE `" . DBPREFIX . "module_{$this->moduleNameLC}_deals` SET project_id = {$projectId} WHERE id = {$id}");
                 }
                 //print base64_decode($redirect);
                 \Cx\Core\Csrf\Controller\Csrf::header("Location:./index.php?cmd=" . $this->moduleName . "&mes=" . base64_encode($msg) . base64_decode($redirect));
                 $this->_strOkMessage = "Saved successfully";
             } else {
                 $this->_strErrMessage = "Err in saving";
             }
         } else {
             $this->_strErrMessage = "All fields must be filled out";
         }
     } elseif (!empty($id)) {
         $objResult = $objDatabase->Execute("SELECT d.title,\n                                       d.website,\n                                       web.url AS siteName,\n                                       d.quoted_price,\n                                       d.customer,\n                                       c.customer_name AS customerName,\n                                       c.contact_familyname AS customerFamilyName,\n                                       d.customer_contact,\n                                       d.quote_number,\n                                       d.assigned_to,\n                                       d.due_date,\n                                       d.description,\n                                       d.stage,\n                                       d.project_id\n                            FROM " . DBPREFIX . "module_{$this->moduleNameLC}_deals AS d\n                                LEFT JOIN " . DBPREFIX . "module_{$this->moduleNameLC}_contacts AS c\n                            ON d.customer = c.id\n                                LEFT JOIN `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_websites` AS web\n                            ON d.website = web.id\n                            WHERE d.id = {$id}");
         $fields = array('title' => $objResult->fields['title'], 'website' => $objResult->fields['website'], 'siteName' => $objResult->fields['siteName'], 'customer' => $objResult->fields['customer'], 'customer_name' => $objResult->fields['customerName'] . " " . $objResult->fields['customerFamilyName'], 'customer_contact' => $objResult->fields['customer_contact'], 'quoted_price' => $objResult->fields['quoted_price'], 'assigned_to' => $objResult->fields['assigned_to'], 'due_date' => $objResult->fields['due_date'], 'description' => $objResult->fields['description'], 'stage' => $objResult->fields['stage']);
         $projectId = (int) $objResult->fields['project_id'];
         if ($allowPm && !empty($projectId)) {
             $objProjectResult = $objDatabase->Execute("SELECT p.internal,\n                                                            p.project_type_id,\n                                                            p.status,\n                                                            p.priority,\n                                                            p.send_partial_invoice,\n                                                            p.projectDuration,\n                                                            p.quoteNumber,\n                                                            p.billing_info\n                                                        FROM `" . DBPREFIX . "module_{$this->pm_moduleName}_projects` AS p\n                                                         WHERE id = {$projectId}");
             $projectFileds = array('invoice_type' => $objProjectResult->fields['internal'], 'project_type' => $objProjectResult->fields['project_type_id'], 'project_status' => $objProjectResult->fields['status'], 'priority' => $objProjectResult->fields['priority'], 'send_invoice' => $objProjectResult->fields['send_partial_invoice'], 'hrs_offered' => $objProjectResult->fields['projectDuration'], 'quote_number' => $objProjectResult->fields['quoteNumber'], 'bill_info' => $objProjectResult->fields['billing_info']);
         }
     }
     if (!empty($fields['customer'])) {
         $contactType = $objDatabase->getOne("SELECT contact_type FROM `" . DBPREFIX . "module_crm_contacts` WHERE id = {$fields['customer']}");
         $contatWhere = $contactType == 1 ? "c.contact_customer" : "c.id";
         $objContactPerson = $objDatabase->Execute("SELECT c.`id`,\n                                                          c.`contact_customer`,\n                                                          c.`customer_name`,\n                                                          c.`contact_familyname`,\n                                                          email.`email`\n                                                   FROM `" . DBPREFIX . "module_crm_contacts` AS c\n                                                   LEFT JOIN `" . DBPREFIX . "module_crm_customer_contact_emails` AS email\n                                                       ON c.`id` = email.`contact_id` AND email.`is_primary` = '1'\n                                                   WHERE {$contatWhere} = '{$fields['customer']}' AND (status=1 OR c.id ='{$fields['customer_contact']}')");
         while (!$objContactPerson->EOF) {
             $selected = $fields['customer_contact'] == $objContactPerson->fields['id'] ? "selected" : '';
             $contactName = $objContactPerson->fields['customer_name'] . " " . $objContactPerson->fields['contact_familyname'];
             $this->_objTpl->setVariable(array('TXT_CONTACT_ID' => (int) $objContactPerson->fields['id'], 'TXT_CONTACT_NAME' => contrexx_raw2xhtml($contactName), 'TXT_SELECTED' => $selected));
             $this->_objTpl->parse('Contacts');
             $objContactPerson->MoveNext();
         }
         // Get customer Name
         $objCustomer = $objDatabase->Execute("SELECT customer_name, contact_familyname  FROM `" . DBPREFIX . "module_crm_contacts` WHERE id = {$fields['customer']}");
         $fields['customer_name'] = $objCustomer->fields['customer_name'] . " " . $objCustomer->fields['contact_familyname'];
     }
     $this->getDealsStages($fields['stage']);
     $this->_getResourceDropDown('Members', $fields['assigned_to'], $settings['emp_default_user_group']);
     if ($allowPm) {
         $objPmLib->getProjectTypeDropdown($objTpl, $projectFileds['project_type']);
         $objPmLib->getProjectStatusDropdown($objTpl, $projectFileds['project_status']);
         $objPmLib->getProjectPriorityDropdown($objTpl, $projectFileds['priority']);
         $objTpl->setvariable(array('PROJECT_BILLING_INFO' => new \Cx\Core\Wysiwyg\Wysiwyg('billing_info', contrexx_raw2xhtml($projectFileds['bill_info'])), 'PROJECT_INVOICETYPE_PROJECT' => $projectFileds['invoice_type'] == 3 ? 'checked=checked' : '', 'PROJECT_INVOICETYPE_COLLECTIVE' => $projectFileds['invoice_type'] == 2 ? 'checked=checked' : '', 'PROJECT_INVOICETYPE_INTERNAL' => $projectFileds['invoice_type'] == 1 ? 'checked=checked' : '', 'PM_SEND_PARTIAL_INVOICE_CHECKED' => !empty($projectFileds['send_invoice']) ? 'checked' : '', 'CRM_QUOTATION_NUMBER' => contrexx_raw2xhtml($projectFileds['quote_number']), 'PROJECT_DURATION' => number_format($projectFileds['hrs_offered'], 2), 'TXT_CRM_ADDITIONAL_INFO' => $_ARRAYLANG['TXT_CRM_ADDITIONAL_INFO'], 'TXT_CRM_INVOICE_TYPE' => $_ARRAYLANG['TXT_CRM_INVOICE_TYPE'], 'TXT_CRM_PROJECT_INVOICETYPE_PROJECT' => $_ARRAYLANG['TXT_CRM_PROJECT_INVOICETYPE_PROJECT'], 'TXT_CRM_PROJECT_INVOICETYPE_COLLECTIVE' => $_ARRAYLANG['TXT_CRM_PROJECT_INVOICETYPE_COLLECTIVE'], 'TXT_CRM_PROJECT_INVOICETYPE_INTERNAL' => $_ARRAYLANG['TXT_CRM_PROJECT_INVOICETYPE_INTERNAL'], 'TXT_CRM_PROJECT_TYPE' => $_ARRAYLANG['TXT_CRM_PROJECT_TYPE'], 'TXT_CRM_SELECT_PROJECT_TYPE' => $_ARRAYLANG['TXT_CRM_SELECT_PROJECT_TYPE'], 'TXT_CRM_PROJECT_STATUS' => $_ARRAYLANG['TXT_CRM_PROJECT_STATUS'], 'TXT_CRM_PRIORITY' => $_ARRAYLANG['TXT_CRM_PRIORITY'], 'TXT_CRM_SELECT_PRIORITY' => $_ARRAYLANG['TXT_CRM_SELECT_PRIORITY'], 'TXT_CRM_LOW' => $_ARRAYLANG['TXT_CRM_LOW'], 'TXT_CRM_MEDIUM' => $_ARRAYLANG['TXT_CRM_MEDIUM'], 'TXT_CRM_HIGH' => $_ARRAYLANG['TXT_CRM_HIGH'], 'TXT_CRM_SEND_PARTIAL_INVOICE' => $_ARRAYLANG['TXT_CRM_SEND_PARTIAL_INVOICE'], 'TXT_CRM_PROJECT_DURATION' => $_ARRAYLANG['TXT_CRM_PROJECT_DURATION'], 'TXT_CRM_QUOTE_NUMBER' => $_ARRAYLANG['TXT_CRM_QUOTE_NUMBER'], 'TXT_CRM_DOCUMENT_UPLOAD' => $_ARRAYLANG['TXT_CRM_DOCUMENT_UPLOAD'], 'TXT_CRM_BILLING_INFORMATION' => $_ARRAYLANG['TXT_CRM_BILLING_INFORMATION']));
         if (!empty($id)) {
             $objTpl->hideBlock("projectDocUpload");
         }
     }
     if (!$allowPm) {
         $objTpl->hideBlock("projectEntryBlock");
     }
     $objTpl->setVariable(array('TXT_CRM_DEALS_OVERVIEW' => $_ARRAYLANG['TXT_CRM_DEALS_OVERVIEW'], 'TXT_CRM_DEALS_PERCENTAGE' => $_ARRAYLANG['TXT_CRM_DEALS_PERCENTAGE'], 'TXT_CRM_DEALS_CUSTOMER_NAME' => $_ARRAYLANG['TXT_CRM_CUSTOMER_NAME'], 'TXT_CRM_DEALS_CONTACT_PERSON' => $_ARRAYLANG['TXT_CRM_CONTACT_PERSON'], 'TXT_CRM_DEALS_QUOTED_PRICE' => $_ARRAYLANG['TXT_CRM_PROJECT_QUOTED_PRICE'], 'TXT_CRM_DEALS_ESTIMATED_HOURS' => $_ARRAYLANG['TXT_CRM_DEALS_ESTIMATED_HOURS'], 'TXT_CRM_DEALS_QUOTE_NUMBER' => $_ARRAYLANG['TXT_CRM_DEALS_QUOTE_NUMBER'], 'TXT_CRM_DEALS_RESPONSIBLE' => $_ARRAYLANG['TXT_CRM_PROJECT_RESPONSIBLE'], 'TXT_CRM_DEALS_DUE_DATE' => $_ARRAYLANG['TXT_CRM_DUE_DATE'], 'TXT_CRM_DEALS_STAGES' => $_ARRAYLANG['TXT_CRM_DEALS_STAGES'], 'TXT_CRM_DEALS_SUCC_RATE' => $_ARRAYLANG['TXT_CRM_DEALS_SUCC_RATE'], 'TXT_CRM_SAVE' => $_ARRAYLANG['TXT_CRM_SAVE'], 'TXT_CRM_BACK' => $_ARRAYLANG['TXT_CRM_BACK'], 'CRM_MODIFY_DEAL_TITLE' => empty($id) ? $_ARRAYLANG['TXT_CRM_ADD_DEAL_TITLE'] : $_ARRAYLANG['TXT_CRM_EDIT_DEAL_TITLE'], 'CRM_DEALS_TITLE' => contrexx_raw2xhtml($fields['title']), 'PM_PROJECT_DOMAIN_ID' => (int) $fields['website'], 'PM_PROJECT_DOMAIN_NAME' => contrexx_raw2xhtml($fields['siteName']), 'CRM_DEALS_CUSTOMER' => (int) $fields['customer'], 'CRM_DEALS_CUSTOMER_NAME' => contrexx_raw2xhtml($fields['customer_name']), 'CRM_DEALS_QUOTED_PRICE' => contrexx_raw2xhtml($fields['quoted_price']), 'DEALS_DUE_DATE' => contrexx_raw2xhtml($fields['due_date']), 'CRM_REDIRECT_LINK' => $redirect, 'CRM_BACK_LINK' => base64_decode($redirect), 'CRM_DEALS_DESCRIPTION' => new \Cx\Core\Wysiwyg\Wysiwyg('description', contrexx_raw2xhtml($fields['description'])), 'TXT_CRM_DEALS_TITLE' => $_ARRAYLANG['TXT_CRM_DEALS_TITLE'], 'TXT_CRM_SELECT_MEMBER_NAME' => $_ARRAYLANG['TXT_CRM_SELECT_MEMBER_NAME'], 'CRM_MODIFY_DEAL_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_DESCRIPTION'], 'IS_EDIT_TRUE' => empty($id) ? 'false' : 'true', 'TXT_CRM_FIND_COMPANY_BY_NAME' => $_ARRAYLANG['TXT_CRM_FIND_COMPANY_BY_NAME'], 'TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT' => $_ARRAYLANG['TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT'], 'TXT_CRM_OPPORTUNITY_QUOTE_PRICE_ERROR' => $_ARRAYLANG['TXT_CRM_OPPORTUNITY_QUOTE_PRICE_ERROR']));
     $this->_pageTitle = empty($id) ? $_ARRAYLANG['TXT_CRM_ADD_DEAL_TITLE'] : $_ARRAYLANG['TXT_CRM_EDIT_DEAL_TITLE'];
 }
 /**
  * Get the XHTML to display the widget.
  */
 public function getXhtml()
 {
     \JS::activate('mediabrowser');
     \JS::registerJS('core_modules/MediaBrowser/View/Script/FolderWidget.js');
     \JS::registerCSS('core_modules/MediaBrowser/View/Style/FolderWidget.css');
     $tpl = new \Cx\Core\Html\Sigma(\Cx\Core\Core\Controller\Cx::instanciate()->getCoreModuleFolderName() . '/MediaBrowser/View/Template/');
     $tpl->loadTemplateFile('FolderWidget.html');
     $tpl->setVariable(array('MEDIABROWSER_FOLDER_WIDGET_ID' => $this->id, 'MEDIABROWSER_FOLDER_WIDGET_IS_EDITABLE' => $this->mode != self::MODE_VIEW_ONLY ? 'true' : 'false'));
     return $tpl->get();
 }
    /**
     * Creates and returns the HTML Form for requesting the payment service.
     *
     * @access  public     
     * @return  string                      The HTML form code
     */
    static function getForm($arrOrder, $landingPage = null)
    {
        global $_ARRAYLANG;
        if (gettype($landingPage) != 'object' || get_class($landingPage) != 'Cx\\Core\\ContentManager\\Model\\Entity\\Page') {
            self::$arrError[] = 'No landing page passed.';
        }
        if (($sectionName = $landingPage->getModule()) && !empty($sectionName)) {
            self::$sectionName = $sectionName;
        } else {
            self::$arrError[] = 'Passed landing page is not an application.';
        }
        JS::registerCSS('modules/shop/payments/paymill/css/paymill_styles.css');
        JS::registerJS('modules/shop/payments/paymill/js/creditcardBrandDetection.js');
        JS::registerJS(self::$paymillJsBridge);
        $testMode = intval(\Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop')) == 0;
        $apiKey = $testMode ? \Cx\Core\Setting\Controller\Setting::getValue('paymill_test_public_key', 'Shop') : \Cx\Core\Setting\Controller\Setting::getValue('paymill_live_public_key', 'Shop');
        $mode = $testMode ? 'true' : 'false';
        $code = <<<APISETTING
                var PAYMILL_PUBLIC_KEY = '{$apiKey}';
                var PAYMILL_TEST_MODE  = {$mode};
                var VALIDATE_CVC       = true;
APISETTING;
        JS::registerCode($code);
        JS::registerCode(self::$formScript);
        \ContrexxJavascript::getInstance()->setVariable(array('invalid-card-holdername' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_HOLDER'], 'invalid-card-cvc' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_CVC'], 'invalid-card-number' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_NUMBER'], 'invalid-card-expiry-date' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_EXPIRY_DATE']), 'shop');
        $formContent = self::getElement('div', 'class="paymill-error-text"');
        $formContent .= self::fieldset('');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CREDIT_CARD_NUMBER']);
        $formContent .= Html::getInputText('', '', '', 'class="card-number" size="20"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::openElement('label');
        $formContent .= $_ARRAYLANG['TXT_SHOP_CVC'] . '&nbsp;';
        $formContent .= self::getElement('span', 'class="tooltip-trigger icon-info"');
        $formContent .= self::getElement('span', 'class="tooltip-message"', $_ARRAYLANG['TXT_SHOP_CVC_TOOLTIP']);
        $formContent .= self::closeElement('label');
        $formContent .= Html::getInputText('', '', '', 'class ="card-cvc" size="4" maxlength="4"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CARD_HOLDER']);
        $formContent .= Html::getInputText('', '', '', 'class="card-holdername" size="20"');
        $formContent .= self::closeElement('div');
        $arrMonths = array();
        for ($i = 1; $i <= 12; $i++) {
            $month = str_pad($i, 2, '0', STR_PAD_LEFT);
            $arrMonths[$month] = $month;
        }
        $arrYears = array();
        $currentYear = date('Y');
        for ($i = $currentYear; $i <= $currentYear + 6; $i++) {
            $arrYears[$i] = $i;
        }
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CARD_EXPIRY']);
        $formContent .= Html::getSelect('card-expiry-month', $arrMonths, '', false, '', 'class="card-expiry-month"');
        $formContent .= Html::getSelect('card-expiry-year', $arrYears, '', false, '', 'class="card-expiry-year"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', '&nbsp;');
        $formContent .= Html::getInputButton('', $_ARRAYLANG['TXT_SHOP_BUY_NOW'], 'submit', '', 'class="submit-button"');
        $formContent .= self::closeElement('div');
        $formContent .= Html::getHidden('handler', 'paymill_cc');
        $formContent .= self::closeElement('fieldset');
        $form = Html::getForm('', Cx\Core\Routing\Url::fromPage($landingPage)->toString(), $formContent, 'card-tds-form', 'post');
        return $form;
    }
Example #15
0
 /**
  * add /edit task
  *
  * @global array $_ARRAYLANG
  * @global object $objDatabase
  * @return true
  */
 public function _modifyTask()
 {
     global $_ARRAYLANG, $objDatabase, $objJs, $objFWUser;
     \JS::registerCSS("modules/Crm/View/Style/contact.css");
     if (gettype($objFWUser) === 'NULL') {
         $objFWUser = \FWUser::getFWUserObject();
     }
     $objtpl = $this->_objTpl;
     $_SESSION['pageTitle'] = empty($_GET['id']) ? $_ARRAYLANG['TXT_CRM_ADDTASK'] : $_ARRAYLANG['TXT_CRM_EDITTASK'];
     $this->_objTpl->loadTemplateFile('module_' . $this->moduleNameLC . '_addtasks.html');
     $objtpl->setGlobalVariable("MODULE_NAME", $this->moduleName);
     $settings = $this->getSettings();
     $id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
     $date = date('Y-m-d H:i:s');
     $title = isset($_POST['taskTitle']) ? contrexx_input2raw($_POST['taskTitle']) : '';
     $type = isset($_POST['taskType']) ? (int) $_POST['taskType'] : 0;
     $customer = isset($_REQUEST['customerId']) ? (int) $_REQUEST['customerId'] : '';
     $duedate = isset($_POST['date']) ? $_POST['date'] : $date;
     $assignedto = isset($_POST['assignedto']) ? intval($_POST['assignedto']) : 0;
     $description = isset($_POST['description']) ? contrexx_input2raw($_POST['description']) : '';
     $notify = isset($_POST['notify']);
     $taskId = isset($_REQUEST['searchType']) ? intval($_REQUEST['searchType']) : 0;
     $taskTitle = isset($_REQUEST['searchTitle']) ? contrexx_input2raw($_REQUEST['searchTitle']) : '';
     $redirect = isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : base64_encode('&act=task');
     // check permission
     if (!empty($id)) {
         $objResult = $objDatabase->Execute("SELECT `added_by`,\n                                                       `assigned_to`\n                                                    FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_task`\n                                                 WHERE `id` = '{$id}'\n                                               ");
         $added_user = (int) $objResult->fields['added_by'];
         $assigned_user = (int) $objResult->fields['assigned_to'];
         if ($objResult) {
             list($task_edit_permission) = $this->getTaskPermission($added_user, $assigned_user);
             if (!$task_edit_permission) {
                 \Permission::noAccess();
             }
         }
     }
     if (isset($_POST['addtask'])) {
         if (!empty($id)) {
             if ($objFWUser->objUser->getAdminStatus() || $added_user == $objFWUser->objUser->getId() || $assigned_user == $assignedto) {
                 $fields = array('task_title' => $title, 'task_type_id' => $type, 'customer_id' => $customer, 'due_date' => $duedate, 'assigned_to' => $assignedto, 'description' => $description);
                 $query = \SQL::update("module_{$this->moduleNameLC}_task", $fields, array('escape' => true)) . " WHERE `id` = {$id}";
                 $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_UPDATE_MESSAGE'];
             } else {
                 $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE_ERR'];
             }
         } else {
             $addedDate = date('Y-m-d H:i:s');
             $fields = array('task_title' => $title, 'task_type_id' => $type, 'customer_id' => $customer, 'due_date' => $duedate, 'assigned_to' => $assignedto, 'added_by' => $objFWUser->objUser->getId(), 'added_date_time' => $addedDate, 'task_status' => '0', 'description' => $description);
             $query = \SQL::insert("module_{$this->moduleNameLC}_task", $fields, array('escape' => true));
             $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_CRM_TASK_OK_MESSAGE'];
         }
         $db = $objDatabase->Execute($query);
         if ($db) {
             if ($notify) {
                 $cx = \Cx\Core\Core\Controller\Cx::instanciate();
                 $id = !empty($id) ? $id : $objDatabase->INSERT_ID();
                 $info['substitution'] = array('CRM_ASSIGNED_USER_NAME' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($assignedto)), 'CRM_ASSIGNED_USER_EMAIL' => $objFWUser->objUser->getUser($assignedto)->getEmail(), 'CRM_DOMAIN' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath(), 'CRM_TASK_NAME' => $title, 'CRM_TASK_LINK' => "<a href='" . ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=task&tpl=modify&id={$id}'>{$title}</a>", 'CRM_TASK_URL' => ASCMS_PROTOCOL . "://{$_SERVER['HTTP_HOST']}" . $cx->getCodeBaseOffsetPath() . $cx->getBackendFolderName() . "/index.php?cmd=" . $this->moduleName . "&act=task&tpl=modify&id={$id}", 'CRM_TASK_DUE_DATE' => $duedate, 'CRM_TASK_CREATED_USER' => contrexx_raw2xhtml(\FWUser::getParsedUserTitle($objFWUser->objUser->getId())), 'CRM_TASK_DESCRIPTION_TEXT_VERSION' => contrexx_html2plaintext($description), 'CRM_TASK_DESCRIPTION_HTML_VERSION' => $description);
                 //setting email template lang id
                 $availableMailTempLangAry = $this->getActiveEmailTemLangId('Crm', CRM_EVENT_ON_TASK_CREATED);
                 $availableLangId = $this->getEmailTempLang($availableMailTempLangAry, $objFWUser->objUser->getUser($assignedto)->getEmail());
                 $info['lang_id'] = $availableLangId;
                 $dispatcher = CrmEventDispatcher::getInstance();
                 $dispatcher->triggerEvent(CRM_EVENT_ON_TASK_CREATED, null, $info);
             }
             \Cx\Core\Csrf\Controller\Csrf::header("Location:./index.php?cmd=" . $this->moduleName . base64_decode($redirect));
             exit;
         }
     } elseif (!empty($id)) {
         $objValue = $objDatabase->Execute("SELECT task_id,\n                                                            task_title,\n                                                            task_type_id,\n                                                            due_date,\n                                                            assigned_to,\n                                                            description,\n                                                            c.id,\n                                                            c.customer_name,\n                                                            c.contact_familyname\n                                                       FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_task` AS t\n                                                       LEFT JOIN `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` AS c\n                                                            ON t.customer_id = c.id\n                                                       WHERE t.id='{$id}'");
         $title = $objValue->fields['task_title'];
         $type = $objValue->fields['task_type_id'];
         $customer = $objValue->fields['id'];
         $customerName = !empty($objValue->fields['customer_name']) ? $objValue->fields['customer_name'] . " " . $objValue->fields['contact_familyname'] : '';
         $duedate = $objValue->fields['due_date'];
         $assignedto = $objValue->fields['assigned_to'];
         $description = $objValue->fields['description'];
         $taskAutoId = $objValue->fields['task_id'];
     }
     $this->_getResourceDropDown('Members', $assignedto, $settings['emp_default_user_group']);
     $this->taskTypeDropDown($objtpl, $type);
     if (!empty($customer)) {
         // Get customer Name
         $objCustomer = $objDatabase->Execute("SELECT customer_name, contact_familyname  FROM `" . DBPREFIX . "module_crm_contacts` WHERE id = {$customer}");
         $customerName = $objCustomer->fields['customer_name'] . " " . $objCustomer->fields['contact_familyname'];
     }
     $objtpl->setVariable(array('CRM_LOGGED_USER_ID' => $objFWUser->objUser->getId(), 'CRM_TASK_AUTOID' => contrexx_raw2xhtml($taskAutoId), 'CRM_TASK_ID' => (int) $id, 'CRM_TASKTITLE' => contrexx_raw2xhtml($title), 'CRM_DUE_DATE' => contrexx_raw2xhtml($duedate), 'CRM_CUSTOMER_ID' => intval($customer), 'CRM_CUSTOMER_NAME' => contrexx_raw2xhtml($customerName), 'CRM_TASK_DESC' => new \Cx\Core\Wysiwyg\Wysiwyg('description', contrexx_raw2xhtml($description)), 'CRM_BACK_LINK' => base64_decode($redirect), 'TXT_CRM_ADD_TASK' => empty($id) ? $_ARRAYLANG['TXT_CRM_ADD_TASK'] : $_ARRAYLANG['TXT_CRM_EDITTASK'], 'TXT_CRM_TASK_ID' => $_ARRAYLANG['TXT_CRM_TASK_ID'], 'TXT_CRM_TASK_TITLE' => $_ARRAYLANG['TXT_CRM_TASK_TITLE'], 'TXT_CRM_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_TASK_TYPE'], 'TXT_CRM_SELECT_TASK_TYPE' => $_ARRAYLANG['TXT_CRM_SELECT_TASK_TYPE'], 'TXT_CRM_CUSTOMER_NAME' => $_ARRAYLANG['TXT_CRM_CUSTOMER_NAME'], 'TXT_CRM_TASK_DUE_DATE' => $_ARRAYLANG['TXT_CRM_TASK_DUE_DATE'], 'TXT_CRM_TASK_RESPONSIBLE' => $_ARRAYLANG['TXT_CRM_TASK_RESPONSIBLE'], 'TXT_CRM_SELECT_MEMBER_NAME' => $_ARRAYLANG['TXT_CRM_SELECT_MEMBER_NAME'], 'TXT_CRM_OVERVIEW' => $_ARRAYLANG['TXT_CRM_OVERVIEW'], 'TXT_CRM_TASK_DESCRIPTION' => $_ARRAYLANG['TXT_CRM_TASK_DESCRIPTION'], 'TXT_CRM_FIND_COMPANY_BY_NAME' => $_ARRAYLANG['TXT_CRM_FIND_COMPANY_BY_NAME'], 'TXT_CRM_SAVE' => $_ARRAYLANG['TXT_CRM_SAVE'], 'TXT_CRM_BACK' => $_ARRAYLANG['TXT_CRM_BACK'], 'TXT_CRM_NOTIFY' => $_ARRAYLANG['TXT_CRM_NOTIFY'], 'TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT' => $_ARRAYLANG['TXT_CRM_MANDATORY_FIELDS_NOT_FILLED_OUT']));
 }
 /**
  * This is called by the default ComponentController and does all the repeating work
  * 
  * This loads a template named after current $act and calls parsePage($actTemplate)
  * @todo $this->cx->getTemplate()->setVariable() should not be called here but in Cx class
  * @global array $_ARRAYLANG Language data
  * @global $subMenuTitle
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Resolved page
  */
 public function getPage(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_ARRAYLANG, $subMenuTitle;
     $subMenuTitle = $_ARRAYLANG['TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName())];
     $cmd = array('');
     if (isset($_GET['act'])) {
         $cmd = explode('/', contrexx_input2raw($_GET['act']));
     } else {
         $cmd[0] = 'Wysiwyg';
     }
     $actTemplate = new \Cx\Core\Html\Sigma($this->getDirectory(true) . '/View/Template/Backend');
     $filename = $cmd[0] . '.html';
     $testFilename = $cmd[0];
     if (!\Env::get('ClassLoader')->getFilePath($actTemplate->getRoot() . '/' . $filename)) {
         $filename = 'Default.html';
         $testFilename = 'Default';
     }
     foreach ($cmd as $index => $name) {
         if ($index == 0) {
             continue;
         }
         $testFilename .= $name;
         if (\Env::get('ClassLoader')->getFilePath($actTemplate->getRoot() . '/' . $testFilename . '.html')) {
             $filename = $testFilename . '.html';
         } else {
             break;
         }
     }
     $actTemplate->loadTemplateFile($filename);
     // todo: Messages
     $this->parsePage($actTemplate, $cmd);
     // set tabs
     $navigation = new \Cx\Core\Html\Sigma(\Env::get('cx')->getCodeBaseCorePath() . '/Core/View/Template/Backend');
     $navigation->loadTemplateFile('Navigation.html');
     $commands = array_merge($this->getCommands());
     foreach ($commands as $key => $command) {
         $subnav = array();
         if (is_array($command)) {
             $subnav = array_merge(array(''), $command);
             $command = $key;
         }
         if ($key !== '') {
             if ($cmd[0] == $command) {
                 $navigation->touchBlock('tab_active');
             } else {
                 $navigation->hideBlock('tab_active');
             }
             $act = '&amp;act=' . $command;
             $txt = $command;
             if (empty($command)) {
                 $act = '';
                 $txt = 'DEFAULT';
             }
             $actTxtKey = 'TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt);
             $actTitle = isset($_ARRAYLANG[$actTxtKey]) ? $_ARRAYLANG[$actTxtKey] : $actTxtKey;
             $navigation->setVariable(array('HREF' => 'index.php?cmd=' . $this->getName() . $act, 'TITLE' => $actTitle));
             $navigation->parse('tab_entry');
         }
         // subnav
         if ($cmd[0] == $command && count($subnav)) {
             $first = true;
             foreach ($subnav as $subcommand) {
                 if (!isset($cmd[1]) && $first || (isset($cmd[1]) ? $cmd[1] : '') == $subcommand) {
                     $navigation->touchBlock('subnav_active');
                 } else {
                     $navigation->hideBlock('subnav_active');
                 }
                 $act = '&amp;act=' . $cmd[0] . '/' . $subcommand;
                 $txt = (empty($cmd[0]) ? 'DEFAULT' : $cmd[0]) . '_';
                 if (empty($subcommand)) {
                     $act = '&amp;act=' . $cmd[0] . '/';
                     $txt .= 'DEFAULT';
                 } else {
                     $txt .= strtoupper($subcommand);
                 }
                 $actTxtKey = 'TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt);
                 $actTitle = isset($_ARRAYLANG[$actTxtKey]) ? $_ARRAYLANG[$actTxtKey] : $actTxtKey;
                 $navigation->setVariable(array('HREF' => 'index.php?cmd=' . $this->getName() . $act, 'TITLE' => $actTitle));
                 $navigation->parse('subnav_entry');
                 $first = false;
             }
         }
     }
     $txt = $cmd[0];
     if (empty($txt)) {
         $txt = 'DEFAULT';
     }
     // default css and js
     if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Style/Backend.css'))) {
         \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Backend.css', 1));
     }
     if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Script/Backend.js'))) {
         \JS::registerJS(substr($this->getDirectory(false, true) . '/View/Script/Backend.js', 1));
     }
     // finish
     $actTemplate->setGlobalVariable($_ARRAYLANG);
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($actTemplate);
     $page->setContent($actTemplate->get());
     $cachedRoot = $this->cx->getTemplate()->getRoot();
     $this->cx->getTemplate()->setRoot(\Env::get('cx')->getCodeBaseCorePath() . '/Core/View/Template/Backend');
     $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'ContentMaster.html');
     $this->cx->getTemplate()->setRoot($cachedRoot);
     $this->cx->getTemplate()->setVariable(array('CONTENT_NAVIGATION' => $navigation->get(), 'ADMIN_CONTENT' => $page->getContent(), 'CONTENT_TITLE' => $_ARRAYLANG['TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt)]));
 }
Example #17
0
 /**
  * Shows the image settings page
  *
  * @access  public
  *
  * @param $arrData
  *
  * @throws \Exception
  * @return  boolean  true on success, false otherwise
  */
 public function image($arrData)
 {
     \JS::registerCSS(substr(ASCMS_CORE_MODULE_FOLDER . '/MediaBrowser/View/Style/mediabrowser.css', 1));
     global $objDatabase, $objTemplate, $_ARRAYLANG;
     $this->strPageTitle = $_ARRAYLANG['TXT_SETTINGS_IMAGE'];
     $objTemplate->addBlockfile('ADMIN_CONTENT', 'settings_image', 'settings_image.html');
     \ContrexxJavascript::getInstance()->setVariable(array('publicTempPath' => Cx::instanciate()->getWebsitePublicTempWebPath()), 'config/image');
     // Saves the settings
     if (isset($arrData['submit'])) {
         $arrSettings['image_cut_width'] = contrexx_input2db(intval($arrData['image_cut_width']));
         $arrSettings['image_cut_height'] = contrexx_input2db(intval($arrData['image_cut_height']));
         //$arrSettings['image_scale_width']  = contrexx_input2db(intval($arrData['image_scale_width']));
         //$arrSettings['image_scale_height'] = contrexx_input2db(intval($arrData['image_scale_height']));
         $arrSettings['image_compression'] = contrexx_input2db(intval($arrData['image_compression']));
         foreach ($arrSettings as $name => $value) {
             $query = '
                 UPDATE `' . DBPREFIX . 'settings_image`
                 SET `value` = "' . $value . '"
                 WHERE `name` = "' . $name . '"
             ';
             $objResult = $objDatabase->Execute($query);
             if ($objResult === false) {
                 throw new \Exception('Could not update the settings');
             }
         }
         $this->strOkMessage = $_ARRAYLANG['TXT_SETTINGS_UPDATED'];
     }
     /**
      * @var $cx \Cx\Core\Core\Controller\Cx
      */
     $cx = \Env::get('cx');
     $pdo = $cx->getDb()->getPdoConnection();
     $sth = $pdo->query('SELECT id, name, size FROM  `' . DBPREFIX . 'settings_thumbnail`');
     $thumbnails = $sth->fetchAll();
     $newThumbnailTemplate = new \Cx\Core\Html\Sigma($cx->getCodeBasePath());
     $newThumbnailTemplate->loadTemplateFile($cx->getCodeBaseCorePath() . '/Config/View/Template/Backend/settings_image_edit.html');
     $newThumbnailTemplate->removeUnknownVariables = false;
     $newThumbnailTemplate->setVariable(array('TXT_IMAGE_TITLE' => $_ARRAYLANG['TXT_SETTINGS_IMAGE_TITLE'], 'TXT_IMAGE_CSRF' => \Cx\Core\Csrf\Controller\Csrf::param(), 'TXT_IMAGE_THUMBNAILS_DELETE' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_DELETE'], 'TXT_IMAGE_CUT_WIDTH' => $_ARRAYLANG['TXT_SETTINGS_IMAGE_CUT_WIDTH'], 'TXT_IMAGE_CUT_HEIGHT' => $_ARRAYLANG['TXT_SETTINGS_IMAGE_CUT_HEIGHT'], 'TXT_IMAGE_THUMBNAILS' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS'], 'TXT_IMAGE_COMPRESSION' => $_ARRAYLANG['TXT_SETTINGS_IMAGE_COMPRESSION'], 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_IMAGE_THUMBNAILS_ID' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_ID'], 'TXT_IMAGE_THUMBNAILS_NAME' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_NAME'], 'TXT_IMAGE_THUMBNAILS_SIZE' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_SIZE'], 'TXT_SETTINGS_FUNCTIONS' => $_ARRAYLANG['TXT_SETTINGS_FUNCTIONS'], 'TXT_IMAGE_THUMBNAILS_RELOAD' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_RELOAD'], 'TXT_IMAGE_THUMBNAILS_NEW' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_NEW'], 'TXT_IMAGE_THUMBNAILS_MAX_SIZE' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_MAX_SIZE'], 'SETTINGS_IMAGE_CUT_WIDTH' => !empty($arrSettings['image_cut_width']) ? $arrSettings['image_cut_width'] : 0, 'SETTINGS_IMAGE_CUT_HEIGHT' => !empty($arrSettings['image_cut_height']) ? $arrSettings['image_cut_height'] : 0));
     $objTemplate->setVariable('CONFIG_THUMBNAIL_NEW_TEMPLATE', implode(' ', explode("\n", str_replace("'", "\"", $newThumbnailTemplate->get()))));
     foreach ($thumbnails as $thumbnail) {
         $objTemplate->setVariable(array('IMAGE_THUMBNAIL_ID' => $thumbnail['id'], 'IMAGE_THUMBNAIL_NAME' => $thumbnail['name'], 'IMAGE_THUMBNAIL_SIZE' => $thumbnail['size'], 'TXT_IMAGE_THUMBNAILS_MAXIMUM' => sprintf($_ARRAYLANG['TXT_IMAGE_THUMBNAILS_MAXIMUM'], $thumbnail['size'] . 'px')));
         $objTemplate->parse('settings_image_thumbnails_list');
     }
     // Gets the settings
     $query = '
         SELECT `name`, `value`
         FROM `' . DBPREFIX . 'settings_image`
     ';
     $objResult = $objDatabase->Execute($query);
     if ($objResult !== false) {
         $arrSettings = array();
         while (!$objResult->EOF) {
             // Creates the settings array
             $arrSettings[$objResult->fields['name']] = $objResult->fields['value'];
             $objResult->MoveNext();
         }
     } else {
         throw new \Exception('Could not query the settings.');
     }
     // Defines the compression values
     $arrCompressionOptions = array();
     for ($i = 1; $i <= 20; $i++) {
         $arrCompressionOptions[] = $i * 5;
     }
     // Parses the compression options
     $imageCompression = !empty($arrSettings['image_compression']) ? intval($arrSettings['image_compression']) : 95;
     foreach ($arrCompressionOptions as $compression) {
         $objTemplate->setVariable(array('IMAGE_COMPRESSION_VALUE' => $compression, 'IMAGE_COMPRESSION_NAME' => $compression, 'OPTION_SELECTED' => $compression == $imageCompression ? 'selected="selected"' : ''));
         $objTemplate->parse('settings_image_compression_options');
     }
     // Parses the settings
     $objTemplate->setVariable(array('TXT_IMAGE_TITLE' => $_ARRAYLANG['TXT_SETTINGS_IMAGE_TITLE'], 'TXT_IMAGE_CSRF' => \Cx\Core\Csrf\Controller\Csrf::param(), 'TXT_IMAGE_THUMBNAILS_DELETE' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_DELETE'], 'TXT_IMAGE_CUT_WIDTH' => $_ARRAYLANG['TXT_SETTINGS_IMAGE_CUT_WIDTH'], 'TXT_IMAGE_CUT_HEIGHT' => $_ARRAYLANG['TXT_SETTINGS_IMAGE_CUT_HEIGHT'], 'TXT_IMAGE_THUMBNAILS' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS'], 'TXT_IMAGE_COMPRESSION' => $_ARRAYLANG['TXT_SETTINGS_IMAGE_COMPRESSION'], 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_IMAGE_THUMBNAILS_ID' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_ID'], 'TXT_IMAGE_THUMBNAILS_NAME' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_NAME'], 'TXT_IMAGE_THUMBNAILS_SIZE' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_SIZE'], 'TXT_SETTINGS_FUNCTIONS' => $_ARRAYLANG['TXT_SETTINGS_FUNCTIONS'], 'TXT_IMAGE_THUMBNAILS_RELOAD' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_RELOAD'], 'TXT_IMAGE_THUMBNAILS_NEW' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_NEW'], 'TXT_IMAGE_THUMBNAILS_MAX_SIZE' => $_ARRAYLANG['TXT_IMAGE_THUMBNAILS_MAX_SIZE'], 'SETTINGS_IMAGE_CUT_WIDTH' => !empty($arrSettings['image_cut_width']) ? $arrSettings['image_cut_width'] : 0, 'SETTINGS_IMAGE_CUT_HEIGHT' => !empty($arrSettings['image_cut_height']) ? $arrSettings['image_cut_height'] : 0));
     $objTemplate->parse('settings_image');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTemplate);
     return true;
 }
Example #18
0
 /**
  * Finds all <link>-Tags in the passed HTML content, strips them out
  * and puts them in the internal CSS placeholder store.
  * You can then retreive them all-in-one with JS::getCode().
  * @param string $content - Reference to the HTML content. Note that it
  *                          WILL be modified in-place.
  */
 public static function findCSS(&$content)
 {
     JS::grabComments($content);
     //deactivate error handling for not well formed html
     libxml_use_internal_errors(true);
     $css = array();
     $dom = new domDocument();
     $dom->loadHTML($content);
     libxml_clear_errors();
     foreach ($dom->getElementsByTagName('link') as $element) {
         if (preg_match('/\\.css(\\?.*)?$/', $element->getAttribute('href'))) {
             $css[] = $element->getAttribute('href');
             JS::registerCSS($element->getAttribute('href'));
         }
     }
     JS::restoreComments($content);
     return $css;
 }
 /**
  * Add the warning banner
  *
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Resolved page
  */
 public function postContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     \JS::registerJS('core_modules/Workbench/View/Script/Warning.js');
     $objTemplate = $this->cx->getTemplate();
     $warning = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Workbench/View/Template/Backend');
     $warning->loadTemplateFile('Warning.html');
     if ($this->cx->getMode() == \Cx\Core\Core\Controller\Cx::MODE_BACKEND) {
         \JS::registerCSS('core_modules/Workbench/View/Style/WarningBackend.css');
         $objTemplate->_blocks['__global__'] = preg_replace('/<div id="container"[^>]*>/', '\\0' . $warning->get(), $objTemplate->_blocks['__global__']);
     } else {
         \JS::registerCSS('core_modules/Workbench/View/Style/WarningFrontend.css');
         $objTemplate->_blocks['__global__'] = preg_replace('/<body[^>]*>/', '\\0' . $warning->get(), $objTemplate->_blocks['__global__']);
     }
 }
Example #20
0
 /**
  * Returns an array of all basic templates for the active theme
  * @return  array           The array of template strings
  * @access  public
  */
 function getTemplates($page)
 {
     global $objDatabase;
     if (isset($_GET['custom_content']) && preg_match('/^[a-zA-Z0-9_]+$/', $_GET['custom_content'])) {
         $this->customContentTemplate = $_GET['custom_content'];
     }
     if (isset($_GET['preview']) && intval($_GET['preview'])) {
         $id = intval($_GET['preview']);
         $theme = $this->themeRepository->findById($id);
         if ($theme) {
             $this->currentThemesId = $id;
         }
     }
     // get theme object so we get the configured libraries
     $theme = $this->getFrontendTemplate();
     $themesPath = $theme->getFoldername();
     if ($theme && $theme->isComponent()) {
         $libraries = JS::getConfigurableLibraries();
         foreach ($theme->getDependencies() as $libraryName => $libraryVersions) {
             if (!isset($libraries[$libraryName])) {
                 continue;
             }
             $version = $libraryVersions[0];
             $libraryData = isset($libraries[$libraryName]['versions'][$version]) ? $libraries[$libraryName]['versions'][$version] : array();
             if (isset($libraryData['jsfiles'])) {
                 foreach ($libraryData['jsfiles'] as $file) {
                     \JS::registerJS($file, true);
                 }
             }
             if (isset($libraryData['cssfiles'])) {
                 foreach ($libraryData['cssfiles'] as $file) {
                     \JS::registerCSS($file);
                 }
             }
         }
     }
     $this->themesPath = $themesPath;
     $this->templates['index'] = $this->getThemeFileContent($themesPath, 'index.html');
     $this->templates['home'] = $this->getThemeFileContent($themesPath, 'home.html');
     $this->templates['navbar'] = $this->getThemeFileContent($themesPath, 'navbar.html');
     $this->templates['navbar2'] = $this->getThemeFileContent($themesPath, 'navbar2.html');
     $this->templates['navbar3'] = $this->getThemeFileContent($themesPath, 'navbar3.html');
     $this->templates['subnavbar'] = $this->getThemeFileContent($themesPath, 'subnavbar.html');
     $this->templates['subnavbar2'] = $this->getThemeFileContent($themesPath, 'subnavbar2.html');
     $this->templates['subnavbar3'] = $this->getThemeFileContent($themesPath, 'subnavbar3.html');
     $this->templates['sidebar'] = $this->getThemeFileContent($themesPath, 'sidebar.html');
     $this->templates['top_news'] = $this->getThemeFileContent($themesPath, 'top_news.html');
     $this->templates['shopnavbar'] = $this->getThemeFileContent($themesPath, 'shopnavbar.html');
     $this->templates['shopnavbar2'] = $this->getThemeFileContent($themesPath, 'shopnavbar2.html');
     $this->templates['shopnavbar3'] = $this->getThemeFileContent($themesPath, 'shopnavbar3.html');
     $this->templates['headlines'] = $this->getThemeFileContent($themesPath, 'headlines.html');
     $this->templates['headlines2'] = $this->getThemeFileContent($themesPath, 'headlines2.html');
     $this->templates['headlines3'] = $this->getThemeFileContent($themesPath, 'headlines3.html');
     $this->templates['headlines4'] = $this->getThemeFileContent($themesPath, 'headlines4.html');
     $this->templates['news_recent_comments'] = $this->getThemeFileContent($themesPath, 'news_recent_comments.html');
     $this->templates['javascript'] = $this->getThemeFileContent($themesPath, 'javascript.js');
     //$this->templates['style']                 = $this->getThemeFileContent($themesPath, 'style.css');
     $this->templates['buildin_style'] = $this->getThemeFileContent($themesPath, 'buildin_style.css');
     $this->templates['calendar_headlines'] = $this->getThemeFileContent($themesPath, 'events.html');
     $this->templates['directory_content'] = $this->getThemeFileContent($themesPath, 'directory.html');
     $this->templates['forum_content'] = $this->getThemeFileContent($themesPath, 'forum.html');
     $this->templates['podcast_content'] = $this->getThemeFileContent($themesPath, 'podcast.html');
     $this->templates['blog_content'] = $this->getThemeFileContent($themesPath, 'blog.html');
     $this->templates['immo'] = $this->getThemeFileContent($themesPath, 'immo.html');
     if (!$this->hasCustomContent() || !$this->loadCustomContent($page)) {
         // load default content layout if page doesn't have a custom content
         // layout or if it failed to be loaded
         $this->templates['content'] = $this->getThemeFileContent($themesPath, 'content.html');
     }
     return $this->templates;
 }
Example #21
0
 /**
  * Registers all css and js to be loaded for crm module
  *
  */
 public function _initCrmModule()
 {
     \JS::activate('cx');
     \JS::activate('jqueryui');
     \JS::registerJS("modules/Crm/View/Script/main.js");
     \JS::registerCSS("modules/Crm/View/Style/main.css");
 }
 public function __construct($entity, $actionUrl = null, $entityClass = '', $title = '', $options = array(), $entityId = 0, $componentOptions)
 {
     $this->componentOptions = $componentOptions;
     $this->formId = static::$formIncrement;
     static::$formIncrement++;
     $this->options = $options;
     $this->entity = $entity;
     // Remove the virtual element from array
     unset($entity['virtual']);
     if (empty($entityClass) && is_object($entity)) {
         $entityClass = get_class($entity);
     }
     $this->entityClass = $entityClass;
     if (empty($title)) {
         $title = $entityClass;
     }
     \JS::registerCSS(\Env::get('cx')->getCoreFolderName() . '/Html/View/Style/Backend.css');
     $this->form = new \Cx\Core\Html\Model\Entity\FormElement($actionUrl, 'post', \Cx\Core\Html\Model\Entity\FormElement::ENCTYPE_MULTIPART_FORMDATA, !isset($options['functions']) || !isset($options['functions']['formButtons']) || $options['functions']['formButtons'] == true);
     $this->form->setAttribute('id', 'form-' . $this->formId);
     $this->form->setAttribute('class', 'cx-ui');
     $titleElement = new \Cx\Core\Html\Model\Entity\HtmlElement('legend');
     $titleElement->addChild(new \Cx\Core\Html\Model\Entity\TextElement($title));
     $this->form->addChild($titleElement);
     // @todo replace this by auto-find editid
     if (isset($_REQUEST['editid'])) {
         $editIdField = new \Cx\Core\Html\Model\Entity\DataElement('editid', contrexx_input2raw($_REQUEST['editid']), 'input');
         $editIdField->setAttribute('type', 'hidden');
         $this->form->addChild($editIdField);
     }
     // foreach entity field
     foreach ($entity as $field => $value) {
         $type = null;
         if (!empty($options[$field]['type'])) {
             $type = $options[$field]['type'];
         }
         if (is_object($value)) {
             if ($value instanceof \Cx\Model\Base\EntityBase) {
                 $type = 'Cx\\Model\\Base\\EntityBase';
             } elseif ($value instanceof \Doctrine\Common\Collections\Collection) {
                 continue;
             } else {
                 $type = get_class($value);
             }
         }
         $length = 0;
         $value = $entity[$field];
         $fieldOptions = array();
         if (isset($options['fields']) && isset($options['fields'][$field])) {
             $fieldOptions = $options['fields'][$field];
         }
         if (!empty($fieldOptions['type'])) {
             $type = $fieldOptions['type'];
         }
         $dataElement = $this->getDataElement($field, $type, $length, $value, $fieldOptions, $entityId);
         if (empty($dataElement)) {
             continue;
         }
         $dataElement->setAttribute('id', 'form-' . $this->formId . '-' . $field);
         if ($type == 'hidden') {
             $element = $dataElement;
         } else {
             $element = $this->getDataElementGroup($field, $dataElement, $fieldOptions);
         }
         $this->form->addChild($element);
     }
     if (isset($options['cancelUrl'])) {
         $this->form->cancelUrl = $options['cancelUrl'];
     }
 }
 /**
  * Modify Group Page
  *
  * This page shows the dialog to modify a group.
  *
  * @return unknown
  */
 function _modifyGroup()
 {
     global $_ARRAYLANG, $_CORELANG, $objDatabase;
     $arrAreas = array();
     $associatedUsers = '';
     $arrContentAccessIds = array();
     $arrSelectedAccessIds = array();
     $notAssociatedUsers = '';
     $objFWUser = \FWUser::getFWUserObject();
     $objGroup = $objFWUser->objGroup->getGroup(isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
     if (isset($_POST['access_save_group'])) {
         // only administrators are allowed to modify a group
         if (!\Permission::hasAllAccess()) {
             \Permission::noAccess();
         }
         $objGroup->setName(!empty($_POST['access_group_name']) ? trim(contrexx_input2raw($_POST['access_group_name'])) : '');
         $objGroup->setDescription(!empty($_POST['access_group_description']) ? trim(contrexx_input2raw($_POST['access_group_description'])) : '');
         $objGroup->setActiveStatus(isset($_POST['access_group_status']) ? (bool) $_POST['access_group_status'] : false);
         $objGroup->setType(!empty($_POST['access_group_type']) ? $_POST['access_group_type'] : '');
         $objGroup->setHomepage(!empty($_POST['access_group_homepage']) ? trim(contrexx_input2raw($_POST['access_group_homepage'])) : '');
         $objGroup->setUsers(isset($_POST['access_group_associated_users']) && is_array($_POST['access_group_associated_users']) ? $_POST['access_group_associated_users'] : array());
         $objGroup->setStaticPermissionIds(isset($_POST['access_area_id']) && is_array($_POST['access_area_id']) ? $_POST['access_area_id'] : array());
         // set dynamic access ids
         $arrSelectedPageIds = isset($_POST['access_page_id']) && is_array($_POST['access_page_id']) ? $_POST['access_page_id'] : array();
         $objJsonData = new \Cx\Core\Json\JsonData();
         $jsonData = $objJsonData->data('node', 'getTree', array('get' => array('recursive' => 'true')));
         $nodeStack = $jsonData['data']['tree'];
         while (count($nodeStack)) {
             $node = array_pop($nodeStack);
             foreach ($node['data'] as $page) {
                 if ($page['attr']['id'] == 'broken') {
                     continue;
                 }
                 if (empty($page['attr'][$objGroup->getType() . '_access_id'])) {
                     continue;
                 }
                 $arrContentAccessIds[] = $page['attr'][$objGroup->getType() . '_access_id'];
                 if (in_array($page['attr']['id'], $arrSelectedPageIds)) {
                     $arrSelectedAccessIds[] = $page['attr'][$objGroup->getType() . '_access_id'];
                 }
             }
             $children = $node['children'];
             $hasChilds = count($children) > 0;
             if ($hasChilds) {
                 foreach ($children as $child) {
                     array_push($nodeStack, $child);
                 }
             }
         }
         $arrCurrentAccessIds = $objGroup->getDynamicPermissionIds();
         foreach ($arrContentAccessIds as $accessId) {
             // add new access ids
             if (in_array($accessId, $arrSelectedAccessIds) && !in_array($accessId, $arrCurrentAccessIds)) {
                 $arrCurrentAccessIds[] = $accessId;
             }
             // delete access ids
             if (!in_array($accessId, $arrSelectedAccessIds) && in_array($accessId, $arrCurrentAccessIds)) {
                 unset($arrCurrentAccessIds[array_search($accessId, $arrCurrentAccessIds)]);
             }
         }
         $objGroup->setDynamicPermissionIds($arrCurrentAccessIds);
         if (isset($_POST['access_save_group'])) {
             if ($objGroup->store()) {
                 self::$arrStatusMsg['ok'][] = $_ARRAYLANG['TXT_ACCESS_GROUP_STORED_SUCCESSFULLY'];
                 $objFWUser->objUser->getDynamicPermissionIds(true);
                 $objFWUser->objUser->getStaticPermissionIds(true);
                 $this->_groupList();
                 return;
             } else {
                 self::$arrStatusMsg['error'][] = $objGroup->getErrorMsg();
             }
         }
     } elseif (isset($_POST['access_create_group'])) {
         $objGroup->setType(isset($_POST['access_group_type']) ? $_POST['access_group_type'] : '');
     }
     $this->_objTpl->addBlockfile('ACCESS_GROUP_TEMPLATE', 'module_access_group_modify', 'module_access_group_modify.html');
     $this->_pageTitle = $objGroup->getId() ? $_ARRAYLANG['TXT_ACCESS_MODIFY_GROUP'] : $_ARRAYLANG['TXT_ACCESS_CREATE_NEW_USER_GROUP'];
     $objUser = $objFWUser->objUser->getUsers(null, null, array('username' => 'asc', 'email' => 'asc'), array('id', 'username', 'email', 'firstname', 'lastname'));
     if ($objUser) {
         $arrGroupUsers = $objGroup->getAssociatedUserIds();
         while (!$objUser->EOF) {
             $arrUsers[] = $objUser->getId();
             $objUser->next();
         }
         $arrOtherUsers = array_diff($arrUsers, $arrGroupUsers);
         foreach ($arrGroupUsers as $uId) {
             $objUser = $objFWUser->objUser->getUser($uId);
             if ($objUser) {
                 $associatedUsers .= "<option value=\"" . $objUser->getId() . "\">" . htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET) . ($objUser->getProfileAttribute('lastname') != '' || $objUser->getProfileAttribute('firstname') != '' ? " (" . htmlentities($objUser->getProfileAttribute('firstname'), ENT_QUOTES, CONTREXX_CHARSET) . " " . htmlentities($objUser->getProfileAttribute('lastname'), ENT_QUOTES, CONTREXX_CHARSET) . ")" : '') . "</option>\n";
             }
         }
         foreach ($arrOtherUsers as $uId) {
             $objUser = $objFWUser->objUser->getUser($uId);
             if ($objUser) {
                 $notAssociatedUsers .= "<option value=\"" . $objUser->getId() . "\">" . htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET) . ($objUser->getProfileAttribute('lastname') != '' || $objUser->getProfileAttribute('firstname') != '' ? " (" . htmlentities($objUser->getProfileAttribute('firstname'), ENT_QUOTES, CONTREXX_CHARSET) . " " . htmlentities($objUser->getProfileAttribute('lastname'), ENT_QUOTES, CONTREXX_CHARSET) . ")" : '') . "</option>\n";
             }
         }
     }
     $this->_objTpl->setVariable('ACCESS_WEBSITE_TAB_NAME', 'Webseiten');
     $arrModules = array();
     $objResult = $objDatabase->Execute("SELECT id, name FROM " . DBPREFIX . "modules");
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             $arrModules[$objResult->fields['id']] = $objResult->fields['name'];
             $objResult->MoveNext();
         }
     }
     $this->_objTpl->setGlobalVariable(array('TXT_ACCESS_SHOW_PAGE_IN_NEW_DOCUMENT' => $_ARRAYLANG['TXT_ACCESS_SHOW_PAGE_IN_NEW_DOCUMENT'], 'TXT_ACCESS_MODIFY_PAGE_IN_NEW_DOCUMENT' => $_ARRAYLANG['TXT_ACCESS_MODIFY_PAGE_IN_NEW_DOCUMENT'], 'TXT_ACCESS_CHECK_ALL' => $_ARRAYLANG['TXT_ACCESS_CHECK_ALL'], 'TXT_ACCESS_UNCHECK_ALL' => $_ARRAYLANG['TXT_ACCESS_UNCHECK_ALL']));
     \JS::registerCSS('core/ContentManager/View/Style/Main.css');
     $objJsonData = new \Cx\Core\Json\JsonData();
     $jsonData = $objJsonData->data('node', 'getTree', array('get' => array('recursive' => 'true')));
     $nodeTree = $jsonData['data']['tree'];
     $this->parseContentTree($nodeTree, $objGroup->getType(), $objGroup->getDynamicPermissionIds());
     $objResult = $objDatabase->Execute("\n            SELECT\n                `areas`.`area_id`,\n                `areas`.`area_name`,\n                `areas`.`access_id`,\n                `areas`.`module_id`,\n                `areas`.`is_active`,\n                `areas`.`type`,\n                `areas`.`scope`,\n                `areas`.`parent_area_id`,\n                `modules`.`name` AS `module_name`\n            FROM\n                `" . DBPREFIX . "backend_areas` AS `areas`\n            INNER JOIN\n                `" . DBPREFIX . "modules` AS `modules`\n            ON\n                `modules`.`id` = `areas`.`module_id`\n            WHERE\n                `areas`.`is_active` = 1 AND\n                `areas`.`access_id` != '0'\n            ORDER BY\n                `areas`.`parent_area_id`,\n                `areas`.`order_id`\n        ");
     if ($objResult) {
         while (!$objResult->EOF) {
             if (isset($_CORELANG[$objResult->fields['area_name']])) {
                 $areaName = $_CORELANG[$objResult->fields['area_name']];
             } else {
                 // load language file
                 $objInit = \Env::get('init');
                 $moduleLanguageData = $objInit->getComponentSpecificLanguageData($objResult->fields['module_name'], false, $objInit->backendLangId);
                 if (isset($moduleLanguageData[$objResult->fields['area_name']])) {
                     $areaName = $moduleLanguageData[$objResult->fields['area_name']];
                 } else {
                     $areaName = $objResult->fields['area_name'];
                 }
             }
             $arrAreas[$objResult->fields['area_id']] = array('name' => $areaName, 'access_id' => $objResult->fields['access_id'], 'status' => $objResult->fields['is_active'], 'type' => $objResult->fields['type'], 'module_id' => $objResult->fields['module_id'], 'scope' => $objResult->fields['scope'], 'group_id' => $objResult->fields['parent_area_id'], 'allowed' => in_array($objResult->fields['access_id'], $objGroup->getStaticPermissionIds()) ? 1 : 0);
             $objResult->MoveNext();
         }
     }
     $tabNr = 1;
     foreach ($arrAreas as $groupId => $arrAreaGroup) {
         if ($arrAreaGroup['type'] == 'group') {
             $arrAreaTree = array();
             if ($arrAreaGroup['scope'] == $objGroup->getType() || $arrAreaGroup['scope'] == 'global') {
                 $arrAreaTree[] = array($groupId, $objGroup->getType());
                 $groupParsed = true;
             } else {
                 $groupParsed = false;
             }
             foreach ($arrAreas as $navigationId => $arrAreaNavigation) {
                 if ($groupId == $arrAreaNavigation['group_id'] && $arrAreaNavigation['type'] == 'navigation') {
                     if ($arrAreaNavigation['scope'] == $objGroup->getType() || $arrAreaNavigation['scope'] == 'global') {
                         if (!$groupParsed) {
                             $arrAreaTree[] = array($groupId, $objGroup->getType());
                             $groupParsed = true;
                         }
                         $arrAreaTree[] = array($navigationId, $objGroup->getType());
                         $navigationParsed = true;
                     } else {
                         $navigationParsed = false;
                     }
                     foreach ($arrAreas as $functionId => $arrAreaFunction) {
                         if ($navigationId == $arrAreaFunction['group_id'] && $arrAreaFunction['type'] == 'function') {
                             if ($arrAreaFunction['scope'] == $objGroup->getType() || $arrAreaFunction['scope'] == 'global') {
                                 if (!$navigationParsed) {
                                     if (!$groupParsed) {
                                         $arrAreaTree[] = array($groupId, $objGroup->getType());
                                         $groupParsed = true;
                                     }
                                     $arrAreaTree[] = array($navigationId, $objGroup->getType());
                                     $navigationParsed = true;
                                 }
                                 $arrAreaTree[] = array($functionId, $objGroup->getType());
                             }
                         }
                     }
                 }
             }
             if ($groupParsed) {
                 foreach ($arrAreaTree as $arrArea) {
                     $this->_parsePermissionAreas($arrAreas, $arrArea[0], $arrArea[1]);
                 }
                 $this->_objTpl->setGlobalVariable('ACCESS_TAB_NR', $tabNr);
                 $this->_objTpl->setVariable('ACCESS_TAB_NAME', isset($_CORELANG[$arrAreaGroup['name']]) ? htmlentities($_CORELANG[$arrAreaGroup['name']], ENT_QUOTES, CONTREXX_CHARSET) : $arrAreaGroup['name']);
                 $this->_objTpl->parse('access_permission_tab_menu');
                 $this->_objTpl->parse('access_permission_tabs');
                 $tabNr++;
             }
         }
     }
     if ($tabNr > 1) {
         $this->_objTpl->parse('access_permission_tabs_menu');
     } else {
         $this->_objTpl->hideBlock('access_permission_tabs_menu');
     }
     //Display MediaBrowser for selecting webpage
     $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
     $mediaBrowser->setOptions(array('type' => 'button', 'data-cx-mb-views' => 'sitestructure', 'id' => 'media-browser-button', 'style' => 'display: none;'));
     $mediaBrowser->setCallback('SetUrl');
     $this->attachJavaScriptFunction('accessSetWebpage');
     $this->attachJavaScriptFunction('accessSelectAllGroups');
     $this->attachJavaScriptFunction('accessDeselectAllGroups');
     $this->attachJavaScriptFunction('accessAddGroupToList');
     $this->attachJavaScriptFunction('accessRemoveGroupFromList');
     $this->_objTpl->setVariable(array('ACCESS_MEDIA_BROWSER_BUTTON' => $mediaBrowser->getXHtml($_ARRAYLANG['TXT_ACCESS_BROWSE']), 'TXT_ACCESS_GENERAL' => $_ARRAYLANG['TXT_ACCESS_GENERAL'], 'TXT_ACCESS_PERMISSIONS' => $_ARRAYLANG['TXT_ACCESS_PERMISSIONS'], 'TXT_ACCESS_NAME' => $_ARRAYLANG['TXT_ACCESS_NAME'], 'TXT_ACCESS_DESCRIPTION' => $_ARRAYLANG['TXT_ACCESS_DESCRIPTION'], 'TXT_ACCESS_STATUS' => $_ARRAYLANG['TXT_ACCESS_STATUS'], 'TXT_ACCESS_ACTIVE' => $_ARRAYLANG['TXT_ACCESS_ACTIVE'], 'TXT_ACCESS_CANCEL' => $_ARRAYLANG['TXT_ACCESS_CANCEL'], 'TXT_ACCESS_SAVE' => $_ARRAYLANG['TXT_ACCESS_SAVE'], 'TXT_ACCESS_USERS' => $_ARRAYLANG['TXT_ACCESS_USERS'], 'TXT_ACCESS_AVAILABLE_USERS' => $_ARRAYLANG['TXT_ACCESS_AVAILABLE_USERS'], 'TXT_ACCESS_CHECK_ALL' => $_ARRAYLANG['TXT_ACCESS_CHECK_ALL'], 'TXT_ACCESS_UNCHECK_ALL' => $_ARRAYLANG['TXT_ACCESS_UNCHECK_ALL'], 'TXT_ACCESS_ASSOCIATED_USERS' => $_ARRAYLANG['TXT_ACCESS_ASSOCIATED_USERS'], 'TXT_ACCESS_UNPROTECT_PAGE' => $_ARRAYLANG['TXT_ACCESS_UNPROTECT_PAGE'], 'TXT_ACCESS_PROTECT_PAGE' => $_ARRAYLANG['TXT_ACCESS_PROTECT_PAGE'], 'TXT_ACCESS_PROMT_EXEC_WARNING' => $_ARRAYLANG['TXT_ACCESS_PROMT_EXEC_WARNING'], 'TXT_ACCESS_HOMEPAGE' => $_ARRAYLANG['TXT_ACCESS_HOMEPAGE'], 'TXT_ACCESS_HOMEPAGE_DESC' => $_ARRAYLANG['TXT_ACCESS_HOMEPAGE_DESC'], 'TXT_ACCESS_BROWSE' => $_ARRAYLANG['TXT_ACCESS_BROWSE']));
     $this->_objTpl->setVariable(array('ACCESS_GROUP_ID' => $objGroup->getId(), 'ACCESS_GROUP_NAME' => contrexx_raw2xhtml($objGroup->getName()), 'ACCESS_GROUP_DESCRIPTION' => contrexx_raw2xhtml($objGroup->getDescription()), 'ACCESS_GROUP_STATUS' => $objGroup->getActiveStatus() ? 'checked="checked"' : '', 'ACCESS_GROUP_TYPE' => $objGroup->getType(), 'ACCESS_GROUP_HOMEPAGE' => $objGroup->getHomepage(), 'ACCESS_GROUP_NOT_ASSOCIATED_USERS' => $notAssociatedUsers, 'ACCESS_GROUP_ASSOCIATED_USERS' => $associatedUsers, 'ACCESS_PROTECT_PAGE_TXT' => $objGroup->getType() == 'backend' ? $_ARRAYLANG['TXT_ACCESS_CONFIRM_LOCK_PAGE'] : $_ARRAYLANG['TXT_ACCESS_CONFIRM_PROTECT_PAGE'], 'ACCESS_UNPROTECT_PAGE_TXT' => $objGroup->getType() == 'backend' ? $_ARRAYLANG['TXT_ACCESS_CONFIRM_UNLOCK_PAGE'] : $_ARRAYLANG['TXT_ACCESS_CONFIRM_UNPROTECT_PAGE'], 'ACCESS_JAVASCRIPT_FUNCTIONS' => $this->getJavaScriptCode()));
     $this->_objTpl->parse('module_access_group_modify');
 }
 /**
  * This is called by the default ComponentController and does all the repeating work
  * 
  * This loads a template named after current $act and calls parsePage($actTemplate)
  * @todo $this->cx->getTemplate()->setVariable() should not be called here but in Cx class
  * @global array $_ARRAYLANG Language data
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Resolved page
  */
 public function getPage(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $_ARRAYLANG, $subMenuTitle;
     $subMenuTitle = $_ARRAYLANG['TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName())];
     $cmd = array('');
     if (isset($_GET['act'])) {
         $cmd = explode('/', contrexx_input2raw($_GET['act']));
     }
     $actTemplate = new \Cx\Core\Html\Sigma($this->getDirectory(true) . '/View/Template/Backend');
     $filename = $cmd[0] . '.html';
     $testFilename = $cmd[0];
     if (!\Env::get('ClassLoader')->getFilePath($actTemplate->getRoot() . '/' . $filename)) {
         $filename = 'Default.html';
         $testFilename = 'Default';
     }
     foreach ($cmd as $index => $name) {
         if ($index == 0) {
             continue;
         }
         $testFilename .= $name;
         if (\Env::get('ClassLoader')->getFilePath($actTemplate->getRoot() . '/' . $testFilename . '.html')) {
             $filename = $testFilename . '.html';
         } else {
             break;
         }
     }
     $actTemplate->loadTemplateFile($filename);
     // todo: Messages
     $navigation = $this->parseNavigation($cmd);
     $this->parsePage($actTemplate, $cmd);
     $txt = $cmd[0];
     if (empty($txt)) {
         $txt = 'DEFAULT';
     }
     // default css and js
     if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Style/Backend.css'))) {
         \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Backend.css', 1));
     }
     if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Script/Backend.js'))) {
         \JS::registerJS(substr($this->getDirectory(false, true) . '/View/Script/Backend.js', 1));
     }
     // finish
     $actTemplate->setGlobalVariable($_ARRAYLANG);
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($actTemplate);
     $page->setContent($actTemplate->get());
     $cachedRoot = $this->cx->getTemplate()->getRoot();
     $this->cx->getTemplate()->setRoot(\Env::get('cx')->getCodeBaseCorePath() . '/Core/View/Template/Backend');
     $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'ContentMaster.html');
     $this->cx->getTemplate()->setRoot($cachedRoot);
     $this->cx->getTemplate()->setVariable(array('CONTENT_NAVIGATION' => $navigation->get(), 'ADMIN_CONTENT' => $page->getContent(), 'CONTENT_TITLE' => $_ARRAYLANG['TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt)]));
 }
 /**
  *
  * @param mixed $object Array, instance of DataSet, instance of EntityBase, object
  * @param $options is functions array 
  * @throws ViewGeneratorException 
  */
 public function __construct($object, $options = array())
 {
     global $_ARRAYLANG;
     $this->number = static::$increment++;
     try {
         $this->options = $options;
         $entityNS = null;
         if (is_array($object)) {
             $object = new \Cx\Core_Modules\Listing\Model\Entity\DataSet($object);
         }
         \JS::registerCSS(\Env::get('cx')->getCoreFolderName() . '/Html/View/Style/Backend.css');
         if ($object instanceof \Cx\Core_Modules\Listing\Model\Entity\DataSet) {
             // render table if no parameter is set
             $this->object = $object;
             $entityNS = $this->object->getDataType();
         } else {
             if (!is_object($object)) {
                 $entityClassName = $object;
                 $entityRepository = \Env::get('em')->getRepository($entityClassName);
                 $entities = $entityRepository->findAll();
                 if (empty($entities)) {
                     $this->object = new $entityClassName();
                     $entityNS = $entityClassName;
                 } else {
                     $this->object = new \Cx\Core_Modules\Listing\Model\Entity\DataSet($entities);
                     $entityNS = $this->object->getDataType();
                 }
             } else {
                 // render form
                 $this->object = $object;
                 $entityNS = get_class($this->object);
             }
         }
         if ((!isset($_POST['vg_increment_number']) || $_POST['vg_increment_number'] != $this->number) && (!isset($_GET['vg_increment_number']) || $_GET['vg_increment_number'] != $this->number)) {
             $vgIncrementNo = 'empty';
             if (isset($_POST['vg_increment_number'])) {
                 $vgIncrementNo = '#' . $_POST['vg_increment_number'];
             } else {
                 if (isset($_GET['vg_increment_number'])) {
                     $vgIncrementNo = '#' . $_GET['vg_increment_number'];
                 }
             }
             // do not make any changes to entities of other view generator instances!
             \DBG::msg('Omitting changes, my ID is #' . $this->number . ', supplied number was ' . $vgIncrementNo);
             return;
         }
         /** 
          *  postSave event
          *  execute save if entry is a doctrine entity (or execute callback if specified in configuration)
          */
         $add = !empty($_GET['add']) ? contrexx_input2raw($_GET['add']) : null;
         if (!empty($add) && (!empty($this->options['functions']['add']) && $this->options['functions']['add'] != false) || !empty($this->options['functions']['allowAdd']) && $this->options['functions']['allowAdd'] != false) {
             $this->renderFormForEntry(null);
             $form = $this->formGenerator;
             if ($form === false) {
                 // cannot save, no such entry
                 \Message::add('Cannot save, no such entry', \Message::CLASS_ERROR);
                 return;
             }
             if (!$form->isValid() || isset($this->options['validate']) && !$this->options['validate']($form)) {
                 // data validation failed, stay in add view
                 \Message::add('Cannot save, validation failed', \Message::CLASS_ERROR);
                 return;
             }
             if (!empty($_POST)) {
                 $post = $_POST;
                 unset($post['csrf']);
                 $blankPost = true;
                 if (!empty($post)) {
                     foreach ($post as $value) {
                         if ($value) {
                             $blankPost = false;
                         }
                     }
                 }
                 if ($blankPost) {
                     \Message::add('Cannot save, You should fill any one field!', \Message::CLASS_ERROR);
                     return;
                 }
                 $entityObject = \Env::get('em')->getClassMetadata($entityNS);
                 $primaryKeyName = $entityObject->getSingleIdentifierFieldName();
                 //get primary key name
                 $entityColumnNames = $entityObject->getColumnNames();
                 //get all field names
                 // create new entity without calling the constructor
                 // TODO: this might break certain entities!
                 $entityObj = $entityObject->newInstance();
                 foreach ($entityColumnNames as $column) {
                     $field = $entityObject->getFieldName($column);
                     if (isset($this->options['fields']) && isset($this->options['fields'][$field]) && isset($this->options['fields'][$field]['storecallback']) && is_callable($this->options['fields'][$field]['storecallback'])) {
                         $storecallback = $this->options['fields'][$field]['storecallback'];
                         $postedValue = null;
                         if (isset($_POST['field'])) {
                             $postedValue = contrexx_input2raw($_POST[$field]);
                         }
                         $_POST[$field] = $storecallback($postedValue);
                     }
                     if (isset($_POST[$field]) && $field != $primaryKeyName) {
                         $fieldDefinition = $entityObject->getFieldMapping($field);
                         if ($fieldDefinition['type'] == 'datetime') {
                             $newValue = new \DateTime($_POST[$field]);
                         } elseif ($fieldDefinition['type'] == 'array') {
                             $newValue = unserialize($_POST[$field]);
                             // verify that the value is actually an array -> prevent to store other php data
                             if (!is_array($newValue)) {
                                 $newValue = array();
                             }
                         } else {
                             $newValue = contrexx_input2raw($_POST[$field]);
                         }
                         $entityObj->{'set' . preg_replace('/_([a-z])/', '\\1', ucfirst($field))}($newValue);
                     }
                 }
                 // store single-valued-associations
                 $associationMappings = \Env::get('em')->getClassMetadata($entityNS)->getAssociationMappings();
                 $classMethods = get_class_methods($entityObj);
                 foreach ($associationMappings as $field => $associationMapping) {
                     if (!empty($_POST[$field]) && \Env::get('em')->getClassMetadata($entityNS)->isSingleValuedAssociation($field) && in_array('set' . ucfirst($field), $classMethods)) {
                         $col = $associationMapping['joinColumns'][0]['referencedColumnName'];
                         $association = \Env::get('em')->getRepository($associationMapping['targetEntity'])->findOneBy(array($col => $_POST[$field]));
                         $entityObj->{'set' . ucfirst($field)}($association);
                     }
                 }
                 if ($entityObj instanceof \Cx\Core\Model\Model\Entity\YamlEntity) {
                     $entityRepository = \Env::get('em')->getRepository($entityNS);
                     $entityRepository->add($entityObj);
                     $entityRepository->flush();
                 } else {
                     if (!$entityObj instanceof \Cx\Model\Base\EntityBase) {
                         \DBG::msg('Unkown entity model ' . get_class($entityObj) . '! Trying to persist using entity manager...');
                     }
                     \Env::get('em')->persist($entityObj);
                     \Env::get('em')->flush();
                 }
                 \Message::add($_ARRAYLANG['TXT_CORE_RECORD_ADDED_SUCCESSFUL']);
                 $actionUrl = clone \Env::get('cx')->getRequest()->getUrl();
                 $actionUrl->setParam('add', null);
                 \Cx\Core\Csrf\Controller\Csrf::redirect($actionUrl);
             }
         }
         /** 
          *  postEdit event
          *  execute edit if entry is a doctrine entity (or execute callback if specified in configuration)
          */
         if ($this->isInEditMode() && (!empty($this->options['functions']['edit']) && $this->options['functions']['edit'] != false || !empty($this->options['functions']['allowEdit']) && $this->options['functions']['allowEdit'] != false)) {
             $entityId = contrexx_input2raw($this->isInEditMode());
             // render form for editid
             $this->renderFormForEntry($entityId);
             $form = $this->formGenerator;
             if ($form === false) {
                 // cannot save, no such entry
                 \Message::add('Cannot save, no such entry', \Message::CLASS_ERROR);
                 return;
             }
             if (!$form->isValid() || isset($this->options['validate']) && !$this->options['validate']($form)) {
                 // data validation failed, stay in edit view
                 \Message::add('Cannot save, validation failed', \Message::CLASS_ERROR);
                 return;
             }
             $entityObject = array();
             if ($this->object->entryExists($entityId)) {
                 $entityObject = $this->object->getEntry($entityId);
             }
             if (empty($entityObject)) {
                 \Message::add('Cannot save, Invalid entry', \Message::CLASS_ERROR);
                 return;
             }
             $updateArray = array();
             $entityObj = \Env::get('em')->getClassMetadata($entityNS);
             $primaryKeyName = $entityObj->getSingleIdentifierFieldName();
             //get primary key name
             $associationMappings = \Env::get('em')->getClassMetadata($entityNS)->getAssociationMappings();
             $classMethods = get_class_methods($entityObj->newInstance());
             foreach ($entityObject as $name => $value) {
                 if (!isset($_POST[$name])) {
                     continue;
                 }
                 $methodName = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
                 if (\Env::get('em')->getClassMetadata($entityNS)->isSingleValuedAssociation($name) && in_array($methodName, $classMethods)) {
                     // store single-valued-associations
                     $col = $associationMappings[$name]['joinColumns'][0]['referencedColumnName'];
                     $association = \Env::get('em')->getRepository($associationMappings[$name]['targetEntity'])->findOneBy(array($col => $_POST[$name]));
                     $updateArray[$methodName] = $association;
                 } elseif ($_POST[$name] != $value && in_array($methodName, $classMethods)) {
                     $fieldDefinition = $entityObj->getFieldMapping($name);
                     if (isset($this->options['fields']) && isset($this->options['fields'][$name]) && isset($this->options['fields'][$name]['storecallback']) && is_callable($this->options['fields'][$name]['storecallback'])) {
                         $storecallback = $this->options['fields'][$name]['storecallback'];
                         $newValue = $storecallback(contrexx_input2raw($_POST[$name]));
                     } else {
                         if ($fieldDefinition['type'] == 'datetime') {
                             if (empty($_POST[$name])) {
                                 $newValue = null;
                             } else {
                                 $newValue = new \DateTime($_POST[$name]);
                             }
                         } elseif ($fieldDefinition['type'] == 'array') {
                             $newValue = unserialize($_POST[$name]);
                             // verify that the value is actually an array -> prevent to store other php data
                             if (!is_array($newValue)) {
                                 $newValue = array();
                             }
                         } else {
                             $newValue = contrexx_input2raw($_POST[$name]);
                         }
                     }
                     $updateArray[$methodName] = $newValue;
                 }
             }
             $id = $entityObject[$primaryKeyName];
             //get primary key value
             if (!empty($updateArray) && !empty($id)) {
                 $entityObj = \Env::get('em')->getRepository($entityNS)->find($id);
                 if (!empty($entityObj)) {
                     foreach ($updateArray as $key => $value) {
                         $entityObj->{$key}($value);
                     }
                     if ($entityObj instanceof \Cx\Core\Model\Model\Entity\YamlEntity) {
                         \Env::get('em')->getRepository($entityNS)->flush();
                     } else {
                         \Env::get('em')->flush();
                     }
                     \Message::add($_ARRAYLANG['TXT_CORE_RECORD_UPDATED_SUCCESSFUL']);
                 } else {
                     \Message::add('Cannot save, Invalid argument!', \Message::CLASS_ERROR);
                 }
             }
             $actionUrl = clone \Env::get('cx')->getRequest()->getUrl();
             $actionUrl->setParam('editid', null);
             \Cx\Core\Csrf\Controller\Csrf::redirect($actionUrl);
         }
         /**
          * trigger pre- and postRemove event
          * execute remove if entry is a doctrine entity (or execute callback if specified in configuration)
          */
         $deleteId = !empty($_GET['deleteid']) ? contrexx_input2raw($_GET['deleteid']) : '';
         if ($deleteId != '' && (!empty($this->options['functions']['delete']) && $this->options['functions']['delete'] != false || !empty($this->options['functions']['allowDelete']) && $this->options['functions']['allowDelete'] != false)) {
             $entityObject = $this->object->getEntry($deleteId);
             if (empty($entityObject)) {
                 \Message::add('Cannot save, Invalid entry', \Message::CLASS_ERROR);
                 return;
             }
             $entityObj = \Env::get('em')->getClassMetadata($entityNS);
             $primaryKeyName = $entityObj->getSingleIdentifierFieldName();
             //get primary key name
             $id = $entityObject[$primaryKeyName];
             //get primary key value
             if (!empty($id)) {
                 $entityObj = \Env::get('em')->getRepository($entityNS)->find($id);
                 if (!empty($entityObj)) {
                     if ($entityObj instanceof \Cx\Core\Model\Model\Entity\YamlEntity) {
                         $ymlRepo = \Env::get('em')->getRepository($entityNS);
                         $ymlRepo->remove($entityObj);
                         $ymlRepo->flush();
                     } else {
                         \Env::get('em')->remove($entityObj);
                         \Env::get('em')->flush();
                     }
                     \Message::add($_ARRAYLANG['TXT_CORE_RECORD_DELETED_SUCCESSFUL']);
                 }
             }
             $actionUrl = clone \Env::get('cx')->getRequest()->getUrl();
             $actionUrl->setParam('deleteid', null);
             \Cx\Core\Csrf\Controller\Csrf::redirect($actionUrl);
         }
     } catch (\Exception $e) {
         \Message::add($e->getMessage());
         return;
     }
 }