Skip to content
Permalink
Browse files

Show updates for installed themes

  • Loading branch information...
Ayoola FALOLA
Ayoola FALOLA committed May 19, 2019
1 parent c14d423 commit d14994237157ef8a116fb0de57e84f5ca2cc0896
@@ -261,6 +261,8 @@ public function setXml()
$data['category_id'] = @$data['category_id'] ? : array();
$data['category_name'] = array_merge( $data['category_name'], $data['category_id'] );
$categoryText = self::getCategories( $data['category_name'], array( 'template' => $this->getParameter( 'category_template' ), 'glue' => ( $this->getParameter( 'category_template_glue' ) ? : ', ' ) ) );
$this->_objectData = $data;
$this->_objectTemplateValues = $data;
$this->_objectData['category_text'] = $categoryText;
$this->_objectTemplateValues['category_text'] = $categoryText;
$categoryText = $categoryText ? 'Category: ' . $categoryText : null;
@@ -97,6 +97,22 @@ public function init()
// $this->setViewContent( '' );
}
// check update for themes
foreach( Ayoola_Page_PageLayout::getInstance()->select() as $layout )
{
if( empty( $layout['article_url'] ) )
{
// only check update for one that is in repo
continue;
}
$url = 'https://themes.pagecarton.org/tools/classplayer/get/name/Application_Article_View?article_url=' . $layout['article_url'] . '&pc_widget_output_method=JSON';
$feed = self::fetchLink( $url, array( 'time_out' => 288000, 'connect_time_out' => 288000, ) );
$layoutInfo = json_decode( $feed, true );
if( $layoutInfo['creation_time'] !== $layout['creation_time'] )
{
$this->setViewContent( '<div style="font-size:smaller;" class="badnews">' . $layout['layout_label'] . ' theme is outdated. <a style="font-size:smaller;" onClick="ayoola.spotLight.showLinkInIFrame( this.href, \'page_refresh\' ); return false;" href="' . Ayoola_Application::getUrlPrefix() . '/tools/classplayer/get/name/Ayoola_Page_Layout_Repository?title=' . $layout['layout_label'] . '&layout_type=upload&install=' . $layout['article_url'] . '&update=' . $layout['article_url'] . '" class="">Update now!</a> </div>', true );
}
}
// end of widget process
@@ -67,22 +67,49 @@ protected function init()
{
// var_export( array( 'article_url' => @$_GET['install'] ) );
// var_export( Ayoola_Page_PageLayout::getInstance()->select( null, array( 'article_url' => @$_GET['install'] ) ) );
$layout = Ayoola_Page_PageLayout::getInstance()->selectOne( null, array( 'article_url' => @$_GET['install'] ) );
if( $layout['article_url'] === @$_GET['install'] )
$url = 'https://' . static::$_site . '/tools/classplayer/get/name/Application_Article_View?article_url=' . $_GET['install'] . '&pc_widget_output_method=JSON';
$feed = self::fetchLink( $url, array( 'time_out' => 288000, 'connect_time_out' => 288000, ) );
$allFeed = json_decode( $feed, true );
// var_export( $allFeed );
$install = 'Install';
if( ! empty( $_GET['update'] ) )
{
$install = 'Update';
}
if( $layout['article_url'] === @$_GET['install'] && empty( $_GET['update'] ) )
{
$this->setViewContent( '<h1 class="pc-heading">' . @$_GET['title'] . ' Installed</h1>' );
// $this->setViewContent( '<h1 class="pc-heading">' . @$_GET['title'] . ' Installed</h1>' );
$this->setViewContent( '<a class="pc-btn" href="#" onclick="location.search+=\'&update=' . $_GET['install'] . '\'">Update</a></p>' );
}
else
{
$this->createConfirmationForm( 'Install ' . static::$_pluginType . '', 'Download and install ' . static::$_pluginType . ' and its components' );
$this->createConfirmationForm( $install . ' ' . static::$_pluginType . '', 'Download and install latest ' . static::$_pluginType . ' files and its components' );
$this->setViewContent( '<h1 class="pc-heading">' . @$_GET['title'] . '</h1>' );
$this->setViewContent( $this->getForm()->view() );
}
$photoUrl = 'https://' . static::$_site . '/tools/classplayer/get/object_name/Application_Article_PhotoViewer/?article_url=' . $_GET['install'] . '';
$this->setViewContent( '<img style="width:100%;" src="' . $photoUrl . '&width=1500&height=600" alt="">' );
$this->setViewContent( self::getMenu() );
if( ! $values = $this->getForm()->getValues() ){ return false; }
if( ! $values = $this->getForm()->getValues() ){ return false; }
// delete first if this is upgrade
// var_export( $layout['article_url'] );
// var_export( @$_GET['update'] );
if( $layout['article_url'] === @$_GET['update'] )
{
$layout = Ayoola_Page_PageLayout::getInstance()->delete( array( 'article_url' => @$_GET['update'] ) );
var_export( $layout['article_url'] );
var_export( @$_GET['update'] );
}
$link = 'https://' . static::$_site . '/tools/classplayer/get/object_name/Application_Article_Type_Download/?article_url=' . $_GET['install'] . '&auto_download=1';
// var_export( $link );
@@ -135,6 +135,7 @@ public function createPrivateList( $data = array() )
require_once 'Ayoola/Paginator.php';
$list = new Ayoola_Paginator();
$list->pageName = $this->getObjectName();
$list->crossColumnFields = true;
$list->listTitle = 'My Themes';
// $list->noRowClass = true;
// $list->noOptionsColumn = true;
@@ -174,6 +175,7 @@ public function createPrivateList( $data = array() )
// 'Export' => '<a rel="spotlight;" onClick="ayoola.spotLight.showLinkInIFrame( \'' . Ayoola_Application::getUrlPrefix() . '/tools/classplayer/get/object_name/Ayoola_Page_Layout_Export/?' . $this->getIdColumn() . '=%KEY%\' );" title="Export Theme">Export</a>' ,
'Default' => '<a rel="" onClick="ayoola.spotLight.showLinkInIFrame( \'' . Ayoola_Application::getUrlPrefix() . '/tools/classplayer/get/object_name/Ayoola_Page_Layout_MakeDefault/?' . $this->getIdColumn() . '=%KEY%\' );" title="Make this the default site theme">Make Default</a>' ,
'Preview' => '<a rel="spotlight;" onClick="ayoola.spotLight.showLinkInIFrame( \'' . Ayoola_Application::getUrlPrefix() . '/object/name/Ayoola_Page_Layout_Preview/?' . $this->getIdColumn() . '=%KEY%\' );" title="Preview">Preview</a>' ,
'Update' => '<a rel="spotlight;" onClick="ayoola.spotLight.showLinkInIFrame( \'' . Ayoola_Application::getUrlPrefix() . '/object/name/Ayoola_Page_Layout_Repository?title={{{%layout_label%}}}&layout_type=upload&install={{{%article_url%}}}&update={{{%article_url%}}}\' );" title="Preview">Re-install</a>',
'Delete' => '<a rel="spotlight;" onClick="ayoola.spotLight.showLinkInIFrame( \'' . Ayoola_Application::getUrlPrefix() . '/tools/classplayer/get/object_name/Ayoola_Page_Layout_Delete/?' . $this->getIdColumn() . '=%KEY%\', \'' . $this->getObjectName() . '\' );" title="Delete">Delete</a>' ,
)
);
@@ -493,6 +493,8 @@ public function createList( $fields = null )
$columnReplace[] = $eachValue;
}
}
// var_export( $columnSearch );
// var_export( $columnReplace );
// $bg = $bg == '#ffffff' ? '#eeeeee' : '#ffffff';
$rowClass = @$rowClass == 'pc-table-row1' ? 'pc-table-row2' : 'pc-table-row1';
@@ -509,6 +511,7 @@ public function createList( $fields = null )
foreach( $this->getRowOptions() as $option )
{
$option = str_replace( array( '%KEY%', '%FIELD%' ), array( $row[$key], '' ), $option );
$option = str_replace( $columnSearch, $columnReplace, $option );
$optionsHtml .= '<span style="" class=""> ' . $option . ' </span> ';
}
// var_export( $fields );
@@ -590,6 +593,7 @@ public function createList( $fields = null )
$value = str_replace( '%KEY%', @$row[$key], $value );
$value = str_replace( '%PC-TABLES-ROW-OPTIONS%', $optionsHtml, $value );
$value = str_replace( $columnSearch, $columnReplace, $value );
// var_export( $value );
// if( $this->crossColumnFields )
// we want to include html here // use personal filters for this
@@ -600,6 +604,9 @@ public function createList( $fields = null )
{
// I made this to allow for links like delete, edit, etc
$value = str_replace( array( '%KEY%', '%FIELD%' ), array( $row[$key], '' ), $value );
$value = str_replace( $columnSearch, $columnReplace, $value );
var_export( $value );
$records .='<td> ' . $value . '</td>';
}
/*

0 comments on commit d149942

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