本文整理汇总了PHP中object::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP object::getContent方法的具体用法?PHP object::getContent怎么用?PHP object::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::getContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doScrapping
/**
* [doScrapping description]
* @param [type] $endpoint [description]
* @return [type] [description]
*/
private function doScrapping($endpoint)
{
$event = null;
$earthquake = null;
Debugger::dump('endpoint: ' . $endpoint . ' _' . $_SERVER['HTTP_USER_AGENT']);
Debugger::dump('***INICIANDO SCRAPPING****');
$content = $this->scrapper->getContent($endpoint);
if (!$content) {
Debugger::dump('***ERROR, NO SE OBTUBIERON DATOS');
return;
}
$this->scrapper->domLoad($content);
$tableList = $this->scrapper->findInDom('table tbody tr');
foreach ($tableList as $table) {
$earthquakeData = [];
foreach ($table->find('td') as $key => $tableItem) {
$earthquakeData[$key] = $tableItem->text();
}
if (empty($earthquakeData)) {
Debugger::dump('***NO HAY DATOS****');
continue;
}
$dateUTC = $earthquakeData[1];
$dateTs = DatesUtils::toTimestamp($dateUTC);
$dateSQL = DatesUtils::toSQLDate($dateUTC);
$eventData = ['lat' => $earthquakeData[2], 'lon' => $earthquakeData[3], 'ts' => $dateSQL, 'hash' => md5($dateTs)];
/* Evitar crear eventos duplicados que muestren erroneamente más de un evento siendo que se trata del mismo
* pero actualizado.
* Esto se hace debido a que el primer informe ante un evento, puede ser preliminar
* y se pueden publicar actualizaciones de datos con cambios en magnitud o ubicación geográfica posteriormente.
*/
$eventExists = $this->Event->checkForExists($eventData, $this->dateBounds);
if ($eventExists['exists']) {
Debugger::dump('***EVENTO YA EXISTE ****');
$event = $eventExists;
} else {
Debugger::dump('***NO SE ENCONTRO EVENTO, CREANDO ****');
$this->Event->create();
$event = $this->Event->save($eventData);
}
if ($event) {
$metadatum = ['event_id' => $event['Event']['id'], 'agency_id' => 1, 'lat' => $eventData['lat'], 'lon' => $eventData['lon'], 'ts' => $dateSQL, 'depth' => $earthquakeData[4], 'magnitude' => floatval($earthquakeData[5]), 'geo_reference' => $earthquakeData[6]];
if (!$eventExists['exists']) {
Debugger::dump('***EVENTO NO EXISTE, SISMO TAMPOCO ****');
$this->EventMetadatum->create();
$earthquake = $this->EventMetadatum->save($metadatum);
} else {
$earthquakeExists = $this->EventMetadatum->checkForExists($metadatum, $this->dateBounds, $eventExists['Event']['id']);
if ($earthquakeExists['exists']) {
Debugger::dump('***EVENTO EXISTE, SISMO TAMBIEN ****');
} else {
Debugger::dump('***EVENTO EXISTE, NUEVO SISMO NO. CREANDO NUEVO ASOCIADO A EVENTO****');
$this->EventMetadatum->create();
$earthquake = $this->EventMetadatum->save($metadatum);
}
}
}
}
return true;
}
示例2: doScrapping
/**
* [doScrapping description]
* @param [type] $endpoint [description]
* @return [type] [description]
*/
private function doScrapping($endpoint)
{
$event = null;
$earthquake = null;
Debugger::dump('endpoint: ' . $endpoint . ' _' . $_SERVER['HTTP_USER_AGENT']);
Debugger::dump('***INICIANDO SCRAPPING****');
$content = $this->scrapper->getContent($endpoint);
$content = json_decode($content);
foreach ($content->features as $earthquakeData) {
if (empty($earthquakeData)) {
Debugger::dump('***NO HAY DATOS****');
continue;
}
$dateUTC = DatesUtils::toReadableDate($earthquakeData->properties->time / 1000);
$dateTs = $earthquakeData->properties->time;
$dateSQL = DatesUtils::toSQLDate($dateUTC);
$eventData = ['lat' => $earthquakeData->geometry->coordinates[1], 'lon' => $earthquakeData->geometry->coordinates[0], 'ts' => $dateSQL, 'hash' => md5($dateTs)];
/* Evitar crear eventos duplicados que muestren erroneamente más de un evento siendo que se trata del mismo
* pero actualizado.
* Esto se hace debido a que el primer informe ante un evento, puede ser preliminar
* y se pueden publicar actualizaciones de datos con cambios en magnitud o ubicación geográfica posteriormente.
*/
$eventExists = $this->Event->checkForExists($eventData, $this->dateBounds);
if ($eventExists['exists']) {
Debugger::dump('***EVENTO YA EXISTE ****');
$event = $eventExists;
} else {
Debugger::dump('***NO SE ENCONTRO EVENTO, CREANDO ****');
$this->Event->create();
$event = $this->Event->save($eventData);
}
if ($event) {
$metadatum = ['event_id' => $event['Event']['id'], 'agency_id' => 3, 'lat' => $eventData['lat'], 'lon' => $eventData['lon'], 'ts' => $dateSQL, 'depth' => $earthquakeData->geometry->coordinates[2], 'magnitude' => floatval($earthquakeData->properties->mag), 'geo_reference' => $earthquakeData->properties->place, 'magnitude_type' => $earthquakeData->properties->magType];
if (!$eventExists['exists']) {
Debugger::dump('***EVENTO NO EXISTE, SISMO TAMPOCO ****');
$this->EventMetadatum->create();
$earthquake = $this->EventMetadatum->save($metadatum);
} else {
$earthquakeExists = $this->EventMetadatum->checkForExists($metadatum, $this->dateBounds, $eventExists['Event']['id']);
if ($earthquakeExists['exists']) {
Debugger::dump('***EVENTO EXISTE, SISMO TAMBIEN ****');
} else {
Debugger::dump('***EVENTO EXISTE, NUEVO SISMO NO. CREANDO NUEVO ASOCIADO A EVENTO****');
$this->EventMetadatum->create();
$earthquake = $this->EventMetadatum->save($metadatum);
}
}
}
}
}
示例3: testDisplay
/**
* Test the display() function
*
* @return void
*/
public function testDisplay()
{
// Setup
$content = 'anything';
// Test display() with all null params
$this->handler = new RDFa();
$this->assertEquals($this->handler->display(), '');
// Test if the params are reseted after the display() function
$this->handler->setType('Article')->content($content)->property('name')->fallback('Thing', 'url')->display();
$this->assertNull($this->handler->getFallbackProperty());
$this->assertNull($this->handler->getFallbackType());
$this->assertNull($this->handler->getProperty());
$this->assertNull($this->handler->getContent());
// Test for a simple display
$response = $this->handler->property('url')->display();
$this->assertEquals($response, "property='url'");
// Test for a simple display with $content
$response = $this->handler->property('url')->content($content)->display();
$this->assertEquals($response, "<span property='url'>{$content}</span>");
// Test for a simple display if the $content is empty ''
$response = $this->handler->enable(true)->content('')->property('name')->display();
$this->assertEquals($response, "<span property='name'></span>");
// Test for a simple 'nested' display
$response = $this->handler->property('author')->display();
$this->assertEquals($response, "property='author' vocab='https://schema.org' typeof='Organization'");
// Test for a 'nested' display with $content
$response = $this->handler->property('author')->content($content)->display();
$this->assertEquals($response, "<span property='author' vocab='https://schema.org' typeof='Organization'>{$content}</span>");
// Test for a 'nested' display with $content and $Fallback
$response = $this->handler->fallback('Person', 'name')->property('author')->content($content)->display();
$this->assertEquals($response, "<span property='author' vocab='https://schema.org' typeof='Person'><span property='name'>{$content}</span></span>");
// Test for a 'nested' display with $Fallback and without $content
$response = $this->handler->fallback('Person', 'name')->property('author')->display();
$this->assertEquals($response, "property='author' vocab='https://schema.org' typeof='Person' property='name'");
// Test for a 'meta' display without $content
$response = $this->handler->property('datePublished')->display();
$this->assertEquals($response, "property='datePublished'");
// Test for a 'meta' display with $content
$content = '01 January 2011';
$response = $this->handler->property('datePublished')->content($content)->display();
$this->assertEquals($response, "<meta property='datePublished' content='{$content}'/>{$content}");
// Test for a 'meta' display with human $content and $machineContent
$machineContent = "2011-01-01T00:00:00+00:00";
$response = $this->handler->property('datePublished')->content($content, $machineContent)->display();
$this->assertEquals($response, "<meta property='datePublished' content='{$machineContent}'/>{$content}");
// Test when if fallbacks that the library returns an empty string as specified
$response = $this->handler->content('en-GB')->property('doesNotExist')->display('meta', true);
$this->assertEquals($response, '');
// Test if the library is disabled
$response = $this->handler->enable(false)->content($content)->fallback('Article', 'about')->property('datePublished')->display();
$this->assertEquals($response, $content);
// Test if the library is disabled and if it have a $content it must return an empty string
$response = $this->handler->enable(false)->content('en-GB')->property('inLanguage')->fallback('Language', 'name')->display('meta', true);
$this->assertEquals($response, '');
// Test if the params are reseted after display(), if the library is disabled
$this->assertNull($this->handler->getFallbackProperty());
$this->assertNull($this->handler->getFallbackType());
$this->assertNull($this->handler->getProperty());
$this->assertNull($this->handler->getContent());
}
示例4: extract
/**
* Extract values from an object
*
* @param object $object
*
* @return array
*/
public function extract($object)
{
if (!$object instanceof Post) {
return array();
}
return array('id' => $object->getId(), 'title' => $object->getTitle(), 'slug' => $object->getSlug(), 'content' => $object->getContent(), 'created' => $object->getCreated());
}
示例5: sectionUpdateDate
/**
* @param object $section
*
* @return \DateTime
*/
public function sectionUpdateDate($section)
{
if (!$section instanceof OnePageSection) {
return null;
}
$modified = $section->getUpdatedAt();
$modified = max($modified, SeoContentLastModifiedGuesser::recursiveBlockUpdateDate($section->getContent()));
$modified = max($modified, SeoContentLastModifiedGuesser::recursiveBlockUpdateDate($section->getBlock()));
return $modified;
}
示例6: filterLoad
/**
* On load filter callback.
*
* @param object $asset
*/
public function filterLoad($asset)
{
// has url?
if (!$asset->getUrl()) {
return;
}
// set base path
self::$path = dirname($asset->getUrl()) . '/';
$asset->setContent(preg_replace_callback('/url\\(\\s*[\'"]?(?![a-z]+:|\\/+)([^\'")]+)[\'"]?\\s*\\)/i', array($this, 'rewrite'), $asset->getContent()));
}
示例7: filterContent
/**
* On content filter callback.
*
* @param object $asset
*/
public function filterContent($asset)
{
$images = array();
$content = $asset->getContent();
// get images and the related path
if (preg_match_all('/url\\(\\s*[\'"]?([^\'"]+)[\'"]?\\s*\\)/Ui', $asset->getContent(), $matches)) {
foreach ($matches[0] as $i => $url) {
if ($path = realpath($asset['base_path'] . '/' . ltrim(preg_replace('/' . preg_quote($asset['base_url'], '/') . '/', '', $matches[1][$i], 1), '/'))) {
$images[$url] = $path;
}
}
}
// check if image exists and filesize < 10kb
foreach ($images as $url => $path) {
if (filesize($path) <= 10240 && preg_match('/\\.(gif|png|jpg)$/i', $path, $extension)) {
$content = str_replace($url, sprintf('url(data:image/%s;base64,%s)', str_replace('jpg', 'jpeg', strtolower($extension[1])), base64_encode(file_get_contents($path))), $content);
}
}
$asset->setContent($content);
}
示例8: filterContent
/**
* On content filter callback.
*
* @param object $asset
*/
public function filterContent($asset)
{
$content = $asset->getContent();
// move unresolved @import rules to the top
$regexp = '/@import[^;]+;/i';
if (preg_match_all($regexp, $content, $matches)) {
$content = preg_replace($regexp, '', $content);
$content = implode("\n", $matches[0]) . "\n" . $content;
}
$asset->setContent($content);
}
示例9: test_get_content
/**
* Check the standardised FPDI PDF getContent() method
* From fpdi_pdf_parser.php
* @since 6.1.0
*/
public function test_get_content()
{
/* Set Page 1*/
$this->fpdi_parser->pageno = 0;
/* Get contents */
$content = $this->fpdi_parser->getContent();
/* Check if contains specific text */
$this->assertNotSame(false, strpos($content, 'MAIN HEADING'));
$this->assertNotSame(false, strpos($content, 'Secondary Heading'));
$this->assertNotSame(false, strpos($content, 'Blue Liquid Designs'));
$this->assertSame(false, strpos($content, 'String Not In PDF'));
}
示例10: testDisplay
/**
* Test the display() function
*
* @return void
*
* @since 3.2
*/
public function testDisplay()
{
// Setup
$content = 'anything';
// Test display() with all null params
$this->handler = new JMicrodata();
$this->assertEquals($this->handler->display(), '');
// Test if the params are reseted after display()
$this->handler->setType('Article')->content($content)->property('name')->fallback('Thing', 'url')->display();
$this->assertNull($this->handler->getFallbackProperty());
$this->assertNull($this->handler->getFallbackType());
$this->assertNull($this->handler->getProperty());
$this->assertEmpty($this->handler->getContent());
// Test for a simple display
$responce = $this->handler->property('url')->display();
$this->assertEquals($responce, "itemprop='url'");
// Test for a simple display with content
$responce = $this->handler->property('url')->content($content)->display();
$this->assertEquals($responce, "<span itemprop='url'>{$content}</span>");
// Test for a simple display if the content is empty ''
$responce = $this->handler->enable(true)->content('')->property('name')->display();
$this->assertEquals($responce, "<span itemprop='name'></span>");
// Test for a simple nested display
$responce = $this->handler->property('author')->display();
$this->assertEquals($responce, "itemprop='author' itemscope itemtype='https://schema.org/Organization'");
// Test for a nested display with content
$responce = $this->handler->property('author')->content($content)->display();
$this->assertEquals($responce, "<span itemprop='author' itemscope itemtype='https://schema.org/Organization'>{$content}</span>");
// Test for a nested display with content and Fallback
$responce = $this->handler->fallback('Person', 'name')->property('author')->content($content)->display();
$this->assertEquals($responce, "<span itemprop='author' itemscope itemtype='https://schema.org/Person'><span itemprop='name'>{$content}</span></span>");
// Test for a nested display with Fallback and without content
$responce = $this->handler->fallback('Person', 'name')->property('author')->display();
$this->assertEquals($responce, "itemprop='author' itemscope itemtype='https://schema.org/Person' itemprop='name'");
// Test for a meta display without content
$responce = $this->handler->property('datePublished')->display();
$this->assertEquals($responce, "itemprop='datePublished'");
// Test for a meta display with content
$content = '01 January 2011';
$responce = $this->handler->property('datePublished')->content($content)->display();
$this->assertEquals($responce, "<meta itemprop='datePublished' content='{$content}'/>{$content}");
// Test if the JMicrodata is disabled
$responce = $this->handler->enable(false)->content($content)->fallback('Article', 'about')->property('datePublished')->display();
$this->assertEquals($responce, $content);
// Test if JMicrodata is disabled and have a $content it must return an empty string
$responce = $this->handler->enable(false)->content('en-GB')->property('inLanguage')->fallback('Language', 'name')->display('meta', true);
$this->assertEquals($responce, '');
// Test if the params are reseted after display(), if the library is disabled
$this->assertNull($this->handler->getFallbackProperty());
$this->assertNull($this->handler->getFallbackType());
$this->assertNull($this->handler->getProperty());
$this->assertNull($this->handler->getContent());
}
示例11: assertResponse
/**
* Assert against an api response
* @param object $response
* @param boolean $fail
* @return array $data
*/
protected function assertResponse($response, $statusCode = 200)
{
// Check status code
$this->assertEquals((int) $statusCode, $response->getStatusCode(), "Response: " . $response->getContent());
// Response should be json
$data = json_decode($response->getContent());
$this->assertNotEmpty($data, "Response was not JSON: " . $response->getContent());
// If fail response
if (strpos('40', (string) $response->getStatusCode())) {
// Error responses should contain error(s)
$this->assertTrue(!empty($data->errors) || !empty($data->error), "Error response should contain error(s). Response: " . print_r($data, 1));
}
return $data;
}
示例12: create
/**
* Create an element from attributes, including a DocBlock
*
* @param string $pkg_dir
* @param object $Obj
* @param boolean $graph whether to include related data
*
* @throws \Exception
*/
public function create($pkg_dir, $Obj, $graph)
{
$array = $Obj->toArray('', false, false, $graph);
$content = $Obj->getContent();
$attributes = $this->getObjAttributes($content, $this->dox_start, $this->dox_end);
// TODO: getProperties?
if (!isset($attributes[$this->objectname])) {
$name_attribute = $this->objectname;
$name = $Obj->get($name_attribute);
} else {
$name = $attributes[$this->objectname];
}
$dir = $this->Repoman->get_core_path($pkg_dir) . rtrim($this->Repoman->get($this->dir_key), '/');
$filename = $dir . '/' . $name . $this->write_ext;
if (file_exists($filename) && !$this->Repoman->get('overwrite')) {
throw new \Exception('Element already exists. Overwrite not allowed. ' . $filename);
}
// Create DocBlock if it doesn't already exist
if (empty($attributes)) {
$docblock = $this->dox_start . "\n";
$docblock .= $this->dox_pad . '@' . $this->objectname . ' ' . $array[$this->objectname] . "\n";
$docblock .= $this->dox_pad . '@description ' . $array['description'] . "\n";
$docblock .= $this->extend_docblock($Obj);
$docblock .= $this->dox_end . "\n";
$this->modx->log(\modX::LOG_LEVEL_DEBUG, "DocBlock generated:\n" . $docblock);
$content = $docblock . $content;
}
// Create dir if doesn't exist
if (!file_exists($dir) && false === mkdir($dir, $this->Repoman->get('dir_mode'), true)) {
throw new \Exception('Could not create directory ' . $dir);
}
if (false === file_put_contents($filename, $content)) {
throw new \Exception('Could not write to file ' . $filename);
} else {
$this->modx->log(\modX::LOG_LEVEL_INFO, 'Created static element at ' . $filename);
}
// Do you want to mess with the original object? Or just grab a snapshot of it?
if ($this->Repoman->get('move')) {
$Obj->set('static', true);
$Obj->set('static_file', self::path_to_rel($filename, MODX_BASE_PATH));
$Obj->set('source', $this->getSource());
if (!$Obj->save()) {
throw new \Exception('Problem saving ' . $this->classname . ' ' . $array[$this->objectname]);
}
$this->modx->log(\modX::LOG_LEVEL_INFO, 'Original ' . $this->classname . ' ' . $array[$this->objectname] . ' updated to new location.');
} else {
$this->modx->log(\modX::LOG_LEVEL_DEBUG, 'Original ' . $this->classname . ' ' . $array[$this->objectname] . ' copied only.');
}
}
示例13: ticketNew
/**
* Runs when new ticket is created
* @param object $ticket
* @param object $customer [optional]
* @return
*/
public function ticketNew($ticket, $customer = null)
{
// If email notifications are not disabled, notify admin
$department = $ticket->getDepartment();
/*parse content for send into mail*/
$originalContent = $ticket->getContent();
$parsedContent = $this->_parseContent($ticket);
$ticket->setContent(nl2br($parsedContent));
$ticket->setContent($this->_processContent($ticket->getContent(), array('ticket' => $ticket, 'department' => $department)));
if ($department->getEnabled() && $department->getNotify()) {
// Notify admin/department
$tpl = $department->getToAdminNewEmail();
$sender = array('name' => $customer->getName(), 'email' => $customer->getEmail());
$recipientEmail = $department->getContact();
$recipientName = $department->getName();
$mailTemplate = $this->_getMailTemplate($ticket, $department);
if (!is_null($mailTemplate)) {
$this->log('Sending mail about new ticket ' . $ticket->getUid() . ' to department ' . $recipientName . '<' . $recipientEmail . '>');
$mailTemplate->setDesignConfig(array('area' => 'backend', 'store' => $ticket->getStoreId()))->sendTransactional($tpl, $sender, $recipientEmail, $recipientName, array('ticket' => $ticket, 'department' => $department), $ticket->getStoreId());
}
}
if ($customer) {
$recipientEmail = is_string($customer) ? $customer : $customer->getEmail();
$recipientName = is_string($customer) ? $customer : $customer->getName();
} else {
$recipientEmail = $ticket->getCustomerEmail();
$recipientName = $ticket->getCustomerName();
}
if ($recipientEmail) {
if ($ticket->getCreatedBy() == 'admin') {
$tpl = $department->getNewFromAdminToCustomer();
} else {
$tpl = $department->getToCustomerNewEmail();
}
$sender = $department->getSender();
$mailTemplate = $this->_getMailTemplate($ticket, $department);
if (isset($mailTemplate) && !is_null($mailTemplate)) {
$this->log('Sending mail about new ticket ' . $ticket->getUid() . ' to customer ' . $recipientName . '<' . $recipientEmail . '>');
$mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $ticket->getStoreId()))->sendTransactional($tpl, $sender, $recipientEmail, $recipientName, array('ticket' => $ticket, 'department' => $department), $ticket->getStoreId());
}
}
$ticket->setContent($originalContent);
}
示例14: filterResponse
/**
* prepare a deserialized copy of a json response
*
* @param object $response Response containing our return value as raw json
*
* @return \Symfony\Component\BrowserKit\Response response
*
* @todo use JMSSerializer for additional JSON validation
*/
protected function filterResponse($response)
{
$this->results = json_decode($response->getContent());
return parent::filterResponse($response);
}
示例15: getContentAsQuot
/**
* Returns text-formatted content for message or ticket with "quot marks"
* @param object $item
* @return
*/
public function getContentAsQuot($item)
{
$item->getContentType() || $item->setContentType(self::DEFAULT_CONTENT_TYPE);
$text = $item->getContent();
switch ($item->getContentType()) {
case 'text/html':
case 'html':
$text = $this->html2text($text);
break;
case 'text/plain':
break;
}
$text = trim($text);
$text = preg_replace('/\\[quot\\s+name="(.*)"\\](.*)\\[\\/quot\\]/Usi', '', $text);
$item->getAuthorName() || $item->setAuthorName(self::DEFAULT_QUOTE_TEXT);
return "[quot name=\"" . $item->getAuthorName() . "\"]" . trim(htmlentities($text, null, self::DEFAULT_ENCODING)) . "[/quot]";
}