Skip to content
Permalink
Browse files

Save Page Widgets

  • Loading branch information...
Ayoola FALOLA
Ayoola FALOLA committed May 28, 2019
1 parent 4c7076f commit 06b23c2bde219396df177ef41aecd6b3dacd06f3
@@ -1137,7 +1137,7 @@ protected static function getViewableObjectRepresentation( array $object )
if( ! empty( $_REQUEST['rebuild_widget_box'] ) && @$object['pagewidget_id_switch'] )
{
// var_export( $object );
$object = $pageWidgetToRestore['parameters'];
$object = $pageWidgetToRestore['parameters'];
$object['widget_options'][] = 'savings';
$object['pagewidget_id'] = $pageWidgetToRestore['pagewidget_id'];
@@ -1149,7 +1149,7 @@ protected static function getViewableObjectRepresentation( array $object )
{
// var_export( $object );
$object = $pageWidgetToRestore['parameters'];
$object['widget_options'][] = 'savings';
// $object['widget_options'][] = 'savings';
$object['pagewidget_id'] = $pageWidgetToRestore['pagewidget_id'];
// avoid double saves
@@ -25,7 +25,7 @@ class Ayoola_Object_PageWidget extends PageCarton_Table
*
* @param string
*/
protected $_tableVersion = '0.1';
protected $_tableVersion = '0.2';
/**
* Table data types and declaration
@@ -39,6 +39,7 @@ class Ayoola_Object_PageWidget extends PageCarton_Table
'parameters' => 'JSON',
'parameters_key' => 'INPUTTEXT',
'widget_name' => 'INPUTTEXT',
'history' => 'JSON',
);
@@ -908,7 +908,8 @@ public function getLayoutRepresentation()
if( empty( $parameters['widget_name'] ) )
{
$parameters['widget_name'] = ( ( $parameters['preserved_content'] ? : $parameters['codes'] ) ? : $parameters['editable'] ) ? : implode( ' - ', $parameters );
$parameters['widget_name'] = trim( strip_tags( $parameters['widget_name'] ) ) ? : ( $eachObject['class_name'] ) . ' - ' . $numberedSectionName;
$parameters['widget_name'] = strip_tags( $parameters['widget_name'] ) ? : ( $eachObject['class_name'] ) . ' - ' . $numberedSectionName;
$parameters['widget_name'] = trim( preg_replace( '|(\s)*|', ' ', $parameters['widget_name'] ) );
}
else
{
@@ -944,12 +945,17 @@ public function getLayoutRepresentation()
}
elseif(
! empty( $parameters['pagewidget_id'] ) && Ayoola_Object_PageWidget::getInstance()->select( null, array( 'pagewidget_id' => $parameters['pagewidget_id'] ) )
! empty( $parameters['pagewidget_id'] ) AND $previousWidgetInfo = Ayoola_Object_PageWidget::getInstance()->select( null, array( 'pagewidget_id' => $parameters['pagewidget_id'] ) )
)
{
// var_export( $parameters['widget_name'] );
// var_export( $parametersKey );
// var_export( $whatToSave );
// var_export( $whatToSave );
// save history
$previousWidgetInfo['history'][time()] = $whatToSave['parameters'];
$whatToSave['history'] = $previousWidgetInfo['history'];
// update
$response = Ayoola_Object_PageWidget::getInstance()->update( $whatToSave, array( 'pagewidget_id' => $parameters['pagewidget_id'] ) );
}

0 comments on commit 06b23c2

Please sign in to comment.
You can’t perform that action at this time.