本文整理汇总了PHP中Gadget::getJsLibraries方法的典型用法代码示例。如果您正苦于以下问题:PHP Gadget::getJsLibraries方法的具体用法?PHP Gadget::getJsLibraries怎么用?PHP Gadget::getJsLibraries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gadget
的用法示例。
在下文中一共展示了Gadget::getJsLibraries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetJsLibraries
/**
* Tests Gadget->getJsLibraries()
*/
public function testGetJsLibraries()
{
$this->Gadget->addJsLibrary('A');
$this->Gadget->addJsLibrary('B');
$this->Gadget->addJsLibrary('C');
$this->Gadget->addJsLibrary('D');
$string = implode('', $this->Gadget->getJsLibraries());
$this->assertEquals('ABCD', $string);
}
示例2: getJsUrl
/**
* generates the library string (core:caja:etc.js) including a checksum of all the
* javascript content (?v=<sha1 of js) for cache busting
*
* @param string $libs
* @param Gadget $gadget
* @return string the list of libraries in core:caja:etc.js?v=checksum> format
*/
private function getJsUrl($libs, $gadget)
{
$buf = '';
if (!is_array($libs) || !count($libs)) {
$buf = 'core';
} else {
$firstDone = false;
foreach ($libs as $lib) {
if ($firstDone) {
$buf .= ':';
} else {
$firstDone = true;
}
$buf .= $lib;
}
}
// Build a version string from the sha1() checksum of all included javascript
// to ensure the client always has the right version
$inlineJs = '';
foreach ($gadget->getJsLibraries() as $library) {
$type = $library->getType();
if ($type != 'URL') {
$inlineJs .= $library->getContent() . "\n";
}
}
$buf .= ".js?v=" . sha1($inlineJs);
return $buf;
}
示例3: appendJsConfig
/**
* Appends the javascript features configuration string
*
* @param Gadget $gadget
* @param unknown_type $hasForcedLibs
* @return string
*/
private function appendJsConfig(Gadget $gadget, $hasForcedLibs)
{
$container = $this->context->getContainer();
$containerConfig = $this->context->getContainerConfig();
//TODO some day we should parse the forcedLibs too, and include their config selectivly as well for now we just include everything if forced libs is set.
if ($hasForcedLibs) {
$gadgetConfig = $containerConfig->getConfig($container, 'gadgets.features');
} else {
$gadgetConfig = array();
$featureConfig = $containerConfig->getConfig($container, 'gadgets.features');
foreach ($gadget->getJsLibraries() as $library) {
$feature = $library->getFeatureName();
if (!isset($gadgetConfig[$feature]) && !empty($featureConfig[$feature])) {
$gadgetConfig[$feature] = $featureConfig[$feature];
}
}
}
// Add gadgets.util support. This is calculated dynamically based on request inputs.
// See java/org/apache/shindig/gadgets/render/RenderingContentRewriter.java for reference.
$requires = array();
foreach ($gadget->features as $feature) {
$requires[$feature] = new EmptyClass();
}
$gadgetConfig['core.util'] = $requires;
if (isset($gadgetConfig['osml'])) {
unset($gadgetConfig['osml']);
}
if (!isset($gadgetConfig['osapi.services']) || count($gadgetConfig['osapi.services']) == 1) {
// this should really be set in config/container.js, but if not, we build a complete default set so at least most of it works out-of-the-box
$gadgetConfig['osapi.services'] = array('gadgets.rpc' => array('container.listMethods'), 'http://%host%/social/rpc' => array("messages.update", "albums.update", "activities.delete", "activities.update", "activities.supportedFields", "albums.get", "activities.get", "mediaitems.update", "messages.get", "appdata.get", "system.listMethods", "people.supportedFields", "messages.create", "mediaitems.delete", "mediaitems.create", "people.get", "people.create", "albums.delete", "messages.delete", "appdata.update", "activities.create", "mediaitems.get", "albums.create", "appdata.delete", "people.update", "appdata.create"), 'http://%host%/gadgets/api/rpc' => array('cache.invalidate'));
}
return "gadgets.config.init(" . json_encode($gadgetConfig) . ");\n";
}