Exemplo n.º 1
0
 public function setLangDir($langDir, $page = null)
 {
     $this->langDir = $langDir;
     if ($page) {
         $langId = \FWLanguage::getLanguageIdByCode($langDir);
         $page = $page->getNode()->getPage($langId);
         if ($page) {
             $this->setPath(substr($page->getPath(), 1));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Returns the preview page built from the session page array.
  * @return Cx\Core\ContentManager\Model\Entity\Page $page
  */
 private function getPreviewPage()
 {
     $data = $this->sessionPage;
     $page = $this->pageRepo->findOneById($data['pageId']);
     if (!$page) {
         $page = new \Cx\Core\ContentManager\Model\Entity\Page();
         $node = new \Cx\Core\ContentManager\Model\Entity\Node();
         $node->setParent($this->nodeRepo->getRoot());
         $node->setLvl(1);
         $this->nodeRepo->getRoot()->addChildren($node);
         $node->addPage($page);
         $page->setNode($node);
         $this->pageRepo->addVirtualPage($page);
     }
     unset($data['pageId']);
     $page->setLang(\FWLanguage::getLanguageIdByCode($data['lang']));
     unset($data['lang']);
     $page->updateFromArray($data);
     $page->setUpdatedAtToNow();
     $page->setActive(true);
     $page->setVirtual(true);
     $page->validate();
     return $page;
 }
Exemplo n.º 3
0
 /**
  * Save the block content
  *
  * @param array $params all given params from http request
  * @throws NoPermissionException
  * @throws NotEnoughArgumentsException
  * @throws BlockCouldNotBeSavedException
  * @return boolean true if everything finished with success
  */
 public function saveBlockContent($params)
 {
     global $_CORELANG, $objDatabase;
     // security check
     if (!\FWUser::getFWUserObject()->objUser->login() || !\Permission::checkAccess(76, 'static', true)) {
         throw new NoPermissionException($_CORELANG['TXT_ACCESS_DENIED_DESCRIPTION']);
     }
     // check arguments
     if (empty($params['get']['block']) || empty($params['get']['lang'])) {
         throw new NotEnoughArgumentsException('not enough arguments');
     }
     // get language and block id
     $id = intval($params['get']['block']);
     $lang = \FWLanguage::getLanguageIdByCode($params['get']['lang']);
     if (!$lang) {
         $lang = FRONTEND_LANG_ID;
     }
     $content = $params['post']['content'];
     // query to update content in database
     $query = "UPDATE `" . DBPREFIX . "module_block_rel_lang_content`\n                      SET content = '" . \contrexx_input2db($content) . "'\n                  WHERE\n                      block_id = " . $id . " AND lang_id = " . $lang;
     $result = $objDatabase->Execute($query);
     // error handling
     if ($result === false) {
         throw new BlockCouldNotBeSavedException('block could not be saved');
     }
     \LinkGenerator::parseTemplate($content);
     $ls = new \LinkSanitizer(ASCMS_PATH_OFFSET . \Env::get('virtualLanguageDirectory') . '/', $content);
     $this->messages[] = $_CORELANG['TXT_CORE_SAVED_BLOCK'];
     return array('content' => $ls->replace());
 }
Exemplo n.º 4
0
 /**
  * Import Users from a CSV file
  *
  * Sets up common User and Profile fields as well as
  * Newsletter list relations.
  * Fields and their mapping:
  *  Anrede    -> Titel
  *  Vorname
  *  Name
  *  eMail
  *  Firma
  *  Strasse    -> Zusammen mit Hausnummer in Adresse
  *  Hausnummer    -> Zusammen mit Strasse in Adresse
  *  PLZ
  *  Ort
  *  Land
  *  Bundesland    -> Evtl in Ort?
  *  Tel.-Vorwahl    -> Zusammen mit Tel.-Nummer in phone_office
  *  Tel.-Nummer        -> Zusammen mit Tel.-Vorwahl in phone_office
  *  Fax-Vorwahl        -> Zusammen mit Fax.-Nummer in phone_fax
  *  Fax-Nummer        -> Zusammen mit Fax.-Vorwahl in phone_fax
  *  Mobil-Vorwahl    -> Zusammen mit Mobil-Nummer in phone_mobile
  *  Mobil-Nummer    -> Zusammen mit Mobil-Vorwahl in phone_mobile
  *  P1    -> Interessen: Newsletter Listen, kommagetrennt
  *      -> Nicht vorhandene Listen werden angelegt
  *  P2    -> Antwort: ?
  *  P3    -> ?
  *  P4    -> Titel: ?
  *  P5    -> ?
  *  Ursprungsformular    -> ?
  *  Permission    -> ?
  *  Ausgetragen    -> Wenn true, alle Listenzuordnungen entfernen, sonst fehlende anlegen
  *  Anzahl Hard-Bounces    -> Nicht vorhanden?
  *  Status    -> Bedeutung?
  *  Sprache    -> Wird die verwendet?
  *  ID    -> Bedeutung?
  *  Eintragungsdatum    -> regdate
  *  Aenderungsdatum    -> ? (Nur regdate)
  *  Austragungsdatum    -> ? (Nur regdate)
  * @param   string    $file_name    The CSV file name
  */
 static function import_csv($file_name)
 {
     global $_ARRAYLANG;
     \Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/importexport/lib/csv.class.php');
     //DBG::activate(DBG_ADODB_ERROR|DBG_LOG_FIREPHP|DBG_PHP);
     $objUser = \FWUser::getFWUserObject()->objUser;
     $objCsv = new \CsvLib();
     $arrCsv = $objCsv->parse($file_name);
     //        $arrFields = $arrCsv['fieldnames'];
     $arrUsers = $arrCsv['data'];
     //DBG::log("Found ".count($arrUsers)." Users in the CSV file");
     foreach ($arrUsers as $arrUser) {
         //echo(var_export($arrUser, true)."<br />");// var_export($objUser, true)."<hr />"
         $email = $arrUser['3'];
         //DBG::log("Found e-mail $email");
         if (!\FWValidator::isEmail($email)) {
             self::$arrStatusMsg['error'][] = sprintf($_ARRAYLANG['TXT_ACCESS_IMPORT_MESSAGE_TEMPLATE'], $email, $_ARRAYLANG['TXT_ACCESS_IMPORT_ERROR_INVALID_EMAIL']);
             continue;
         }
         // TODO: I suppose that the imported file is ISO-8859-1 or so
         $title = utf8_encode($arrUser[0]);
         $gender = preg_match('//', $title) ? 'gender_male' : 'gender_female';
         $firstname = utf8_encode($arrUser[1]);
         $lastname = utf8_encode($arrUser[2]);
         $company = utf8_encode($arrUser[4]);
         $address = utf8_encode($arrUser[5]) . ' ' . utf8_encode($arrUser[6]);
         $zip = utf8_encode($arrUser[7]);
         $city = utf8_encode($arrUser[8]);
         $country = utf8_encode($arrUser[9]);
         $state = utf8_encode($arrUser[10]);
         if ($state) {
             $city .= ", {$state}";
         }
         $phone_office = utf8_encode($arrUser[11]) . ' ' . utf8_encode($arrUser[12]);
         $phone_fax = utf8_encode($arrUser[13]) . ' ' . utf8_encode($arrUser[14]);
         $phone_mobile = utf8_encode($arrUser[15]) . ' ' . utf8_encode($arrUser[16]);
         $p1_lists = utf8_encode($arrUser[17]);
         $unsubscribed = utf8_encode($arrUser[24]);
         $language = utf8_encode($arrUser[27]);
         // These are all unused for the time being
         //                $p2_answer = $arrUser[18];
         //                $p3 = $arrUser[19];
         //                $p4_title = $arrUser[20];
         //                $p5 = $arrUser[21];
         //                $source = $arrUser[22];
         //                $permission = $arrUser[23];
         //                $bounces = $arrUser[25];
         //                $status = $arrUser[26];
         //                $id = $arrUser[28];
         //                $date_subscribed = $arrUser[29];
         //                $date_changed = $arrUser[30];
         //                $date_unsubscribe = $arrUser[31];
         $objUser = new \User();
         $objUser = $objUser->getUsers(array('email' => array($email)));
         $new_user = false;
         if (!$objUser) {
             $new_user = true;
             $objUser = new \User();
             $objUser->setUsername(\User::makeUsername($lastname, $firstname));
             $objUser->setPassword(\User::makePassword());
             $objUser->setEmail($email);
         }
         // TODO: Make new Users active or inactive?
         //            $objUser->setActiveStatus(0);
         //            $objUser->setAdminStatus(0);
         $lang_id = \FWLanguage::getLanguageIdByCode($language);
         $objUser->setFrontendLanguage($lang_id);
         $objUser->setBackendLanguage($lang_id);
         $objUser->setProfile(array('gender' => array($gender), 'title' => array($title), 'firstname' => array($firstname), 'lastname' => array($lastname), 'company' => array($company), 'address' => array($address), 'city' => array($city), 'zip' => array($zip), 'country' => array($country), 'phone_office' => array($phone_office), 'phone_mobile' => array($phone_mobile), 'phone_fax' => array($phone_fax)));
         $arrLists = preg_split('/\\s*,\\s*/', $p1_lists, null, PREG_SPLIT_NO_EMPTY);
         $arrListId = array();
         if (preg_match('/false/i', $unsubscribed)) {
             // User has not unsubscribed (yet), collect the List IDs
             foreach ($arrLists as $list_name) {
                 $list_id = \Cx\Modules\Newsletter\Controller\NewsletterLib::getListIdByName($list_name);
                 //DBG::log("List '$list_name' => ID $list_id");
                 if (!$list_id) {
                     // TODO: Shall I do this?
                     $list_id = \Cx\Modules\Newsletter\Controller\NewsletterLib::_addList(addslashes($list_name));
                     self::$arrStatusMsg['ok'][] = sprintf($_ARRAYLANG['TXT_ACCESS_IMPORT_MESSAGE_TEMPLATE'], $list_name, $_ARRAYLANG['TXT_ACCESS_IMPORT_SUCCESS_LIST_CREATED']);
                 }
                 $arrListId[$list_id] = $list_id;
             }
         }
         $objUser->setNewsletterCategories($arrListId);
         if ($objUser->store()) {
             self::$arrStatusMsg['ok'][] = sprintf($_ARRAYLANG['TXT_ACCESS_IMPORT_MESSAGE_TEMPLATE'], $email, $new_user ? $_ARRAYLANG['TXT_ACCESS_IMPORT_SUCCESS_USER_CREATED'] : $_ARRAYLANG['TXT_ACCESS_IMPORT_SUCCESS_USER_UPDATED']);
         } else {
             self::$arrStatusMsg['error'][] = sprintf($_ARRAYLANG['TXT_ACCESS_IMPORT_MESSAGE_TEMPLATE'], $email, $_ARRAYLANG['TXT_ACCESS_IMPORT_ERROR_CREATING_USER']);
         }
     }
 }
Exemplo n.º 5
0
 /**
  * @todo We could use this in a much more efficient way. There's no need to call this method twice!
  * @todo Remove parameter $search_mode
  * @todo Return a single page or null
  * @param type $path
  * @param type $search_mode
  * @return boolean 
  */
 public function resolve($path, $search_mode)
 {
     // remove slash at the beginning
     if (substr($path, 0, 1) == '/') {
         $path = substr($path, 1);
     }
     $parts = explode('/', $path);
     $lang = \FWLanguage::getLanguageIdByCode($parts[0]);
     // let's see if path starts with a language (which it should)
     if ($lang !== false) {
         if ($search_mode != self::SEARCH_MODE_PAGES_ONLY) {
             return false;
         }
         unset($parts[0]);
     } else {
         if ($search_mode != self::SEARCH_MODE_ALIAS_ONLY) {
             return false;
         }
         // it's an alias we try to resolve
         // search for alias pages with matching slug
         $pages = $this->findBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS, 'slug' => $parts[0]), true);
         $page = null;
         if (count($pages) == 1) {
             $page = $pages[0];
         } else {
             if (count($pages) != 0) {
                 foreach ($pages as $currentPage) {
                     if ($currentPage->getSlug() == $parts[0]) {
                         $page = $currentPage;
                         break;
                     }
                 }
             }
         }
         if (!$page) {
             return false;
         }
         return array('matchedPath' => substr($page->getPath(), 1) . '/', 'unmatchedPath' => implode('/', $parts), 'treePointer' => array('__data' => array('lang' => array($lang), 'page' => $page, 'node' => $page->getNode())));
         return false;
     }
     $nodeRepo = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
     $page = null;
     $node = $nodeRepo->getRoot();
     if (!$node) {
         throw new PageRepositoryException('No pages found!');
     }
     $q = $this->em->createQuery("SELECT n FROM Cx\\Core\\ContentManager\\Model\\Entity\\Node n JOIN n.pages p WHERE p.type != 'alias' AND n.parent = ?1 AND p.lang = ?2 AND p.slug = ?3");
     foreach ($parts as $index => $slug) {
         if (empty($slug)) {
             break;
         }
         $q->setParameter(1, $node);
         $q->setParameter(2, $lang);
         $q->setParameter(3, $slug);
         try {
             $child = $q->getSingleResult();
             $node = $child;
             $page = $node->getPage($lang);
             unset($parts[$index]);
         } catch (\Doctrine\ORM\NoResultException $e) {
             break;
         }
     }
     if (!$page) {
         // no matching page
         return false;
     }
     return array('matchedPath' => substr($page->getPath(), 1) . '/', 'unmatchedPath' => implode('/', $parts), 'treePointer' => array('__data' => array('lang' => array($lang), 'page' => $page, 'node' => $page->getNode())));
 }
Exemplo n.º 6
0
 /**
  * Returns the selected User Frontend Language id
  *
  * Backend use only!
  * @return   string $this->userFrontendLangId
  */
 function getUserFrontendLangId()
 {
     // Mind: Changed from $_POST to $_REQUEST, so it can be changed by
     // clicking a link (used in the Shop, and for MailTemplates)
     if (!empty($_REQUEST['userFrontendLangId'])) {
         if (preg_match('/[0-9]/', $_REQUEST['userFrontendLangId'])) {
             $id = intval($_REQUEST['userFrontendLangId']);
         } else {
             $id = FWLanguage::getLanguageIdByCode($_REQUEST['userFrontendLangId']);
         }
     } elseif (!empty($_COOKIE['userFrontendLangId'])) {
         $id = FWLanguage::getLanguageIdByCode($_COOKIE['userFrontendLangId']);
     } elseif (!empty($_SESSION['userFrontendLangId'])) {
         $id = intval($_SESSION['userFrontendLangId']);
     } else {
         $id = $this->defaultFrontendLangId;
     }
     if (empty($this->arrLang[$id]['frontend'])) {
         $id = $this->defaultFrontendLangId;
     }
     $this->userFrontendLangId = $id;
     $_SESSION['userFrontendLangId'] = $id;
     setcookie("userFrontendLangId", "", time() - 3600);
     return $this->userFrontendLangId;
 }
Exemplo n.º 7
0
 /**
  * Returns the array representation of a fallback page
  * @param   \Cx\Core\ContentManager\Model\Entity\Node $node Node to get the page of
  * @param   string  $lang  Language code to get the fallback of
  * @return  array   Array  representing a fallback page
  */
 private function getFallbackPageArray($node, $lang)
 {
     $page = null;
     foreach ($node->getPages() as $page) {
         if ($page->getLang() == \FWLanguage::getLanguageIdByCode($this->fallbacks[$lang])) {
             break;
         }
     }
     if (!$page) {
         throw new \Cx\Core\ContentManager\Model\Entity\NodeException('Node (id ' . $node->getId() . ') has no pages.');
     }
     // Access Permissions
     $pg = \Env::get('pageguard');
     $accessData = array();
     $accessData['frontend'] = array('groups' => $pg->getGroups(true), 'assignedGroups' => $pg->getAssignedGroupIds($page, true));
     $accessData['backend'] = array('groups' => $pg->getGroups(false), 'assignedGroups' => $pg->getAssignedGroupIds($page, false));
     $pageArray = array('id' => 0, 'lang' => $lang, 'node' => $node->getId(), 'type' => $this->fallbacks[$lang] ? 'fallback' : 'content', 'name' => $page->getTitle(), 'title' => $page->getContentTitle(), 'metatitle' => $page->getMetatitle(), 'metadesc' => $page->getMetadesc(), 'metakeys' => $page->getMetakeys(), 'metarobots' => $page->getMetarobots(), 'frontend_protection' => $page->isFrontendProtected(), 'backend_protection' => $page->isBackendProtected(), 'accessData' => $accessData, 'slug' => $page->getSlug(), 'sourceMode' => false, 'sourceMode' => $page->getSourceMode());
     return $pageArray;
 }
Exemplo n.º 8
0
 * Search script
 *
 * This script is standalone because otherwise it would be too slow.
 * @author      Stefan Heinemann <*****@*****.**>
 * @copyright   CLOUDREXX Development Team <*****@*****.**>
 * @package     cloudrexx
 * @subpackage  module_knowledge
 */
/**
 * Search script
 *
 * This script is standalone because otherwise it would be too slow.
 * @author      Stefan Heinemann <*****@*****.**>
 * @copyright   CLOUDREXX Development Team <*****@*****.**>
 * @package     cloudrexx
 * @subpackage  module_knowledge
 */
global $objDatabase;
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/core/Core/init.php';
$cx = init('minimal');
$objDatabase = $cx->getDb()->getAdoDb();
\Env::get('ClassLoader')->loadFile(ASCMS_MODULE_PATH . '/Knowledge/Controller/DatabaseError.class.php');
//require_once '../../lib/CSRF.php';
// Temporary fix until all GET operation requests will be replaced by POSTs
//CSRF::setFrontendMode();
if (!defined('FRONTEND_LANG_ID') && !empty($_GET['lang'])) {
    define('FRONTEND_LANG_ID', \FWLanguage::getLanguageIdByCode($_GET['lang']));
}
$search = new \Cx\Modules\Knowledge\Controller\Search();
$search->performSearch();
die;