public function render($value = false) { $color = ''; if ($value) { $color = $value->toStyleString(); } $inputName = $this->getVariable(); $r = Request::getInstance(); if ($r->request->has($inputName)) { $color = h($r->request->get($inputName)); } $view = View::getInstance(); $view->requireAsset('core/colorpicker'); $json = new Json(); print "<input type=\"text\" name=\"{$inputName}[color]\" value=\"{$color}\" id=\"ccm-colorpicker-{$inputName}\" />"; print "<script type=\"text/javascript\">"; print "\$(function() { \$('#ccm-colorpicker-{$inputName}').spectrum({\n showInput: true,\n showInitial: true,\n preferredFormat: 'rgb',\n allowEmpty: true,\n className: 'ccm-widget-colorpicker',\n showAlpha: true,\n value: " . $json->encode($color) . ",\n cancelText: " . $json->encode(t('Cancel')) . ",\n chooseText: " . $json->encode(t('Choose')) . ",\n clearText: " . $json->encode(t('Clear Color Selection')) . ",\n change: function() {ConcreteEvent.publish('StyleCustomizerControlUpdate');}\n });});"; print "</script>"; }
<?php use Concrete\Core\Application\Service\Dashboard; use Concrete\Core\Http\Service\Json; use Concrete\Core\Marketplace\RemoteItemList as MarketplaceRemoteItemList; $dh = new Dashboard(); if ($dh->canRead()) { session_write_close(); $js = new Json(); $mri = new MarketplaceRemoteItemList(); $mri->setItemsPerPage(5); $mri->setIncludeInstalledItems(false); $mri->setType('addons'); $keywords = $_REQUEST['q']; $mri->filterByKeywords($keywords); $mri->execute(); $items = $mri->getPage(); $r = array(); foreach ($items as $it) { $obj = new stdClass(); $obj->mpID = $it->getMarketplaceItemID(); $obj->name = $it->getName(); $obj->img = $it->getRemoteIconURL(); $obj->href = $it->getRemoteURL(); $r[] = $obj; } print $js->encode($r); exit; }
private function installSampleData($pkg) { $db = \Database::get(); $json = new Json(); $q = "insert into TutorialDbTableDemoAttribute (keyID, displayTitle, data) values (?,?,?)"; for ($i = 1; $i <= 10; $i++) { if ($i < 10) { $displayNum = "0" . $i; } else { $displayNum = $i; } $item = array(); // keyID $item[] = $i; // displayTitle $item[] = t("Display Title (Key = " . $displayNum . ")"); // data $itemData = array(); $itemData["Department Name"] = "Facility Name (Key = " . $displayNum . ")"; $itemData["Address 1"] = "Address 1 (Key = " . $displayNum . ")"; $itemData["Address 2"] = "Address 2 (Key = " . $displayNum . ")"; $itemData["City"] = "City (Key = " . $displayNum . ")"; $itemData["State"] = "State (Key = " . $displayNum . ")"; $itemData["Zip"] = "Zip (Key = " . $displayNum . ")"; $item[] = $json->encode($itemData); $db->query($q, $item); } }