Skip to content

Commit

Permalink
Merge pull request #6 from issuu/add-documents-info-inside-update-stack
Browse files Browse the repository at this point in the history
FIX: add documents info inside update stack
  • Loading branch information
augustovicente authored May 10, 2024
2 parents d3ac4a9 + 948524e commit 3bb0357
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 16 deletions.
6 changes: 3 additions & 3 deletions issuu-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Plugin Name: Issuu Panel
Plugin URI: https://github.com/issuu/issuu-panel
Description: Admin panel for Issuu. You can upload your documents, create folders and embed documents in posts.
Version: 2.0.1
Version: 2.1.0
Author: Pedro Marcelo and Issuu
Author URI: https://issuu.com
License: GPL3
*/

if (defined('ISSUU_PANEL_VERSION'))
{
switch (version_compare(ISSUU_PANEL_VERSION, '2.0.1')) {
switch (version_compare(ISSUU_PANEL_VERSION, '2.1.0')) {
case -1:
wp_die("A lower version of Issuu Panel plugin is already installed");
break;
Expand All @@ -30,7 +30,7 @@
|--------------------------------------
*/

define('ISSUU_PANEL_VERSION', '2.0.1');
define('ISSUU_PANEL_VERSION', '2.1.0');
define('ISSUU_PANEL_DIR', plugin_dir_path(__FILE__));
define('ISSUU_PANEL_URL', plugin_dir_url(__FILE__));
define('ISSUU_PANEL_PREFIX', 'issuu_painel_');
Expand Down
47 changes: 42 additions & 5 deletions issuuservice-lib/lib/class.issuufolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,50 @@ protected function returnSingleResult($params)
$stackId = $params['folderId'];
$this->setParams($params);

$response = $this->curlRequest(
$response_stack = $this->curlRequest(
$this->getApiUrl('/stacks/'.$stackId),
array(),
$this->headers
);
$response = json_decode($response, true);
$response_stack = json_decode($response_stack, true);

if(isset($response['id']))
if(isset($response_stack['id']))
{
$result['stat'] = 'ok';
$result['stack'] = $this->clearObjectJson($response);
$result['stack'] = $this->clearObjectJson($response_stack);

// get stack items
$response_stack_items = $this->curlRequest(
$this->getApiUrl('/stacks/'.$stackId.'/items'),
array(
'includeUnlisted' => 'true',
),
$this->headers
);
$response_stack_items = json_decode($response_stack_items, true);

$stack_items = $this->clearObjectJson($response_stack_items)->results;
// get data from each document
foreach($stack_items as $item)
{
$result_document = $this->curlRequest(
$this->getApiUrl('/publications/'.$item),
array(),
$this->headers
);

$document = json_decode($result_document, true);
$document = $this->clearObjectJson($document);
$documents[] = $document;
}

$result['documents'] = $documents;

return $result;
}
else
{
return $this->returnErrorJson($response);
return $this->returnErrorJson($response_stack);
}
}

Expand Down Expand Up @@ -212,6 +239,16 @@ protected function clearObjectJson($folder)
{
$fold = (object) $folder;

if(isset($doc->cover['small'])) {
$fold->coverImage = $fold->cover['small']['url'];
}
if(isset($fold->cover['medium'])) {
$fold->coverImage = $fold->cover['medium']['url'];
}
if(isset($fold->cover['large'])) {
$fold->coverImage = $fold->cover['large']['url'];
}

return $fold;
}

Expand Down
5 changes: 2 additions & 3 deletions menu/folder/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ private function addPage()
private function updatePage()
{
$issuuFolder = $this->getConfig()->getIssuuServiceApi('IssuuFolder');
$issuuBookmark = $this->getConfig()->getIssuuServiceApi('IssuuBookmark');
$folderId = filter_input(INPUT_GET, 'folder');
$folder = $issuuFolder->getUpdateData(array('folderId' => $folderId));
$params = $issuuFolder->getParams();
Expand All @@ -56,10 +55,10 @@ private function updatePage()

if ($folder['stat'] == 'ok')
{
$bookmarks = $issuuBookmark->issuuList(array('folderId' => $folderId));
$folders_documents = $folder['documents'];
$folder = $folder['stack'];
$image = 'https://image.issuu.com/%s/jpg/page_1_thumb_large.jpg';
include(ISSUU_PANEL_DIR . 'menu/folder/forms/update.php');
include(ISSUU_PANEL_DIR . 'menu/folder/forms/update.php');
}
else
{
Expand Down
10 changes: 5 additions & 5 deletions menu/folder/forms/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
</tr>
</tbody>
</table>
<?php if (isset($folders_documents['documentsId']) && !empty($folders_documents['documentsId'])) : ?>
<?php if (isset($folders_documents) && !empty($folders_documents)) : ?>
<h3>Shortcode</h3>
<input type="text" class="code shortcode" disabled size="70"
value='[issuu-panel-folder-list id="<?php echo $folder->folderId; ?>"]'>
value='[issuu-panel-folder-list id="<?php echo $folder->id; ?>"]'>
<?php endif; ?>
<div id="document-list">
<?php if (isset($folders_documents['documentsId']) && !empty($folders_documents['documentsId'])) : ?>
<?php if (isset($folders_documents) && !empty($folders_documents)) : ?>
<h3><?php the_issuu_message("Folder's documents"); ?></h3>
<?php foreach ($folders_documents['documentsId'] as $doc) : ?>
<?php foreach ($folders_documents as $doc) : ?>
<div class="document complete">
<div class="document-box">
<img src="<?php echo sprintf($image, $doc->documentId) ?>" alt="">
<img src="<?php echo $doc->coverImage ?>" alt="">
</div>
<p class="description"><?php echo $doc->title ?></p>
</div>
Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ You can send the translation by e-mail. Send for [email protected]

== Changelog ==

= 2.1.0 =
* Updated: show documents information inside folders

= 2.0.1 =
* Updated: allow customizing show detected links option while creating and editing documents

Expand Down

0 comments on commit 3bb0357

Please sign in to comment.