Initial commit

This commit is contained in:
Felix Förtsch
2020-10-20 14:39:50 +02:00
commit 648ded8896
1225 changed files with 216511 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
body
{
background-color: white;
}
div#wcfe-profile-edit {
}
div#wcfe-profile-edit fieldset {
border:none;
}
div#wcfe-profile-edit fieldset ul
{
list-style-type:none;
}
div#wcfe-profile-edit fieldset ul li
{
margin-bottom:16px
}
div#wcfe-profile-edit fieldset ul li label{
display:inline-block;
width: 200px
}
#profile-description
{
width: 420px;
height: 219px;
}

View File

@@ -0,0 +1,26 @@
<?php
/**
*
*/
/**
*
*/
namespace WCFE\Modules\Profiles\View\Profile\Media;
# Script resource
use WPPFW\Services\Queue\StyleResource;
/**
*
*/
class EditCSS extends StyleResource {
/**
* put your comment there...
*
* @var mixed
*/
protected $fileName = 'Edit.css';
}

View File

@@ -0,0 +1,48 @@
/**
*
*/
/**
*
*/
(function( $ )
{
/**
*
*/
var WCFEEditProfile = new function()
{
/**
*
*/
var initialize = function()
{
$( '#wcfe-profile-edit form input[type="submit"]' ).click(
function()
{
var profileId = $( '#wcfe-profile-edit form input[name="profileForm[id]"]' ).val();
if ( ! profileId && ! $( '#profile-name' ).val() )
{
alert( WCFEProfileL10N.msg_profileNameEmpty );
return false;
}
}
);
};
// Initialize form script when document lodaed
$( initialize );
};
})( jQuery );

View File

@@ -0,0 +1,26 @@
<?php
/**
*
*/
/**
*
*/
namespace WCFE\Modules\Profiles\View\Profile\Media;
# Script resource
use WPPFW\Services\Queue\ScriptResource;
/**
*
*/
class Profile extends ScriptResource {
/**
* put your comment there...
*
* @var mixed
*/
protected $fileName = 'Profile.js';
}

View File

@@ -0,0 +1,15 @@
<?php
/**
*
*/
/**
*
*/
return array
(
'msg_profileNameEmpty' => $this->__( 'Profile name cannot be empty' ),
);

View File

@@ -0,0 +1,54 @@
<?php
/**
*
*/
# Define namespace
namespace WCFE\Modules\Editor\View\Editor\Templates;
# No direct access
defined('ABSPATH') or die( WCFE\NO_DIRECT_ACCESS_MESSAGE );
$router = $this->router();
$result = $this->result();
$form =& $result[ 'form' ];
$securityToken = $result[ 'securityToken' ];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<?php do_action( 'admin_print_scripts' ); ?>
<?php do_action( 'admin_print_styles' ); ?>
</head>
<body>
<div id="wcfe-profile-edit" class="wcfe-popup-view">
<form action="<?php echo $router->route( new \WPPFW\MVC\MVCViewParams( '', '', 'Edit', '', 'Profile' ) ) ?>&caller=<?php echo $result[ 'caller' ] ?>&storageId=<?php echo $result[ 'storageId' ] ?>" method="post">
<fieldset>
<ul>
<li>
<label for="profile-name"><?php $this->_e( 'Name' ) ?></label>
<input<?php echo ( ! $result[ 'isNew' ] ? ' readonly="readonly"' : '' ) ?> type="text" id="profile-name" name="profileForm[name]" value="<?php echo $form->get( 'name' )->getValue() ?>" />
</li>
<li>
<label for="profile-description"><?php $this->_e( 'Description' ) ?></label>
<textarea id="profile-description" name="profileForm[description]"><?php echo $form->get( 'description' )->getValue() ?></textarea>
</li>
<li>
<input type="submit" name="Save" value="Save" />
</li>
</ul>
</fieldset>
<input type="hidden" name="securityToken" value="<?php echo $securityToken ?>" />
<input type="hidden" name="profileForm[id]" value="<?php echo $form->get( 'id' )->getValue() ?>" />
</form>
</div>
<?php
if ( isset( $result[ 'profile' ] ) ) :
$callbackName = $result[ 'isNew' ] ? '_onprofilecreated' : '_onprofileupdated';
?>
<script type="text/javascript"> window.parent[ '<?php echo $result[ 'caller' ] ?>' ].<?php echo $callbackName ?>( <?php echo json_encode( $result[ 'profile' ] ) ?> );</script>
<?php endif; ?>
</body>
</html>

