mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Added Rebuild option for SEF Urls.
This commit is contained in:
@@ -62,14 +62,80 @@ class eurl_admin_ui extends e_admin_controller_ui
|
|||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(is_array($_POST['rebuild']))
|
||||||
|
{
|
||||||
|
$table = key($_POST['rebuild']);
|
||||||
|
list($primary, $input, $output) = explode("::",$_POST['rebuild'][$table]);
|
||||||
|
$this->rebuild($table, $primary, $input, $output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->api = e107::getInstance();
|
$this->api = e107::getInstance();
|
||||||
$this->addTitle(LAN_EURL_NAME);
|
$this->addTitle(LAN_EURL_NAME);
|
||||||
|
|
||||||
if($this->getAction() != 'settings') return;
|
if($this->getAction() != 'settings') return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebuild SEF Urls for a particular table
|
||||||
|
* @param $table
|
||||||
|
* @param primary field id.
|
||||||
|
* @param input field (title)
|
||||||
|
* @param output field (sef)
|
||||||
|
*/
|
||||||
|
private function rebuild($table, $primary, $input,$output)
|
||||||
|
{
|
||||||
|
if(empty($table) || empty($input) || empty($output) || empty($primary))
|
||||||
|
{
|
||||||
|
e107::getMessage()->addError("Missing Generator data");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = e107::getDb();
|
||||||
|
|
||||||
|
$data = $sql->retrieve($table, $primary.",".$input, $input ." != '' ", true);
|
||||||
|
|
||||||
|
$success = 0;
|
||||||
|
$failed = 0;
|
||||||
|
|
||||||
|
foreach($data as $row)
|
||||||
|
{
|
||||||
|
$sef = eHelper::title2sef($row[$input]);
|
||||||
|
|
||||||
|
if($sql->update($table, $output ." = '".$sef."' WHERE ".$primary. " = ".intval($row[$primary]). " LIMIT 1")!==false)
|
||||||
|
{
|
||||||
|
$success++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$failed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// echo $row[$input]." => ".$output ." = '".$sef."' WHERE ".$primary. " = ".intval($row[$primary]). " LIMIT 1 <br />";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($success)
|
||||||
|
{
|
||||||
|
e107::getMessage()->addSuccess($success." SEF URLs were updated.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if($failed)
|
||||||
|
{
|
||||||
|
e107::getMessage()->addError($failed." SEF URLs were NOT updated.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function HelpObserver()
|
public function HelpObserver()
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -231,15 +297,15 @@ class eurl_admin_ui extends e_admin_controller_ui
|
|||||||
<legend>".LAN_EURL_LEGEND_CONFIG."</legend>
|
<legend>".LAN_EURL_LEGEND_CONFIG."</legend>
|
||||||
<table class='table adminlist'>
|
<table class='table adminlist'>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col class='col-label' />
|
<col class='col-label' style='width:20%' />
|
||||||
<col class='col-control' />
|
<col class='col-control' style='width:60%' />
|
||||||
|
<col style='width:20%' />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>".LAN_TYPE."</th>
|
<th>".LAN_TYPE."</th>
|
||||||
<th>".LAN_URL."</th>
|
<th>".LAN_URL."</th>
|
||||||
|
<th>".LAN_OPTIONS."</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -429,6 +495,8 @@ class eurl_admin_form_ui extends e_admin_form_ui
|
|||||||
{
|
{
|
||||||
$text = '';
|
$text = '';
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
$frm = e107::getForm();
|
||||||
|
|
||||||
if(empty($data))
|
if(empty($data))
|
||||||
{
|
{
|
||||||
return "
|
return "
|
||||||
@@ -444,10 +512,11 @@ class eurl_admin_form_ui extends e_admin_form_ui
|
|||||||
|
|
||||||
foreach ($data as $obj)
|
foreach ($data as $obj)
|
||||||
{
|
{
|
||||||
$admin = $obj->config->admin();
|
$admin = $obj->config->admin();
|
||||||
$section = vartrue($admin['labels'], array());
|
$section = vartrue($admin['labels'], array());
|
||||||
$rowspan = count($obj->locations)+1;
|
$rowspan = count($obj->locations)+1;
|
||||||
$module = $obj->module;
|
$module = $obj->module;
|
||||||
|
$generate = vartrue($admin['generate'], array());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$info .= "
|
$info .= "
|
||||||
@@ -505,24 +574,41 @@ class eurl_admin_form_ui extends e_admin_form_ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
$selected = varset($obj->current[$module]) == $location ? "selected='selected'" : '';
|
$selected = varset($obj->current[$module]) == $location ? "selected='selected'" : '';
|
||||||
$opt .= "<option value='{$location}' {$selected} >".$diz.": ".$exampleUrl[0]."</option>";
|
$opt .= "<option value='{$location}' {$selected} >".$diz.": ".$exampleUrl[0]."</option>";
|
||||||
|
|
||||||
$info .= "<tr><td>".$label."
|
$info .= "<tr><td>".$label."
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td><strong>".LAN_EURL_LOCATION."</strong>: ".$path."
|
<td><strong>".LAN_EURL_LOCATION."</strong>: ".$path."
|
||||||
<p>".vartrue($section['description'], LAN_EURL_PROFILE_INFO)."</p><small>".implode("<br />", $exampleUrl)."</small></td></tr>
|
<p>".vartrue($section['description'], LAN_EURL_PROFILE_INFO)."</p><small>".implode("<br />", $exampleUrl)."</small></td>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
";
|
";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$info .= "</table>";
|
$info .= "</table>";
|
||||||
|
|
||||||
|
$title = vartrue($section['name'], eHelper::labelize($obj->module));
|
||||||
|
|
||||||
$title = vartrue($section['name'], eHelper::labelize($obj->module));
|
$text .= "
|
||||||
$text .= "
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>".$this->moreInfo($title, $info)."</td>
|
<td>".$this->moreInfo($title, $info)."</td>
|
||||||
<td><select name='eurl_config[$module]' class='span6 tbox'>".$opt."</select></td>
|
<td><select name='eurl_config[$module]' class='input-block-level'>".$opt."</select></td>
|
||||||
|
<td>";
|
||||||
|
|
||||||
|
$bTable = ($admin['generate']['table']);
|
||||||
|
$bInput = $admin['generate']['input'];
|
||||||
|
$bOutput = $admin['generate']['output'];
|
||||||
|
$bPrimary = $admin['generate']['primary'];
|
||||||
|
|
||||||
|
|
||||||
|
$text .= (is_array($admin['generate'])) ? $frm->admin_button('rebuild['.$bTable.']', $bPrimary."::".$bInput."::".$bOutput,'delete',"Rebuild") : "";
|
||||||
|
|
||||||
|
|
||||||
|
$text .= "</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -139,6 +139,7 @@ class core_news_sef_url extends eUrlConfig
|
|||||||
'description' => LAN_EURL_NEWS_REWRITEX_DESCR, //
|
'description' => LAN_EURL_NEWS_REWRITEX_DESCR, //
|
||||||
'examples' => array('{SITEURL}news/1/news-title')
|
'examples' => array('{SITEURL}news/1/news-title')
|
||||||
),
|
),
|
||||||
|
'generate' => array('table'=> 'news', 'primary'=>'news_id', 'input'=>'news_title', 'output'=>'news_sef'),
|
||||||
'form' => array(), // Under construction - additional configuration options
|
'form' => array(), // Under construction - additional configuration options
|
||||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||||
);
|
);
|
||||||
|
@@ -54,6 +54,7 @@ class core_page_sef_url extends eUrlConfig
|
|||||||
'description' => LAN_EURL_PAGE_SEF_DESCR, //
|
'description' => LAN_EURL_PAGE_SEF_DESCR, //
|
||||||
'examples' => array("{SITEURL}page/1/page-name")
|
'examples' => array("{SITEURL}page/1/page-name")
|
||||||
),
|
),
|
||||||
|
'generate' => array('table'=> 'page', 'primary'=>'page_id', 'input'=>'page_title', 'output'=>'page_sef'),
|
||||||
'form' => array(), // Under construction - additional configuration options
|
'form' => array(), // Under construction - additional configuration options
|
||||||
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user