当前位置: 首页>>代码示例>>PHP>>正文


PHP Gadget类代码示例

本文整理汇总了PHP中Gadget的典型用法代码示例。如果您正苦于以下问题:PHP Gadget类的具体用法?PHP Gadget怎么用?PHP Gadget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Gadget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
     }
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:31,代码来源:ContentRewriteFeature.php

示例2: 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;
 }
开发者ID:ahmedadham88,项目名称:enhanced-social-network,代码行数:30,代码来源:ContentRewriter.php

示例3: up

 public function up()
 {
     $gadget = new Gadget();
     $gadget->setType('loginTop');
     $gadget->setName('loginForm');
     $gadget->setSortOrder(10);
     $gadget->save();
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:8,代码来源:002_insert_login_gadget.php

示例4: 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());
 }
开发者ID:emma5021,项目名称:toba,代码行数:13,代码来源:GadgetRewriterTest.php

示例5: 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());
 }
开发者ID:vuxuandung,项目名称:Partuza-bundle,代码行数:12,代码来源:MetadataHandler.php

示例6: up

 public function up()
 {
     $criteria = new Criteria();
     $criteria->add(GadgetPeer::TYPE, 'mobileLoginContents');
     $criteria->add(GadgetPeer::NAME, 'loginForm');
     if (!GadgetPeer::doSelectOne($criteria)) {
         $gadget = new Gadget();
         $gadget->setType('mobileLoginContents');
         $gadget->setName('loginForm');
         $gadget->setSortOrder(10);
         $gadget->save();
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:13,代码来源:006_add_mobile_login_gadget.php

示例7: save

 public function save()
 {
     foreach ($this->values as $type => $gadgets) {
         if (!$gadgets) {
             continue;
         }
         foreach ($gadgets as $value) {
             $gadget = new Gadget();
             $gadget->setType($type);
             $gadget->setName($value);
             $gadget->save();
         }
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:14,代码来源:GadgetAddForm.class.php

示例8: 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");
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:20,代码来源:GadgetRenderingServlet.php

示例9: getList

 private function getList()
 {
     $data = array();
     $result = $this->getResult();
     $gadgets = Gadget::loadStructuredList();
     foreach ($gadgets as $category => $list) {
         if (!$this->neededNames || isset($this->neededNames[$category])) {
             $row = array();
             if (isset($this->props['name'])) {
                 $row['name'] = $category;
             }
             if ($category !== "") {
                 if (isset($this->props['title'])) {
                     $row['desc'] = wfMessage("gadget-section-{$category}")->parse();
                 }
             }
             if (isset($this->props['members'])) {
                 $row['members'] = count($list);
             }
             $data[] = $row;
         }
     }
     $result->setIndexedTagName($data, 'category');
     $result->addValue('query', $this->getModuleName(), $data);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:ApiQueryGadgetCategories.php

示例10: log_user_in

 /**
  * logs a user in
  *
  * Status Codes:<br />
  * 0: success<br />
  * 1: incorrect password<br />
  * 1: incorrect email<br />
  *
  * @param   String  $u          Username
  * @param   String  $p          Password
  * @param   Boolean $redirect   redirect on successful login
  * @return  Int     status code
  */
 public static function log_user_in($u, $p, $redirect = true) {
     if ($_SESSION['logged_in']) {
         self::logout();
     }
     $u   = dbi()->escape($u);
     $ip  = $_SESSION['IpAddr'];
     if ($row = dbi()->q_1("SELECT CustomerID, Password FROM Customers WHERE Email = '$u'")) {
         if (crypt($p, $row->Password) == $row->Password) { // match found
             self::force_login($row->CustomerID);
             if ($redirect) {
                 if ($_SESSION['last_page']) {
                     $page = $_SESSION['last_page'];
                     unset($_SESSION['last_page']);
                 } else {
                     $page = '/';
                 }
                 Gadget::redirect($page);
             }
             return 0;
         } else { // incorrect password
             return 1;
         }
     } else { // email not found
         return 2;
     }
 }
开发者ID:elliecm,项目名称:MadisonandRayne,代码行数:39,代码来源:access.class.php

示例11: testPreferences

    function testPreferences()
    {
        global $wgUser, $wgOut, $wgTitle;
        // This test makes call to the parser which requires valids Outputpage
        // and Title objects. Set them up there, they will be released at the
        // end of the test.
        $old_wgOut = $wgOut;
        $old_wgTitle = $wgTitle;
        $wgTitle = Title::newFromText('Parser test for Gadgets extension');
        // Proceed with test setup:
        $prefs = array();
        $context = new RequestContext();
        $wgOut = $context->getOutput();
        $wgOut->setTitle(Title::newFromText('test'));
        Gadget::loadStructuredList('* foo | foo.js
==keep-section1==
* bar| bar.js
==remove-section==
* baz [rights=embezzle] |baz.js
==keep-section2==
* quux [rights=read] | quux.js');
        $this->assertTrue(GadgetHooks::getPreferences($wgUser, $prefs), 'GetPrefences hook should return true');
        $options = $prefs['gadgets']['options'];
        $this->assertFalse(isset($options['&lt;gadget-section-remove-section&gt;']), 'Must not show empty sections');
        $this->assertTrue(isset($options['&lt;gadget-section-keep-section1&gt;']));
        $this->assertTrue(isset($options['&lt;gadget-section-keep-section2&gt;']));
        // Restore globals
        $wgOut = $old_wgOut;
        $wgTitle = $old_wgTitle;
    }
开发者ID:Tarendai,项目名称:spring-website,代码行数:30,代码来源:GadgetTest.php

示例12: 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);
 }
开发者ID:ndkhoiits,项目名称:gatein-shindig,代码行数:17,代码来源:GadgetRenderingServlet.php

示例13: __construct

 public function __construct(Gadget $gadget, $options = array(), $CSRFSecret = null)
 {
     $this->gadget = $gadget;
     parent::__construct(array(), $options, $CSRFSecret);
     $config = Doctrine::getTable('Gadget')->getGadgetConfigListByType($options['type']);
     if (empty($config[$gadget->getName()]['config'])) {
         throw new RuntimeException('The gadget has not registered or it doesn\'t have any configuration items.');
     }
     $gadgetConfig = $config[$gadget->getName()]['config'];
     foreach ($gadgetConfig as $key => $value) {
         $this->setWidget($key, opFormItemGenerator::generateWidget($value));
         $this->setValidator($key, opFormItemGenerator::generateValidator($value));
         $config = Doctrine::getTable('GadgetConfig')->retrieveByGadgetIdAndName($gadget->getId(), $key);
         if ($config) {
             $this->setDefault($key, $config->getValue());
         }
     }
     $this->widgetSchema->setNameFormat('gadget_config[%s]');
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:19,代码来源:GadgetConfigForm.class.php

示例14: up

 public function up()
 {
     $eventNavigation = new Navigation();
     $eventNavigation->setType('community');
     $eventNavigation->setUri('communityEvent/listCommunity');
     $eventNavigation->setSortOrder(6);
     $eventNavigation->setCaption('Events', 'en');
     $eventNavigation->setCaption('イベントリスト', 'ja_JP');
     $gadget = new Gadget();
     $gadget->setType('contents');
     $gadget->setName('recentCommunityEventComment');
     $gadget->setSortOrder(132);
     $gadget->save();
     $gadget = new Gadget();
     $gadget->setType('mobileContents');
     $gadget->setName('recentCommunityEventComment');
     $gadget->setSortOrder(111);
     $gadget->save();
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:19,代码来源:004_update_op_community_topic_plugin_0_8_1_4.php

示例15: up

 public function up()
 {
     $gadget = new Gadget();
     $gadget->setType('top');
     $gadget->setName('birthdayBox');
     $gadget->setSortOrder(0);
     $gadget->save();
     $gadget = new Gadget();
     $gadget->setType('mobileTop');
     $gadget->setName('birthdayBox');
     $gadget->setSortOrder(0);
     $gadget->save();
     $gadget = new Gadget();
     $gadget->setType('profileTop');
     $gadget->setName('birthdayBox');
     $gadget->setSortOrder(0);
     $gadget->save();
     $gadget = new Gadget();
     $gadget->setType('mobileProfileTop');
     $gadget->setName('birthdayBox');
     $gadget->setSortOrder(0);
     $gadget->save();
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:23,代码来源:045_insert_birthday_gadget.php


注:本文中的Gadget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。