View File

@@ -0,0 +1,82 @@
<?php
/**
*
*/
namespace WCFE\Modules\Profiles\View\Profile;
# Imports
use WPPFW\MVC\View\TemplateView;
# Dashboard script queue
use WPPFW\Services\Queue\DashboardScriptsQueue;
use WPPFW\Services\Queue\DashboardStylesQueue;
/**
*
*/
class ProfileHTMLView extends TemplateView {
/**
* put your comment there...
*
* @var mixed
*/
protected $actionsRoute = array();
/**
* put your comment there...
*
* @var mixed
*/
protected $extraExtension = '.php';
/**
* put your comment there...
*
* @var \WCFE\Libraries\ResStorage
*/
private $resFactory;
/**
* put your comment there...
*
* @var DashboardScriptsQueue
*/
private $scriptsQueue;
/**
* put your comment there...
*
* @var DashboardStylesQueue
*/
private $stylesQueue;
/**
* put your comment there...
*
*/
protected function initialize() {
# ENQUEUE SCRIPT and STYLES
$this->resFactory = new \WCFE\Libraries\ResStorage(
WP_PLUGIN_URL . '/wp-config-file-editor',
WP_PLUGIN_DIR . '/wp-config-file-editor'
);
# Scripts and Styles queues
$this->scriptsQueue = new DashboardScriptsQueue( $this, 'js', 'localization.php' );
$this->stylesQueue = new DashboardStylesQueue();
# Scripts
$this->scriptsQueue->enqueueNamedResource( \WPPFW\Services\Queue\DashboardScriptsQueue::JQUERY );
$this->scriptsQueue->enqueueNamedResource( 'jquery-serialize-object' );
$this->scriptsQueue->add( $this->resFactory->getRes( 'WCFE\Modules\Profiles\View\Profile\Media\Profile' ), true );
# Styles
$this->stylesQueue->add( $this->resFactory->getRes( 'WCFE\Modules\Profiles\View\Profile\Media\EditCSS' ) );
}
}

View File

@@ -0,0 +1,45 @@
body
{
margin-top: 10px;
}
table.wcfe-grid-table
{
width: 100%;
background-color: gray;
margin-top: 4px;
}
table.wcfe-grid-table tr th
{
background-color: #D9D9DA;
}
table.wcfe-grid-table tr td
{
background-color: white;
text-align: center;
}
.wcfe-table-grid-column-actions a {
font-size: 13px;
color: #0B9BD4;
font-weight: bold;
text-decoration: none;
}
.wcfe-table-grid-column-actions a:hover {
color: #0D5C7B;
}
#wcfe-profiles-list-menu
{
width: 80px;
font-size: 0.9em;
}
#wcfe-profiles-list-menu ul li
{
width: 90px;
}
.active-profile-state {
color: red;
font-weight: bold;
}

View File

@@ -0,0 +1,26 @@
<?php
/**
*
*/
/**
*
*/
namespace WCFE\Modules\Profiles\View\Profiles\Media;
# Script resource
use WPPFW\Services\Queue\StyleResource;
/**
*
*/
class Style extends StyleResource {
/**
* put your comment there...
*
* @var mixed
*/
protected $fileName = 'List.css';
}

View File

