first commit
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Unlimited Elements
|
||||
* @author unlimited-elements.com
|
||||
* @copyright (C) 2021 Unlimited Elements, All Rights Reserved.
|
||||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
||||
* */
|
||||
defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
|
||||
|
||||
class UniteCreatorActivationView extends UniteElementsBaseUC{
|
||||
|
||||
const CODE_TYPE_ACTIVATION = "activation";
|
||||
const CODE_TYPE_ENVATO = "envato";
|
||||
const CODE_TYPE_FREEMIUS = "freemius";
|
||||
const CODE_TYPE_UPRESS = "upress";
|
||||
|
||||
protected $urlPricing;
|
||||
protected $urlSupport;
|
||||
protected $textGoPro, $textAndTemplates, $textPasteActivationKey, $textPlaceholder;
|
||||
protected $textLinkToBuy, $textDontHave, $textActivationFailed, $textActivationCode;
|
||||
protected $codeType = self::CODE_TYPE_ACTIVATION;
|
||||
protected $product;
|
||||
protected $isExpireEnabled = true, $textSwitchTo;
|
||||
protected $writeRefreshPageMessage = true;
|
||||
protected $textDontHaveLogin, $textLinkToLogin, $urlLogin;
|
||||
protected $textUnleash, $textActivate, $textYourProAccountLifetime;
|
||||
protected $showCodeInput = true;
|
||||
protected $simpleButtonMode = false;
|
||||
|
||||
|
||||
/**
|
||||
* init the variables
|
||||
*/
|
||||
public function __construct(){
|
||||
|
||||
$this->urlPricing = GlobalsUC::URL_BUY;
|
||||
$this->urlSupport = GlobalsUC::URL_SUPPORT;
|
||||
|
||||
$this->textActivate = esc_html__("Activate Blox Pro", "unlimited-elements-for-elementor");
|
||||
|
||||
$this->textGoPro = esc_html__("GO PRO", "unlimited-elements-for-elementor");
|
||||
$this->textUnleash = esc_html__("Unleash access to +700 addons,", "unlimited-elements-for-elementor");
|
||||
|
||||
$this->textAndTemplates = esc_html__("+100 page templates and +50 section designs", "unlimited-elements-for-elementor");
|
||||
|
||||
$this->textPasteActivationKey = esc_html__("Paste your activation key here", "unlimited-elements-for-elementor");
|
||||
|
||||
$this->textPlaceholder = "xxxx-xxxx-xxxx-xxxx";
|
||||
$this->textLinkToBuy = esc_html__("View our pricing plans", "unlimited-elements-for-elementor");
|
||||
|
||||
$this->textDontHave = esc_html__("Don't have a pro activation key?", "unlimited-elements-for-elementor");
|
||||
|
||||
$this->textDontHaveLogin = esc_html__("If you already purchased, get the key from my account?", "unlimited-elements-for-elementor");
|
||||
$this->textLinkToLogin = esc_html__("Go to My Account", "unlimited-elements-for-elementor");
|
||||
$this->urlLogin = "http://my.unitecms.net";
|
||||
|
||||
$this->textActivationFailed = esc_html__("You probably got your activation code wrong", "unlimited-elements-for-elementor");
|
||||
|
||||
$this->textYourProAccountLifetime = esc_html__("Your pro account is activated lifetime for this site", "unlimited-elements-for-elementor");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put pending activation html
|
||||
*/
|
||||
public function putPendingHTML(){
|
||||
?>
|
||||
You are using free version of <b>Unlimited Elements</b>. The pro version will be available for sale in codecanyon.net within 5 days.
|
||||
<br>
|
||||
<br>
|
||||
Please follow the plugin updates, and the pro version activation will be revealed.
|
||||
<br>
|
||||
<br>
|
||||
For any quesiton you can turn to: <b>support@blox-builder.com</b>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* put popup form
|
||||
*/
|
||||
protected function putPopupForm(){
|
||||
?>
|
||||
<?php if(!empty($this->textPasteActivationKey)):?>
|
||||
<label><?php echo esc_html($this->textPasteActivationKey)?>:</label>
|
||||
<?php endif?>
|
||||
|
||||
<?php if($this->showCodeInput == true):?>
|
||||
<input id="uc_activate_pro_code" type="text" placeholder="<?php echo esc_attr($this->textPlaceholder)?>" value="">
|
||||
<?php endif?>
|
||||
|
||||
<div class="uc-activation-section-wrapper">
|
||||
|
||||
<input id="uc_button_activate_pro" type="button" class='uc-button-activate' data-codetype="<?php echo esc_attr($this->codeType)?>" data-product="<?php echo esc_attr($this->product)?>" value="<?php echo esc_attr($this->textActivate)?>">
|
||||
|
||||
<div id="uc_loader_activate_pro" class="uc-loader-activation" style='display:none'>
|
||||
|
||||
<span class='loader_text'>
|
||||
<?php esc_html_e("Activating", "unlimited-elements-for-elementor")?>...
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* put activation html
|
||||
*/
|
||||
public function putActivationHtml(){
|
||||
|
||||
|
||||
?>
|
||||
<div class="uc-activation-view">
|
||||
|
||||
<div class="uc-popup-container uc-start">
|
||||
<div class="uc-popup-content">
|
||||
<div class="uc-popup-holder">
|
||||
<div class="xlarge-title"><?php echo esc_html($this->textGoPro)?></div>
|
||||
|
||||
<div class="popup-text"><?php echo esc_html($this->textUnleash)?><br> <?php echo esc_html($this->textAndTemplates)?></div>
|
||||
<div class="popup-form">
|
||||
|
||||
<?php $this->putPopupForm()?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="bottom-text">
|
||||
<?php echo $this->textDontHave?>
|
||||
<br>
|
||||
<a href="<?php echo esc_url($this->urlPricing)?>" target="_blank" class="blue-text"><?php echo esc_html($this->textLinkToBuy)?></a>
|
||||
</div>
|
||||
|
||||
<?php if(!empty($this->textDontHaveLogin)):?>
|
||||
|
||||
<div class="bottom-text">
|
||||
<?php echo esc_html($this->textDontHaveLogin)?>
|
||||
<br>
|
||||
<a href="<?php echo esc_url($this->urlLogin)?>" target="_blank" class="blue-text"><?php echo esc_html($this->textLinkToLogin)?></a>
|
||||
</div>
|
||||
|
||||
<?php endif?>
|
||||
|
||||
<?php if(!empty($this->textSwitchTo)):?>
|
||||
<div class="bottom-text">
|
||||
<?php echo $this->textSwitchTo?><br>
|
||||
</div>
|
||||
<?php endif?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- failed dialog -->
|
||||
|
||||
<div class="uc-popup-container uc-fail hidden">
|
||||
<div class="uc-popup-content">
|
||||
<div class="uc-popup-holder">
|
||||
<div class="large-title"><?php esc_html_e("Ooops", "unlimited-elements-for-elementor")?>.... <br><?php esc_html_e("Activation Failed", "unlimited-elements-for-elementor")?> :(</div>
|
||||
<div class="popup-error"></div>
|
||||
<div class="popup-text"><?php echo esc_html($this->textActivationFailed)?> <br>to try again <a id="activation_link_try_again" href="javascript:void(0)">click here</a></div>
|
||||
<div class="bottom-text"><?php esc_html_e("or contact our","unlimited-elements-for-elementor")?> <a href="<?php echo esc_url($this->urlSupport)?>" target="_blank"><?php esc_html_e("support center", "unlimited-elements-for-elementor")?></a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- activated dialog -->
|
||||
|
||||
<div class="uc-popup-container uc-activated hidden">
|
||||
<div class="uc-popup-content">
|
||||
<div class="uc-popup-holder">
|
||||
<div class="xlarge-title"><?php esc_html_e("Hi Five", "unlimited-elements-for-elementor")?>!</div>
|
||||
|
||||
<?php if($this->isExpireEnabled == true):?>
|
||||
<div class="popup-text small-padding"><?php echo esc_html($this->textYourProAccountLifetime)?></div>
|
||||
<div class="days"></div>
|
||||
<span><?php esc_html_e("DAYS", "unlimited-elements-for-elementor")?></span>
|
||||
<br><br>
|
||||
|
||||
<?php if($this->writeRefreshPageMessage == true):?>
|
||||
<a href="javascript:location.reload()" class="btn"><?php esc_html_e("Refresh page to View Your Pro Catalog", "unlimited-elements-for-elementor")?></a>
|
||||
<?php endif?>
|
||||
|
||||
<?php else:?>
|
||||
|
||||
<div class="popup-text small-padding"><?php esc_html_e("Your pro account is activated lifetime for this site","unlimited-elements-for-elementor")?>!</div>
|
||||
|
||||
<div class="popup-text small-padding"><?php esc_html_e("Thank you for purchasing from us and good luck", "unlimited-elements-for-elementor")?>!</div>
|
||||
|
||||
<?php endif?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* put deactivate html
|
||||
*/
|
||||
public function putHtmlDeactivate(){
|
||||
|
||||
?>
|
||||
<h2><?php esc_html_e("This pro version is active!", "unlimited-elements-for-elementor")?></h2>
|
||||
|
||||
<a href="javascript:void(0)" class="uc-link-deactivate unite-button-primary" data-product="<?php echo esc_attr($this->product)?>"><?php esc_html_e("Deactivate Pro Version", "unlimited-elements-for-elementor")?></a>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put initing JS
|
||||
*/
|
||||
public function putJSInit(){
|
||||
?>
|
||||
|
||||
<script>
|
||||
|
||||
jQuery("document").ready(function(){
|
||||
|
||||
if(!g_ucAdmin)
|
||||
var g_ucAdmin = new UniteAdminUC();
|
||||
|
||||
g_ucAdmin.initActivationDialog(true);
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* put activation HTML
|
||||
*/
|
||||
public function putHtmlPopup(){
|
||||
|
||||
$title = esc_html__("Activate Your Pro Account", "unlimited-elements-for-elementor");
|
||||
|
||||
?>
|
||||
<div class="activateProDialog" title="<?php echo esc_attr($title)?>" style="display:none">
|
||||
|
||||
<?php $this->putActivationHtml(true) ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Unlimited Elements
|
||||
* @author unlimited-elements.com
|
||||
* @copyright (C) 2021 Unlimited Elements, All Rights Reserved.
|
||||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
||||
* */
|
||||
defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
|
||||
|
||||
/**
|
||||
* addons list view
|
||||
*
|
||||
*/
|
||||
|
||||
class UniteCreatorAddonsView{
|
||||
|
||||
protected $showButtons = true;
|
||||
protected $showHeader = true;
|
||||
protected $headerTextInner = null;
|
||||
protected $addonType, $objAddonType;
|
||||
protected $objManager;
|
||||
protected $product;
|
||||
protected $pluginTitle;
|
||||
protected $putUpdatePluginsButton = false;
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public function __construct(){
|
||||
|
||||
$this->initAddonType();
|
||||
|
||||
$this->init();
|
||||
|
||||
$this->putHtml();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* init addon types
|
||||
*/
|
||||
protected function initAddonType(){
|
||||
|
||||
if(empty($this->addonType)){
|
||||
$this->addonType = UniteFunctionsUC::getGetVar("addontype", null, UniteFunctionsUC::SANITIZE_KEY);
|
||||
}
|
||||
|
||||
$this->objAddonType = UniteCreatorAddonType::getAddonTypeObject($this->addonType);
|
||||
|
||||
UniteCreatorAdmin::setAdminGlobalsByAddonType($this->objAddonType);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* get header text
|
||||
* @return unknown
|
||||
*/
|
||||
protected function getHeaderText(){
|
||||
|
||||
if(!empty($this->objAddonType->managerHeaderPrefix))
|
||||
GlobalsUC::$alterViewHeaderPrefix = $this->objAddonType->managerHeaderPrefix;
|
||||
|
||||
$headerTitle = esc_html__("Manage", "unlimited-elements-for-elementor")." ".$this->objAddonType->textPlural;
|
||||
|
||||
|
||||
return($headerTitle);
|
||||
}
|
||||
|
||||
/**
|
||||
* validate addon type
|
||||
*/
|
||||
private function validateAddonType(){
|
||||
|
||||
if(empty($this->objAddonType))
|
||||
UniteFunctionsUC::throwError("This view should have an addon type");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* validate addon type
|
||||
*/
|
||||
private function validateManager(){
|
||||
|
||||
if(empty($this->objManager))
|
||||
UniteFunctionsUC::throwError("The manager is not inited");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* init the view, function for override
|
||||
*/
|
||||
protected function init(){
|
||||
|
||||
$view = UniteCreatorAdmin::getView();
|
||||
|
||||
$this->objManager = new UniteCreatorManagerAddons();
|
||||
$this->objManager->init($this->addonType);
|
||||
|
||||
if(!empty($this->product))
|
||||
$this->objManager->addPassData("product", $this->product);
|
||||
|
||||
if(!empty($this->headerTextInner))
|
||||
$this->objManager->setHeaderLineText($this->headerTextInner);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put view html
|
||||
*/
|
||||
protected function putHtml(){
|
||||
|
||||
$this->validateAddonType();
|
||||
$this->validateManager();
|
||||
|
||||
if($this->showHeader == true){
|
||||
|
||||
$headerTitle = $this->getHeaderText();
|
||||
|
||||
require HelperUC::getPathTemplate("header");
|
||||
}else
|
||||
require HelperUC::getPathTemplate("header_missing");
|
||||
|
||||
$pluginName = GlobalsUC::PLUGIN_NAME;
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
if($this->showButtons == true)
|
||||
UniteProviderFunctionsUC::putAddonViewAddHtml()
|
||||
?>
|
||||
|
||||
<div class="content_wrapper unite-content-wrapper">
|
||||
<?php $this->objManager->outputHtml() ?>
|
||||
</div>
|
||||
|
||||
<div class="uc-addons-bottom">
|
||||
|
||||
<?php
|
||||
if($this->putUpdatePluginsButton == true){
|
||||
|
||||
if(method_exists("UniteProviderFunctionsUC", "putUpdatePluginHtml"))
|
||||
UniteProviderFunctionsUC::putUpdatePluginHtml($pluginName, $this->pluginTitle);
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Unlimited Elements
|
||||
* @author unlimited-elements.com
|
||||
* @copyright (C) 2021 Unlimited Elements, All Rights Reserved.
|
||||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
|
||||
|
||||
class UCFormEntryView{
|
||||
|
||||
private $service;
|
||||
private $entry;
|
||||
|
||||
/**
|
||||
* Create a new view instance.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($id){
|
||||
|
||||
$this->service = new UCFormEntryService();
|
||||
$this->entry = $this->getEntry($id);
|
||||
|
||||
$this->service->readEntry($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the view.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display(){
|
||||
|
||||
$this->displayHeader();
|
||||
$this->displayContent();
|
||||
$this->displayFooter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry data.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getEntry($id){
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM {$this->service->getTable()}
|
||||
WHERE id = %d
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
$sql = $wpdb->prepare($sql, array($id));
|
||||
$entry = $wpdb->get_row($sql, ARRAY_A);
|
||||
|
||||
if(empty($entry) === true)
|
||||
UniteFunctionsUC::throwError("Entry with ID {$id} not found.");
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM {$this->service->getFieldsTable()}
|
||||
WHERE entry_id = %d
|
||||
";
|
||||
|
||||
$sql = $wpdb->prepare($sql, array($id));
|
||||
$entry["fields"] = $wpdb->get_results($sql, ARRAY_A);
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the header.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function displayHeader(){
|
||||
|
||||
$headerTitle = sprintf(__("Form Entry (ID %d)", "unlimited-elements-for-elementor"), $this->entry["id"]);
|
||||
|
||||
require HelperUC::getPathTemplate("header");
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the content.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function displayContent(){
|
||||
|
||||
$asides = array(
|
||||
__("Entry Information", "unlimited-elements-for-elementor") => array(
|
||||
__("Entry ID", "unlimited-elements-for-elementor") => $this->entry["id"],
|
||||
__("Form", "unlimited-elements-for-elementor") => $this->entry["form_name"],
|
||||
__("Page", "unlimited-elements-for-elementor") => $this->entry["post_title"],
|
||||
__("Date", "unlimited-elements-for-elementor") => $this->service->formatEntryDate($this->entry["created_at"]),
|
||||
),
|
||||
__("User Information", "unlimited-elements-for-elementor") => array(
|
||||
__("User ID", "unlimited-elements-for-elementor") => $this->entry["user_id"],
|
||||
__("User IP", "unlimited-elements-for-elementor") => $this->entry["user_ip"],
|
||||
__("User Agent", "unlimited-elements-for-elementor") => $this->entry["user_agent"],
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="columns-2">
|
||||
|
||||
<div id="post-body-content">
|
||||
<div class="postbox">
|
||||
<div class="postbox-header">
|
||||
<h2><?php echo esc_html__("Entry Fields", "unlimited-elements-for-elementor"); ?></h2>
|
||||
</div>
|
||||
<div class="inside">
|
||||
<table class="wp-list-table widefat">
|
||||
<tbody>
|
||||
<?php foreach($this->entry["fields"] as $field): ?>
|
||||
<tr>
|
||||
<td><?php echo esc_html($field["title"]); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
switch($field["type"]){
|
||||
case UniteCreatorForm::TYPE_FILES:
|
||||
$form = new UniteCreatorForm();
|
||||
echo $form->getFilesFieldLinksHtml($field["value"], "<br />", true);
|
||||
break;
|
||||
|
||||
default:
|
||||
echo esc_html($field["value"]);
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="postbox-container-1">
|
||||
<?php foreach($asides as $title => $fields): ?>
|
||||
<div class="postbox">
|
||||
<div class="postbox-header">
|
||||
<h2><?php echo esc_html($title); ?></h2>
|
||||
</div>
|
||||
<div class="inside">
|
||||
<div id="misc-publishing-actions">
|
||||
<?php foreach($fields as $label => $value): ?>
|
||||
<?php if(isset($value) === true): ?>
|
||||
<div class="misc-pub-section">
|
||||
<?php echo esc_html($label); ?>: <b><?php echo esc_html($value); ?></b>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#post-body-content .postbox .postbox-header {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
#post-body-content .postbox .inside {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#post-body-content .postbox .wp-list-table {
|
||||
border: none;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
#post-body-content .postbox .wp-list-table td {
|
||||
border-top: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
#post-body-content .postbox .wp-list-table td:first-child {
|
||||
width: 150px;
|
||||
background: #f6f7f7;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the footer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function displayFooter(){
|
||||
|
||||
$url = wp_get_referer() ?: "?page={$_REQUEST["page"]}";
|
||||
|
||||
?>
|
||||
<div>
|
||||
<a class="button" href="<?php echo esc_url($url); ?>">
|
||||
<?php echo esc_html__("Back to Form Entries", "unlimited-elements-for-elementor"); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,566 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Unlimited Elements
|
||||
* @author unlimited-elements.com
|
||||
* @copyright (C) 2021 Unlimited Elements, All Rights Reserved.
|
||||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
||||
* */
|
||||
defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
|
||||
|
||||
|
||||
class UniteCreatorLayoutsView{
|
||||
|
||||
protected $isTemplate = false;
|
||||
protected $layoutType, $layoutTypeTitle, $layoutTypeTitlePlural;
|
||||
protected $objLayoutType;
|
||||
|
||||
protected $showButtonsPanel = true, $showHeaderTitle = true;
|
||||
protected $showColCategory = true, $showColShortcode = true;
|
||||
protected $isDisplayTable = true;
|
||||
protected $objTable, $urlViewCreateObject, $urlManageAddons;
|
||||
protected $arrLayouts, $pageBuilder, $objLayouts, $objManager;
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public function __construct(){
|
||||
|
||||
$this->objTable = new UniteTableUC();
|
||||
$this->pageBuilder = new UniteCreatorPageBuilder();
|
||||
$this->objLayouts = new UniteCreatorLayouts();
|
||||
|
||||
}
|
||||
|
||||
private function z_INIT(){}
|
||||
|
||||
|
||||
/**
|
||||
* set templates text
|
||||
*/
|
||||
protected function getTemplatesTextArray(){
|
||||
|
||||
$pluralLower = strtolower($this->layoutTypeTitlePlural);
|
||||
$titleLower = strtolower($this->layoutTypeTitle);
|
||||
|
||||
|
||||
$arrText = array(
|
||||
"import_layout"=>esc_html__("Import ","unlimited-elements-for-elementor").$this->layoutTypeTitle,
|
||||
"import_layouts"=>esc_html__("Import ","unlimited-elements-for-elementor").$this->layoutTypeTitlePlural,
|
||||
"uploading_layouts_file"=>esc_html__("Uploading ","unlimited-elements-for-elementor"). $this->layoutTypeTitlePlural. esc_html__(" file...","unlimited-elements-for-elementor"),
|
||||
"layouts_added_successfully"=> $this->layoutTypeTitle.esc_html__(" Added Successfully","unlimited-elements-for-elementor"),
|
||||
"my_layouts"=>esc_html__("My ","unlimited-elements-for-elementor").$this->layoutTypeTitlePlural,
|
||||
"search_layout"=> esc_html__("Search","unlimited-elements-for-elementor")." ". $this->layoutTypeTitlePlural,
|
||||
"layout_title"=>$this->layoutTypeTitle." ". esc_html__("Title","unlimited-elements-for-elementor"),
|
||||
"no_layouts_found"=>esc_html__("No","unlimited-elements-for-elementor")." ".$this->layoutTypeTitlePlural. " ". esc_html__("Found","unlimited-elements-for-elementor"),
|
||||
"are_you_sure_to_delete_this_layout"=>esc_html__("Are you sure to delete this ?","unlimited-elements-for-elementor").$titleLower,
|
||||
"edit_layout"=>esc_html__("Edit","unlimited-elements-for-elementor")." ".$this->layoutTypeTitle,
|
||||
"manage_layout_categories"=>esc_html__("Manage ","unlimited-elements-for-elementor"). $this->layoutTypeTitlePlural. esc_html__(" Categories","unlimited-elements-for-elementor"),
|
||||
"select_layouts_export_file"=>esc_html__("Select ","unlimited-elements-for-elementor"). $pluralLower. esc_html__(" export file","unlimited-elements-for-elementor"),
|
||||
"new_layout"=>esc_html__("New","unlimited-elements-for-elementor")." ". $this->layoutTypeTitle,
|
||||
);
|
||||
|
||||
return($arrText);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set templat etype
|
||||
*/
|
||||
public function setLayoutType($layoutType){
|
||||
|
||||
$this->layoutType = $layoutType;
|
||||
|
||||
$this->objLayoutType = UniteCreatorAddonType::getAddonTypeObject($layoutType, true);
|
||||
|
||||
//set title
|
||||
$this->layoutTypeTitle = $this->objLayoutType->textSingle;
|
||||
$this->layoutTypeTitlePlural = $this->objLayoutType->textPlural;
|
||||
|
||||
//set text
|
||||
$arrText = $this->getTemplatesTextArray();
|
||||
|
||||
HelperUC::setLocalText($arrText);
|
||||
|
||||
//set other settings
|
||||
$this->isTemplate = $this->objLayoutType->isTemplate;
|
||||
$this->showColCategory = $this->objLayoutType->enableCategories;
|
||||
$this->showColShortcode = $this->objLayoutType->enableShortcodes;
|
||||
|
||||
//set display type manager / table
|
||||
$displayType = UniteFunctionsUC::getGetVar("displaytype", "",UniteFunctionsUC::SANITIZE_TEXT_FIELD);
|
||||
if(empty($displayType))
|
||||
$displayType = $this->objLayoutType->displayType;
|
||||
|
||||
|
||||
if($displayType == UniteCreatorAddonType_Layout::DISPLAYTYPE_MANAGER)
|
||||
$this->isDisplayTable = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* validate inited
|
||||
*/
|
||||
protected function validateInited(){
|
||||
|
||||
if(empty($this->objLayoutType))
|
||||
UniteFunctionsUC::throwError("The layout type not inited, please use : setLayoutType function");
|
||||
|
||||
if($this->objLayoutType->isLayout == false)
|
||||
UniteFunctionsUC::throwError("The layout type should be layout type, now: ".$this->objLayoutType->textShowType);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* init display vars table related
|
||||
*/
|
||||
protected function initDisplayVars_table(){
|
||||
|
||||
$this->objTable->setDefaultOrderby("title");
|
||||
|
||||
$pagingOptions = $this->objTable->getPagingOptions();
|
||||
|
||||
if(!empty($this->layoutType)){
|
||||
$pagingOptions["layout_type"] = $this->layoutType;
|
||||
}
|
||||
|
||||
$response = $this->objLayouts->getArrLayoutsPaging($pagingOptions);
|
||||
|
||||
$this->arrLayouts = $response["layouts"];
|
||||
$pagingData = $response["paging"];
|
||||
|
||||
$urlLayouts = HelperUC::getViewUrl_LayoutsList();
|
||||
|
||||
$this->objTable->setPagingData($urlLayouts, $pagingData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* init manager display vars
|
||||
*/
|
||||
protected function initDisplayVars_manager(){
|
||||
|
||||
$this->objManager = new UniteCreatorManagerLayouts();
|
||||
$this->objManager->init($this->layoutType);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* init display vars
|
||||
*/
|
||||
protected function initDisplayVars(){
|
||||
|
||||
//init layout type
|
||||
$this->urlViewCreateObject = HelperUC::getViewUrl_Layout();
|
||||
$this->urlManageAddons = HelperUC::getViewUrl_Addons();
|
||||
|
||||
|
||||
if($this->showHeaderTitle == true){
|
||||
$headerTitle = HelperUC::getText("my_layouts");
|
||||
require HelperUC::getPathTemplate("header");
|
||||
}else
|
||||
require HelperUC::getPathTemplate("header_missing");
|
||||
|
||||
//table object
|
||||
if($this->isDisplayTable == true)
|
||||
$this->initDisplayVars_table();
|
||||
else
|
||||
$this->initDisplayVars_manager();
|
||||
}
|
||||
|
||||
|
||||
private function z_PUT_HTML(){}
|
||||
|
||||
|
||||
/**
|
||||
* put page catalog browser
|
||||
*/
|
||||
public function putDialogPageCatalog(){
|
||||
|
||||
$webAPI = new UniteCreatorWebAPI();
|
||||
$isPageCatalogExists = $webAPI->isPagesCatalogExists();
|
||||
if($isPageCatalogExists == false)
|
||||
return(false);
|
||||
|
||||
$objBrowser = new UniteCreatorBrowser();
|
||||
$objBrowser->initAddonType(GlobalsUC::ADDON_TYPE_REGULAR_LAYOUT);
|
||||
$objBrowser->putBrowser();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put manage categories dialog
|
||||
*/
|
||||
public function putDialogCategories(){
|
||||
|
||||
$prefix = "uc_dialog_add_category";
|
||||
|
||||
?>
|
||||
<div id="uc_dialog_add_category" title="<?php HelperUC::putText("manage_layout_categories")?>" style="display:none; height: 300px;" class="unite-inputs">
|
||||
|
||||
<div class="unite-dialog-top">
|
||||
|
||||
<input type="text" class="uc-catdialog-button-clearfilter" style="margin-bottom: 1px;">
|
||||
<a class='uc-catdialog-button-filter unite-button-secondary' href="javascript:void(0)"><?php esc_html_e("Filter", "unlimited-elements-for-elementor")?></a>
|
||||
<a class='uc-catdialog-button-filter-clear unite-button-secondary' href="javascript:void(0)"><?php esc_html_e("Clear Filter", "unlimited-elements-for-elementor")?></a>
|
||||
|
||||
<span class="uc-catlist-sort-wrapper">
|
||||
|
||||
<?php esc_html_e("Sort: ","unlimited-elements-for-elementor")?>
|
||||
<a href="javascript:void(0)" class="uc-link-change-cat-sort" data-type="a-z">a-z</a>
|
||||
,
|
||||
<a href="javascript:void(0)" class="uc-link-change-cat-sort" data-type="z-a">z-a</a>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="list_layouts_cats" class="uc-categories-list"></div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<?php esc_html_e("Add New Category", "unlimited-elements-for-elementor")?>:
|
||||
<input id="uc_dialog_add_category_catname" type="text" class="unite-input-regular" value="">
|
||||
|
||||
<a id="uc_dialog_add_category_button_add" href="javascript:void(0)" class="unite-button-secondary" data-action="add_category"><?php esc_html_e("Create Category", "unlimited-elements-for-elementor")?></a>
|
||||
|
||||
<div>
|
||||
|
||||
<?php
|
||||
$buttonTitle = esc_html__("Set Category to Page", "unlimited-elements-for-elementor");
|
||||
$loaderTitle = esc_html__("Updating Category...", "unlimited-elements-for-elementor");
|
||||
$successTitle = esc_html__("Category Updated", "unlimited-elements-for-elementor");
|
||||
HelperHtmlUC::putDialogActions($prefix, $buttonTitle, $loaderTitle, $successTitle);
|
||||
?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div id="uc_layout_categories_message" title="<?php esc_html_e("Categories Message", "unlimited-elements-for-elementor")?>">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put import addons dialog
|
||||
*/
|
||||
public function putDialogImportLayout(){
|
||||
|
||||
$dialogTitle = HelperUC::getText("import_layout");
|
||||
|
||||
?>
|
||||
|
||||
<div id="uc_dialog_import_layouts" class="unite-inputs" title="<?php echo esc_attr($dialogTitle)?>" style="display:none;">
|
||||
|
||||
<div class="unite-dialog-top"></div>
|
||||
|
||||
<div class="unite-inputs-label">
|
||||
<?php HelperUC::putText("select_layouts_export_file")?>:
|
||||
</div>
|
||||
|
||||
<form id="dialog_import_layouts_form" name="form_import_layouts">
|
||||
<input id="dialog_import_layouts_file" type="file" name="import_layout">
|
||||
|
||||
</form>
|
||||
|
||||
<div class="unite-inputs-sap-double"></div>
|
||||
|
||||
<div class="unite-inputs-label" >
|
||||
<label for="dialog_import_layouts_file_overwrite">
|
||||
<?php esc_html_e("Overwrite Addons", "unlimited-elements-for-elementor")?>:
|
||||
</label>
|
||||
<input type="checkbox" id="dialog_import_layouts_file_overwrite">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="unite-clear"></div>
|
||||
|
||||
<?php
|
||||
$prefix = "uc_dialog_import_layouts";
|
||||
|
||||
$buttonTitle = HelperUC::getText("import_layouts");
|
||||
$loaderTitle = HelperUC::getText("uploading_layouts_file");
|
||||
$successTitle = HelperUC::getText("layouts_added_successfully");
|
||||
|
||||
HelperHtmlUC::putDialogActions($prefix, $buttonTitle, $loaderTitle, $successTitle);
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* put buttons panel html
|
||||
*/
|
||||
protected function putHtmlButtonsPanel(){
|
||||
|
||||
?>
|
||||
<div class="uc-buttons-panel unite-clearfix">
|
||||
<a href="<?php echo esc_url($this->urlViewCreateObject)?>" class="unite-button-primary unite-float-left"><?php HelperUC::putText("new_layout");?></a>
|
||||
|
||||
<a id="uc_button_import_layout" href="javascript:void(0)" class="unite-button-secondary unite-float-left mleft_20"><?php HelperUC::putText("import_layouts");?></a>
|
||||
|
||||
<a href="javascript:void(0)" id="uc_layouts_global_settings" class="unite-float-right mright_20 unite-button-secondary"><?php HelperUC::putText("layouts_global_settings");?></a>
|
||||
<a href="<?php echo esc_url($this->urlManageAddons)?>" class="unite-float-right mright_20 unite-button-secondary"><?php esc_html_e("My Addons", "unlimited-elements-for-elementor")?></a>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* display notice
|
||||
*/
|
||||
protected function putHtmlTemplatesNotice(){
|
||||
|
||||
if($this->isTemplate == false)
|
||||
return(false);
|
||||
|
||||
?>
|
||||
<div class="uc-layouts-notice"> Notice - The templates will work for only if the blox template selected</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put layout type tabs
|
||||
*/
|
||||
public function putLayoutTypeTabs(){
|
||||
|
||||
|
||||
dmp("get all template types");
|
||||
exit();
|
||||
|
||||
?>
|
||||
<div class="uc-layout-type-tabs-wrapper">
|
||||
|
||||
<?php foreach($arrLayoutTypes as $type => $arrType):
|
||||
|
||||
$tabTitle = UniteFunctionsUC::getVal($arrType, "plural");
|
||||
|
||||
$urlView = HelperUC::getViewUrl_TemplatesList(null, $type);
|
||||
|
||||
$addClass = "";
|
||||
if($type == $this->layoutType){
|
||||
$addClass = " uc-tab-selected";
|
||||
$urlView = "#";
|
||||
}
|
||||
|
||||
?>
|
||||
<a href="<?php echo esc_url($urlView)?>" class="uc-tab-layouttype<?php echo esc_attr($addClass)?>"><?php echo esc_html($tabTitle)?></a>
|
||||
|
||||
<?php endforeach?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* display manager
|
||||
*/
|
||||
public function displayManager(){
|
||||
|
||||
$this->objManager->outputHtml();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* display table view
|
||||
*/
|
||||
public function display(){
|
||||
|
||||
$this->validateInited();
|
||||
$this->initDisplayVars();
|
||||
|
||||
if($this->isDisplayTable)
|
||||
$this->displayTable();
|
||||
else
|
||||
$this->displayManager();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* display layouts view
|
||||
*/
|
||||
public function displayTable(){
|
||||
|
||||
$sizeActions = UniteProviderFunctionsUC::applyFilters(UniteCreatorFilters::FILTER_LAYOUTS_ACTIONS_COL_WIDTH, 380);
|
||||
|
||||
$numLayouts = count($this->arrLayouts);
|
||||
|
||||
|
||||
?>
|
||||
<?php if($this->showButtonsPanel == true)
|
||||
$this->putHtmlButtonsPanel();
|
||||
?>
|
||||
|
||||
<div class="unite-content-wrapper">
|
||||
|
||||
<?php
|
||||
|
||||
$this->objTable->putActionsFormStart();
|
||||
|
||||
if($this->isTemplate == true)
|
||||
$this->putLayoutTypeTabs();
|
||||
|
||||
?>
|
||||
<div class="unite-table-filters">
|
||||
|
||||
|
||||
<?php
|
||||
$this->objTable->putSearchForm(HelperUC::getText("search_layout"), "Clear");
|
||||
|
||||
if($this->isTemplate == false):
|
||||
|
||||
$this->objTable->putFilterCategory();
|
||||
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if(empty($this->arrLayouts)): ?>
|
||||
<div class="uc-no-layouts-wrapper">
|
||||
<?php HelperUC::putText("no_layouts_found");?>
|
||||
</div>
|
||||
<?php else:?>
|
||||
|
||||
<!-- sort chars: ∧ , ∨ -->
|
||||
|
||||
<table id="uc_table_layouts" class='unite_table_items' data-text-delete="<?php HelperUC::putText("are_you_sure_to_delete_this_layout")?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width=''>
|
||||
<?php $this->objTable->putTableOrderHeader("title", HelperUC::getText("layout_title")) ?>
|
||||
</th>
|
||||
|
||||
<?php if($this->showColShortcode == true):?>
|
||||
<th width='200'><?php esc_html_e("Shortcode","unlimited-elements-for-elementor"); ?></th>
|
||||
<?php endif?>
|
||||
|
||||
<?php if($this->showColCategory == true):?>
|
||||
<th width='200'><?php $this->objTable->putTableOrderHeader("catid", esc_html__("Category","unlimited-elements-for-elementor")) ?>
|
||||
<?php endif?>
|
||||
|
||||
<th width='<?php echo esc_attr($sizeActions)?>'><?php esc_html_e("Actions","unlimited-elements-for-elementor"); ?></th>
|
||||
<th width='60'><?php esc_html_e("Preview","unlimited-elements-for-elementor"); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php foreach($this->arrLayouts as $key=>$layout):
|
||||
|
||||
$id = $layout->getID();
|
||||
|
||||
$title = $layout->getTitle();
|
||||
|
||||
$shortcode = $layout->getShortcode();
|
||||
$shortcode = UniteFunctionsUC::sanitizeAttr($shortcode);
|
||||
|
||||
$editLink = HelperUC::getViewUrl_Layout($id);
|
||||
|
||||
$previewLink = HelperUC::getViewUrl_LayoutPreview($id, true);
|
||||
|
||||
$showTitle = HelperHtmlUC::getHtmlLink($editLink, $title);
|
||||
|
||||
$rowClass = ($key%2==0)?"unite-row1":"unite-row2";
|
||||
|
||||
$arrCategory = $layout->getCategory();
|
||||
|
||||
$catID = UniteFunctionsUC::getVal($arrCategory, "id");
|
||||
$catTitle = UniteFunctionsUC::getVal($arrCategory, "name");
|
||||
|
||||
?>
|
||||
<tr class="<?php echo esc_attr($rowClass)?>">
|
||||
<td><?php echo esc_html($showTitle)?></td>
|
||||
|
||||
<?php if($this->showColShortcode):?>
|
||||
|
||||
<td>
|
||||
<input type="text" readonly onfocus="this.select()" class="unite-input-medium unite-cursor-text" value="<?php echo esc_attr($shortcode)?>" />
|
||||
</td>
|
||||
|
||||
<?php endif?>
|
||||
|
||||
<?php if($this->showColCategory):?>
|
||||
|
||||
<td><a href="javascript:void(0)" class="uc-layouts-list-category" data-layoutid="<?php echo esc_attr($id)?>" data-catid="<?php echo esc_attr($catID)?>" data-action="manage_category"><?php echo esc_html($catTitle)?></a></td>
|
||||
|
||||
<?php endif?>
|
||||
|
||||
<td>
|
||||
<a href='<?php echo esc_attr($editLink)?>' class="unite-button-primary float_left mleft_15"><?php HelperUC::putText("edit_layout"); ?></a>
|
||||
|
||||
<a href='javascript:void(0)' data-layoutid="<?php echo esc_attr($id)?>" data-id="<?php echo esc_attr($id)?>" class="button_delete unite-button-secondary float_left mleft_15"><?php esc_html_e("Delete","unlimited-elements-for-elementor"); ?></a>
|
||||
<span class="loader_text uc-loader-delete" style="display:none"><?php esc_html_e("Deleting", "unlimited-elements-for-elementor")?></span>
|
||||
<a href='javascript:void(0)' data-layoutid="<?php echo esc_attr($id)?>" data-id="<?php echo esc_attr($id)?>" class="button_duplicate unite-button-secondary float_left mleft_15"><?php esc_html_e("Duplicate","unlimited-elements-for-elementor"); ?></a>
|
||||
<span class="loader_text uc-loader-duplicate" style="display:none"><?php esc_html_e("Duplicating", "unlimited-elements-for-elementor")?></span>
|
||||
<a href='javascript:void(0)' data-layoutid="<?php echo esc_attr($id)?>" data-id="<?php echo esc_attr($id)?>" class="button_export unite-button-secondary float_left mleft_15"><?php esc_html_e("Export","unlimited-elements-for-elementor"); ?></a>
|
||||
<?php UniteProviderFunctionsUC::doAction(UniteCreatorFilters::ACTION_LAYOUTS_LIST_ACTIONS, $id); ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href='<?php echo esc_attr($previewLink)?>' target="_blank" class="unite-button-secondary float_left"><?php esc_html_e("Preview","unlimited-elements-for-elementor"); ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
|
||||
$this->objTable->putPaginationHtml();
|
||||
$this->objTable->putInpageSelect();
|
||||
|
||||
?>
|
||||
|
||||
<?php endif?>
|
||||
|
||||
<?php
|
||||
|
||||
$this->objTable->putActionsFormEnd();
|
||||
|
||||
$this->pageBuilder->putLayoutsGlobalSettingsDialog();
|
||||
$this->putDialogImportLayout();
|
||||
|
||||
$this->putDialogCategories();
|
||||
|
||||
//put pages catalog if exists
|
||||
$this->putDialogPageCatalog();
|
||||
?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
|
||||
var objAdmin = new UniteCreatorAdmin_LayoutsList();
|
||||
objAdmin.initObjectsListView();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,597 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Unlimited Elements
|
||||
* @author unlimited-elements.com
|
||||
* @copyright (C) 2021 Unlimited Elements, All Rights Reserved.
|
||||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
||||
* */
|
||||
defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
|
||||
|
||||
class UniteCreatorMappickerView{
|
||||
|
||||
private $settings, $settingsOutput;
|
||||
private $defaultAPIKey = "AIzaSyCFgj4Ipg5KSml6cMMHX4S50oRZ9_TIP34";
|
||||
private $apiKey = null;
|
||||
private $arrLangs = array('[default]'=>"", 'English' => 'en', 'Arabic' => 'ar', 'Basque' => 'eu', 'Bengali' => 'bn', 'Bulgarian' => 'bg', 'Catalan' => 'ca', 'Chinese (Simplified)' => 'zh-CN', 'Chinese (Traditional)' => 'zh-TW', 'Croatian' => 'hr', 'Czech' => 'cs', 'Danish' => 'da', 'Dutch' => 'nl', 'English (Australian)' => 'en-AU', 'English (Great Britain)' => 'en-GB', 'Farsi' => 'fa', 'Filipino' => 'fil', 'Finnish' => 'fi', 'French' => 'fr', 'Galician' => 'gl', 'German' => 'de', 'Greek' => 'el', 'Gujarati' => 'gu', 'Hebrew' => 'iw', 'Hindi' => 'hi', 'Hungarian' => 'hu', 'Indonesian' => 'id', 'Italian' => 'it', 'Japanese' => 'ja', 'Kannada' => 'kn', 'Korean' => 'ko', 'Latvian' => 'lv', 'Lithuanian' => 'lt', 'Malayalam' => 'ml', 'Marathi' => 'mr', 'Norwegian' => 'no', 'Polish' => 'pl', 'Portuguese' => 'pt', 'Portuguese (Brazil)' => 'pt-BR', 'Portuguese (Portugal)' => 'pt-PT', 'Romanian' => 'ro', 'Russian' => 'ru', 'Serbian' => 'sr', 'Slovak' => 'sk', 'Slovenian' => 'sl', 'Spanish' => 'es', 'Swedish' => 'sv', 'Tagalog' => 'tl', 'Tamil' => 'ta', 'Telugu' => 'te', 'Thai' => 'th', 'Turkish' => 'tr', 'Ukrainian' => 'uk', 'Vietnamese' => 'vi');
|
||||
private $urlScript, $urlGoogleScript, $mapData, $settingsData;
|
||||
private $defaultLocation = array("lat"=>"-33.8688","lng"=>151.2195);
|
||||
private $defaultZoom = 13, $isInited = false;
|
||||
private $urlStatic;
|
||||
private static $serial = 0;
|
||||
|
||||
|
||||
/**
|
||||
* the constructor
|
||||
*/
|
||||
public function __construct(){
|
||||
|
||||
$this->apiKey = "yourkey"; //get from general settings later
|
||||
|
||||
$this->apiKey = trim($this->apiKey);
|
||||
if(empty($this->apiKey))
|
||||
$this->apiKey = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get API key, default or private
|
||||
*/
|
||||
private function getAPIKey(){
|
||||
|
||||
if(!empty($this->apiKey))
|
||||
return($this->apiKey);
|
||||
|
||||
return($this->defaultAPIKey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* init scripts url
|
||||
*/
|
||||
private function initScripts(){
|
||||
|
||||
$rand = rand(10,999999);
|
||||
|
||||
$this->urlScript = GlobalsUC::$urlPlugin."js/unitecreator_map_picker.js?rand=".$rand;
|
||||
|
||||
$apiKey = $this->getAPIKey();
|
||||
|
||||
$this->urlGoogleScript = "https://maps.googleapis.com/maps/api/js?key={$apiKey}&libraries=places";
|
||||
|
||||
$this->urlStatic = "https://maps.googleapis.com/maps/api/staticmap?key={$apiKey}";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* init
|
||||
*/
|
||||
private function initSettings(){
|
||||
|
||||
$settings = new UniteCreatorSettings();
|
||||
|
||||
$settings->addSap(esc_html__("Size and Location", "unlimited-elements-for-elementor"), "size_location");
|
||||
|
||||
$settings->addTextBox("width","100%",esc_html__("Map Width","unlimited-elements-for-elementor"),array("unit"=>"px or %"));
|
||||
$settings->addTextBox("height","300",esc_html__("Map Height","unlimited-elements-for-elementor"),array("unit"=>"px or %"));
|
||||
|
||||
$settings->addHr();
|
||||
|
||||
$settings->addTextBox("location", "", "Location");
|
||||
|
||||
$params = array(UniteSettingsUC::PARAM_ADDTEXT => "<span id='uc_loader_mylocation' class='loader_round' style='display:none'></span>");
|
||||
$settings->addButton("button_my_location", esc_html__("Goto My Location", "unlimited-elements-for-elementor"), UniteSettingsUC::PARAM_NOTEXT, $params);
|
||||
|
||||
//--------- add marker
|
||||
|
||||
$settings->addSap(esc_html__("Marker", "unlimited-elements-for-elementor"), "marker");
|
||||
|
||||
$arrMarkerType = array();
|
||||
$arrMarkerType["Default Marker"] = "default";
|
||||
$arrMarkerType["No Marker"] = "no";
|
||||
$arrMarkerType["Shape from Icon"] = "icon";
|
||||
$arrMarkerType["Shape from Image"] = "image";
|
||||
|
||||
$settings->addSelect("marker_type", $arrMarkerType, "Marker Type","default");
|
||||
|
||||
$iconParams = array("icons_type"=>"map");
|
||||
$settings->addIconPicker("icon","","Marker Icon", $iconParams);
|
||||
$settings->addControl("marker_type", "icon", "show", "icon");
|
||||
|
||||
$settings->addImage("marker_image","",esc_html__("Marker Image","unlimited-elements-for-elementor"));
|
||||
$settings->addControl("marker_type", "marker_image", "show", "image");
|
||||
|
||||
|
||||
$settings->addSap(esc_html__("Style", "unlimited-elements-for-elementor"), "style");
|
||||
|
||||
$arrStyles = array(
|
||||
"[Standard]"=>"",
|
||||
"Silver"=>"silver",
|
||||
"Retro"=>"retro",
|
||||
"Dark"=>"dark",
|
||||
"Night"=>"night",
|
||||
"Aubegine"=>"aubegine",
|
||||
"Custom"=>"custom"
|
||||
);
|
||||
|
||||
$settings->addSelect("style", $arrStyles, "Map Style");
|
||||
|
||||
//add custom style textarea
|
||||
$params = array();
|
||||
$params[UniteSettingsUC::PARAM_ADDTEXT] = "<div id='uc-mappicker-style-error' class='unite-color-red' style='display:none;'></div>";
|
||||
$settings->addTextArea("style_json", "", "Custom Style", $params);
|
||||
$settings->addStaticText("Paste here map style from <a href='https://mapstyle.withgoogle.com/' target='_blank'>Google Map Styler</a> or <a href='https://snazzymaps.com/explore' target='_blank'>Snazzy Maps</a>");
|
||||
$settings->addControl("style", "style_json", "show", "custom");
|
||||
|
||||
|
||||
//add advanced
|
||||
$settings->addHr();
|
||||
|
||||
//--- map type
|
||||
$arrMapType = array(
|
||||
"Roadmap"=> "roadmap",
|
||||
"Satellite"=> "satellite",
|
||||
"Hybrid"=> "hybrid",
|
||||
"Terrain"=> "terrain"
|
||||
);
|
||||
|
||||
$settings->addSelect("map_type", $arrMapType, "Map Type", "roadmap");
|
||||
|
||||
$settings->addSap(esc_html__("Language and Controls", "unlimited-elements-for-elementor"), "language_controls");
|
||||
|
||||
//--- language
|
||||
$settings->addSelect("language", $this->arrLangs, esc_html__("Language", "unlimited-elements-for-elementor"), "");
|
||||
|
||||
$settings->addHr();
|
||||
|
||||
$settings->addRadioBoolean("zoomControl", "Show Zoom Control");
|
||||
$settings->addRadioBoolean("mapTypeControl", "Show Type Control");
|
||||
$settings->addRadioBoolean("streetViewControl", "Show Street View Control");
|
||||
$settings->addRadioBoolean("fullscreenControl", "Show Full Screen Control");
|
||||
|
||||
//set settings data
|
||||
if(!empty($this->settingsData))
|
||||
$settings->setStoredValues($this->settingsData);
|
||||
|
||||
$this->settingsData = $settings->getArrValues();
|
||||
|
||||
$this->settings = $settings;
|
||||
|
||||
$this->settingsOutput = new UniteSettingsOutputSidebarUC();
|
||||
$this->settingsOutput->init($this->settings);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put parse icons html from google earty icons page
|
||||
*/
|
||||
private function putParseIconsHtml(){
|
||||
?>
|
||||
<div id="icons" style="display:none"></div>
|
||||
<div id="icons_parsed"></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* output html
|
||||
*/
|
||||
private function outputHtml(){
|
||||
|
||||
$data = $this->mapData;
|
||||
|
||||
$addHtml = "";
|
||||
if(!empty($data))
|
||||
$addHtml = UniteFunctionsUC::jsonEncodeForHtmlData($data,"mapdata");
|
||||
|
||||
$addOverlay = false;
|
||||
if(empty($this->apiKey) || $this->apiKey === $this->defaultAPIKey)
|
||||
$addOverlay = true;
|
||||
|
||||
$urlGeneralSettings = HelperUC::getViewUrl(GlobalsUC::VIEW_SETTINGS);
|
||||
$urlGeneralSettings .= "#tab=fields_settings";
|
||||
|
||||
$linkGeneralSettings = HelperHtmlUC::getHtmlLink($urlGeneralSettings, esc_html__("General Settings","unlimited-elements-for-elementor"),"","",true);
|
||||
|
||||
?>
|
||||
<div class="uc-mappicker-panels-wrapper">
|
||||
|
||||
<?php if($addOverlay == true):?>
|
||||
<div class="uc-mappicker-overlay-trans"></div>
|
||||
<div class="uc-mappicker-overlay-black"></div>
|
||||
<div class="uc-mappicker-overlay-text">
|
||||
<?php esc_html_e("For edit the map, please enter your google map API Key in", "unlimited-elements-for-elementor")?> <?php echo UniteProviderFunctionsUC::escAddParam($linkGeneralSettings)?>.
|
||||
<br>
|
||||
<br>
|
||||
You can create your API key in <a href="https://developers.google.com/maps/documentation/javascript/" target="_blank">google map developes page</a>
|
||||
|
||||
</div>
|
||||
|
||||
<?php endif;?>
|
||||
|
||||
<div class="unite-panels-wrapper unite-clearfix">
|
||||
<div class="unite-left-panel">
|
||||
<?php $this->settingsOutput->draw("uc_settings_map", true); ?>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<div class="unite-right-panel">
|
||||
|
||||
<div id="uc_mappicker_mapwrapper" <?php echo UniteProviderFunctionsUC::escAddParam($addHtml)?> class="uc-mappicker-wrapper">
|
||||
<div id="uc_mappicker_map" ></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* output scripts
|
||||
*/
|
||||
private function outputScripts(){
|
||||
|
||||
$urlGoogleScript = $this->getUrlScriptAPI();
|
||||
|
||||
$apiKey = $this->getAPIKey();
|
||||
|
||||
?>
|
||||
<script type="text/javascript" src="<?php echo esc_attr($this->urlScript)?>"></script>
|
||||
<script id="uc_mappicker_script" src="<?php echo esc_attr($urlGoogleScript)?>"></script>
|
||||
|
||||
<script>
|
||||
var g_objMapPicker;
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
g_objMapPicker = new UniteCreatorMapPicker();
|
||||
g_objMapPicker.initMap("<?php echo esc_attr($apiKey)?>");
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* global function for get data
|
||||
*/
|
||||
document.getIframeData = function(){
|
||||
|
||||
var data = g_objMapPicker.getData();
|
||||
|
||||
return(data);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* get map data
|
||||
*/
|
||||
private function getMapData(){
|
||||
|
||||
$data = $this->mapData;
|
||||
if(empty($data))
|
||||
$data = array();
|
||||
|
||||
if(!isset($data["center"]))
|
||||
$data["center"] = $this->defaultLocation;
|
||||
|
||||
if(!isset($data["zoom"]))
|
||||
$data["zoom"] = $this->defaultZoom;
|
||||
|
||||
return($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get map date for client side
|
||||
*/
|
||||
private function getMapDataClientSide(){
|
||||
|
||||
$data = $this->getMapData();
|
||||
|
||||
$mapData = array();
|
||||
|
||||
$mapData["center"] = $data["center"];
|
||||
$mapData["zoom"] = $data["zoom"];
|
||||
|
||||
return($mapData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get default iframe url
|
||||
*/
|
||||
private function getUrlStaticMap($width, $height){
|
||||
|
||||
$this->init();
|
||||
|
||||
$url = $this->urlStatic;
|
||||
|
||||
$url .= "&size={$width}x{$height}";
|
||||
|
||||
$data = $this->getMapData();
|
||||
|
||||
//add center
|
||||
$location = UniteFunctionsUC::getVal($data, "center");
|
||||
if($location){
|
||||
$lat = $location["lat"];
|
||||
$lng = $location["lng"];
|
||||
$url .= "¢er={$lat},{$lng}";
|
||||
}
|
||||
|
||||
//add zoom
|
||||
$zoom = UniteFunctionsUC::getVal($data, "zoom");
|
||||
if($zoom)
|
||||
$url .= "&zoom={$zoom}";
|
||||
|
||||
return($url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get script API url
|
||||
*/
|
||||
private function getUrlScriptAPI($callback = ""){
|
||||
|
||||
$url = $this->urlGoogleScript;
|
||||
|
||||
if(!empty($callback))
|
||||
$url .= "&callback=$callback";
|
||||
|
||||
$language = UniteFunctionsUC::getVal($this->mapData, "lang");
|
||||
if(!empty($language))
|
||||
$url .= "&language=$language";
|
||||
|
||||
|
||||
return($url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set map and settings data
|
||||
*/
|
||||
public function setData($data){
|
||||
|
||||
if(empty($data))
|
||||
return(false);
|
||||
|
||||
$this->mapData = UniteFunctionsUC::getVal($data, "map");
|
||||
$this->settingsData = UniteFunctionsUC::getVal($data, "settings");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get map data
|
||||
*/
|
||||
public function getStoredMapData(){
|
||||
return($this->mapData);
|
||||
}
|
||||
|
||||
/**
|
||||
* init all the objects
|
||||
*/
|
||||
private function init(){
|
||||
|
||||
if($this->isInited == true)
|
||||
return(false);
|
||||
|
||||
$this->initSettings();
|
||||
|
||||
$this->initScripts();
|
||||
|
||||
$this->isInited = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put html of picker input
|
||||
*/
|
||||
public function putPickerInputHtml(){
|
||||
|
||||
$this->init();
|
||||
|
||||
$status = esc_html__("No Map Chosen", "unlimited-elements-for-elementor");
|
||||
|
||||
$width = 220;
|
||||
$height = 100;
|
||||
|
||||
$urlImage = $this->getUrlStaticMap($width, $height);
|
||||
|
||||
?>
|
||||
<div class="unite-mappicker-chooser-wrapper">
|
||||
<img class="unite-mappicker-mapimage" src="<?php echo esc_attr($urlImage)?>" width="<?php echo esc_attr($width)?>" height="<?php echo esc_attr($height)?>">
|
||||
<div class="unite-mappicker-chooser-overlay"></div>
|
||||
<a href="javascript:void(0)" class="unite-mappicker-button unite-button-secondary unite-center-position" ><?php esc_html_e("Choose Map", "unlimited-elements-for-elementor")?></a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put html
|
||||
*/
|
||||
public function putHtml(){
|
||||
|
||||
$this->init();
|
||||
|
||||
$this->outputHtml();
|
||||
$this->outputScripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* get map output id
|
||||
*/
|
||||
private function getMapOutputID(){
|
||||
|
||||
self::$serial++;
|
||||
$random = UniteFunctionsUC::getRandomString(5,true);
|
||||
$mapID = "uc_googlemap_output_{$random}_".self::$serial;
|
||||
|
||||
return($mapID);
|
||||
}
|
||||
|
||||
/**
|
||||
* get some setting
|
||||
*/
|
||||
private function getSetting($name){
|
||||
|
||||
if(empty($this->settingsData))
|
||||
UniteFunctionsUC::throwError("Settigns data is empty");
|
||||
|
||||
if(!isset($this->settingsData[$name]))
|
||||
UniteFunctionsUC::throwError("Setting with name: $name not found");
|
||||
|
||||
$value = $this->settingsData[$name];
|
||||
|
||||
return($value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put map client side
|
||||
*/
|
||||
private function putHtmlClientSide(){
|
||||
|
||||
$mapID = $this->getMapOutputID();
|
||||
$functionName = "initMap_".$mapID;
|
||||
$url = $this->getUrlScriptAPI($functionName);
|
||||
|
||||
//set size
|
||||
$width = $this->getSetting("width");
|
||||
$height = $this->getSetting("height");
|
||||
|
||||
$width = UniteFunctionsUC::normalizeSize($width);
|
||||
$height = UniteFunctionsUC::normalizeSize($height);
|
||||
|
||||
$css = "#{$mapID}{ width:{$width};height:{$height} }";
|
||||
|
||||
$mapDataEncode = $this->getMapDataClientSide();
|
||||
$jsonOptions = json_encode($mapDataEncode);
|
||||
|
||||
$mapData = $this->getMapData();
|
||||
|
||||
//marker
|
||||
$marker = UniteFunctionsUC::getVal($mapData, "marker");
|
||||
$putMarker = true;
|
||||
$isMarkerVisible = UniteFunctionsUC::getVal($marker, "isvisible");
|
||||
if($isMarkerVisible === false)
|
||||
$putMarker = false;
|
||||
|
||||
|
||||
if($putMarker){
|
||||
|
||||
$markerLat = UniteFunctionsUC::getVal($marker, "lat");
|
||||
$markerLng = UniteFunctionsUC::getVal($marker, "lng");
|
||||
|
||||
if(empty($markerLat)){
|
||||
$markerLat = $this->defaultLocation["lat"];
|
||||
$markerLng = $this->defaultLocation["lng"];
|
||||
}
|
||||
|
||||
$markerIcon = UniteFunctionsUC::getVal($marker, "icon");
|
||||
if($markerIcon)
|
||||
$markerIcon = HelperUC::URLtoFull($markerIcon);
|
||||
}
|
||||
|
||||
$style = UniteFunctionsUC::getVal($mapData, "style");
|
||||
$style = trim($style);
|
||||
$style = str_replace("\n", "", $style);
|
||||
$style = str_replace("\r", "", $style);
|
||||
|
||||
$mapTypeID = UniteFunctionsUC::getVal($mapData, "maptypeid");
|
||||
|
||||
$lang = UniteFunctionsUC::getVal($mapData,"lang");
|
||||
|
||||
?>
|
||||
|
||||
<style type="text/css">
|
||||
<?php echo UniteProviderFunctionsUC::escCombinedHtml($css)?>
|
||||
</style>
|
||||
<div id="<?php echo esc_attr($mapID)?>"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function <?php echo UniteProviderFunctionsUC::escCombinedHtml($functionName)?>(){
|
||||
|
||||
g_ucGoogleMapLoaded = true;
|
||||
|
||||
var strOptions = '<?php echo UniteProviderFunctionsUC::escCombinedHtml($jsonOptions)?>';
|
||||
var mapOptions = JSON.parse(strOptions);
|
||||
mapOptions.center.lat = Number(mapOptions.center.lat);
|
||||
mapOptions.center.lng = Number(mapOptions.center.lng);
|
||||
mapOptions.zoom = Number(mapOptions.zoom);
|
||||
|
||||
<?php if($style):?>
|
||||
var strStyles = '<?php echo UniteProviderFunctionsUC::escAddParam($style)?>';
|
||||
mapOptions.styles = JSON.parse(strStyles);
|
||||
<?php endif?>
|
||||
|
||||
<?php if($mapTypeID):?>
|
||||
mapOptions.mapTypeId = "<?php echo UniteProviderFunctionsUC::escAddParam($mapTypeID)?>";
|
||||
<?php endif?>
|
||||
|
||||
var map = new google.maps.Map(document.getElementById("<?php echo UniteProviderFunctionsUC::escAddParam($mapID)?>"), mapOptions);
|
||||
|
||||
<?php if($putMarker):?>
|
||||
marker = new google.maps.Marker({
|
||||
position:{
|
||||
lat: <?php echo UniteProviderFunctionsUC::escAddParam($markerLat)?>,
|
||||
lng: <?php echo UniteProviderFunctionsUC::escAddParam($markerLng)?>
|
||||
},
|
||||
map:map
|
||||
<?php if($markerIcon):?>,icon:"<?php echo UniteProviderFunctionsUC::escAddParam($markerIcon)?>"<?php endif?>
|
||||
});
|
||||
<?php endif?>
|
||||
}
|
||||
|
||||
|
||||
//include api
|
||||
if(typeof g_ucGoogleMapLoading == "undefined" && (typeof google == "undefined" || typeof google.maps == "undefined")){
|
||||
|
||||
g_ucGoogleMapLoaded = false;
|
||||
|
||||
var tag = document.createElement('script');
|
||||
tag.src = "<?php echo UniteProviderFunctionsUC::escAddParam($url)?>";
|
||||
var firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
g_ucGoogleMapLoading = true;
|
||||
|
||||
}else{ //just run function
|
||||
if(typeof g_ucGoogleMapLoaded != "undefined" && g_ucGoogleMapLoaded == true)
|
||||
<?php echo UniteProviderFunctionsUC::escAddParam($functionName)?>();
|
||||
else
|
||||
g_interval_<?php echo UniteProviderFunctionsUC::escAddParam($mapID)?> = setInterval(function(){
|
||||
if(typeof g_ucGoogleMapLoaded != "undefined" && g_ucGoogleMapLoaded == true){
|
||||
clearInterval(g_interval_<?php echo UniteProviderFunctionsUC::escAddParam($mapID)?>);
|
||||
<?php echo UniteProviderFunctionsUC::escAddParam($functionName)?>();
|
||||
}
|
||||
},200);
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* get client side html
|
||||
*/
|
||||
public function getHtmlClientSide($data){
|
||||
|
||||
$this->init();
|
||||
|
||||
ob_start();
|
||||
$this->putHtmlClientSide();
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return($content);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Unlimited Elements
|
||||
* @author unlimited-elements.com
|
||||
* @copyright (C) 2021 Unlimited Elements, All Rights Reserved.
|
||||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
||||
* */
|
||||
defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
|
||||
|
||||
|
||||
class UniteCreatorObjectsListView extends UniteElementsBaseUC{
|
||||
|
||||
protected $objectClass;
|
||||
protected $dbTable;
|
||||
protected $viewObject, $viewObjectPreview, $urlListBase;
|
||||
protected $actionDelete;
|
||||
|
||||
protected $enableCategories = false;
|
||||
|
||||
protected $defaultOrderBy = "title";
|
||||
protected $sizeActions = 380;
|
||||
protected $txtSingleName = "Object"; //for phrases like "Search Template"
|
||||
protected $txtMultipleName = "Objects"; //name for multiple objects phrases like: "templates"
|
||||
|
||||
private $arrObjects, $objTable, $numObjects;
|
||||
|
||||
|
||||
/**
|
||||
* validate that all inited
|
||||
*/
|
||||
private function validateInited(){
|
||||
|
||||
if(empty($this->objectClass))
|
||||
UniteFunctionsUC::throwError("The object class should be inited");
|
||||
|
||||
UniteFunctionsUC::validateNotEmpty($this->dbTable, "DB Table");
|
||||
UniteFunctionsUC::validateNotEmpty($this->urlListBase, "Url List Base");
|
||||
UniteFunctionsUC::validateNotEmpty($this->viewObject, "Single object view");
|
||||
UniteFunctionsUC::validateNotEmpty($this->viewObjectPreview, "Single Object Preview View");
|
||||
UniteFunctionsUC::validateNotEmpty($this->actionDelete, "Action Delete");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* validate object methods
|
||||
*/
|
||||
private function validateObjectMethods($object){
|
||||
|
||||
$arrMethods = array("initByID","getID","getTitle");
|
||||
foreach($arrMethods as $method)
|
||||
UniteFunctionsUC::validateObjectMethod($object, $method, $this->objectClass);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public function __construct(){
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->validateInited();
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
private function a_PUT_HTML(){}
|
||||
|
||||
|
||||
/**
|
||||
* put html before table
|
||||
*/
|
||||
protected function putHtml_beforeTable(){
|
||||
|
||||
$this->objTable->putActionsFormStart();
|
||||
$isPutSearchForm = ($this->numObjects > 5);
|
||||
|
||||
$textSearch = "Search"." ".$this->txtSingleName;
|
||||
|
||||
//if less then 5, put only if the search phrase exists
|
||||
$this->objTable->putSearchForm($textSearch, esc_html__("Clear","unlimited-elements-for-elementor"), $isPutSearchForm);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* put html after table
|
||||
*/
|
||||
protected function putHtml_afterTable(){
|
||||
|
||||
$this->objTable->putPaginationHtml();
|
||||
$this->objTable->putInpageSelect();
|
||||
|
||||
$this->objTable->putActionsFormEnd();
|
||||
|
||||
if($this->enableCategories)
|
||||
$this->putDialogCategories();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get client side options
|
||||
*/
|
||||
protected function getClientSideOptions(){
|
||||
|
||||
$options = array();
|
||||
$options["enable_categories"] = $this->enableCategories;
|
||||
$options["action_delete"] = $this->actionDelete;
|
||||
|
||||
return($options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put table html
|
||||
*/
|
||||
protected function putHtml_table(){
|
||||
|
||||
$txtDelete = esc_html__("Are you sure you want to delete this", "unlimited-elements-for-elementor")." ".$this->txtSingleName;
|
||||
|
||||
$options = $this->getClientSideOptions();
|
||||
$strOptions = UniteFunctionsUC::jsonEncodeForHtmlData($options);
|
||||
|
||||
?>
|
||||
<div id="uc_table_objects_wrapper" data-options="<?php echo UniteProviderFunctionsUC::escAddParam($strOptions)?>">
|
||||
|
||||
<?php if(empty($this->arrObjects)): ?>
|
||||
<div>
|
||||
<?php
|
||||
$txtNotFound = esc_html__("No","unlimited-elements-for-elementor")." ".$this->txtMultipleName." ".esc_html__("Found","unlimited-elements-for-elementor");
|
||||
echo esc_html($txtNotFound);
|
||||
?>
|
||||
</div>
|
||||
<?php else:?>
|
||||
|
||||
<table id="uc_table_objects" class='unite_table_items' data-text-confirm-delete="<?php echo esc_attr($txtDelete)?>">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width=''>
|
||||
<?php $this->objTable->putTableOrderHeader("title", $this->txtSingleName." ".esc_html__("Title", "unlimited-elements-for-elementor")) ?>
|
||||
</th>
|
||||
|
||||
<?php if($this->enableCategories == true):?>
|
||||
<th width='200'><?php $objTable->putTableOrderHeader("catid", esc_html__("Category","unlimited-elements-for-elementor")) ?>
|
||||
<?php endif?>
|
||||
|
||||
<th width='<?php echo esc_attr($sizeActions)?>'><?php esc_html_e("Actions","unlimited-elements-for-elementor"); ?></th>
|
||||
<th width='60'><?php esc_html_e("Preview","unlimited-elements-for-elementor"); ?></th>
|
||||
</tr>
|
||||
|
||||
<?php foreach($this->arrObjects as $key=>$object):
|
||||
|
||||
$id = $object->getID();
|
||||
$title = $object->getTitle();
|
||||
$editLink = HelperUC::getViewUrl($this->viewObject,"id=".$id);
|
||||
$previewLink = HelperUC::getViewUrl($this->viewObjectPreview,"id=".$id, true);
|
||||
|
||||
$showTitle = HelperHtmlUC::getHtmlLink($editLink, $title);
|
||||
$rowClass = ($key%2==0)?"unite-row1":"unite-row2";
|
||||
|
||||
if($this->enableCategories){
|
||||
dmp("check the getCategoryInfo function");
|
||||
$arrCategory = $object->getCategoryInfo();
|
||||
$catID = UniteFunctionsUC::getVal($arrCategory, "id");
|
||||
$catTitle = UniteFunctionsUC::getVal($arrCategory, "title");
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
<tr class="<?php echo esc_attr($rowClass)?>">
|
||||
<td><?php echo esc_html($showTitle)?></td>
|
||||
|
||||
<?php if($this->enableCategories):?>
|
||||
<td><a href="javascript:void(0)" class="uc-layouts-list-category" data-layoutid="<?php echo esc_attr($id)?>" data-catid="<?php echo esc_attr($catID)?>" data-action="manage_category"><?php echo esc_html($catTitle)?></a></td>
|
||||
<?php endif?>
|
||||
|
||||
<td>
|
||||
<a href='<?php echo esc_attr($editLink)?>' class="unite-button-primary float_left mleft_15"><?php echo esc_html__("Edit", "unlimited-elements-for-elementor")." ".$this->txtSingleName ?></a>
|
||||
|
||||
<a href='javascript:void(0)' data-action="delete" data-id="<?php echo esc_attr($id)?>" class="uc-button-action unite-button-secondary float_left mleft_15"><?php esc_html_e("Delete","unlimited-elements-for-elementor"); ?></a>
|
||||
<span class="loader_text uc-loader-delete" style="display:none"><?php esc_html_e("Deleting", "unlimited-elements-for-elementor")?></span>
|
||||
|
||||
<!--
|
||||
<a href='javascript:void(0)' data-layoutid="<?php echo esc_attr($id)?>" data-id="<?php echo esc_attr($id)?>" class="button_duplicate unite-button-secondary float_left mleft_15"><?php esc_html_e("Duplicate","unlimited-elements-for-elementor"); ?></a>
|
||||
<span class="loader_text uc-loader-duplicate" style="display:none"><?php esc_html_e("Duplicating", "unlimited-elements-for-elementor")?></span>
|
||||
|
||||
<a href='javascript:void(0)' data-layoutid="<?php echo esc_attr($id)?>" data-id="<?php echo esc_attr($id)?>" class="button_export unite-button-secondary float_left mleft_15"><?php esc_html_e("Export","unlimited-elements-for-elementor"); ?></a>
|
||||
-->
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<a href='<?php echo esc_attr($previewLink)?>' target="_blank" class="unite-button-secondary float_left"><?php esc_html_e("Preview","unlimited-elements-for-elementor"); ?></a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php endforeach?>
|
||||
</thead>
|
||||
|
||||
</table>
|
||||
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put scripts
|
||||
*/
|
||||
protected function putHtml_scripts(){
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
|
||||
var objAdmin = new UniteCreatorAdmin_ObjectsList();
|
||||
objAdmin.initObjectsListView();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* put html
|
||||
*/
|
||||
protected function putHtml(){
|
||||
|
||||
$txtDelete = esc_html__("Are you sure you want to delete this", "unlimited-elements-for-elementor")." ".$this->txtSingleName;
|
||||
|
||||
?>
|
||||
<div class="unite-content-wrapper">
|
||||
|
||||
<?php
|
||||
$this->putHtml_beforeTable();
|
||||
$this->putHtml_table();
|
||||
$this->putHtml_afterTable();
|
||||
$this->putHtml_scripts();
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
private function a_INIT(){}
|
||||
|
||||
/**
|
||||
* convert records to layouts objects
|
||||
*/
|
||||
private function recordsToObjects($records){
|
||||
|
||||
$arrObjects = array();
|
||||
foreach($records as $index=>$record){
|
||||
$objectID = UniteFunctionsUC::getVal($record, "id");
|
||||
|
||||
$object = new $this->objectClass();
|
||||
|
||||
//validate single object methods
|
||||
if($index == 0)
|
||||
$this->validateObjectMethods($object);
|
||||
|
||||
$object->initByID($objectID);
|
||||
|
||||
$arrObjects[] = $object;
|
||||
}
|
||||
|
||||
|
||||
return($arrObjects);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* get records with paging
|
||||
*/
|
||||
protected function getRecordsPaging($pagingOptions){
|
||||
|
||||
$where = "";
|
||||
|
||||
//search
|
||||
$search = UniteFunctionsUC::getVal($pagingOptions, "search");
|
||||
|
||||
if(!empty($search)) {
|
||||
$search = $this->db->escape($search);
|
||||
$where = "title LIKE '%{$search}%'";
|
||||
}
|
||||
|
||||
$order = UniteFunctionsUC::getVal($pagingOptions, "ordering");
|
||||
|
||||
$response = $this->db->fetchPage($this->dbTable, $pagingOptions, $where, $order);
|
||||
|
||||
return($response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get layouts with paging data
|
||||
*/
|
||||
protected function initAllObjects(){
|
||||
|
||||
$this->objTable = new UniteTableUC();
|
||||
$this->objTable->setDefaultOrderby($this->defaultOrderBy);
|
||||
|
||||
$pagingOptions = $this->objTable->getPagingOptions();
|
||||
|
||||
$response = $this->getRecordsPaging($pagingOptions);
|
||||
|
||||
$rows = $response["rows"];
|
||||
unset($response["rows"]);
|
||||
|
||||
$this->arrObjects = $this->recordsToObjects($rows);
|
||||
$this->numObjects = count($this->arrObjects);
|
||||
|
||||
$this->objTable->setPagingData($this->urlListBase, $response);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* put script inlcudes
|
||||
*/
|
||||
protected function putScriptIncludes(){
|
||||
|
||||
HelperUC::addScript("unitecreator_admin_objectslist", "unitecreator_admin_objectslist.js");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public function display(){
|
||||
|
||||
$this->initAllObjects();
|
||||
$this->putScriptIncludes();
|
||||
|
||||
$this->putHtml();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Unlimited Elements
|
||||
* @author unlimited-elements.com
|
||||
* @copyright (C) 2021 Unlimited Elements, All Rights Reserved.
|
||||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
||||
* */
|
||||
defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
|
||||
|
||||
class UniteCreatorSettingsView{
|
||||
|
||||
const SETTINGS_KEY_GENERAL_SETTINGS = "general_settings";
|
||||
|
||||
protected $showHeader = true;
|
||||
protected $headerTitle = null;
|
||||
protected $saveAction = null;
|
||||
|
||||
protected $isModeCustomSettings = false; //any custom settings
|
||||
protected $customSettingsKey = null;
|
||||
protected $customSettingsXmlFile = null;
|
||||
|
||||
protected $objSettings = null;
|
||||
protected $textButton = null;
|
||||
|
||||
|
||||
/**
|
||||
* function for override
|
||||
*/
|
||||
protected function drawAdditionalTabs(){}
|
||||
|
||||
protected function drawAdditionalTabsContent(){}
|
||||
|
||||
|
||||
/**
|
||||
* draw save settings button
|
||||
*/
|
||||
protected function drawSaveSettingsButton($prefix){
|
||||
|
||||
$buttonText = $this->textButton;
|
||||
if(empty($buttonText))
|
||||
$buttonText = esc_html__("Save Settings", "unlimited-elements-for-elementor");
|
||||
|
||||
$addParams = "";
|
||||
if($this->isModeCustomSettings == true)
|
||||
$addParams = " data-settingskey='{$this->customSettingsKey}'";
|
||||
|
||||
|
||||
?>
|
||||
<div class="uc-button-action-wrapper">
|
||||
|
||||
<a id="<?php echo esc_attr($prefix)?>_button_save_settings" data-prefix="<?php echo esc_attr($prefix)?>" <?php echo UniteProviderFunctionsUC::escAddParam($addParams)?> class="unite-button-primary uc-button-save-settings" href="javascript:void(0)"><?php echo esc_html($buttonText)?></a>
|
||||
|
||||
<div style="padding-top:6px;">
|
||||
|
||||
<span id="<?php echo esc_attr($prefix)?>_loader_save" class="loader_text" style="display:none"><?php esc_html_e("Saving...", "unlimited-elements-for-elementor")?></span>
|
||||
<span id="<?php echo esc_attr($prefix)?>_message_saved" class="unite-color-green" style="display:none"></span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="unite-clear"></div>
|
||||
|
||||
<div id="<?php echo esc_attr($prefix)?>_save_settings_error" class="unite_error_message" style="display:none"></div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* validate that the view is inited
|
||||
*/
|
||||
private function validateInited(){
|
||||
|
||||
if(empty($this->headerTitle))
|
||||
UniteFunctionsUC::throwError("Please init the header title variable");
|
||||
|
||||
if($this->isModeCustomSettings == true){
|
||||
UniteFunctionsUC::validateNotEmpty($this->customSettingsKey, "Custom settings key");
|
||||
UniteFunctionsUC::validateNotEmpty($this->customSettingsXmlFile, "Custom settings xml file");
|
||||
}
|
||||
|
||||
if(empty($this->saveAction))
|
||||
UniteFunctionsUC::throwError("Please init the save action");
|
||||
|
||||
if(empty($this->objSettings))
|
||||
UniteFunctionsUC::throwError("Please init the settings object");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* modify custom settings - function for override
|
||||
*/
|
||||
protected function modifyCustomSettings($settings){
|
||||
|
||||
return($settings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* init the custom mode
|
||||
*/
|
||||
protected function initCustomMode(){
|
||||
|
||||
$this->saveAction = "save_custom_settings";
|
||||
|
||||
UniteFunctionsUC::validateNotEmpty($this->customSettingsXmlFile,"xml file( customSettingsXmlFile variable)");
|
||||
|
||||
$this->objSettings = new UniteCreatorSettings();
|
||||
$this->objSettings->loadXMLFile($this->customSettingsXmlFile);
|
||||
|
||||
$arrValues = HelperUC::$operations->getCustomSettingsValues($this->customSettingsKey);
|
||||
|
||||
if(!empty($arrValues))
|
||||
$this->objSettings->setStoredValues($arrValues);
|
||||
|
||||
$this->objSettings = $this->modifyCustomSettings($this->objSettings);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* add scripts
|
||||
*/
|
||||
protected function addScripts(){
|
||||
|
||||
HelperUC::addScript("unitecreator_admin_generalsettings", "unitecreator_admin_generalsettings");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* display settings
|
||||
*/
|
||||
protected function display(){
|
||||
|
||||
$this->addScripts();
|
||||
|
||||
if($this->isModeCustomSettings == true)
|
||||
$this->initCustomMode();
|
||||
|
||||
$this->validateInited();
|
||||
|
||||
//show header
|
||||
if($this->showHeader == true){
|
||||
$headerTitle = $this->headerTitle;
|
||||
require HelperUC::getPathTemplate("header");
|
||||
}else
|
||||
require HelperUC::getPathTemplate("header_missing");
|
||||
|
||||
|
||||
$objSettings = $this->objSettings;
|
||||
|
||||
//get saps
|
||||
$arrSaps = $objSettings->getArrSaps();
|
||||
|
||||
$formID = "uc_general_settings";
|
||||
|
||||
$objOutput = new UniteSettingsOutputWideUC();
|
||||
$objOutput->init($objSettings);
|
||||
$objOutput->setFormID($formID);
|
||||
|
||||
$randomString = UniteFunctionsUC::getRandomString(5, true);
|
||||
|
||||
require HelperUC::getPathTemplate("settings");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Unlimited Elements
|
||||
* @author unlimited-elements.com
|
||||
* @copyright (C) 2021 Unlimited Elements, All Rights Reserved.
|
||||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
||||
* */
|
||||
defined('UNLIMITED_ELEMENTS_INC') or die('Restricted access');
|
||||
|
||||
|
||||
class UniteCreatorViewsChooser{
|
||||
|
||||
protected $showButtons = true;
|
||||
protected $showHeader = true;
|
||||
protected $defaultIcon = "puzzle-piece";
|
||||
protected $arrPages = array();
|
||||
protected $headerTemplate = "header";
|
||||
protected $headerText;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
public function __construct(){
|
||||
|
||||
$this->initDefaults();
|
||||
$this->init();
|
||||
$this->putHtml();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* init defaults
|
||||
*/
|
||||
protected function initDefaults(){
|
||||
|
||||
$this->headerText = "My Pages List";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* init the pages
|
||||
*/
|
||||
protected function init(){
|
||||
|
||||
$urlAddons = helperUC::getViewUrl_Addons();
|
||||
$urlDividers = helperUC::getViewUrl_Addons(GlobalsUC::ADDON_TYPE_SHAPE_DEVIDER);
|
||||
$urlShapes = helperUC::getViewUrl_Addons(GlobalsUC::ADDON_TYPE_SHAPES);
|
||||
|
||||
$urlSections = HelperUC::getViewUrl_LayoutsList(array(), GlobalsUC::ADDON_TYPE_LAYOUT_SECTION);
|
||||
|
||||
$textAddons = esc_html__("My Addons", "unlimited-elements-for-elementor");
|
||||
$textDividers = esc_html__("Dividers", "unlimited-elements-for-elementor");
|
||||
$textShapes = esc_html__("Shapes", "unlimited-elements-for-elementor");
|
||||
$textSection = esc_html__("Sections", "unlimited-elements-for-elementor");
|
||||
$textPageTemplates = esc_html__("Page Templates", "unlimited-elements-for-elementor");
|
||||
|
||||
$this->addPage($urlAddons, $textAddons);
|
||||
$this->addPage($urlDividers, $textDividers, "map");
|
||||
$this->addPage($urlShapes, $textShapes, "map");
|
||||
$this->addPage($urlSections, $textSection);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* add page
|
||||
*/
|
||||
protected function addPage($url, $title, $icon=null){
|
||||
|
||||
if(empty($icon))
|
||||
$icon = $this->defaultIcon;
|
||||
|
||||
$this->arrPages[] = array(
|
||||
"url"=>$url,
|
||||
"title"=>$title,
|
||||
"icon"=>$icon);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* put pages html
|
||||
*/
|
||||
protected function putHtmlPages(){
|
||||
|
||||
if($this->showHeader == true){
|
||||
|
||||
$headerTitle = $this->headerText;
|
||||
|
||||
require HelperUC::getPathTemplate("header");
|
||||
}else
|
||||
require HelperUC::getPathTemplate("header_missing");
|
||||
|
||||
|
||||
?>
|
||||
<ul class='uc-list-pages-thumbs'>
|
||||
<?php
|
||||
foreach($this->arrPages as $page){
|
||||
|
||||
$url = $page["url"];
|
||||
$icon = $page["icon"];
|
||||
|
||||
if(empty($icon))
|
||||
$icon = "angellist";
|
||||
|
||||
$title = $page["title"];
|
||||
|
||||
?>
|
||||
<li>
|
||||
<a href="<?php echo esc_url($url)?>">
|
||||
<i class="fa fa-<?php echo esc_attr($icon)?>"></i>
|
||||
<?php esc_html($title)?>
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
protected function putHtml(){
|
||||
|
||||
$this->putHtmlPages();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user