/** * Iterate through $config_fields and set the matched values from $item. * @global $sf_factory API-Factory to instanciate the editors * @param array $config_fields Configuration of all fields as array * @param SF_INTERFACE_Item $item Item that uses the interface * @param boolean $form_was_send * @return array Returns the given $config_fields with added values. */ protected function _assignValuesToConfigFields($config_fields, $item, $form_was_send = FALSE) { global $sf_factory; //get form vals foreach ($config_fields as $k => $v) { //show if type exists if (!array_key_exists('type', $v)) { continue; } //filter type switch ($v['type']) { case 'headline': case 'info': continue; break; case 'hidden': case 'text': case 'textarea': case 'cmslink': case 'directorychooser': $item_val = $item === null ? '' : $this->req->req($k, $item->getField($k)); if ($item_val == '') { continue; } $config_fields[$k]['val'] = $item_val; break; case 'infofield': if ($v['format'] == '') { $item_val = $item === null ? '' : $this->req->req($k, $item->getField($k)); } else { if ($item !== null && $item->getField($k) != '') { // format created and lastmodified switch ($k) { case 'created': $date = $item->getCreatedDate(); $time = $item->getCreatedTime(); $author = $item->getCreatedAuthor('', 'username'); break; case 'lastmodified': $date = $item->getLastmodifiedDate(); $time = $item->getLastmodifiedTime(); $author = $item->getLastmodifiedAuthor('', 'username'); break; default: $author = $time = $date = $this->req->req($k, $item->getField($k)); break; } $item_val = str_replace('{date}', $date, $v['format']); $item_val = str_replace('{time}', $time, $item_val); $item_val = str_replace('{author}', $author, $item_val); } } if ($item_val == '') { continue; } $config_fields[$k]['val'] = $item_val; break; // TODO This works just with one checkbox per line at the moment. Extend it the assign behavior to use multiple checkboxes. Remove this todo afterwards. // Note: Multiple checkboxes are already implemented in the API/VIEWS/Form.php and form_elements.tpl // TODO This works just with one checkbox per line at the moment. Extend it the assign behavior to use multiple checkboxes. Remove this todo afterwards. // Note: Multiple checkboxes are already implemented in the API/VIEWS/Form.php and form_elements.tpl case 'checkbox': if ($form_was_send == TRUE && $this->req->req($k, FALSE) !== FALSE) { $config_fields[$k]['checked'] = array_key_exists($this->req->req($k), $config_fields[$k]['val']); } else { if ($item !== null && array_key_exists($item->getField($k), $config_fields[$k]['val']) == TRUE) { $config_fields[$k]['checked'] = TRUE; } else { $config_fields[$k]['checked'] = FALSE; } } break; case 'radio': if ($form_was_send && $this->req->req($k, FALSE) !== FALSE) { $config_fields[$k]['checked'] = $this->req->req($k) == $config_fields[$k]['val']; } else { if ($item !== null && $item->getField($k) == $config_fields[$k]['val']) { $config_fields[$k]['checked'] = TRUE; } else { $config_fields[$k]['checked'] = FALSE; } } break; // TODO This works just with single selects at the moment. Extend it the assign behavior to use multiple selectes. Remove this todo afterwards. // Note: Multiple selects are already implemented in the API/VIEWS/Form.php and form_elements.tpl // TODO This works just with single selects at the moment. Extend it the assign behavior to use multiple selectes. Remove this todo afterwards. // Note: Multiple selects are already implemented in the API/VIEWS/Form.php and form_elements.tpl case 'select': $item_val = $item === null ? '' : $this->req->req($k, $item->getField($k)); if ($item_val == '') { continue; } $config_fields[$k]['selected'] = $item_val; break; case 'rightspanel': $config = array_key_exists('panel_config', $config_fields[$k]) ? $config_fields[$k]['panel_config'] : array(); // formname is set in function _buildFormFromConfigFields() $config['formname'] = 'edit'; $view = array_key_exists('panel_view', $config_fields[$k]) ? $config_fields[$k]['panel_view'] : 'text'; $panel_arr = $this->cfg->perm()->get_right_panel($item->getObjectPermType(), $item->getId(), $config, $view); // show panel only if generated and editing the item if (empty($panel_arr) == FALSE && $item->getId() > 0) { $config_fields[$k]['panel'] = implode('', $panel_arr); } else { $config_fields[$k]['panel'] = null; } unset($config, $view, $panel_arr); break; case 'editor': // create editor if exists, store instance and set item if allowed if ($item !== null && array_key_exists('editor_type', $config_fields[$k]) && $config_fields[$k]['editor_instance'] == null && $sf_factory->classExists('VIEW', $config_fields[$k]['editor_type'])) { $config_fields[$k]['editor_instance'] = sf_api('VIEW', $config_fields[$k]['editor_type']); // the editor must be an item editor (that deals only with one item) if ($config_fields[$k]['editor_instance'] instanceof SF_INTERFACE_ItemEditor) { $config_fields[$k]['editor_config'] = !array_key_exists('editor_config', $config_fields[$k]) ? array() : $config_fields[$k]['editor_config']; $config_fields[$k]['editor_instance']->setEditorName($k); $config_fields[$k]['editor_instance']->setConfig($config_fields[$k]['editor_config']); if ($config_fields[$k]['editor_instance']->isItemAllowed($item)) { $config_fields[$k]['editor_instance']->setItem($item); } } else { $config_fields[$k]['editor_instance'] = null; } } else { $config_fields[$k]['editor_instance'] = null; } break; } } return $config_fields; }
/** * Frontend Controller Class * @return void */ public function index() { $cms_path = $this->controller_cfg['cms_path']; $cms_db = $GLOBALS['cms_db']; $cfg_cms = $GLOBALS['cfg_cms']; $cfg_client = $GLOBALS['cfg_client']; //vars from project config $idcatside = FALSE; $idcat = FALSE; $lang = FALSE; $client = FALSE; $sf_frontend_output = sf_api('LIB', 'FrontendOutput'); //set cfg db names $this->cfg->set('db', $cms_db); //lookup for backend view $view = $this->req->req('view'); //get backend or frontend session $sid = FALSE; $sefrengo = FALSE; list($sid, $sefrengo) = $this->ft->getSessionIdsFromRequest($view); //generate frontend/ backend boolean vars $is_onpage = TRUE; $is_frontend = $is_backend = $is_backend_preview = $is_backend_edit = FALSE; list($is_frontend, $is_backend, $is_backend_preview, $is_backend_edit) = $this->ft->getViewModes($view, $sefrengo); $this->_assignGlobals('is_frontend', $is_frontend); $this->_assignGlobals('is_backend', $is_backend); $this->cfg->setVal('env', 'sid', $sid); $this->cfg->setVal('env', 'sefrengo', $sefrengo); $this->cfg->setVal('env', 'is_onpage', $is_onpage); $this->cfg->setVal('env', 'is_frontend', $is_frontend); $this->cfg->setVal('env', 'is_backend', $is_backend); $this->cfg->setVal('env', 'is_backend_preview', $is_backend_preview); $this->cfg->setVal('env', 'is_backend_edit', $is_backend_edit); //init log $cms_log = $this->_initAndGetLog(); //init db $db = new DB_cms(); $this->_assignGlobals('db', $db); $this->ft->setDb($db); $this->ft->setDbNames($cms_db); //$val_ct = new values_ct(); //$this->_assignGlobals('val_ct', $val_ct); //$cfg_cms = array_merge($cfg_cms, $val_ct->get_cfg() ); $valcol = sf_api('MODEL', 'ValueSqlCollection'); $valcol->getByGroup('cfg'); $cfg_cms = array_merge($cfg_cms, $valcol->getAssocKeyArray()); $valcol->getByGroup('lang'); $cms_lang = $valcol->getAssocKeyArray(); $this->_assignGlobals('cfg_cms', $cfg_cms); $this->cfg->set('cms', $cfg_cms); $this->cfg->setVal('env', 'path_backend_http', $this->cfg->cms('path_base_http') . $this->cfg->cms('path_backend_rel')); $this->cfg->setVal('env', 'path_backend', $this->cfg->cms('path_base') . $this->cfg->cms('path_backend_rel')); $client = (int) $GLOBALS['client']; //idclient from projectconfig //$cfg_client = $val_ct->get_by_group('cfg_client', $client); $valcol->setIdclient($client); $valcol->getByGroup('cfg_client'); $cfg_client = $valcol->getAssocKeyArray(); $cfg_client['path_http'] = str_replace(array('{%http_host}', '{%request_uri}'), array($_SERVER['HTTP_HOST'], $_SERVER['QUERY_STRING']), $cfg_client['path_http']); $cfg_client['path_http_edit'] = str_replace(array('{%http_host}', '{%request_uri}'), array($_SERVER['HTTP_HOST'], $_SERVER['QUERY_STRING']), $cfg_client['path_http_edit']); unset($valcol); $this->_assignGlobals('cfg_client', $cfg_client); $this->cfg->set('client', $cfg_client); $sf_path_base = $this->cfg->cms('path_base'); $sf_path_http_frontend = $is_frontend ? $this->cfg->client('path_http') : $this->cfg->client('path_http_edit'); $this->cfg->setVal('env', 'path_frontend_http', $sf_path_http_frontend . $this->cfg->client('path_rel')); $this->cfg->setVal('env', 'path_frontend', $sf_path_base . $this->cfg->client('path_rel')); $this->cfg->setVal('env', 'path_frontend_fm_http', $sf_path_http_frontend . $this->cfg->client('path_rel') . $this->cfg->client('path_fm_rel')); $this->cfg->setVal('env', 'path_frontend_fm', $sf_path_base . $this->cfg->client('path_rel') . $this->cfg->client('path_fm_rel')); $this->cfg->setVal('env', 'path_frontend_css_http', $sf_path_http_frontend . $this->cfg->client('path_rel') . $this->cfg->client('path_css_rel')); $this->cfg->setVal('env', 'path_frontend_css', $sf_path_base . $this->cfg->client('path_rel') . $this->cfg->client('path_css_rel')); $this->cfg->setVal('env', 'path_frontend_js_http', $sf_path_http_frontend . $this->cfg->client('path_rel') . $this->cfg->client('path_js_rel')); $this->cfg->setVal('env', 'path_frontend_js', $sf_path_base . $this->cfg->client('path_rel') . $this->cfg->client('path_js_rel')); //init db cache $db->init_cache(); //init / found idlang $this->_initLang($db, $cms_db, $client); $sf_lang_stack = $this->controller_cfg['sf_lang_stack']; $lang_global_startlang = $this->controller_cfg['lang_global_startlang']; $langarray = $this->controller_cfg['langarray']; $startlang = $this->controller_cfg['startlang']; $this->_assignGlobals('sf_lang_stack', $sf_lang_stack); $this->_assignGlobals('lang_global_startlang', $lang_global_startlang); $this->_assignGlobals('langarray', $langarray); $this->_assignGlobals('startlang', $startlang); // init idactside, idcat, lang list($idcatside, $idcat, $lang) = $this->ft->getPageIdsFromRequest($startlang); $this->_assignGlobals('lang', $lang); $is_frontend_rewrite_no = $cfg_client['url_rewrite'] == '0' && $is_frontend; $is_frontend_rewrite1 = $cfg_client['url_rewrite'] == '1' && $is_frontend; $is_frontend_rewrite2 = $cfg_client['url_rewrite'] == '2' && $is_frontend; $this->cfg->setVal('env', 'is_frontend_rewrite_no', $is_frontend_rewrite_no); $this->cfg->setVal('env', 'is_frontend_rewrite1', $is_frontend_rewrite1); $this->cfg->setVal('env', 'is_frontend_rewrite2', $is_frontend_rewrite2); //extract idcatside/ idcat from frontend rewrite url $_sf_rewrite_session = FALSE; if ($is_frontend_rewrite2 && ($idcatside < 1 && $idcat < 1)) { include_once $cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . 'inc/fnc.mod_rewrite.php'; $_sf_rewrite_session = TRUE; $rewrite_lang = ''; //is not startpage if ($_REQUEST['sf_rewrite'] != '') { list($idcatside, $idcat, $rewrite_lang) = $this->_getIdcatsideIdcatLangByRewriteUrl($db, $cfg_cms, $cfg_client, $cms_db, $client, $sf_lang_stack, $startlang); $lang = (int) $rewrite_lang > 0 ? (int) $rewrite_lang : $lang; //idcatside and idcat can't be found if ($idcatside < 1 && $idcat < 1) { $idcatside = $this->ft->tryToRemapIdcatsideOrShow404(); } } } $this->cfg->setVal('env', 'idclient', $client); $this->cfg->setVal('env', 'idlang', $lang); $this->cfg->setVal('env', 'idstartlang', $startlang); $this->cfg->setVal('env', 'idcatside', $idcatside); $this->cfg->setVal('env', 'idpage', $idcatside); $this->cfg->setVal('env', 'idcat', $idcat); $this->_assignGlobals('idcatside', $idcatside); $this->_assignGlobals('_sf_rewrite_session', $_sf_rewrite_session); $this->_assignGlobals('idcat', $idcat); $this->_assignGlobals('lang', $lang); //start session and auth $this->ft->startSession(); $sess = $this->_getGlobal('sess'); $auth = $this->_getGlobal('auth'); $this->cfg->set('sess', $sess); $this->cfg->set('auth', $auth); // Sprache wechseln $sess->register('sid_idcatside'); $sid_idcatside = $idcatside; $this->_assignGlobals('sid_idcatside', $sid_idcatside); $perm = new cms_perms($client, $lang); $this->_assignGlobals('perm', $perm); $this->cfg->set('perm', $perm); //assign logger client settings $cms_log->setIdclient($client); $cms_log->setIdlang($lang); $cms_log->setStorage('screen', $cfg_client['logs_storage_screen']); $cms_log->setStorage('logfile', $cfg_client['logs_storage_logfile']); $cms_log->setStorage('database', $cfg_client['logs_storage_database']); //get cms_lang strings $lang_charset = $sf_lang_stack[$lang]['charset']; $lang_dir = $cms_path . 'lang/' . $cfg_cms['backend_lang'] . '/'; $cms_lang = $this->ft->getFrontendLangFile($lang_dir, $cms_path); $this->_assignGlobals('lang_charset', $lang_charset); $this->_assignGlobals('lang_dir', $lang_dir); $this->_assignGlobals('cms_lang', $cms_lang); // if idcatside not set found start idcat if ($idcatside < 1) { $idcatside = $this->ft->getStartIdcatside(); $this->_assignGlobals('idcatside', $idcatside); $this->_assignGlobals('idpage', $idcatside); $this->cfg->setVal('env', 'idcatside', $idcatside); } $this->cfg->setVal('env', 'is_https', sf_get_server_protocol() == 'https'); //register globals if ($this->controller_cfg['register_globals']) { $types_to_register = array('GET', 'POST'); foreach ($types_to_register as $global_type) { $arr = @${'_' . $global_type}; if (@count($arr) > 0) { extract($arr, EXTR_SKIP); } } } $code = ''; if ($is_backend) { //idcat is needed for have_perm()- call //wenn vom frontend aus eine Kategorie angelegt wird, ist noch keine $idcat vorhanden if ((int) $idcat < 1 && !empty($idcatside)) { $sql = "SELECT idcat FROM " . $cms_db['cat_side'] . " WHERE idcatside='" . (int) $idcatside . "'"; $db->query($sql); if ($db->next_record()) { $idcat = $db->f('idcat'); $GLOBALS['idcat'] =& $idcat; //todo } } // Modus einstellen: editieren/Vorschau/normal $sf_perm_edit_page = FALSE; if ($perm->have_perm(19, 'side', $idcatside, $idcat)) { $sf_perm_edit_page = TRUE; } $this->cfg->setVal('env', 'view', $view); $this->cfg->setVal('env', 'perm_edit_page', $sf_perm_edit_page); //Generate cat and page informations $SF_catinfos = sf_api('LIB', 'Catinfos'); $con_tree = $SF_catinfos->getCatinfoDataArray(); $tlo_tree = $SF_catinfos->getParentDependanceDataArray(); $this->_assignGlobals('SF_catinfos', $SF_catinfos); $this->_assignGlobals('con_tree', $con_tree); $this->_assignGlobals('tlo_tree', $tlo_tree); tree_level_order('0', 'catlist'); $catlist = $GLOBALS['catlist']; $catlist_level = $GLOBALS['catlist_level']; $SF_pageinfos = sf_api('LIB', 'Pageinfos'); $con_side = $SF_pageinfos->getPageinfoDataArray(); $this->_assignGlobals('SF_pageinfos', $SF_pageinfos); $this->_assignGlobals('con_side', $con_side); // idcatside prüfen, da der User auch in einer Kategorie sein kann, wo es noch keine seite // und damit idcatside gibt. //catch advanced pageinfos for cuurent page if (!empty($idcatside)) { $con_side[$idcatside]['meta_author'] = $SF_pageinfos->getMetaAuthor($idcatside); $con_side[$idcatside]['meta_description'] = $SF_pageinfos->getMetaDescription($idcatside); $con_side[$idcatside]['meta_keywords'] = $SF_pageinfos->getMetaKeywords($idcatside); $con_side[$idcatside]['meta_robots'] = $SF_pageinfos->getMetaRobots($idcatside); $con_side[$idcatside]['meta_redirect'] = $SF_pageinfos->getMetaRedirectIsActive($idcatside); $con_side[$idcatside]['meta_redirect_url'] = $SF_pageinfos->getMetaRedirectUrl($idcatside); $con_side[$idcatside]['summary'] = $SF_pageinfos->getSummary($idcatside); $con_side[$idcatside]['author'] = $SF_pageinfos->getAuthor($idcatside); $con_side[$idcatside]['created'] = $SF_pageinfos->getCreatedTimestamp($idcatside); $con_side[$idcatside]['lastmodified'] = $SF_pageinfos->getLastmodifiedTimestamp($idcatside); $con_side[$idcatside]['is_https'] = $SF_pageinfos->getIsHttps($idcatside); } $idcat = $SF_pageinfos->getIdcat($idcatside); $idside = $SF_pageinfos->getIdside($idcatside); $this->cfg->setVal('env', 'idcat', $idcat); $this->cfg->setVal('env', 'idcatside', $idcatside); $this->_assignGlobals('idcat', $idcat); $this->_assignGlobals('idside', $idside); $arr = $this->ft->getIdtplIdtplconf($idcat, $idside, $lang); $idlay = $this->ft->getIdlay($arr['idtpl']); $this->cfg->setVal('env', 'idtpl', $arr['idtpl']); $this->cfg->setVal('env', 'idtplconf', $arr['idtplconf']); $this->cfg->setVal('env', 'idlay', $idlay); // Inhalt erstellen zum editieren der Seite if ($this->cfg->env('view')) { // es existiert noch keine Seite in diesem Ordner if (!$idcatside) { $this->cfg->setVal('env', 'view', FALSE); } include $cms_path . 'inc/fnc.tpl.php'; include $cms_path . 'inc/fnc.type.php'; $sefrengotag_config = NULL; $GLOBALS['sefrengotag_config'] = $sefrengotag_config; $con_contype = NULL; $GLOBALS['con_contype'] = $con_contype; $con_typenumber = NULL; $GLOBALS['con_typenumber'] = $con_typenumber; $filetarget_is_hidden = NULL; $GLOBALS['filetarget_is_hidden'] = $filetarget_is_hidden; $type_container = NULL; $GLOBALS['con_typenumber'] = $type_container; $type_number = NULL; $GLOBALS['con_typenumber'] = $type_number; $type_typenumber = NULL; $GLOBALS['con_typenumber'] = $type_typenumber; $sf_content_manipulation = sf_api('LIB', 'FrontendPageContentManipulation'); $data = $this->req->req('data'); $action = array_key_exists('action', $_GET) ? $_GET['action'] : $_POST['action']; $idsidelang = $con_side[$idcatside]['idsidelang']; // Content speichern if ($action == 'save' || $action == 'saveedit') { //content f�r event (am Ende der if-Schleife) zwischenspeichern $entry = $this->req->req('entry', FALSE); /** * Aufbau str $content * idcontainer.idrepeat.idformfieldtype-idmodtag[,idformfieldtypeN-idmodtagN] * 520.2.14-2,13-1,4-1,5-1,1-2,14-3 - bearbeiten * 530.new.13-1 - neu einf�gen, Position wird �ber $entry bestimmt * */ $sf_content_string = $this->req->req('content', FALSE); $con_content = explode(';', $sf_content_string); foreach ($con_content as $value) { $con_config = explode('.', $value); $con_container = $con_config['0']; $con_containernumber = $con_config['1']; $con_content_type = explode(',', $con_config[2]); //add space for a "new" repeat container if (is_numeric($entry) || is_int($entry)) { $sf_content_manipulation->addNewRepeatContainer($con_container, $entry, $idsidelang); } foreach ($con_content_type as $value3) { $value3 = explode('-', $value3); $con_formtypenumber = $value3['0']; $con_idmodtag = $value3['1']; $sf_field_content = $this->req->req('content_' . $con_container . '_' . $con_containernumber . '_' . $con_formtypenumber . '_' . $con_idmodtag); $new_containernumber = is_numeric($entry) || is_int($entry) ? $entry + 1 : $con_containernumber; // $idcontainer, $idmodtag, $formtypenumber, $content, $idrepeat, $idsidelang $sf_content_manipulation->save($con_container, $con_idmodtag, $con_formtypenumber, $sf_field_content, $new_containernumber, $idsidelang); } // Modulverdopplung minimieren, wenn Content leer ist. $sf_content_manipulation->checkAndOptimizeRepeatContainer($con_container, $new_containernumber, $idsidelang); } // Event fire_event('con_edit', array('path' => $cms_path, 'idcatside' => $idcatside, 'content' => $sf_content_string)); } else { if ($action == 'delete' || $action == 'move_up' || $action == 'move_down') { $content = $this->req->req('content', FALSE); $con_content = explode(';', $content); foreach ($con_content as $value) { $con_config = explode('.', $value); $con_container = $con_config['0']; $con_contnbr = $con_config['1']; switch ($action) { case 'delete': $sf_content_manipulation->delete($con_container, $con_contnbr, $idsidelang); break; case 'move_up': $sf_content_manipulation->moveUp($con_container, $con_contnbr, $idsidelang); break; case 'move_down': $sf_content_manipulation->moveDown($con_container, $con_contnbr, $idsidelang); break; } } $this->ft->redirect($idcatside); } } //Content bearbeiten if ($action == 'edit' || $action == 'saveedit' || $action == 'new') { $this->sf_is_form_edit_mode = TRUE; $code = $this->ft->getBackendEditForm($cms_path, $lang_charset, $cfg_cms, $idcatside, $lang, $GLOBALS['sess'], $cfg_client, $con_tree, $con_side, $cms_lang, $idside); } else { // Template suchen $container = $this->ft->getTemplateConfig($idcat, $idside, $lang); $content = ''; if (count($container) > 0) { $idtpl = $container['idtpl']; $idtplconf = $container['idtplconf']; $GLOBALS['idtpl'] =& $idtpl; //TODO $GLOBALS['idtplconf'] =& $idtplconf; //TODO $GLOBALS['container'] =& $container; //TODO //Generate content array $content = $this->ft->getContentArray($idside, $lang); $GLOBALS['content'] =& $content; //TODO //Get layout $sf_layoutarray = $this->ft->getLayoutArray($idtpl); $layout = $sf_layoutarray['layout']; $sf_doctype = $sf_layoutarray['doctype']; $sf_doctype_autoinsert = $sf_layoutarray['doctype_autoinsert']; $sf_slash_closing_tag = $sf_layoutarray['doctype_required_tag_postfix']; $sf_frontend_output->setDoctype($sf_layoutarray['doctype']); $sf_frontend_output->setCharset($sf_lang_stack[$lang]['charset']); $sf_frontend_output->setMetaKeywords($con_side[$idcatside]['meta_keywords']); $sf_frontend_output->setMetaDescription($con_side[$idcatside]['meta_description']); $sf_frontend_output->setMetaAuthor($con_side[$idcatside]['meta_author']); $sf_frontend_output->setMetaRobots($con_side[$idcatside]['meta_robots']); $code = $this->ft->mapCMSPHPCACHEToPhp($layout); // Container generieren $list = $this->ft->extractCmsTags($code); $GLOBALS['cms_mod'] =& $cms_mod; //TODO if (is_array($list)) { $search = array(); $replace = array(); $sf_frontend_output->setCmsLayTags($list); foreach ($list as $cms_mod['container']) { $search[] = $cms_mod['container']['full_tag']; //Head-Container if ($cms_mod['container']['type'] == 'head') { $backendcfg = array('is_backend' => $is_backend, 'is_https' => $cfg_client['https'] == 1 && $con_side[$idcatside]['is_https'] == 1, 'cms_html_path' => $cfg_cms['path_base_http'] . $cfg_cms['path_backend_rel'], 'skin' => $cfg_cms['skin'], 'lang_gen_deletealert' => $cms_lang['gen_deletealert'], 'perm' => $perm, 'view' => $view, 'idcatside' => $idcatside, 'idcat' => $idcat, 'lang' => $lang); $replace[] = $this->ft->getContainerHead($idlay, $sf_slash_closing_tag, $lang_charset, $sf_doctype, $backendcfg); } else { if ($cms_mod['container']['type'] == 'config') { $replace[] = $this->ft->getContainerConfig($is_backend); } else { $backendcfg = array('is_backend' => $is_backend, 'idcatside' => $idcatside, 'view' => $this->cfg->env('view')); $replace[] = $this->ft->getContainerContent($container, $cms_mod, $content, $backendcfg); } } } foreach ($search as $key => $value) { $code = str_replace($value, $replace[$key], $code); } } } else { $code = $cms_lang['con_notemplate']; } //echo $code;exit; ob_start(); eval(' ?>' . $code); $code = ob_get_contents(); ob_end_clean(); $code = $this->ft->mapCMSPHPToPhp($code); } } // Seite ausgeben if ($code) { //redirect is active if ($SF_pageinfos->getMetaRedirectIsActive($idcatside) && $SF_pageinfos->getMetaRedirectUrl($idcatside) != '') { $this->ft->redirect($SF_pageinfos->getMetaRedirectUrl($idcatside)); } else { ob_start(); eval('?>' . $code); $code = ob_get_contents(); ob_end_clean(); } } else { $this->ft->show404(); } } else { $cfg_client['session_enabled'] = $this->ft->isSessionDisabledByUseragent() ? 0 : $cfg_client['session_enabled']; $cfg_client['session_enabled'] = $this->ft->isSessionDisabledByIp() ? 0 : $cfg_client['session_enabled']; $this->cfg->setVal('client', 'session_enabled', $cfg_client['session_enabled']); if ($_sf_rewrite_session) { if ($sess->mode == 'get') { $sess->mode = 'getrewrite'; } } //Generate cat and page informations $SF_catinfos = sf_api('LIB', 'Catinfos'); $con_tree = $SF_catinfos->getCatinfoDataArray(); $tlo_tree = $SF_catinfos->getParentDependanceDataArray(); $GLOBALS['SF_catinfos'] = $SF_catinfos; //todo $GLOBALS['con_tree'] = $con_tree; //todo $GLOBALS['tlo_tree'] = $tlo_tree; //todo tree_level_order('0', 'catlist'); $catlist = $GLOBALS['catlist']; $catlist_level = $GLOBALS['catlist_level']; if (is_array($con_tree)) { $SF_pageinfos = sf_api('LIB', 'Pageinfos'); $con_side = $SF_pageinfos->getPageinfoDataArray(); $GLOBALS['SF_pageinfos'] = $SF_pageinfos; //todo $GLOBALS['con_side'] = $con_side; //todo } // $idcat und $idside ermitteln if (empty($idcat)) { $idcat = $con_side[$idcatside]['idcat']; } if (empty($idside)) { $idside = $con_side[$idcatside]['idside']; } $GLOBALS['idcat'] = $idcat; //todo $GLOBALS['idside'] = $idside; //todo if ($cfg_client['url_rewrite'] == '2') { include_once $cfg_cms['path_base'] . $cfg_cms['path_backend_rel'] . 'inc/fnc.mod_rewrite.php'; rewriteGenerateMapping(); } // Ausgabe beenden, wenn Kategorie oder Seite nicht online if ($con_side[$idcatside]['online'] != 1 || $con_tree[$idcat]['visible'] != 1) { $idcatside = $this->ft->tryToRemapIdcatsideOrShow404(); $idcat = $SF_pageinfos->getIdcat($idcatside); $idside = $SF_pageinfos->getIdside($idcatside); } // get advanced sideinfos for this side // idcatside pr�fen, da der User auch in einer Kategorie sein kann, wo es noch keine seite // und damit idcatside gibt. // es gibt keine idsidelang, wenn der user nicht das recht hat, die seite zu sehen if (!empty($idcatside) && !empty($con_side[$idcatside]['idsidelang'])) { $con_side[$idcatside]['meta_author'] = $SF_pageinfos->getMetaAuthor($idcatside); $con_side[$idcatside]['meta_description'] = $SF_pageinfos->getMetaDescription($idcatside); $con_side[$idcatside]['meta_keywords'] = $SF_pageinfos->getMetaKeywords($idcatside); $con_side[$idcatside]['meta_robots'] = $SF_pageinfos->getMetaRobots($idcatside); $con_side[$idcatside]['meta_redirect'] = $SF_pageinfos->getMetaRedirectIsActive($idcatside); $con_side[$idcatside]['meta_redirect_url'] = $SF_pageinfos->getMetaRedirectUrl($idcatside); $con_side[$idcatside]['summary'] = $SF_pageinfos->getSummary($idcatside); $con_side[$idcatside]['author'] = $SF_pageinfos->getAuthor($idcatside); $con_side[$idcatside]['created'] = $SF_pageinfos->getCreatedTimestamp($idcatside); $con_side[$idcatside]['lastmodified'] = $SF_pageinfos->getLastmodifiedTimestamp($idcatside); $con_side[$idcatside]['is_https'] = $SF_pageinfos->getIsHttps($idcatside); $con_side[$idcatside]['protected'] = $SF_pageinfos->getIsProtected($idcatside); } $this->cfg->setVal('env', 'idcat', $idcat); $this->cfg->setVal('env', 'idcatside', $idcatside); $arr = $this->ft->getIdtplIdtplconf($idcat, $idside, $lang); $idlay = $this->ft->getIdlay($arr['idtpl']); $this->cfg->setVal('env', 'idtpl', $arr['idtpl']); $this->cfg->setVal('env', 'idtplconf', $arr['idtplconf']); $this->cfg->setVal('env', 'idlay', $idlay); // Inhalt aus der Datenbank suchen if ($auth->auth['uid'] != 'nobody' | ($con_tree[$idcat]['visible'] == '1' && !empty($con_side[$idcatside]['online']) && $con_side[$idcatside]['online'] != '0')) { if (!empty($con_tree[$con_side[$idcatside]['idcat']]['idcat'])) { $sf_item_code = sf_api('MODEL', 'CodeSqlItem'); $sf_item_code->loadByIdcatside($idcatside); $code = $sf_item_code->getField('code'); if ($sf_item_code->getField('changed') == 1) { // Seite generieren weil keine Daten gefunden oder Daten ver�ndert include $cms_path . 'inc/fnc.type.php'; $container = $this->ft->getTemplateConfig($idcat, $idside, $lang); if (count($container) > 0) { $idtpl = $container['idtpl']; $idtplconf = $container['idtplconf']; $GLOBALS['idtpl'] =& $idtpl; //TODO $GLOBALS['idtplconf'] =& $idtplconf; //TODO $GLOBALS['container'] =& $container; //TODO //Generate content array $content = $this->ft->getContentArray($idside, $lang); $GLOBALS['content'] = $content; //TODO //Get layout $sf_layoutarray = $this->ft->getLayoutArray($idtpl); $layout = $sf_layoutarray['layout']; $sf_doctype = $sf_layoutarray['doctype']; $sf_doctype_autoinsert = $sf_layoutarray['doctype_autoinsert']; $sf_slash_closing_tag = $sf_layoutarray['doctype_required_tag_postfix']; $sf_frontend_output->setDoctype($sf_layoutarray['doctype']); $sf_frontend_output->setCharset($sf_lang_stack[$lang]['charset']); $sf_frontend_output->setMetaKeywords($con_side[$idcatside]['meta_keywords']); $sf_frontend_output->setMetaDescription($con_side[$idcatside]['meta_description']); $sf_frontend_output->setMetaAuthor($con_side[$idcatside]['meta_author']); $sf_frontend_output->setMetaRobots($con_side[$idcatside]['meta_robots']); $layout = $this->ft->mapCMSPHPCACHEToPhp($layout); // Container generieren $list = $this->ft->extractCmsTags($layout); //TODO: 2REMOVE - DEDI BACKWARD COMPATIBILITY $GLOBALS['cms_mod'] =& $cms_mod; //TODO //parse containers $search = array(); $replace = array(); if (is_array($list)) { $sf_frontend_output->setCmsLayTags($list); //TODO DOES NOT WORK WITHOUT CACHE!!!! foreach ($list as $cms_mod['container']) { $search[] = $cms_mod['container']['full_tag']; //Head-Container if ($cms_mod['container']['type'] == 'head') { $replace[] = $this->ft->getContainerHead($idlay, $sf_slash_closing_tag, $lang_charset, $sf_layoutarray['doctype']); } else { if ($cms_mod['container']['type'] == 'config') { $replace[] = $this->ft->getContainerConfig($is_backend); } else { $replace[] = $this->ft->getContainerContent($container, $cms_mod, $content); } } } // Seite erstellen $code = $layout; foreach ($search as $key => $value) { $code = str_replace($value, $replace[$key], $code); } } else { $code = $layout; } //no template found } else { $code = $cms_lang['con_notemplate']; } //render cached php ob_start(); eval(' ?>' . $code); $code = ob_get_contents(); $sf_fo_export = $sf_frontend_output->_exportConfig(); $code = '<CMSPHP> $_sf_frontend_output_cfg_cache = ' . $sf_fo_export . '; </CMSPHP>' . $code; ob_end_clean(); $code = $this->ft->mapCMSPHPToPhp($code); // Delete Content Cache sf_factoryCallMethod('UTILS', 'DbCache', null, null, 'flushByGroup', array('frontend', 'content')); // Seite in die 'code'-Tabelle schreiben if ($this->cfg->client('cache') == '1') { $sf_item_code->setField('code', $code); $sf_item_code->setField('changed', '0'); $sf_item_code->save(); } } } } // Seite ausgeben if ($code) { // handle meta redirect //redirect is active if ($SF_pageinfos->getMetaRedirectIsActive($idcatside) && $SF_pageinfos->getMetaRedirectUrl($idcatside) != '') { $this->ft->redirect($SF_pageinfos->getMetaRedirectUrl($idcatside)); } else { ob_start(); eval('?>' . $code); $sf_frontend_output->_importConfig($_sf_frontend_output_cfg_cache); $code = ob_get_contents(); ob_end_clean(); if ($this->cfg->env('send_header_404')) { $sf_frontend_output->setHttpHeader('HTTP/1.1 404 Not Found'); $sf_frontend_output->setHttpHeader('Status: 404 Not Found'); } } } else { $this->ft->show404(); } } //$sf_frontend_output->addContentToHead('<script>alert("hello")</script>', $position = 'top'); //$sf_frontend_output->changeContainerVisibility(520, FALSE); //$sf_frontend_output->changeContainerVisibility(510, FALSE); $output = $sf_frontend_output->parse($code, TRUE); if (!$this->sf_is_form_edit_mode) { $output = $this->ft->getMappedCmsFileUrlsToNamedUrls($output); $output = $this->ft->getMappedCmsLinks($output); } // event to manipulate the output $event = fire_event('frontend_code_generated', array('output' => $output), array('output')); $output = $event['output']; unset($event); //Logs auf Screen ausgeben, wenn Logs vorhanden if (count($cms_log->getLogs()) > 0) { $log_output = sf_api('VIEW', 'LogOutput'); $log_output->addItemsArray($cms_log->getLogs()); $searches = array('</body>'); foreach ($searches as $search) { $pos = strpos($output, $search); if ($pos !== FALSE) { // replace the last occurence of $search $output = substr_replace($output, "\n" . $log_output->show() . "\n" . $search, $pos, strlen($search)); break; // exit } } } //handle charset - default is UTF-8 if ($sf_lang_stack[$lang]['charset'] == 'iso-8859-1') { $output = utf8_decode($output); } // Seite komprimieren und ausgeben if ($cfg_cms['gzip'] == '1') { // @ob_start('ob_gzhandler'); eval($cfg_client['manipulate_output']); // @ob_end_flush(); } else { eval($cfg_client['manipulate_output']); } }