30 abstract public function loadView($viewName, $pData=NULL, $asString=
false);
32 abstract public function seo();
34 abstract protected function showSimpleMessage($content, $type, $icon=
"info", $timeout=NULL, $staticName=null);
36 abstract protected function _createController($controllerName, $variables=[], $ctrlTemplate=
'controller.tpl', $hasView=
false);
39 $controllerClass=\implode(
"\\", $params);
40 $controllerSeo=
new $controllerClass();
42 $array=$controllerSeo->_getArrayUrls();
44 $parser->parseArray($array,
true);
46 $urls=$parser->getUrls();
47 $dt=$this->jquery->semantic()->dataTable(
"dtSiteMap",
'Ubiquity\seo\Url', $urls);
48 $dt->setFields([
'location',
'lastModified',
'changeFrequency',
'priority',
'delete' ]);
49 $dt->setCaptions([
'Location',
'Last Modified',
'Change Frequency',
'Priority',
'' ]);
50 $dt->fieldAsInput(
"location");
51 $dt->setValueFunction(
"lastModified",
function ($v, $o, $i) {
52 $d=date(
'Y-m-d\TH:i', $v);
53 $input=
new HtmlInput(
"date-" . $i,
'datetime-local', $d);
54 $input->setName(
"lastModified[]");
58 $dt->fieldAsDropDown(
'changeFrequency', \array_combine($freq, $freq));
59 $dt->setValueFunction(
"priority",
function ($v, $o, $i) {
60 $input=
new HtmlInput(
"priority-" . $i,
'number', $v);
61 $f=$input->getDataField();
62 $f->setProperty(
'name',
'priority[]');
63 $f->setProperty(
'max',
'1')->setProperty(
'min',
'0')->setProperty(
'step',
'0.1');
66 $dt->onNewRow(
function ($row, $instance) {
67 if ($instance->getExisting()) {
68 $row->addClass(
'positive');
70 $row->setProperty(
'style',
'display: none;')->addClass(
'toToggle');
74 $dt->setHasCheckboxes(
true);
75 $dt->setCheckedCallback(
function ($object) {
76 return $object->getExisting();
79 $dt->setSubmitParams($this->
_getAdminFiles()->getAdminBaseRoute() .
"/saveUrls",
"#seo-details", [
'attr' =>
'' ]);
80 $this->jquery->execOn(
"click",
"#saveUrls",
'$("#frm-dtSiteMap").form("submit");');
82 $this->jquery->click(
'#displayAllRoutes',
'$(".toToggle").toggle();$(this).toggleClass("active");');
83 $this->jquery->compile($this->view);
85 $this->
loadView($this->
_getAdminFiles()->getViewSeoDetails(), [
"controllerClass" => $controllerClass,
"urlsFile" => $controllerSeo->_getUrlsFilename() ]);
91 $siteUrl=$config[
"siteUrl"];
96 foreach ( $urls as $url ) {
99 if (\
sizeof($content) > 0) {
101 $content=\implode(
"\n", $content);
103 $msg=$this->
showSimpleMessage(
"The file <b>robots.txt</b> has been generated in " . $appDir,
"success",
"info circle");
105 $msg=$this->
showSimpleMessage(
"Can not generate <b>robots.txt</b> if no SEO controller is selected.",
"warning",
"warning circle");
108 echo $this->jquery->compile($this->view);
113 $modal=$this->jquery->semantic()->htmlModal(
"modalNewSeo",
"Creating a new Seo controller");
114 $modal->setInverted();
115 $frm=$this->jquery->semantic()->htmlForm(
"frmNewSeo");
116 $fc=$frm->addField(
'controllerName')->addRule([
"checkController",
"Controller {value} already exists!" ]);
118 $fields=$frm->addFields([
"urlsFile",
"sitemapTemplate" ],
"Urls file & sitemap twig template");
119 $fields->setFieldsPropertyValues(
"value", [
"urls",
"Seo/sitemap.xml.html" ]);
120 $fields->getItem(0)->addRules([
"empty" ]);
122 $frm->addCheckbox(
"ck-add-route",
"Add route...");
124 $frm->addContent(
"<div id='div-new-route' style='display: none;'>");
126 $frm->addInput(
"path",
"",
"text",
"")->addRule([
"checkRoute",
"Route {value} already exists!" ]);
127 $frm->addContent(
"</div>");
129 $frm->setValidationParams([
"on" =>
"blur",
"inline" =>
true ]);
130 $frm->setSubmitParams($this->
_getAdminFiles()->getAdminBaseRoute() .
"/createSeoController",
"#main-content");
131 $modal->setContent($frm);
132 $modal->addAction(
"Validate");
133 $this->jquery->click(
"#action-modalNewSeo-0",
"$('#frmNewSeo').form('submit');",
false,
false);
134 $modal->addAction(
"Close");
135 $this->jquery->change(
'#controllerName',
'if($("#ck-add-route").is(":checked")){$("#path").val($(this).val());}');
136 $this->jquery->exec(
"$('.dimmer.modals.page').html('');$('#modalNewSeo').modal('show');",
true);
137 $this->jquery->jsonOn(
"change",
"#ck-add-route", $this->
_getAdminFiles()->getAdminBaseRoute() .
"/_addRouteWithNewAction",
"post", [
"context" =>
"$('#frmNewSeo')",
"params" =>
"$('#frmNewSeo').serialize()",
"jsCondition" =>
"$('#ck-add-route').is(':checked')" ]);
138 $this->jquery->exec(Rule::ajax($this->jquery,
"checkRoute", $this->
_getAdminFiles()->getAdminBaseRoute() .
"/_checkRoute",
"{}",
"result=data.result;",
"postForm", [
"form" =>
"frmNewSeo" ]),
true);
139 $this->jquery->exec(Rule::ajax($this->jquery,
"checkController", $this->
_getAdminFiles()->getAdminBaseRoute() .
"/_checkController",
"{}",
"result=data.result;",
"postForm", [
"form" =>
"frmNewSeo" ]),
true);
140 $this->jquery->change(
"#ck-add-route",
'$("#div-new-route").toggle($(this).is(":checked"));if($(this).is(":checked")){$("#path").val($("#controllerName").val());}');
142 echo $this->jquery->compile($this->view);
149 $variables[
"%path%"]=$path;
151 $variables[
"%route%"]=
'@route("' . $path .
'")';
154 $variables[
"%sitemapTemplate%"]=
URequest::post(
"sitemapTemplate",
"Seo/sitemap.xml.html");
156 $this->
_createController($_POST[
"controllerName"], $variables,
'seoController.tpl');
166 header(
'Content-type: application/json');
167 $controller=$ctrlNS . $_POST[
"controllerName"];
169 $result[
"result"]=(\array_search($controller, $controllers) ===
false);
170 echo json_encode($result);
181 foreach ( $selections as $index ) {
182 $result[]=[
"location" => $locations[$index - 1],
"lastModified" => \strtotime($lastModified[$index - 1]),
"changeFrequency" => $changeFrequency[$index - 1],
"priority" => $priority[$index - 1] ];
185 if (isset($seoController) && $seoController instanceof
SeoController) {
186 $seoController->_save($result);
187 $r=new \ReflectionClass($seoController);
188 $this->
displaySiteMap($r->getNamespaceName(), $r->getShortName());
static isPost()
Returns true if the request is sent by the POST method.
_createController($controllerName, $variables=[], $ctrlTemplate='controller.tpl', $hasView=false)
loadView($viewName, $pData=NULL, $asString=false)
static post($key, $default=NULL)
Returns the value of the $key variable passed by the post method or $default if the $key variable doe...
static getNS($part="controllers")
createSeoController($force=null)
showSimpleMessage($content, $type, $icon="info", $timeout=NULL, $staticName=null)
static set($key, $value)
Adds or sets a value to the Session at position $key.
displaySiteMap(... $params)
static get($key, $default=NULL)
Returns the value stored at the key position in session.
static getApplicationDir()
static save($filename, $content, $flags=LOCK_EX)