-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
arikaim
committed
Jan 29, 2022
1 parent
1cd8773
commit 3f91ffc
Showing
31 changed files
with
582 additions
and
582 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: arikaim-cms | ||
ko_fi: arikaim | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: arikaim-cms | ||
ko_fi: arikaim | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,116 @@ | ||
<?php | ||
/** | ||
* Arikaim | ||
* | ||
* @link http://www.arikaim.com | ||
* @copyright Copyright (c) Konstantin Atanasov <info@arikaim.com> | ||
* @license http://www.arikaim.com/license | ||
* | ||
*/ | ||
namespace Arikaim\Extensions\Editor\Controllers; | ||
|
||
use Arikaim\Core\Utils\File; | ||
use Arikaim\Core\Controllers\ControlPanelApiController; | ||
|
||
/** | ||
* Files control panel controller | ||
*/ | ||
class FilesControlPanel extends ControlPanelApiController | ||
{ | ||
/** | ||
* Init controller | ||
* | ||
* @return void | ||
*/ | ||
public function init() | ||
{ | ||
$this->loadMessages('editor::admin.messages'); | ||
} | ||
|
||
/** | ||
* Load template file (css,js) | ||
* | ||
* @param \Psr\Http\Message\ServerRequestInterface $request | ||
* @param \Psr\Http\Message\ResponseInterface $response | ||
* @param Validator $data | ||
* @return Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function loadFileController($request, $response, $data) | ||
{ | ||
$this->onDataValid(function($data) { | ||
$theme = $data->get('theme'); | ||
$type = $data->get('type','css'); | ||
$fileName = $data->get('name'); | ||
|
||
$packageManager = $this->get('packages')->create('template'); | ||
$package = $packageManager->createPackage($theme); | ||
if (\is_object($package) == false) { | ||
$this->error('errors.theme_name'); | ||
return false; | ||
} | ||
$properties = $package->getProperties(true); | ||
$filePath = $properties['path'] . $type . DIRECTORY_SEPARATOR . $fileName; | ||
|
||
$fileContent = File::read($filePath); | ||
|
||
$this->setResponse(($fileContent != null),function() use($fileName,$theme,$fileContent,$type) { | ||
$this | ||
->message('file.load') | ||
->field('theme',$theme) | ||
->field('type',$type) | ||
->field('file_name',$fileName) | ||
->field('content',$fileContent); | ||
},'errors.load'); | ||
}); | ||
$data | ||
->addRule('text:min=2','theme') | ||
->addRule('text:min=1','file_name') | ||
->validate(); | ||
} | ||
|
||
/** | ||
* Save template file (css,js) | ||
* | ||
* @param \Psr\Http\Message\ServerRequestInterface $request | ||
* @param \Psr\Http\Message\ResponseInterface $response | ||
* @param Validator $data | ||
* @return Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function saveFileController($request, $response, $data) | ||
{ | ||
$this->onDataValid(function($data) { | ||
$theme = $data->get('theme'); | ||
$type = $data->get('type','css'); | ||
$fileName = $data->get('file_name'); | ||
$content = $data->get('content',''); | ||
|
||
$packageManager = $this->get('packages')->create('template'); | ||
$package = $packageManager->createPackage($theme); | ||
if (\is_object($package) == false) { | ||
$this->error('errors.theme_name'); | ||
return false; | ||
} | ||
$properties = $package->getProperties(true); | ||
$filePath = $properties['path'] . $type . DIRECTORY_SEPARATOR . $fileName; | ||
|
||
if (File::isWritable($filePath) == false) { | ||
File::setWritable($filePath); | ||
} | ||
|
||
$result = File::write($filePath,$content); | ||
|
||
$this->setResponse($result,function() use($fileName,$theme,$content,$type) { | ||
$this | ||
->message('file.save') | ||
->field('theme',$theme) | ||
->field('type',$type) | ||
->field('file_name',$fileName) | ||
->field('content',$content); | ||
},'errors.file.save'); | ||
}); | ||
$data | ||
->addRule('text:min=2','theme') | ||
->addRule('text:min=1','file_name') | ||
->validate(); | ||
} | ||
} | ||
<?php | ||
/** | ||
* Arikaim | ||
* | ||
* @link http://www.arikaim.com | ||
* @copyright Copyright (c) Konstantin Atanasov <info@arikaim.com> | ||
* @license http://www.arikaim.com/license | ||
* | ||
*/ | ||
namespace Arikaim\Extensions\Editor\Controllers; | ||
|
||
use Arikaim\Core\Utils\File; | ||
use Arikaim\Core\Controllers\ControlPanelApiController; | ||
|
||
/** | ||
* Files control panel controller | ||
*/ | ||
class FilesControlPanel extends ControlPanelApiController | ||
{ | ||
/** | ||
* Init controller | ||
* | ||
* @return void | ||
*/ | ||
public function init() | ||
{ | ||
$this->loadMessages('editor::admin.messages'); | ||
} | ||
|
||
/** | ||
* Load template file (css,js) | ||
* | ||
* @param \Psr\Http\Message\ServerRequestInterface $request | ||
* @param \Psr\Http\Message\ResponseInterface $response | ||
* @param Validator $data | ||
* @return Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function loadFileController($request, $response, $data) | ||
{ | ||
$this->onDataValid(function($data) { | ||
$theme = $data->get('theme'); | ||
$type = $data->get('type','css'); | ||
$fileName = $data->get('name'); | ||
|
||
$packageManager = $this->get('packages')->create('template'); | ||
$package = $packageManager->createPackage($theme); | ||
if (\is_object($package) == false) { | ||
$this->error('errors.theme_name'); | ||
return false; | ||
} | ||
$properties = $package->getProperties(true); | ||
$filePath = $properties['path'] . $type . DIRECTORY_SEPARATOR . $fileName; | ||
|
||
$fileContent = File::read($filePath); | ||
|
||
$this->setResponse(($fileContent != null),function() use($fileName,$theme,$fileContent,$type) { | ||
$this | ||
->message('file.load') | ||
->field('theme',$theme) | ||
->field('type',$type) | ||
->field('file_name',$fileName) | ||
->field('content',$fileContent); | ||
},'errors.load'); | ||
}); | ||
$data | ||
->addRule('text:min=2','theme') | ||
->addRule('text:min=1','file_name') | ||
->validate(); | ||
} | ||
|
||
/** | ||
* Save template file (css,js) | ||
* | ||
* @param \Psr\Http\Message\ServerRequestInterface $request | ||
* @param \Psr\Http\Message\ResponseInterface $response | ||
* @param Validator $data | ||
* @return Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function saveFileController($request, $response, $data) | ||
{ | ||
$this->onDataValid(function($data) { | ||
$theme = $data->get('theme'); | ||
$type = $data->get('type','css'); | ||
$fileName = $data->get('file_name'); | ||
$content = $data->get('content',''); | ||
|
||
$packageManager = $this->get('packages')->create('template'); | ||
$package = $packageManager->createPackage($theme); | ||
if (\is_object($package) == false) { | ||
$this->error('errors.theme_name'); | ||
return false; | ||
} | ||
$properties = $package->getProperties(true); | ||
$filePath = $properties['path'] . $type . DIRECTORY_SEPARATOR . $fileName; | ||
|
||
if (File::isWritable($filePath) == false) { | ||
File::setWritable($filePath); | ||
} | ||
|
||
$result = File::write($filePath,$content); | ||
|
||
$this->setResponse($result,function() use($fileName,$theme,$content,$type) { | ||
$this | ||
->message('file.save') | ||
->field('theme',$theme) | ||
->field('type',$type) | ||
->field('file_name',$fileName) | ||
->field('content',$content); | ||
},'errors.file.save'); | ||
}); | ||
$data | ||
->addRule('text:min=2','theme') | ||
->addRule('text:min=1','file_name') | ||
->validate(); | ||
} | ||
} |
Oops, something went wrong.