Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage DaisyUI themes added #98

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions src/legacy/dev-application/controllers/CreatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,65 @@ public function indexAction()
//LOAD SETTINGS
$settings = $this->renderToTable("settings", "id, settingName, description, value", $this->_translate->_("Add new Setting"), array('add' => '', 'edit' => '', 'delete' => 'creator/delete-setting/') );
$this->view->settings = $settings;
}

public function addNewDaisyAction()
{
$this->_checkAccess();

//$taiwlindConf = file_get_contents($this->_nps . '../tailwind.config.js');

}

public function saveDaisyThemesAction()
{
$this->_checkAccess();
if ( !$this->_request->isPost() ) return;
$themes = $this->_request->getPost('themes');

// turn off layout and ViewRenderer
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();

$currentTaiwlindConf = file_get_contents($this->_nps . '../tailwind.config.js');

$filename = NET_PATH_SITE . '../tailwind.config.js';
$themesString = implode( '","', $themes );
$themesString = '"' . $themesString . '"';
$taiwlindConf = $currentTaiwlindConf;

$taiwlindConf = preg_replace('/themes:\s\[(.)*\]/', 'themes: [' . $themesString . ']' , $taiwlindConf);

if (!$handle = fopen($filename, 'w+')) {
//$message = "Cannot open file ($filename)";
//return $message;
exit;
}

// Write to opened file.
if (fwrite($handle, $taiwlindConf) === FALSE) {
//$message = "Cannot write to file ($filename)";
//return $message;
exit;
}

//$message = "Success, wrote tailwind configuration.";
//return $message;
fclose($handle);
}

public function manageAllPagesAction()
{
$this->_checkAccess();
// turn off layout and ViewRenderer
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$this->_helper->viewRenderer->setNoRender();
$settings = $this->renderToTableManagePages("pages_" . $this->_sesija->langAdmin, "id, title, alias, image, homepage, check_access, published", "Add new Page", array('add' => '', 'edit' => '', 'delete' => 'creator/delete-page/') );
echo $settings;
}


private function _backupCSS($css)
private function _backupCSS($css)
{
$filename = NET_PATH_SITE . 'css/userCSS/default_' . $this->_sesija->loggedUser . '.css.bak';
$somecontent = $css;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<ul id="daisyui-themes-changer" tabindex="0" class="dropdown-content z-[99] p-2 shadow-2xl bg-base-300 rounded-box w-auto">
<?php echo $this->daisyuiThemes; ?>
<li>
<a id="add-new-daisy" class="theme-controller btn btn-sm btn-block btn-ghost justify-center text-green-600" title="<?php echo $this->translate->_("THIS FEATURE WILL BE ADDED SOON.");?>">
<a id="add-new-daisy" class="navLinks help theme-controller btn btn-sm btn-block btn-ghost justify-center text-green-600" title="<?php echo $this->translate->_("Manage DaisyUI themes");?>">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-6">
<path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 9a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25V15a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V9Z" clip-rule="evenodd" />
</svg>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<div>
<ul id="manage-daisy-themes">
<?php echo $this->daisyuiThemes;?>
</ul>
<div class="divider"></div>
<div class="grid grid-cols-4">
<div class="col-span-3">
<label for="add-new-daisy-input">Add new theme</label>
<input id="add-new-daisy-input" type="text" class="input input-sm mt-2 w-full" name="add-new-daisy-input" />
</div>
<div class="flex col-span-1 items-end">
<button id="add-daisy-theme" class="btn btn-primary btn-sm w-full">Add</button>
</div>
</div>
<div class="divider"></div>
<button id="save-daisy-themes" class="btn btn-primary btn-sm w-full mt-2 mb-2">Save</button>
</div>
<script>
$('#manage-daisy-themes li').each(function(k,v){
$(v).attr( 'id', 'daisy-theme-li_' + k ).addClass('relative').append('<a id="daisy-theme-a_' + k + '" href="#" class="btn btn-xs btn-error absolute right-1 top-1 remove-theme">X</a>');
});

$('.remove-theme').livequery('click', function(e){
$(e.target).closest('li').remove();
});

$('#add-daisy-theme').on('click', function(){
$('#manage-daisy-themes').append('<li id="daisy-theme-li_' + $('#manage-daisy-themes').children().length + '" class="relative"><input type="radio" name="theme-dropdown" class="theme-controller btn btn-sm btn-block btn-ghost justify-center" aria-label="' + $('#add-new-daisy-input').val() + '" value="' + $('#add-new-daisy-input').val().toLowerCase() + '"><a id="daisy-theme-a_' + $('#manage-daisy-themes').children().length + '" href="#" class="btn btn-xs btn-error absolute right-1 top-1 remove-theme">X</a></li>');
$('#add-new-daisy-input').val('');
});

$('#save-daisy-themes').on('click', function(){
let themes = new Array();

$('#manage-daisy-themes').children().each(function(k,v){

themes.push($(v).find('input').val());
});

$.ajax({
method: "POST",
url: absoluteUrl + "creator/save-daisy-themes",
data: { themes: themes }
}).done(function( msg ) {

let dropdownToReplace = $('#manage-daisy-themes').html() + '<li><a id="add-new-daisy" class="navLinks help theme-controller btn btn-sm btn-block btn-ghost justify-center text-green-600" title="Manage DaisyUI themes"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-6"><path fill-rule="evenodd" d="M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 9a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25V15a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V9Z" clip-rule="evenodd"></path></svg></a></li>';
$('#daisyui-themes-changer').html( dropdownToReplace );
$('#daisyui-themes-changer').find('.remove-theme').remove();
});
});
</script>
16 changes: 14 additions & 2 deletions src/legacy/dev-application/views/scripts/creator/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3437,8 +3437,20 @@ $('#objList').livequery('click', function(e){
$('#'+ selectedObjID ).trigger('mouseover'); // triger refresh of classes in ID assistant
});

$('#add-new-daisy').livequery('click', function(){
ajaxEventDone('THIS FEATURE WILL BE ADDED SOON.');
$('a#add-new-daisy').livequery('click', function(e){
$('#dialogDiv').remove();

$('body').append('<div id="dialogDiv" class="bg-accent text-accent-content"></div>');
$('#dialogDiv').html($('#adminAjaxLoader').html());
dialog();
$.get(absoluteUrl + "creator/add-new-daisy", function(data) {
$('#dialogDiv').html(data);
$('#ajaxEventMask').remove();
});

$('#dialogDiv').dialog( 'option', 'title', $(e.currentTarget).prop('title') );
$('#dialogDiv').show('slow');

});

$('#movePointer').livequery('click', function(){
Expand Down