@@ -0,0 +1,123 @@
/**
* put your comment there...
*
*/
/**
* put your comment there...
*
* @type T_JS_FUNCTION
*/
WCFEProfilesList = new function()
{
this._onprofilecreated = function( profile )
{
window.location.reload();
}
this._onprofileupdated = function( profile )
{
window.location.reload();
};
};
/**
*
*/
jQuery( function() {
var $ = jQuery;
$( '#wcfe-profiles-list-menu' ).menu({ position: { my: "left top", at: "left bottom" },
select : function(event)
{
switch ( event.srcElement.id )
{
case 'wcfe-profiles-list-menu-delete':
if ( confirm( WCFEProfilesL10N.confirm_deleteSelected ) )
{
$( '#wcfe-grid-table-form' ).submit();
}
break;
case 'wcfe-profiles-list-menu-create':
tb_show( WCFEProfilesL10N.title_createProfile, actionsRoute[ 'editProfile' ] + '&caller=WCFEProfilesList&TB_iframe=true' );
break;
}
}
});
$( '#wcfe-table-grid-selectall' ).change(
function()
{
$( '.wcfe-grid-table input[name="id[]"]' ).prop( 'checked', $( this ).prop( 'checked' ) );
}
);
// Notify config form window
$( '.wcfe-select-profile' ).click(
function()
{
// Create compatible profile object similar to
// the one recivied by server. Aggregat
// profile data from greid row
///////// This is not currently being used however leav it for a while to make ///////
//////// sure I don't need it /////////
var profile = {};
var profileId = this.href.substring( this.href.indexOf( '#' ) + 1 );
var profileFields = $( '.wcfe-grid-table #profile-row-' + profileId + ' td span.profile-field' ).each(
function( )
{
var jField = $( this );
// Last word in last class is the field name
var fieldName = this.className.split( '-' )[ 2 ];
profile[ fieldName ] = jField.text();
}
);
// Callback with selected profile object
var callback = window.parent.WCFEEditorForm._onselectprofile;
callback( profileId );
}
);
// Edit Profile
$( '.wcfe-edit-profile' ).click(
function( event )
{
tb_show( 'Edit Profile', event.target.href + '&caller=WCFEProfilesList&TB_iframe=true' );
return false;
}
);
// Disallow deleteing active profile
var gridTable = $( '.wcfe-grid-table' );
var profile = window.parent.WCFEEditorForm.profile.getProfile()
if ( profile )
{
var activeProfileCheckbox = gridTable.find( '#profile-row-' + profile.id + ' input[type="checkbox"]');
activeProfileCheckbox.parent().append( '<span class="active-profile-state">Active</span>' );
activeProfileCheckbox.remove();
}
gridTable.show(); // Its hidding by inline style attribute
} );

View File

@@ -0,0 +1,23 @@
<?php
/**
*
*/
namespace WCFE\Modules\Profiles\View\Profiles\Media;
# Script resource
use WPPFW\Services\Queue\ScriptResource;
/**
*
*/
class Profiles extends ScriptResource
{
/**
* put your comment there...
*
* @var mixed
*/
protected $fileName = 'Profiles.js';
}

View File

@@ -0,0 +1,17 @@
<?php
/**
*
*/
/**
*
*
*/
return array
(
'confirm_deleteSelected' => $this->__( 'Would you like to delete selected profiles?' ),
'title_createProfile' => $this->__( 'Create Profile' ),
);

View File

@@ -0,0 +1,67 @@
<?php
/**
*
*/
# Define namespace
namespace WCFE\Modules\Editor\View\Editor\Templates;
# No direct access
defined('ABSPATH') or die( WCFE\NO_DIRECT_ACCESS_MESSAGE );
$result = $this->result();
$router = $this->router();
$profiles = $result[ 'profiles' ];
$securityNonce = $result[ 'securityNonce' ];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<?php do_action( 'admin_print_scripts' ); ?>
<?php do_action( 'admin_print_styles' ); ?>
</head>
<body>
<div id="wcfe-profiles-list" class="wcfe-popup-view">
<ul id="wcfe-profiles-list-menu">
<li><?php $this->_e( 'Actions' ) ?>
<ul>
<li id="wcfe-profiles-list-menu-delete"><?php $this->_e( 'Delete' ) ?></li>
<li id="wcfe-profiles-list-menu-create"><?php $this->_e( 'Create' ) ?></li>
</ul>
</li>
</ul>
<form id="wcfe-grid-table-form" action="<?php echo $router->routeAction() ?>" method="post">
<table class="wcfe-grid-table" style="display: none;" cellpadding="4" cellspacing="2">
<thead>
<tr>
<th><?php $this->_e( 'Name' ) ?></th>
<th><?php $this->_e( 'escription' ) ?></th>
<th><?php $this->_e( 'ID' ) ?></th>
<th><input type="checkbox" id="wcfe-table-grid-selectall" /></th>
</tr>
</thead>
<tbody>
<?php foreach ( $profiles as $profile ) : ?>
<tr id="profile-row-<?php echo $profile->id ?>">
<td>
<span class="profile-field profile-name"><?php echo $profile->name ?></span>
<div class="wcfe-table-grid-column-actions">
<a class="wcfe-edit-profile" href="<?php echo $router->route( new \WPPFW\MVC\MVCViewParams( '', '', 'Edit', '', 'Profile' ) ) ?>&id=<?php echo $profile->id ?>"><?php $this->_e( 'Edit' ) ?></a> |
<a class="wcfe-select-profile" href="#<?php echo $profile->id ?>"><?php $this->_e( 'Load' ) ?></a>
</div>
</td>
<td><span class="profile-field profile-description"><?php echo $profile->description ?></span></td>
<td><span class="profile-field profile-id"><?php echo $profile->id ?></span></td>
<td><input type="checkbox" name="id[]" value="<?php echo $profile->id ?>" /></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="securityNonce" value="<?php echo $result[ 'securityNonce' ] ?>" />
</form>
</div>
<script type="text/javascript">var actionsRoute = <?php echo json_encode( $this->actionsRoute ) ?>;</script>
<?php do_action( 'admin_print_footer_scripts' ) ?>
</body>
</html>

