Exemplo n.º 1
0
 public function setUp()
 {
     $this->oauthClient = $this->getMock('CultureFeed_OAuthClient');
     $this->entry = new CultureFeed_EntryApi($this->oauthClient);
     $this->event = new CultureFeed_Cdb_Item_Event();
     $this->event->setCdbId('xyz');
 }
Exemplo n.º 2
0
 /**
  * Convert the raw XML into an object
  *
  * @param \SimpleXMLElement $xml
  * @return Result
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $result = new Result();
     if (isset($xml->nofrecords)) {
         $result->setNumResults((int) $xml->nofrecords);
     }
     if (isset($xml->event)) {
         foreach ($xml->event as $event) {
             $result->addEvent(\CultureFeed_Cdb_Item_Event::parseFromCdbXml($event));
         }
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * Update an event.
  *
  * @param CultureFeed_Cdb_Item_Event $event
  *   The event to update.
  */
 public function updateEvent(\CultureFeed_Cdb_Item_Event $event)
 {
     $request = $this->getClient()->post('event/' . $event->getCdbId(), array('Content-Type' => 'application/xml; charset=UTF-8'), $this->getCdbXml($event));
     $response = $request->send();
     $rsp = Rsp::fromResponseBody($response->getBody(true));
     $this->guardItemUpdateResponseIsSuccessful($rsp);
     return $rsp;
 }
Exemplo n.º 4
0
 /**
  * Withdraw link for an event.
  *
  * @param CultureFeed_Cdb_Item_Event $event
  *   Event where the translation will be removed for.
  * @param string $link
  *   Link to remove.
  */
 public function removeLinkFromEvent(CultureFeed_Cdb_Item_Event $event, $link)
 {
     $this->removeLink('event', $event->getCdbId(), $link);
 }
Exemplo n.º 5
0
    /**
     * Integration test for parsing the following additions to cdbxml version 3.3:
     *   - event publisher and weight
     *   - file subbrand and description
     */
    public function testParseCdbXml3Dot3SchemaAdditions()
    {
        $xml = $this->loadSample('085377d6-a3c9-4c8f-88b9-3d6ab0201361.xml', '3.3');
        $event = CultureFeed_Cdb_Item_Event::parseFromCdbXml($xml);
        $this->assertEquals('085377d6-a3c9-4c8f-88b9-3d6ab0201361', $event->getCdbId());
        $this->assertEquals('48fe254ceba710aec4609017d2e34d91', $event->getPublisher());
        $this->assertSame(12, $event->getWeight());
        $nlDetail = $event->getDetails()->getDetailByLanguage('nl');
        $media = $nlDetail->getMedia();
        $media->next();
        /** @var CultureFeed_Cdb_Data_File $secondFile */
        $secondFile = $media->current();
        $this->assertEquals('{"keyword": "Culturefeed.be selectie",
"text": "Hello World",
"image": "https://www.facebook.com/23424317091/photos/a.200759332091.131532.23424317091/10153148846107092/?type=1",
"article": "http://www.humo.be/jeroom/3973/"}', $secondFile->getDescription());
        $this->assertEquals('2b88e17a-27fc-4310-9556-4df7188a051f', $secondFile->getSubBrand());
    }
Exemplo n.º 6
0
 /**
  * Parse a given xml element to an CultureFeed_Cdb_Item_Base.
  * @param SimpleXMLElement $xmlElement
  *   XML element from the item to parse.
  */
 public static function parseItem(SimpleXMLElement $xmlElement)
 {
     // Return the correct cdb item.
     switch ($xmlElement->getName()) {
         case 'event':
             return CultureFeed_Cdb_Item_Event::parseFromCdbXml($xmlElement);
         case 'production':
             return CultureFeed_Cdb_Item_Production::parseFromCdbXml($xmlElement);
         case 'actor':
             return CultureFeed_Cdb_Item_Actor::parseFromCdbXml($xmlElement);
         default:
             return NULL;
     }
 }
Exemplo n.º 7
0
function watersportkampen_bootstrap_form_culturefeed_entry_ui_tags_form_alter(array &$form, array &$form_state, \CultureFeed_Cdb_Item_Event $event = NULL)
{
    // Default values.
    $keywords = array();
    $sports = _watersportkampen_bootstrap_get_sports();
    if ($event && $event->getKeywords(TRUE)) {
        /* @var \CultureFeed_Cdb_Data_Keyword $keyword */
        foreach ($event->getKeywords(TRUE) as $keyword) {
            $kw = $keyword->getValue();
            if (!in_array($kw, $sports)) {
                if ($kw !== 'watersportkampen') {
                    $keywords[$keyword->getValue()] = array('value' => $keyword->getValue(), 'visible' => $keyword->isVisible());
                }
            }
        }
    }
    // Form element.
    $form['extra']['tags'] = array('#type' => 'culturefeed_tags_element', '#title' => t('Tags'), '#description' => t('Add Add tags'), '#default_value' => $keywords);
    $form['extra']['old_tags'] = array('#type' => 'value', '#value' => $keywords);
}