1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 22:57:14 +02:00

Issue #2486 - e_url now supports multiple profiles.

This commit is contained in:
Cameron
2017-04-10 13:28:06 -07:00
parent 2977c7b9c3
commit 630a5aa147
3 changed files with 91 additions and 12 deletions

View File

@@ -439,13 +439,23 @@ class eurl_admin_ui extends e_admin_controller_ui
$locations = eRouter::adminBuildLocations($modules); $locations = eRouter::adminBuildLocations($modules);
$aliases = eRouter::adminSyncAliases(e107::getPref('url_aliases'), $config); $aliases = eRouter::adminSyncAliases(e107::getPref('url_aliases'), $config);
if(!empty($_POST['eurl_profile']))
{
e107::getConfig()->set('url_profiles', $_POST['eurl_profile']);
unset($locations['download']);
unset($config['download']);
}
e107::getConfig() e107::getConfig()
->set('url_aliases', $aliases) ->set('url_aliases', $aliases)
->set('url_config', $config) ->set('url_config', $config)
->set('url_modules', $modules) ->set('url_modules', $modules)
->set('url_locations', $locations) ->set('url_locations', $locations)
->save(); ->save();
eRouter::clearCache(); eRouter::clearCache();
} }
@@ -486,7 +496,11 @@ class eurl_admin_ui extends e_admin_controller_ui
<tbody> <tbody>
"; ";
$text .= $this->renderProfiles();
$text .= $this->renderConfig($set['url_config'], $set['url_locations']); $text .= $this->renderConfig($set['url_config'], $set['url_locations']);
$text .= " $text .= "
@@ -502,6 +516,44 @@ class eurl_admin_ui extends e_admin_controller_ui
return $text; return $text;
} }
/**
* New in v2.1.6
*/
private function renderProfiles()
{
$PLUGINS_DIRECTORY = e107::getFolder("PLUGINS");
$srch = array("{SITEURL}","{e_PLUGIN_ABS}");
$repl = array(SITEURL,SITEURL.$PLUGINS_DIRECTORY);
$profiles = e107::getUrlConfig('profiles');
$form = $this->getUI();
$text = '';
$active = e107::getPref('url_profiles');
foreach($profiles as $plug=>$prof)
{
$arr = array();
foreach($prof as $id=>$val)
{
$arr[$id] = $val['label'].": ". str_replace($srch,$repl,$val['examples'][0]);
}
$sel = $active[$plug];
$selector = $form->select('eurl_profile['.$plug.']',$arr,$sel, array('size'=>'block-level'));
$text .= "<tr><td>".$plug."</td><td>".$selector."</td></tr>";
}
return $text;
}
public function renderConfig($current, $locations) public function renderConfig($current, $locations)
{ {
@@ -637,19 +689,21 @@ class eurl_admin_form_ui extends e_admin_form_ui
$id = 'eurl_'.$this->name2id($title); $id = 'eurl_'.$this->name2id($title);
$text .= "<a data-toggle='modal' href='#".$id."' data-cache='false' data-target='#".$id."' class='e-tip' title='".LAN_MOREINFO."'>"; $text = "<a data-toggle='modal' href='#".$id."' data-cache='false' data-target='#".$id."' class='e-tip' title='".LAN_MOREINFO."'>";
$text .= $title; $text .= $title;
$text .= '</a>'; $text .= '</a>';
$text .= ' $text .= '
<div id="'.$id.'" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"> <div id="'.$id.'" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-header"> <div class="modal-dialog modal-lg">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <div class="modal-content">
<h4>'.$tp->toHtml($title,false,'TITLE').'</h4> <div class="modal-header">
</div> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<div class="modal-body"> <h4>'.$tp->toHtml($title,false,'TITLE').'</h4>
<p>'; </div>
<div class="modal-body">
<p>';
$text .= $info; $text .= $info;
@@ -659,7 +713,8 @@ class eurl_admin_form_ui extends e_admin_form_ui
<div class="modal-footer"> <div class="modal-footer">
<a href="#" data-dismiss="modal" class="btn btn-primary">'.LAN_CLOSE.'</a> <a href="#" data-dismiss="modal" class="btn btn-primary">'.LAN_CLOSE.'</a>
</div> </div>
</div>'; </div>
</div></div>';
return $text; return $text;
@@ -687,6 +742,8 @@ class eurl_admin_form_ui extends e_admin_form_ui
$PLUGINS_DIRECTORY = e107::getFolder("PLUGINS"); $PLUGINS_DIRECTORY = e107::getFolder("PLUGINS");
$srch = array("{SITEURL}","{e_PLUGIN_ABS}"); $srch = array("{SITEURL}","{e_PLUGIN_ABS}");
$repl = array(SITEURL,SITEURL.$PLUGINS_DIRECTORY); $repl = array(SITEURL,SITEURL.$PLUGINS_DIRECTORY);
foreach ($data as $obj) foreach ($data as $obj)
{ {
@@ -707,6 +764,9 @@ class eurl_admin_form_ui extends e_admin_form_ui
*/ */
$opt = ""; $opt = "";
$info = "<table class='table table-striped'>"; $info = "<table class='table table-striped'>";
foreach ($obj->locations as $index => $location) foreach ($obj->locations as $index => $location)
{ {
@@ -773,6 +833,8 @@ class eurl_admin_form_ui extends e_admin_form_ui
$info .= "</table>"; $info .= "</table>";
$title = vartrue($section['name'], eHelper::labelize($obj->module)); $title = vartrue($section['name'], eHelper::labelize($obj->module));
$text .= " $text .= "
<tr> <tr>

View File

@@ -329,6 +329,8 @@ City, State, Country
'search' => 'core', 'search' => 'core',
'system' => 'core', 'system' => 'core',
'user' => 'core', 'user' => 'core',
)]]></core>
<core name="url_profiles"><![CDATA[array (
)]]></core> )]]></core>
<core name="url_disable_pathinfo">1</core> <core name="url_disable_pathinfo">1</core>
<core name="url_error_redirect">0</core> <core name="url_error_redirect">0</core>

View File

@@ -2418,6 +2418,7 @@ class e107
/** /**
* Retrieves the e_url config - new v2.1.6 * Retrieves the e_url config - new v2.1.6
* @param string $mode config | alias | profile
* @return array * @return array
*/ */
public static function getUrlConfig($mode='config') public static function getUrlConfig($mode='config')
@@ -2429,7 +2430,7 @@ class e107
$className = substr($filename, 2); // remove 'e_' $className = substr($filename, 2); // remove 'e_'
$methodName = 'config'; $methodName = 'config';
$profile = null; // for future use. $url_profiles = e107::getPref('url_profiles');
if(!empty($elist)) if(!empty($elist))
{ {
@@ -2437,6 +2438,8 @@ class e107
{ {
if(is_readable(e_PLUGIN.$key.'/'.$filename.'.php')) if(is_readable(e_PLUGIN.$key.'/'.$filename.'.php'))
{ {
include_once(e_PLUGIN.$key.'/'.$filename.'.php'); include_once(e_PLUGIN.$key.'/'.$filename.'.php');
$class_name = $key.'_'.$className; $class_name = $key.'_'.$className;
@@ -2461,6 +2464,18 @@ class e107
continue; continue;
} }
if($mode === 'profiles')
{
if(!empty($obj->profiles))
{
$new_addon[$key] = $obj->profiles;
}
continue;
}
$profile = !empty($url_profiles[$key]) ? $url_profiles[$key] : null;
$array = self::callMethod($obj, $methodName,$profile); $array = self::callMethod($obj, $methodName,$profile);
if($array) if($array)