View File

@@ -0,0 +1,140 @@
<?php
/**
*
*/
namespace WCFE\Modules\Profiles\View\Profiles;
# Imports
use WPPFW\MVC\View\TemplateView;
# Dashboard script queue
use WPPFW\Services\Queue\DashboardScriptsQueue;
use WPPFW\Services\Queue\DashboardStylesQueue;
/**
*
*/
class ProfilesHTMLView extends TemplateView {
/**
* put your comment there...
*
* @var mixed
*/
protected $actionsRoute = array();
/**
* put your comment there...
*
* @var mixed
*/
protected $extraExtension = '.php';
/**
* put your comment there...
*
* @var \WCFE\Libraries\ResStorage
*/
private $resFactory;
/**
* put your comment there...
*
* @var DashboardScriptsQueue
*/
private $scriptsQueue;
/**
* put your comment there...
*
* @var DashboardStylesQueue
*/
private $stylesQueue;
/**
* put your comment there...
*
*/
protected function initialize() {
# ENQUEUE SCRIPT and STYLES
$this->resFactory = new \WCFE\Libraries\ResStorage(
WP_PLUGIN_URL . '/wp-config-file-editor',
WP_PLUGIN_DIR . '/wp-config-file-editor'
);
# Scripts and Styles queues
$this->scriptsQueue = new DashboardScriptsQueue( $this, 'js', 'localization.php' );
$this->stylesQueue = new DashboardStylesQueue();
# Scripts
$this->scriptsQueue->enqueueNamedResource( \WPPFW\Services\Queue\DashboardScriptsQueue::JQUERY );
$this->scriptsQueue->enqueueNamedResource( DashboardScriptsQueue::THICK_BOX );
$this->scriptsQueue->add( $this->resFactory->getRes( 'WCFE\Libraries\JavaScript\jQueryMenu' ) );
$this->scriptsQueue->add( $this->resFactory->getRes( 'WCFE\Modules\Profiles\View\Profiles\Media\Profiles' ), true );
# Styles
$this->stylesQueue->enqueueNamedResource( DashboardStylesQueue::THICK_BOX );
$this->stylesQueue->add( $this->resFactory->getRes( 'WCFE\Libraries\CSS\jQuery\Theme\Theme' ) );
$this->stylesQueue->add( $this->resFactory->getRes( 'WCFE\Modules\Profiles\View\Profiles\Media\Style' ) );
# Actions route
$this->setActionsRoute(
'Profiles', 'profilesView', array
(
'editProfile' => array( 'action' => 'Edit', 'view' => 'Profile' )
)
);
}
/**
* put your comment there...
*
* @param mixed $moduleName
* @param mixed $serviceObjectName
* @param mixed $actionsList
* @return EditorHTMLView
*/
private function & setActionsRoute( $moduleName, $serviceObjectName, $actionsList )
{
$args = func_get_args();
for ( $argIndex = 0; $argIndex < count( $args ); $argIndex += 3 )
{
$serviceRouter = $this->router()->findRouter( $args[ $argIndex ], $args[ $argIndex + 1 ] );
foreach ( ( $args[ $argIndex + 2 ] ) as $key => $route )
{
$route = array_merge( array( 'action' => '', 'controller' => '', 'module' => '', 'view' => '', 'format' => '' ), $route );
$this->actionsRoute[ $key ] = (string) $serviceRouter->route
(
new \WPPFW\MVC\MVCViewParams
(
$route[ 'module' ],
$route[ 'controller' ],
$route[ 'action' ],
$route[ 'format' ],
$route[ 'view' ]
)
);
}
}
return $this;
}
}