本文整理汇总了PHP中Gadget::getView方法的典型用法代码示例。如果您正苦于以下问题:PHP Gadget::getView方法的具体用法?PHP Gadget::getView怎么用?PHP Gadget::getView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gadget
的用法示例。
在下文中一共展示了Gadget::getView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Prepares the environment before running a test.
*/
protected function setUp()
{
parent::setUp();
$this->gadgetContext = new GadgetContext('GADGET');
$gadgetSpecFactory = new MockRewriterGadgetFactory($this->gadgetContext, null);
$gadgetSpecFactory->fetchGadget = null;
$this->gadget = $gadgetSpecFactory->createGadget();
$this->gadgetRewriter = new GadgetRewriter($this->gadgetContext);
$this->view = $this->gadget->getView($this->gadgetContext->getView());
}
示例2: getIframeURL
private function getIframeURL(Gadget $gadget, GadgetContext $context)
{
$v = $gadget->getChecksum();
$view = $gadget->getView($context->getView());
$up = '';
foreach ($gadget->gadgetSpec->userPrefs as $pref) {
$up .= '&up_' . urlencode($pref['name']) . '=' . urlencode($pref['value']);
}
$locale = $context->getLocale();
//Note: putting the URL last, else some browsers seem to get confused (reported by hi5)
return Config::get('default_iframe_prefix') . 'container=' . $context->getContainer() . ($context->getIgnoreCache() ? '&nocache=1' : '&v=' . $v) . ($context->getModuleId() != 0 ? '&mid=' . $context->getModuleId() : '') . '&lang=' . $locale['lang'] . '&country=' . $locale['country'] . '&view=' . $view['view'] . $up . '&url=' . urlencode($context->getUrl());
}
示例3: renderGadget
/**
*
* @param Gadget $gadget
* @throws GadgetException
*/
protected function renderGadget(Gadget $gadget)
{
$view = $gadget->getView($this->context->getView());
$renderClasses = Config::get('gadget_renderer');
foreach ($renderClasses as $renderClass => $constraints) {
// if current view meets the configurated renderer constraints
// render the gadget and stop checking
if ($this->checkConstraints($view, $constraints)) {
$gadgetRenderer = new $renderClass($this->context);
$gadgetRenderer->renderGadget($gadget, $view);
return;
}
}
throw new GadgetException("Invalid view type");
}
示例4: renderGadget
protected function renderGadget(Gadget $gadget)
{
$view = $gadget->getView($this->context->getView());
if ($view['type'] == 'URL') {
require_once "src/gadgets/render/GadgetUrlRenderer.php";
$gadgetRenderer = new GadgetUrlRenderer($this->context);
} elseif ($view['type'] == 'HTML' && empty($view['href'])) {
require_once "src/gadgets/render/GadgetHtmlRenderer.php";
$gadgetRenderer = new GadgetHtmlRenderer($this->context);
} elseif (empty($view['type']) || !empty($view['href'])) {
require_once "src/gadgets/render/GadgetHrefRenderer.php";
$gadgetRenderer = new GadgetHrefRenderer($this->context);
} else {
throw new GadgetException("Invalid view type");
}
$gadgetRenderer->renderGadget($gadget, $view);
}
示例5: testGetView
/**
* Tests Gadget->getView()
*/
public function testGetView()
{
$this->Gadget->views = array(0 => 'A', 1 => 'B');
$this->assertEquals('B', $this->Gadget->getView(1));
}