diff --git a/e107_admin/eurl.php b/e107_admin/eurl.php index 7041119fa..27d2d99f9 100644 --- a/e107_admin/eurl.php +++ b/e107_admin/eurl.php @@ -24,6 +24,7 @@ e107::coreLan('eurl', true); $e_sub_cat = 'eurl'; + class eurl_admin extends e_admin_dispatcher { protected $modes = array( @@ -63,7 +64,34 @@ class eurl_admin_ui extends e_admin_controller_ui public function init() { + if(e_AJAX_REQUEST) + { + $tp = e107::getParser(); + if(!empty($_POST['pk']) && !empty($_POST['value'])) + { + $cfg = e107::getConfig(); + + list($plug,$key) = explode("|", $_POST['pk']); + + if(is_string($cfg->get('e_url_alias'))) + { + $cfg->setPostedData('e_url_alias', array(e_LAN => array($plug => array($key => $tp->filter($_POST['value']))) ), false); + } + else + { + $cfg->setPref('e_url_alias/'.e_LAN.'/'.$plug."/".$key, $tp->filter($_POST['value'])); + } + + $cfg->save(true, true, true); + } + + + // file_put_contents(e_LOG."e_url.log", print_r($cfg->get('e_url_alias'),true)); + + exit; + + } $htaccess = file_exists(e_BASE.".htaccess"); @@ -205,8 +233,8 @@ class eurl_admin_ui extends e_admin_controller_ui return; } - - $text = $frm->open('simpleSef'); + $text = "
"; + $text .= $frm->open('simpleSef'); $multilan = "".$tp->toGlyph('fa-language').""; @@ -217,7 +245,7 @@ class eurl_admin_ui extends e_admin_controller_ui $text .= "
".$plug."
"; $text .= ""; $text .= " - + "; @@ -225,15 +253,18 @@ class eurl_admin_ui extends e_admin_controller_ui foreach($val as $k=>$v) { - $alias = vartrue($pref[e_LAN][$plug][$k], $v['alias']); - $regex = (!empty($alias)) ? str_replace('{alias}', $alias, $v['regex']) : $v['regex']; - $sefurl = (!empty($alias)) ? str_replace('{alias}', $alias, $v['sef']) : $v['sef']; - $aliasForm = (!empty($alias)) ? $home.$frm->text('e_url_alias['.$plug.']['.$k.']', $alias).$multilan : 'Not available'; + $alias = vartrue($pref[e_LAN][$plug][$k], $v['alias']); + // $sefurl = (!empty($alias)) ? str_replace('{alias}', $alias, $v['sef']) : $v['sef']; + $pid = $plug."|".$k; + + $v['regex'] = str_replace("^",$home,$v['regex']); + $aliasForm = $frm->renderInline('e_url_alias['.$plug.']['.$k.']', $pid, 'e_url_alias['.$plug.']['.$k.']', $alias, $alias,'text',null,array('title'=>LAN_EDIT." (".e_LANGUAGE." Only)", 'url'=>e_REQUEST_SELF)); + $aliasRender = str_replace('{alias}', $aliasForm, $v['regex']); $text .= " - - + + "; } @@ -242,8 +273,9 @@ class eurl_admin_ui extends e_admin_controller_ui $text .= "
KeyRegular ExpressionAlias".LAN_URL."
".$k."".$regex."".$aliasForm."".$aliasRender."". $v['redirect']."
"; } - $text .= "
".$frm->button('saveSimpleSef',LAN_SAVE." (".e_LANGUAGE.")",'submit')."
"; + // $text .= "
".$frm->button('saveSimpleSef',LAN_SAVE." (".e_LANGUAGE.")",'submit')."
"; $text .= $frm->close(); + $text .= "
"; return $text; } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 278cba0ce..8fadccd96 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -2974,7 +2974,7 @@ class e_form * @param $type text|textarea|select|date|checklist * @param $array : array data used in dropdowns etc. */ - private function renderInline($dbField, $pid, $fieldName, $curVal, $linkText, $type='text', $array=null) + public function renderInline($dbField, $pid, $fieldName, $curVal, $linkText, $type='text', $array=null, $options=array()) { $jsonArray = array(); @@ -2989,10 +2989,36 @@ class e_form $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); - + + if(!isset($options['url'])) + { + $options['url'] = e_SELF."?mode={$mode}&action=inline&id={$pid}&ajax_used=1"; + } + + if(!empty($pid)) + { + $options['pk'] = $pid; + } + + $title = varset($options['title'] , (LAN_EDIT." ".$fieldName)); + unset( $options['title']); + $text = "".$linkText.""; + $text .= " title=\"".$title."\" data-type='".$type."' data-inputclass='x-editable-".$this->name2id($dbField)."' data-value=\"{$curVal}\" href='#' "; + + if(!empty($options)) + { + foreach($options as $k=>$opt) + { + if(!empty($opt)) + { + $text .= " data-".$k."='".$opt."'"; + } + } + } + + $text .= ">".$linkText.""; return $text; }