本文整理汇总了PHP中Marketplace类的典型用法代码示例。如果您正苦于以下问题:PHP Marketplace类的具体用法?PHP Marketplace怎么用?PHP Marketplace使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Marketplace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: marketplaces
function marketplaces()
{
$objs = new Marketplace();
$objs->get();
$data = array('marketplaces' => $objs);
$this->load->view('backend/marketplaces', $data);
}
示例2: update
function update()
{
$params = $this->input->post();
$obj = new Marketplace();
$obj->where('id', $params['id'])->update($params);
echo $obj->check_last_query();
}
示例3: getLatestAvailableVersionNumber
public function getLatestAvailableVersionNumber() {
if (defined('MULTI_SITE') && MULTI_SITE == 1) {
$updates = Update::getLocalAvailableUpdates();
$multiSiteVersion = 0;
foreach($updates as $up) {
if (version_compare($up->getUpdateVersion(), $multiSiteVersion, '>')) {
$multiSiteVersion = $up->getUpdateVersion();
}
}
Config::save('APP_VERSION_LATEST', $multiSiteVersion);
return $multiSiteVersion;
}
$d = Loader::helper('date');
// first, we check session
$queryWS = false;
Cache::disableCache();
$vNum = Config::get('APP_VERSION_LATEST', true);
Cache::enableCache();
if (is_object($vNum)) {
$seconds = strtotime($vNum->timestamp);
$version = $vNum->value;
if (is_object($version)) {
$versionNum = $version->version;
} else {
$versionNum = $version;
}
$diff = time() - $seconds;
if ($diff > APP_VERSION_LATEST_THRESHOLD) {
// we grab a new value from the service
$queryWS = true;
}
} else {
$queryWS = true;
}
if ($queryWS) {
Loader::library('marketplace');
$mi = Marketplace::getInstance();
if ($mi->isConnected()) {
Marketplace::checkPackageUpdates();
}
$update = Update::getLatestAvailableUpdate();
$versionNum = $update->version;
if ($versionNum) {
Config::save('APP_VERSION_LATEST', $versionNum);
if (version_compare($versionNum, APP_VERSION, '>')) {
Loader::model('system_notification');
SystemNotification::add(SystemNotification::SN_TYPE_CORE_UPDATE, t('A new version of concrete5 is now available.'), '', $update->notes, View::url('/dashboard/system/update'));
}
} else {
// we don't know so we're going to assume we're it
Config::save('APP_VERSION_LATEST', APP_VERSION);
}
}
return $versionNum;
}
示例4: view
public function view() {
$tp = new TaskPermission();
if ($tp->canInstallPackages()) {
$mi = Marketplace::getInstance();
if ($mi->isConnected()) {
Marketplace::checkPackageUpdates();
}
}
}
示例5: getSlotContents
public static function getSlotContents() {
if (!isset(self::$slots)) {
$fh = Loader::helper('file');
Loader::library('marketplace');
$cfToken = Marketplace::getSiteToken();
$r = $fh->getContents(NEWSFLOW_SLOT_CONTENT_URL . '?cfToken=' . $cfToken);
self::$slots = NewsflowSlotItem::parseResponse($r);
}
return self::$slots;
}
示例6: download_update
public function download_update()
{
if (MULTI_SITE == 1) {
return false;
}
$vt = Loader::helper('validation/token');
if (!$vt->validate('download_update')) {
$this->error->add($vt->getErrorMessage());
}
if (!is_dir(DIR_APP_UPDATES)) {
$this->error->add(t('The directory %s does not exist.', DIR_APP_UPDATES));
} else {
if (!is_writable(DIR_APP_UPDATES)) {
$this->error->add(t('The directory %s must be writable by the web server.', DIR_APP_UPDATES));
}
}
if (!$this->error->has()) {
$remote = Update::getApplicationUpdateInformation();
if (is_object($remote)) {
// try to download
Loader::library("marketplace");
$r = Marketplace::downloadRemoteFile($remote->url);
if (empty($r) || $r == Package::E_PACKAGE_DOWNLOAD) {
$response = array(Package::E_PACKAGE_DOWNLOAD);
} else {
if ($r == Package::E_PACKAGE_SAVE) {
$response = array($r);
}
}
if (isset($response)) {
$errors = Package::mapError($response);
foreach ($errors as $e) {
$this->error->add($e);
}
}
if (!$this->error->has()) {
// the file exists in the right spot
Loader::library('archive');
$ar = new UpdateArchive();
try {
$ar->install($r);
} catch (Exception $e) {
$this->error->add($e->getMessage());
}
}
} else {
$this->error->add(t('Unable to retrieve software from update server.'));
}
}
$this->view();
}
示例7: download_update
public function download_update()
{
$p = new \Permissions();
if (!$p->canUpgrade()) {
return false;
}
$vt = Loader::helper('validation/token');
if (!$vt->validate('download_update')) {
$this->error->add($vt->getErrorMessage());
}
if (!is_dir(DIR_CORE_UPDATES)) {
$this->error->add(t('The directory %s does not exist.', DIR_CORE_UPDATES));
} else {
if (!is_writable(DIR_CORE_UPDATES)) {
$this->error->add(t('The directory %s must be writable by the web server.', DIR_CORE_UPDATES));
}
}
if (!$this->error->has()) {
$remote = \Concrete\Core\Updater\Update::getApplicationUpdateInformation();
if (is_object($remote)) {
// try to download
$r = \Marketplace::downloadRemoteFile($remote->getDirectDownloadURL());
if (empty($r) || $r == \Package::E_PACKAGE_DOWNLOAD) {
$response = array(\Package::E_PACKAGE_DOWNLOAD);
} else {
if ($r == \Package::E_PACKAGE_SAVE) {
$response = array($r);
}
}
if (isset($response)) {
$errors = \Package::mapError($response);
foreach ($errors as $e) {
$this->error->add($e);
}
}
if (!$this->error->has()) {
// the file exists in the right spot
$ar = new UpdateArchive();
try {
$ar->install($r);
} catch (Exception $e) {
$this->error->add($e->getMessage());
}
}
} else {
$this->error->add(t('Unable to retrieve software from update server.'));
}
}
$this->view();
}
示例8: checkPackageUpdates
/**
* Runs through all packages on the marketplace, sees if they're installed here, and updates the available version number for them
*/
public static function checkPackageUpdates()
{
Loader::model('system_notification');
$items = Marketplace::getAvailableMarketplaceItems(false);
foreach ($items as $i) {
$p = Package::getByHandle($i->getHandle());
if (is_object($p)) {
// we only add a notification if it's newer than the last one we know about
if (version_compare($p->getPackageVersionUpdateAvailable(), $i->getVersion(), '<') && version_compare($p->getPackageVersion(), $i->getVersion(), '<')) {
SystemNotification::add(SystemNotification::SN_TYPE_ADDON_UPDATE, t('An updated version of %s is available.', $i->getName()), t('New Version: %s.', $i->getVersion()), '', View::url('/dashboard/extend/update'), $i->getRemoteURL());
}
$p->updateAvailableVersionNumber($i->getVersion());
}
}
}
示例9: view
public function view($updated = false, $aux = false)
{
$u = new User();
$this->set('site_tracking_code', Config::get('SITE_TRACKING_CODE'));
$this->set('url_rewriting', URL_REWRITING);
$this->set('marketplace_enabled_in_config', Config::get('ENABLE_MARKETPLACE_SUPPORT'));
$this->set('site', SITE);
$this->set('ui_breadcrumb', $u->config('UI_BREADCRUMB'));
$this->set('ui_filemanager', $u->config('UI_FILEMANAGER'));
$this->set('ui_sitemap', $u->config('UI_SITEMAP'));
$this->set('api_key_picnik', Config::get('API_KEY_PICNIK'));
$txtEditorMode = Config::get('CONTENTS_TXT_EDITOR_MODE');
$this->set('txtEditorMode', $txtEditorMode);
$this->set('rewriteRules', $this->getRewriteRules());
$textEditorWidth = Config::get('CONTENTS_TXT_EDITOR_WIDTH');
$this->set('textEditorWidth', $textEditorWidth);
$textEditorHeight = Config::get('CONTENTS_TXT_EDITOR_HEIGHT');
$this->set('textEditorHeight', $textEditorHeight);
$txtEditorCstmCode = Config::get('CONTENTS_TXT_EDITOR_CUSTOM_CODE');
if (!strlen($txtEditorCstmCode) || $txtEditorMode != 'CUSTOM') {
$txtEditorCstmCode = $this->get_txt_editor_default();
}
$this->set('txtEditorCstmCode', $txtEditorCstmCode);
Loader::library('marketplace');
$mi = Marketplace::getInstance();
if ($mi->isConnected()) {
$this->set('marketplacePageURL', Marketplace::getSitePageURL());
}
if ($updated) {
switch ($updated) {
case 'statistics_saved':
$this->set('message', t('Statistics tracking preference saved.'));
break;
case "tracking_code_saved":
$this->set('message', t('Your tracking code has been saved.'));
break;
/*
//moved to set_permissions
case "maintenance_enabled";
$this->set('message', t('Maintenance Mode turned on. Your site is now private.'));
break;
case "maintenance_disabled":
$this->set('message', t('Maintenance Mode turned off. Your site is public.'));
break;
*/
/*
//moved to set_permissions
case "maintenance_enabled";
$this->set('message', t('Maintenance Mode turned on. Your site is now private.'));
break;
case "maintenance_disabled":
$this->set('message', t('Maintenance Mode turned off. Your site is public.'));
break;
*/
case "marketplace_turned_on":
$this->set('message', t('Marketplace support is now enabled.'));
break;
case "marketplace_turned_off":
$this->set('message', t('Marketplace support is now disabled.'));
break;
case "favicon_saved":
$this->set('message', t('Bookmark icon saved.'));
break;
case "favicon_removed":
$this->set('message', t('Bookmark icon removed.'));
break;
case "editing_preferences_saved":
$this->set('message', t('Editing preferences saved.'));
break;
case "sitename_saved":
$this->set('message', t("Your site's name has been saved."));
break;
case "image_editing_saved":
$this->set('message', t("Image editing options have been saved."));
break;
case "debug_saved":
$this->set('message', t('Debug configuration saved.'));
break;
case "cache_cleared":
$this->set('message', t('Cached files removed.'));
break;
case "cache_updated":
$this->set('message', t('Cache settings saved.'));
break;
case "txt_editor_config_saved":
$this->set('message', t('Content text editor settings saved.'));
break;
case "rewriting_saved":
if (URL_REWRITING) {
if ($aux == 0) {
$this->set('message', t('URL rewriting enabled. Make sure you copy the lines below these URL Rewriting settings area and place them in your .htaccess or web server configuration file.'));
} else {
$this->set('message', t('URL rewriting enabled. .htaccess file updated.'));
}
} else {
$this->set('message', t('URL rewriting disabled.'));
}
break;
}
}
//.........这里部分代码省略.........
示例10: execute
public function execute()
{
$params = $this->params;
$params['version'] = APP_VERSION;
$params['itemsPerPage'] = $this->itemsPerPage;
Loader::library("marketplace");
$mi = Marketplace::getInstance();
$params['csToken'] = $mi->getSiteToken();
if ($this->includeInstalledItems) {
$params['includeInstalledItems'] = 1;
} else {
$params['includeInstalledItems'] = 0;
$list = Package::getInstalledList();
foreach ($list as $pkg) {
$params['installedPackages'][] = $pkg->getPackageHandle();
}
}
if (isset($_REQUEST[$this->queryStringPagingVariable])) {
$params[$this->queryStringPagingVariable] = $_REQUEST[$this->queryStringPagingVariable];
}
$uh = Loader::helper('url');
$url = $uh->buildQuery(MARKETPLACE_REMOTE_ITEM_LIST_WS . $this->type . '/-/get_remote_list', $params);
$r = Loader::helper('file')->getContents($url);
$r2 = @Loader::helper('json')->decode($r);
$total = 0;
$items = array();
if (is_object($r2)) {
$items = $r2->items;
$total = $r2->total;
}
$this->total = $total;
$this->setItems($items);
}
示例11: view
public function view()
{
$tp = new TaskPermission();
$mi = Marketplace::getInstance();
if ($mi->isConnected() && $tp->canInstallPackages()) {
Loader::model('marketplace_remote_item');
$mri = new MarketplaceRemoteItemList();
$mri->setItemsPerPage(9);
$sets = MarketplaceRemoteItemList::getItemSets('themes');
$setsel = array('' => t('All Items'), 'FEATURED' => t('Featured Items'));
if (is_array($sets)) {
foreach ($sets as $s) {
$setsel[$s->getMarketplaceRemoteSetID()] = $s->getMarketplaceRemoteSetName();
}
}
$sortBy = array('' => t('Recommended'), 'popular' => t('Popular'), 'recent' => t('Recently Added'), 'rating' => t('Highest Rated'), 'price_low' => t('Price: Low to High'), 'price_high' => t('Price: High to Low'));
$mri->setIncludeInstalledItems(false);
if (isset($_REQUEST['marketplaceRemoteItemSetID'])) {
$set = $_REQUEST['marketplaceRemoteItemSetID'];
}
if (isset($_REQUEST['mpID'])) {
$mri->filterByMarketplaceItemID($_REQUEST['mpID']);
}
if (isset($_REQUEST['marketplaceRemoteItemSortBy'])) {
$this->set('selectedSort', Loader::helper('text')->entities($_REQUEST['marketplaceRemoteItemSortBy']));
$mri->sortBy($_REQUEST['marketplaceRemoteItemSortBy']);
} else {
$mri->sortBy('recommended');
}
if (isset($_REQUEST['marketplaceIncludeOnlyCompatibleAddons']) && $_REQUEST['marketplaceIncludeOnlyCompatibleAddons'] == 1) {
$mri->filterByCompatibility(1);
}
if (isset($_REQUEST['marketplaceRemoteItemKeywords']) && $_REQUEST['marketplaceRemoteItemKeywords']) {
$keywords = $_REQUEST['marketplaceRemoteItemKeywords'];
$sortBy = array('relevance' => t('Relevance')) + $sortBy;
}
if ($keywords != '') {
$mri->filterByKeywords($keywords);
}
if ($set == 'FEATURED') {
$mri->filterByIsFeaturedRemotely(1);
} else {
if ($set > 0) {
$mri->filterBySet($set);
}
}
$mri->setType('themes');
$mri->execute();
$items = $mri->getPage();
$this->set('sortBy', $sortBy);
$this->set('selectedSet', $set);
$this->set('list', $mri);
$this->set('items', $items);
$this->set('form', Loader::helper('form'));
$this->set('sets', $setsel);
$this->set('pagination', $mri->getPagination());
$this->set('type', $what);
} else {
$this->redirect('/dashboard/extend/connect');
}
}
示例12: addByIDAction
public function addByIDAction()
{
$request = $this->request;
$response = $this->response;
$flash = $this->flash;
if ($request->isPost()) {
$product_id = $request->getPost('product_id', 'int');
$mplace_id = $request->getPost('mplace_id', 'int');
$lang = $request->getPost('lang', 'string');
$product = PProductMain::findFirst($product_id);
$mplace = Marketplace::findFirst($mplace_id);
// Validations
if (!$product) {
$flash->error('Ошибка: товар не найден!');
return $response->redirect('seller/addbyid');
}
if ($product->hold == 1) {
$flash->error('Ошибка: товар на холде!');
return $response->redirect('seller/addbyid');
}
if (!$mplace) {
$flash->error('Ошибка: площадка не найдена!');
return $response->redirect('seller/addbyid');
}
if (!preg_match("/{$lang}/", $mplace->prefs)) {
$flash->error('Ошибка: язык не соответствует площадке!');
return $response->redirect('seller/addbyid');
}
// Check for appropriate marketseller
$marketseller = Marketseller::findFirst("user_id={$this->auth->id} AND marketplace_id={$mplace_id} AND tmaterial_id={$product->tmaterial_id} AND langcode LIKE '%{$lang}%'");
// If there is no marketseller or if the product is already placed create a new marketseller
if (!$marketseller or MPlacement::findFirst("marketseller_id={$marketseller->id} AND product_id={$product->id}")) {
$mseller = new Marketseller();
$mseller->id = $mseller->id();
$mseller->created = time();
$mseller->updated = time();
$mseller->fio = "{$product->PCategoryGroup->title} на {$mplace->title}";
$mseller->user_id = $this->auth->id;
$mseller->marketplace_id = $mplace_id;
$mseller->tmaterial_id = $product->tmaterial_id;
$mseller->langcode = $mplace->prefs;
if (!$mseller->create()) {
$flash->error('Ошибка при создании нового виртуального магазина!');
return $response->redirect('seller/addbyid');
} else {
return $response->redirect("seller/product/{$mseller->id}/{$product_id}/{$lang}");
}
} else {
return $response->redirect("seller/product/{$marketseller->id}/{$product_id}/{$lang}");
}
}
}
示例13: function
$blueprint->makeAction(['name' => 'getDetails', 'pattern' => '{vendor}/{package}', 'routeParametersCallback' => function ($action, array $options) {
return [$options['vendor'], $options['package']];
}]);
$blueprint->makeToolbarItem(['action' => 'getDetails', 'label' => 'Show Details', 'icon' => 'info-circle']);
$blueprint->makeAction(['name' => 'postRequire', 'pattern' => '{vendor}/{package}/require/{version?}', 'method' => 'POST', 'routeParametersCallback' => function ($action, array $options) {
return [$options['vendor'], $options['package']];
}]);
$blueprint->makeToolbarItem(['action' => 'postRequire', 'label' => 'Require', 'icon' => 'plus', 'color' => 'green'])->addDynamicCallback(function ($item, $arguments) {
$installer = Marketplace::getInstaller();
$package = $arguments['vendor'] . '/' . $arguments['package'];
if ($installer->isRequired($package)) {
$item->color = 'red';
$item->icon = 'trash-o';
$item->label = 'Remove';
}
});
$blueprint->makeAction(['name' => 'getInstalled', 'pattern' => 'installed']);
$blueprint->makeToolbarItem(['action' => 'getInstalled', 'label' => 'Installed Packages', 'icon' => 'list', 'color' => 'white']);
$blueprint->makeAction(['name' => 'postToggleProvider', 'pattern' => 'provider/toggle/{class}', 'method' => 'POST', 'routeParametersCallback' => function ($action, array $options) {
return [$options['provider']];
}]);
$blueprint->makeToolbarItem(['action' => 'postToggleProvider', 'label' => 'Enable', 'icon' => 'check', 'color' => 'white', 'shouldRenderCallback' => function (ActionToolbarItem $item, array $arguments) {
return $item->shouldRenderBasic($arguments) && !Marketplace::getProviderRepository()->isCore($arguments['provider']);
}])->addDynamicCallback(function ($item, $arguments) {
$repository = Marketplace::getProviderRepository();
if ($repository->isEnabled($arguments['provider'])) {
$item->icon = 'power-off';
$item->label = 'Disable';
}
});
});
示例14: DisabledToolbarItem
</div>
@endif
</div>
<div class="Cell-twoThirds Cell--last">
<h1 class="heading-alpha">{{{ $package->getPrettyName() }}}</h1>
@if($package->getPrettyName() !== $package->getName())
<h2 class="heading-gamma"><code>{{{ $package->getName() }}}</code></h2>
@endif
<div class="Header-toolbar Header-toolbar--alignLeft Header-toolbar--padding">
<?php
$item = $blueprint->getToolbarItem('postRequire');
$arguments = ['vendor' => $package->getSplitName()[0], 'package' => $package->getSplitName()[1]];
if ($item->shouldRender($arguments)) {
echo $item->render($arguments);
}
$item = new DisabledToolbarItem('Status: ' . Marketplace::getInstaller()->getStatus($package->getName()));
echo $item->render();
?>
</div>
</div>
</div>
<div class="Row Row--alignTop Row--border Row--singleLine">
<div class="Cell-oneThird">
<ul class="List--bordered">
<li><span class="Icon Icon--pushRight Icon-fw Icon-star"></span>{{{ $package->favers }}} stars</li>
<li><span class="Icon Icon--pushRight Icon-fw Icon-download"></span>{{{ $package->downloads['total'] }}} downloads</li>
<li><span class="Icon Icon--pushRight Icon-fw Icon-user"></span>Authored by {{{ $package->getAuthorsAsSentence() }}}</li>
<li><span class="Icon Icon--pushRight Icon-fw Icon-clock-o"></span>Added on {{{ $package->time->toFormattedDateString() }}}</li>
<li><span class="Icon Icon--pushRight Icon-fw Icon-info-circle"></span><code>{{{ $package->getName() }}}</code></li>
<li><span class="Icon Icon--pushRight Icon-fw Icon-code-fork"></span>Latest Version: <code>{{{ $package->getLatestVersion()['version'] }}}</code></li>
@if(isset($package->homepage) && $package->homepage !== '')
示例15: array_merge
$coreBlockTypes[] = $_bt;
} else {
$webBlockTypes[] = $_bt;
}
}
}
$availableArray = array_merge($btAvailableArray, $pkgAvailableArray);
usort($availableArray, 'sortAvailableArray');
/* Load featured add-ons from the marketplace.
*/
Loader::model('collection_attributes');
$db = Loader::db();
if(ENABLE_MARKETPLACE_SUPPORT && $tp->canInstallPackages()){
$purchasedBlocksSource = Marketplace::getAvailableMarketplaceItems();
}else{
$purchasedBlocksSource = array();
}
// now we iterate through the purchased items (NOT BLOCKS, THESE CAN INCLUDE THEMES) list and removed ones already downloaded
// This really should be made into a more generic object since it's not block types anymore.
$skipHandles = array();
foreach($availableArray as $ava) {
foreach($purchasedBlocksSource as $pi) {
if ($pi->getHandle() == $ava->getPackageHandle()) {
$skipHandles[] = $ava->getPackageHandle();
}
}
}