本文整理汇总了PHP中Gadget::getRequires方法的典型用法代码示例。如果您正苦于以下问题:PHP Gadget::getRequires方法的具体用法?PHP Gadget::getRequires怎么用?PHP Gadget::getRequires使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gadget
的用法示例。
在下文中一共展示了Gadget::getRequires方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rewriteGadgetView
public function rewriteGadgetView(Gadget $gadget, ViewSpec $gadgetView)
{
// Dont rewrite content if the spec is unavailable
$requires = $gadget->getRequires();
if (isset($requires[ContentRewriteFeature::$REWRITE_TAG])) {
// Store the feature in the spec so we dont keep parsing it
$rewriteFeature = new ContentRewriteFeature();
$rewriteFeature->createRewriteFeature($gadget);
} else {
return false;
}
if (!$rewriteFeature->isRewriteEnabled()) {
return false;
}
if (ContentRewriteFeature::$PROXY_URL != null) {
$defaultTags = ContentRewriteFeature::defaultHTMLTags();
$htmlTags = null;
if (count($rewriteFeature->getTagsParam()) > 0) {
foreach ($rewriteFeature->getTagsParam() as $tag) {
if (isset($defaultTags[$tag])) {
$htmlTags[$tag] = $defaultTags[$tag];
}
}
} else {
$htmlTags = $defaultTags;
}
}
$gadgetView->setRewrittenContent($this->rewrite($gadgetView->getContent(), $htmlTags, $rewriteFeature->getExcludeParam(), $rewriteFeature->getIncludeParam(), Config::get('web_prefix') . ContentRewriteFeature::$PROXY_URL, $gadget->getId()->getURI(), $rewriteFeature->getTagsParam()));
return true;
}
示例2: createRewriteFeature
public function createRewriteFeature(Gadget $gadget)
{
$requires = $gadget->getRequires();
if (!isset($requires[ContentRewriteFeature::$REWRITE_TAG])) {
return;
}
$rewriteFeature = $requires[ContentRewriteFeature::$REWRITE_TAG];
$rewriteParams = $rewriteFeature->getParams();
if (isset($rewriteParams[ContentRewriteFeature::$INCLUDE_URLS])) {
$this->includeParam = $this->normalizeParam($rewriteParams[ContentRewriteFeature::$INCLUDE_URLS], '//');
} else {
$this->includeParam = '//';
}
if (isset($rewriteParams[ContentRewriteFeature::$EXCLUDE_URLS])) {
$this->excludeParam = $this->normalizeParam($rewriteParams[ContentRewriteFeature::$EXCLUDE_URLS], '//');
} else {
$this->excludeParam = '//';
}
if (isset($rewriteParams[ContentRewriteFeature::$INCLUDE_TAGS])) {
$this->tagsParam = $rewriteParams[ContentRewriteFeature::$INCLUDE_TAGS];
$this->tagsParam = explode(',', $this->tagsParam);
} else {
$this->tagsParam = array();
}
if ($this->excludeParam == '.*' || $this->includeParam == null) {
$this->includeNone = true;
}
if ($this->includeParam == '.*' || $this->excludeParam == null) {
$this->includeAll = true;
}
}
示例3: outputUrlGadget
/**
* Output's a URL content type gadget, it adds libs=<list:of:js:libraries>.js and user preferences
* to the href url, and redirects the browser to it
*
* @param Gadget $gadget
*/
private function outputUrlGadget($gadget, $context, $view)
{
// Preserve existing query string parameters.
$redirURI = $view->getHref();
$queryStr = strpos($redirURI, '?') !== false ? substr($redirURI, strpos($redirURI, '?')) : '';
$query = $queryStr;
// TODO: userprefs on the fragment rather than query string
$query .= $this->getPrefsQueryString($gadget->getUserPrefValues());
$libs = array();
$forcedLibs = Config::get('focedJsLibs');
if ($forcedLibs == null) {
$reqs = $gadget->getRequires();
foreach ($reqs as $key => $val) {
$libs[] = $key;
}
} else {
$libs = explode(':', $forcedLibs);
}
$query .= $this->appendLibsToQuery($libs, $gadget);
// code bugs out with me because of the invalid url syntax since we dont have a URI class to fix it for us
// this works around that
if (substr($query, 0, 1) == '&') {
$query = '?' . substr($query, 1);
}
$redirURI .= $query;
header('Location: ' . $redirURI);
die;
}
示例4: testGetRequires
/**
* Tests Gadget->getRequires()
*/
public function testGetRequires()
{
$this->Gadget->requires = 'requires';
$this->assertEquals('requires', $this->Gadget->getRequires());
}
示例5: featuresLoad
function featuresLoad(Gadget $gadget, $context)
{
// Process required / desired features
$requires = $gadget->getRequires();
$needed = array();
$optionalNames = array();
foreach ($requires as $key => $entry) {
$needed[] = $key;
if ($entry->isOptional()) {
$optionalNames[] = $key;
}
}
$resultsFound = array();
$resultsMissing = array();
$missingOptional = array();
$missingRequired = array();
$context->getRegistry()->getIncludedFeatures($needed, $resultsFound, $resultsMissing);
foreach ($resultsMissing as $missingResult) {
if (in_array($missingResult, $optionalNames)) {
$missingOptional[$missingResult] = $missingResult;
} else {
$missingRequired[$missingResult] = $missingResult;
}
}
if (count($missingRequired)) {
throw new GadgetException("Unsupported feature(s): " . implode(', ', $missingRequired));
}
// create features
$features = array();
foreach ($resultsFound as $entry) {
$features[$entry] = $context->getRegistry()->getEntry($entry)->getFeature()->create();
}
// prepare them
foreach ($features as $key => $feature) {
$params = $gadget->getFeatureParams($gadget, $context->getRegistry()->getEntry($key));
$feature->prepare($gadget, $context, $params);
}
// and process them
foreach ($features as $key => $feature) {
$params = $gadget->getFeatureParams($gadget, $context->getRegistry()->getEntry($key));
$feature->process($gadget, $context, $params);
}
}