Skip to content

Commit

Permalink
check for urls file
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheron committed Mar 10, 2018
1 parent e05c49a commit 9f7bd0b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
21 changes: 18 additions & 3 deletions Ubiquity/controllers/admin/UbiquityMyAdminBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,25 @@ protected function _seo(){
$dtCtrl->setFields(['name','urlsFile','siteMapTemplate','route','inRobots','see']);
$dtCtrl->setIdentifierFunction('getName');
$dtCtrl->setCaptions(['Controller name','Urls file','SiteMap template','Route','In robots?','']);
$dtCtrl->fieldAsLabel('route','car');
$dtCtrl->fieldAsLabel('route','car',['jsCallback'=>function($lbl,$instance,$i,$index){if($instance->getRoute()==""){$lbl->setProperty('style','display:none;');}}]);
$dtCtrl->fieldAsCheckbox('inRobots',['type'=>'toggle','disabled'=>true]);
$dtCtrl->setValueFunction('see',function($value,$instance,$index){$bt=new HtmlButton('see-'.$index,'','_see circular basic right floated');$bt->setProperty("data-ajax", $instance->getName());$bt->asIcon('eye'); return $bt;});

$dtCtrl->setValueFunction('see',function($value,$instance,$index){
if($instance->urlExists()){
$bt=new HtmlButton('see-'.$index,'','_see circular basic right floated');
$bt->setProperty("data-ajax", $instance->getName());
$bt->asIcon('eye');
return $bt;
}
});
$dtCtrl->setValueFunction('urlsFile', function($value,$instance,$index){
if(!$instance->urlExists()){
$elm=new HtmlSemDoubleElement('urls-'.$index,'span','',$value);
$elm->addIcon("warning circle red");
$elm->addPopup("Missing",$value.' is missing!');
return $elm;
}
return $value;
});
$dtCtrl->addDeleteButton(false,[],function($bt){$bt->setProperty('class','ui circular basic red right floated icon button _delete');});
$dtCtrl->setTargetSelector(["delete"=>"#messages"]);
$dtCtrl->setUrls(["delete"=>$this->_getAdminFiles()->getAdminBaseRoute()."/deleteSeoController"]);
Expand Down
5 changes: 5 additions & 0 deletions Ubiquity/controllers/admin/popo/ControllerSeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Ubiquity\controllers\Router;
use Ubiquity\utils\base\UFileSystem;
use Ubiquity\utils\base\UString;
use Ubiquity\controllers\seo\SeoController;

class ControllerSeo{
private $name;
Expand Down Expand Up @@ -88,6 +89,10 @@ public function getPath(){
$parts=\explode("\\", $this->name);
return end($parts);
}

public function urlExists(){
return CacheManager::$cache->exists($this->urlsFile);
}

public static function init(){
$result=[ ];
Expand Down
4 changes: 3 additions & 1 deletion Ubiquity/controllers/admin/traits/SeoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public function displaySiteMap(...$params) {
$dt->setSubmitParams($this->_getAdminFiles()->getAdminBaseRoute() . "/saveUrls", "#seo-details", [ 'attr' => '' ]);
$this->jquery->execOn("click", "#saveUrls", '$("#frm-dtSiteMap").form("submit");');
$this->jquery->exec('$("#displayAllRoutes").checkbox();',true);
$this->jquery->click('#displayAllRoutes', '$(".toToggle").toggle();');
$this->jquery->execOn('change', 'input[name="selection[]"]', '$(this).parents("tr").toggleClass("_checked",$(this).prop("checked"));');
$this->jquery->click('#displayAllRoutes', '$(".toToggle:not(._checked)").toggle();');
$this->jquery->execAtLast($this->jquery->execOn('change', '#frm-dtSiteMap input', '$("#saveUrls").show();',["immediatly"=>false]));
$this->jquery->compile($this->view);

$this->loadView($this->_getAdminFiles()->getViewSeoDetails(), [ "controllerClass" => $controllerClass,"urlsFile" => $controllerSeo->_getUrlsFilename() ]);
Expand Down
6 changes: 5 additions & 1 deletion Ubiquity/controllers/seo/SeoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public function _getArrayUrls() {
* @return string
*/
public function _getUrlsFilename() {
return self::SEO_PREFIX . DS . $this->urlsKey;
return self::getUrlsFileName($this->urlsKey);
}

public static function getUrlsFileName($urlsKey){
return self::SEO_PREFIX.DS.$urlsKey;
}

/**
Expand Down

0 comments on commit 9f7bd0b

Please sign in to comment.