Skip to content
Snippets Groups Projects
Commit 9f1493e4 authored by Satish's avatar Satish
Browse files

Extension store files updated for v7

parent fb45ec35
No related branches found
No related tags found
No related merge requests found
Showing
with 326 additions and 296 deletions
/*
* Copyright (C) www.vtiger.com. All rights reserved.
* @license Proprietary
*/
/*+**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
************************************************************************************/
jQuery.Class("ExtensionStore_ExtensionStore_Js", {}, {
/**
* Function to register events for banner
*/
registerEventsForBanner : function(){
var bxTarget = jQuery('.bxslider');
var items = jQuery('li', bxTarget);
if (items.length) {
bxTarget.bxSlider({
mode: 'fade',
auto: true,
pager: items.length > 1,
speed: items.length > 1 ? 1500 : 0,
pause: 3000,
onSlideBefore : function(){
jQuery('.bx-viewport').css({'height': '110px', 'overflow': 'hidden'});
}
});
}
},
/**
* Function to getPromotions from marketplace
*/
getPromotions : function(){
var thisInstance = this;
var params = {
'module': 'ExtensionStore',
'view': 'Listings',
'mode': 'getPromotions'
};
AppConnector.request(params).then(
function(data) {
if((typeof data != 'undefined') && (jQuery(data).find('img').length > 0)){
jQuery('.dashboardHeading').append(data);
thisInstance.registerEventsForBanner();
}else{
jQuery('.togglePromotion').trigger('click');
}
},
function(error) {}
);
},
/**
* Function to request get promotions from market place based on promotion closed date
*/
getPromotionsFromMarketPlace : function(promotionClosedDate){
var thisInstance = this;
if(promotionClosedDate != null){
var maxPromotionParams = {
'module' : 'ExtensionStore',
'action' : 'Promotion',
'mode' : 'maxCreatedOn'
};
AppConnector.request(maxPromotionParams).then(
function(data) {
var date = data['result'];
var dateObj = new Date(date);
var closedDate = new Date(promotionClosedDate);
var dateDiff = ((dateObj.getTime()) - (closedDate.getTime()))/(1000*60*60*24);
if(dateDiff > 0){
thisInstance.getPromotions();
}
});
}else if(promotionClosedDate == null){
thisInstance.getPromotions();
}
},
registerEventsForTogglePromotion : function() {
var thisInstance = this;
jQuery('.togglePromotion').on('click', function(e){
var element = jQuery(e.currentTarget);
var bannerContainer = jQuery(".banner-container");
if(element.hasClass('up')){
bannerContainer.slideUp();
element.find('.icon-chevron-up').addClass('hide');
element.find('.icon-chevron-down').removeClass('hide');
element.addClass('down').removeClass('up');
}else if(element.hasClass('down')){
if(bannerContainer.find('img').length <= 0){
thisInstance.getPromotionsFromMarketPlace(null);
}
bannerContainer.slideDown();
element.find('.icon-chevron-down').addClass('hide');
element.find('.icon-chevron-up').removeClass('hide');
element.addClass('up').removeClass('down');
}
});
},
insertTogglePromotionHtml : function(){
var toggleHtml = '<span class="btn-group">'+
'<button class="btn addButton togglePromotion up">'+
'<span id="hide" class="icon icon-chevron-up"></span>'+
'<span id="show" class="icon icon-chevron-down hide"></span>'+
'</button>'+
'</span>';
jQuery('.dashboardHeading').find('.btn-toolbar').append(toggleHtml);
},
registerEvents: function() {
var thisInstance = this;
var moduleName = app.getModuleName();
var date = new Date();
var promotionClosedDate = date.getUTCFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
var getPromotion = false;
thisInstance.insertTogglePromotionHtml();
if(promotionClosedDate == null){
getPromotion = true;
}else if(promotionClosedDate.length > 0){
var closedDate = promotionClosedDate.split("-");
var closedOn = new Date(parseInt(closedDate[0]), parseInt(closedDate[1]), parseInt(closedDate[2]));
var currentDate = new Date();
var diff = (currentDate.getTime()) - (closedOn.getTime());
var days = diff/(1000*60*60*24);
if(days >= 7){
getPromotion = true;
}else {
getPromotion = false;
}
}
if ((moduleName == "Home") && getPromotion) {
thisInstance.getPromotionsFromMarketPlace(promotionClosedDate);
}else if((moduleName == "Home") && !getPromotion){
jQuery('.togglePromotion').find('.icon-chevron-up').addClass('hide');
jQuery('.togglePromotion').find('.icon-chevron-down').removeClass('hide');
jQuery('.togglePromotion').addClass('down').removeClass('up');
}
thisInstance.registerEventsForTogglePromotion();
}
jQuery.Class('ExtensionStore_ExtensionStore_Js', {}, {
/**
* Function to register events for banner
*/
registerEventsForBanner: function () {
var bxTarget = jQuery('.bxslider');
var items = jQuery('li', bxTarget);
if (items.length) {
bxTarget.bxSlider({
mode: 'fade',
auto: true,
pager: items.length > 1,
speed: items.length > 1 ? 1500 : 0,
pause: 3000,
onSlideBefore: function () {
jQuery('.bx-viewport').css({'height': '150px', 'overflow': 'hidden'});
}
});
}
},
/**
* Function to getPromotions from marketplace
*/
getPromotions: function () {
var thisInstance = this;
var params = {
'module': 'ExtensionStore',
'view': 'Listings',
'mode': 'getPromotions'
};
app.request.post({data:params}).then(
function (err, data) {
if ((typeof data != 'undefined') && (jQuery(data).find('img').length > 0)) {
jQuery('.dashboardHeading').append(data);
thisInstance.registerEventsForBanner();
} else {
jQuery('.togglePromotion').addClass('hide');
}
},
function (error) {
}
);
},
/**
* Function to request get promotions from market place based on promotion closed date
*/
getPromotionsFromMarketPlace: function (promotionClosedDate) {
var thisInstance = this;
if (promotionClosedDate != null) {
var maxPromotionParams = {
'module': 'ExtensionStore',
'action': 'Promotion',
'mode': 'maxCreatedOn'
};
app.request.post({data:maxPromotionParams}).then(
function (err, data) {
var date = data['result'];
var dateObj = new Date(date);
var closedDate = new Date(promotionClosedDate);
var dateDiff = ((dateObj.getTime()) - (closedDate.getTime())) / (1000 * 60 * 60 * 24);
if (dateDiff > 0) {
thisInstance.getPromotions();
} else {
jQuery('.togglePromotion').addClass('hide');
}
});
} else if (promotionClosedDate == null) {
thisInstance.getPromotions();
}
},
registerEventsForTogglePromotion: function () {
var thisInstance = this;
jQuery('.togglePromotion').on('click', function (e) {
var element = jQuery(e.currentTarget);
var bannerContainer = jQuery('.banner-container');
if (element.hasClass('up')) {
bannerContainer.slideUp();
element.find('.icon-chevron-up').addClass('hide');
element.find('.icon-chevron-down').removeClass('hide');
element.addClass('down').removeClass('up');
} else if (element.hasClass('down')) {
if (bannerContainer.find('img').length <= 0) {
thisInstance.getPromotionsFromMarketPlace(null);
}
bannerContainer.slideDown();
element.find('.icon-chevron-down').addClass('hide');
element.find('.icon-chevron-up').removeClass('hide');
element.addClass('up').removeClass('down');
}
});
},
insertTogglePromotionHtml: function () {
var toggleHtml = '<span class="btn-group">'+
'<button class="btn addButton togglePromotion up">'+
'<span id="hide" class="icon icon-chevron-up"></span>'+
'<span id="show" class="icon icon-chevron-down hide"></span>'+
'</button>'+
'</span>';
jQuery('.dashboardHeading').find('.btn-toolbar').append(toggleHtml);
},
registerEvents: function () {
var thisInstance = this;
var moduleName = app.getModuleName();
if ((moduleName == 'Home')) {
thisInstance.insertTogglePromotionHtml();
thisInstance.getPromotionsFromMarketPlace();
jQuery('.togglePromotion').find('.icon-chevron-up').addClass('hide');
jQuery('.togglePromotion').find('.icon-chevron-down').removeClass('hide');
jQuery('.togglePromotion').addClass('down').removeClass('up');
thisInstance.registerEventsForTogglePromotion();
}
}
});
jQuery(document).ready(function() {
var moduleName = app.getModuleName();
if (moduleName == "Home") {
var instance = new ExtensionStore_ExtensionStore_Js();
instance.registerEvents();
}
jQuery(document).ready(function () {
var moduleName = app.getModuleName();
if (moduleName == 'Home') {
var instance = new ExtensionStore_ExtensionStore_Js();
instance.registerEvents();
}
});
<?php
/*
* Copyright (C) www.vtiger.com. All rights reserved.
* @license Proprietary
*/
Class ExtensionStore{
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* ***********************************************************************************/
class ExtensionStore {
}
?>
<?php
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* ***********************************************************************************/
/*
* Copyright (C) www.vtiger.com. All rights reserved.
* @license Proprietary
*/
class ExtensionStore_Promotion_Action extends Vtiger_Index_View {
public function __construct() {
parent::__construct();
$this->exposeMethod('maxCreatedOn');
}
public function process(Vtiger_Request $request) {
$mode = $request->getMode();
if (!empty($mode)) {
$this->invokeExposedMethod($mode, $request);
return;
}
}
class ExtensionStore_Promotion_Action extends Vtiger_Index_View{
public function __construct() {
parent::__construct();
$this->exposeMethod('maxCreatedOn');
}
public function process(Vtiger_Request $request) {
$mode = $request->getMode();
if (!empty($mode)) {
$this->invokeExposedMethod($mode, $request);
return;
}
}
protected function maxCreatedOn(Vtiger_Request $request){
$modelInstance = Settings_ExtensionStore_Extension_Model::getInstance();
$promotions = $modelInstance->getMaxCreatedOn('Promotion', 'max', 'createdon');
$response = new Vtiger_Response();
if ($promotions['success'] != 'true') {
$response->setError('', $promotions['error']);
} else {
$response->setResult($promotions['response']);
}
$response->emit();
}
}
\ No newline at end of file
$modelInstance = Settings_ExtensionStore_Extension_Model::getInstance();
$promotions = $modelInstance->getMaxCreatedOn('Promotion', 'max', 'createdon');
$response = new Vtiger_Response();
if ($promotions['success'] != 'true') {
$response->setError('', $promotions['error']);
} else {
$response->setResult($promotions['response']);
}
$response->emit();
}
}
<?php
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* ***********************************************************************************/
/*
* Copyright (C) www.vtiger.com. All rights reserved.
* @license Proprietary
*/
class ExtensionStore_Listings_View extends Vtiger_Index_View {
class ExtensionStore_Listings_View extends Vtiger_Index_View{
public function __construct() {
parent::__construct();
$this->exposeMethod('getPromotions');
}
public function process(Vtiger_Request $request) {
$mode = $request->getMode();
if (!empty($mode)) {
$this->invokeExposedMethod($mode, $request);
return;
}
}
/**
* Function to get news listings by passing type as News
*/
protected function getPromotions(Vtiger_Request $request) {
$modelInstance = Settings_ExtensionStore_Extension_Model::getInstance();
$promotions = $modelInstance->getListings('','Promotion');
$qualifiedModuleName = $request->getModule(false);
public function __construct() {
parent::__construct();
$this->exposeMethod('getPromotions');
}
$viewer = $this->getViewer($request);
$viewer->assign('PROMOTIONS', $promotions);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->view('Promotions.tpl', $qualifiedModuleName);
}
}
\ No newline at end of file
public function getHeaderScripts(Vtiger_Request $request) {
$jsFileNames = array(
"libraries.jquery.boxslider.jqueryBxslider",
);
$jsScriptInstances = $this->checkAndConvertJsScripts($jsFileNames);
return $jsScriptInstances;
}
public function process(Vtiger_Request $request) {
$mode = $request->getMode();
if (!empty($mode)) {
$this->invokeExposedMethod($mode, $request);
return;
}
}
/**
* Function to get news listings by passing type as News
*/
protected function getPromotions(Vtiger_Request $request) {
$modelInstance = Settings_ExtensionStore_Extension_Model::getInstance();
$promotions = $modelInstance->getListings(null, 'Promotion');
$qualifiedModuleName = $request->getModule(false);
$viewer = $this->getViewer($request);
$viewer->assign('PROMOTIONS', $promotions);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->assign('HEADER_SCRIPTS', $this->getHeaderScripts($request));
$viewer->view('Promotions.tpl', $qualifiedModuleName);
}
}
<?php
/*
* Copyright (C) www.vtiger.com. All rights reserved.
* @license Proprietary
*/
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* ***********************************************************************************/
class Settings_ExtensionStore_Basic_Action extends Settings_Vtiger_IndexAjax_View {
......
<?php
/*
* Copyright (C) www.vtiger.com. All rights reserved.
* @license Proprietary
*/
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* ***********************************************************************************/
include_once dirname(__FILE__).'/../libraries/NetClient.php';
......@@ -467,4 +470,12 @@ class Settings_ExtensionStore_ExtnStore_Connector {
}
}
public function getNews() {
try {
$response = $this->api("/app/news", 'GET', '', false);
return array('success' => true, 'result' => $response);
} catch (Exception $ex) {
return array('success' => false, 'error' => $ex->getMessage());
}
}
}
......@@ -6,25 +6,25 @@
* without explicit permission from Vtiger (www.vtiger.com).
*/
Class Settings_ModuleManager_LoaderSuggest {
Class Settings_ModuleManager_LoaderSuggest {
function vtiger_extensionloader_suggest() {
$PHPVER = sprintf("%s.%s", PHP_MAJOR_VERSION, PHP_MINOR_VERSION);
$OSHWINFO= str_replace('Darwin', 'Mac', PHP_OS) . '_' . php_uname('m');
$WIN = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')? true : false;
$EXTFNAME = 'vtigerextn_loader';
$EXTNFILE = $EXTFNAME . ($WIN? '.dll' :'.so');
$DISTFILE = sprintf("%s_%s_%s.so", $EXTFNAME, $PHPVER, $OSHWINFO);
$DISTFILEZIP = sprintf("%s_%s_%s-yyyymmdd.zip", $EXTFNAME, $PHPVER, $OSHWINFO);
return array(
'loader_zip' => $DISTFILEZIP,
'loader_file' => $DISTFILE,
'php_ini' => php_ini_loaded_file(),
'extensions_dir' => ini_get('extension_dir')
);
}
}
\ No newline at end of file
function vtiger_extensionloader_suggest() {
$PHPVER = sprintf("%s.%s", PHP_MAJOR_VERSION, PHP_MINOR_VERSION);
$OSHWINFO = str_replace('Darwin', 'Mac', PHP_OS).'_'.php_uname('m');
$WIN = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false;
$EXTFNAME = 'vtigerextn_loader';
$EXTNFILE = $EXTFNAME.($WIN ? '.dll' : '.so');
$DISTFILE = sprintf("%s_%s_%s.so", $EXTFNAME, $PHPVER, $OSHWINFO);
$DISTFILEZIP = sprintf("%s_%s_%s-yyyymmdd.zip", $EXTFNAME, $PHPVER, $OSHWINFO);
return array(
'loader_zip' => $DISTFILEZIP,
'loader_file' => $DISTFILE,
'php_ini' => php_ini_loaded_file(),
'extensions_dir' => ini_get('extension_dir')
);
}
}
<?php
/*
* Copyright (C) www.vtiger.com. All rights reserved.
* @license Proprietary
*/
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* ***********************************************************************************/
vimport('~~/vtlib/Vtiger/Package.php');
vimport('~/libraries/PHPMarkdown/Michelf/Markdown.inc.php');
......@@ -210,6 +213,16 @@ class Settings_ExtensionStore_Extension_Model extends Vtiger_Base_Model {
}
}
public function getNews() {
$news = array();
$extensionLookUpUrl = $this->getExtensionsLookUpUrl();
if ($extensionLookUpUrl) {
$connector = Settings_ExtensionStore_ExtnStore_Connector::getInstance($extensionLookUpUrl);
$news = $connector->getNews();
}
return $news;
}
/**
* Function to get all availible extensions
* @param <Object> $xmlContent
......@@ -487,45 +500,36 @@ class Settings_ExtensionStore_Extension_Model extends Vtiger_Base_Model {
foreach ($listing as $key => $value) {
switch ($key) {
case 'name' : $key = 'label';
break;
case 'identifier': $key = 'name';
break;
case 'version' : $key = 'pkgVersion';
break;
case 'minrange': $key = 'vtigerVersion';
break;
case 'maxrange': $key = 'vtigerMaxVersion';
break;
case 'CustomerId': $key = 'publisher';
break;
case 'price': $value = $value ? $value : 'Free';
break;
case 'approvedon': $key = 'pubDate';
break;
case 'ListingFileId':
if ($value) {
$key = 'downloadURL';
$value = $this->getExtensionsLookUpUrl().'/customer/listingfiles?id='.$value;
}
break;
case 'thumbnail':
if ($value) {
$key = 'thumbnailURL';
$value = str_replace('api', "_listingimages/$value", $this->getExtensionsLookUpUrl());
}
break;
case 'banner' :
if ($value) {
$key = 'bannerURL';
$value = str_replace('api', "_listingimages/$value", $this->getExtensionsLookUpUrl());
}
break;
case 'description':
if ($value) {
$markDownInstance = new Michelf\Markdown();
$value = $markDownInstance->transform($value);
}
case 'name' : $key = 'label'; break;
case 'identifier' : $key = 'name'; break;
case 'version' : $key = 'pkgVersion'; break;
case 'minrange' : $key = 'vtigerVersion'; break;
case 'maxrange' : $key = 'vtigerMaxVersion'; break;
case 'CustomerId' : $key = 'publisher'; break;
case 'approvedon' : $key = 'pubDate'; break;
case 'price' : if (!$value) {
$value = 'Free';
}
break;
case 'ListingFileId': if ($value) {
$key = 'downloadURL';
$value = $this->getExtensionsLookUpUrl().'/customer/listingfiles?id='.$value;
}
break;
case 'thumbnail' : if ($value) {
$key = 'thumbnailURL';
$value = str_replace('api', "_listingimages/$value", $this->getExtensionsLookUpUrl());
}
break;
case 'banner' : if ($value) {
$key = 'bannerURL';
$value = str_replace('api', "_listingimages/$value", $this->getExtensionsLookUpUrl());
}
break;
case 'description' : if ($value) {
$markDownInstance = new Michelf\Markdown();
$value = $markDownInstance->transform($value);
}
}
$extensionModel->set($key, $value);
}
......
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
* ***********************************************************************************/
class Settings_ExtensionStore_Module_Model extends Vtiger_Module_Model {
......
<?php
/*
* Copyright (C) www.vtiger.com. All rights reserved.
* @license Proprietary
*/
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* ***********************************************************************************/
include_once dirname(__FILE__).'/../libraries/LoaderSuggest.php';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment