/**
  * @param Database_Result $objSettings The information from which to initialize the setting from
  *
  * @return IMetaModelFilterSetting
  */
 protected function newSetting(Database_Result $objSettings)
 {
     $strClass = $GLOBALS['METAMODELS']['filters'][$objSettings->type]['class'];
     // TODO: add factory support here.
     if ($strClass) {
         return new $strClass($this, $objSettings->row());
     }
     return null;
 }
Exemplo n.º 2
0
 public function __construct(ORM $model, Database_Result $result)
 {
     // Class attributes
     $this->class_name = get_class($model);
     $this->primary_key = $model->primary_key;
     $this->primary_val = $model->primary_val;
     // Database result
     $this->result = $result->result(TRUE);
 }
Exemplo n.º 3
0
 /**
  * Initialize the object
  * @param object
  * @return string
  */
 public function __construct(Database_Result $objElement)
 {
     parent::__construct();
     $this->arrData = $objElement->row();
     $this->space = deserialize($objElement->space);
     $this->cssID = deserialize($objElement->cssID, true);
     $arrHeadline = deserialize($objElement->headline);
     $this->headline = is_array($arrHeadline) ? $arrHeadline['value'] : $arrHeadline;
     $this->hl = is_array($arrHeadline) ? $arrHeadline['unit'] : 'h1';
 }
Exemplo n.º 4
0
 /**
  * Initialize the object
  * @param Database_Result
  * @param string
  */
 public function __construct(Database_Result $objModule, $strColumn = 'main')
 {
     parent::__construct();
     $this->arrData = $objModule->row();
     $this->space = deserialize($objModule->space);
     $this->cssID = deserialize($objModule->cssID, true);
     $arrHeadline = deserialize($objModule->headline);
     $this->headline = is_array($arrHeadline) ? $arrHeadline['value'] : $arrHeadline;
     $this->hl = is_array($arrHeadline) ? $arrHeadline['unit'] : 'h1';
     $this->strColumn = $strColumn;
 }
Exemplo n.º 5
0
	public function __construct(array $result, $sql, $as_object = NULL)
	{
		parent::__construct($result, $sql, $as_object);

		// Find the number of rows in the result
		$this->_total_rows = count($result);
	}
Exemplo n.º 6
0
	public function __construct($result, $sql, $as_object)
	{
		parent::__construct($result, $sql, $as_object);

		// Find the number of rows in the result
		$this->_total_rows = mysql_num_rows($result);
	}
Exemplo n.º 7
0
	public function __construct($result, $sql, $as_object = FALSE, array $params = NULL)
	{
		parent::__construct($result, $sql, $as_object, $params);

		// Find the number of rows in the result
		$this->_total_rows = mysql_num_rows($result);
	}
Exemplo n.º 8
0
 /**
  * Fetch the next result row and create the model
  * 
  * @return boolean True if there was another row
  */
 protected function fetchNext()
 {
     if ($this->objResult->next() == false) {
         return false;
     }
     $strClass = $this->getModelClassFromTable($this->strTable);
     $this->arrModels[$this->intIndex + 1] = new $strClass($this->objResult);
     return true;
 }
 /**
  * Create start tag for given end tag and update it
  *
  * @param Database_Result $objEndTag
  */
 public function createStartTag($objEndTag)
 {
     $arrStartTag = $objEndTag->row();
     unset($arrStartTag['id']);
     unset($arrStartTag['sh5_pid']);
     $arrStartTag['sh5_tag'] = 'start';
     $arrStartTag['sorting'] = $objEndTag->sorting - 1;
     // Support GlobalContentelements extension if installed
     if (in_array('GlobalContentelements', $this->Config->getActiveModules())) {
         $arrStartTag['do'] = $this->Input->get('do');
     }
     // Insert start tag
     $objResult = $this->Database->prepare("INSERT INTO tl_content %s")->set($arrStartTag)->execute();
     $intId = $objResult->insertId;
     // Update start tag
     $this->Database->prepare("UPDATE tl_content %s WHERE id = ?")->set(array('sh5_pid' => $intId))->executeUncached($intId);
     // Update end tag
     $this->Database->prepare("UPDATE tl_content %s WHERE id = ?")->set(array('sh5_pid' => $intId))->executeUncached($objEndTag->id);
 }
Exemplo n.º 10
0
 public function __construct(array $result, $sql, $as_object = NULL)
 {
     if (count($result) > 0) {
         // Determine if we stored as objects or associative arrays
         $as_object = get_class($result[0]);
     }
     // If there are no results, we don't care how they're returned
     parent::__construct($result, $sql, $as_object);
     // Find the number of rows in the result
     $this->_total_rows = count($result);
 }
Exemplo n.º 11
0
 /**
  * Get singleton instance of the class or create new one, if no exists.
  *
  * @param  PDOStatement     $o_set_result   the requested result-set of the last SQL-Statement
  * @return Database_Result                  the instance of the class
  */
 public static function getInstance($o_set_result)
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     //set the result-set object and fetch all rows
     self::$instance->set_result_set($o_set_result);
     self::$instance->set_result_rows($o_set_result);
     //return the instance
     return self::$instance;
 }
Exemplo n.º 12
0
 /**
  * не используется
  * @param type $result имя ключа массвиа
  * @param type $nameNeededValue имя поля массива
  * @return type
  */
 public function showAsArray(Database_Result $result, $nameNeededValue = null)
 {
     $array = $result->as_array();
     $primaryKey = $this->primary_key();
     $key = 0;
     $result = array();
     foreach ($array as $value) {
         if (empty($primaryKey)) {
             $key++;
         } else {
             $key = $value->{$primaryKey};
         }
         if (empty($nameNeededValue)) {
             $result[$key] = $value->as_array();
         } else {
             $result[$key] = $value->{$nameNeededValue};
         }
     }
     return $result;
 }
Exemplo n.º 13
0
 /**
  * Load the relations and optionally process a result set
  * 
  * @param \Database_Result $objResult An optional database result
  */
 public function __construct(\Database_Result $objResult = null)
 {
     parent::__construct();
     $objRelations = new \DcaExtractor(static::$strTable);
     $this->arrRelations = $objRelations->getRelations();
     if ($objResult !== null) {
         $this->arrData = $objResult->row();
         // Look for joined fields
         foreach ($this->arrData as $k => $v) {
             if (strpos($k, '__') !== false) {
                 list($key, $field) = explode('__', $k, 2);
                 // Create the related model
                 if (!isset($this->arrRelated[$key])) {
                     $table = $this->arrRelations[$key]['table'];
                     $strClass = $this->getModelClassFromTable($table);
                     $this->arrRelated[$key] = new $strClass();
                 }
                 $this->arrRelated[$key]->{$field} = $v;
                 unset($this->arrData[$k]);
             }
         }
     }
 }
Exemplo n.º 14
0
 public function as_array($key = NULL, $value = NULL)
 {
     if ($this->_total_rows === 0) {
         return array();
     }
     if (!$this->_as_object and $key === NULL) {
         // Rewind
         $this->_current_row = 0;
         if ($value === NULL) {
             // Indexed rows
             return pg_fetch_all($this->_result);
         }
         // Indexed columns
         return pg_fetch_all_columns($this->_result, pg_field_num($this->_result, $value));
     }
     return parent::as_array($key, $value);
 }
Exemplo n.º 15
0
 /**
  * 获取指定的对象,如果没有数据则尝试从资源中创建数据
  *
  * 无可用数据则返回false
  *
  * @param $group_id
  * @param $index
  * @return OOP_ORM_Data|null
  */
 protected function get_offset_data($index)
 {
     if (!isset($this->data[$index])) {
         if (!$this->resource || !$this->finder) {
             return null;
         }
         # 从数据库中获取
         $data = $this->resource->offsetGet($index);
         # 返回是null,则seek看是否对应指针数据不存在
         if (null === $data && false === $this->resource->seek($index)) {
             return null;
         }
         # 使用获取的数据创建新对象
         $this->data[$index] = $this->finder->create($data, isset($this->option['is_field_key']) ? $this->option['is_field_key'] : true, $this->id);
         if ($this->option['count'] == count($this->data)) {
             # 获取完所有数据后就可以直接释放资源,不用等到对象被消毁
             $this->release_resource();
             # 重新排序,避免排序错乱
             ksort($this->data, SORT_NUMERIC);
         }
     }
     return $this->data[$index];
 }
Exemplo n.º 16
0
 /**
  * Compile the newsletter and send it
  * @param object
  * @param object
  * @param array
  * @param string
  * @param string
  * @param string
  * @return string
  */
 protected function sendNewsletter(Email $objEmail, Database_Result $objNewsletter, $arrRecipient, $text, $html, $css)
 {
     // Prepare text content
     $objEmail->text = $this->parseSimpleTokens($text, $arrRecipient);
     // Add HTML content
     if (!$objNewsletter->sendText) {
         // Get the mail template
         $objTemplate = new BackendTemplate(strlen($objNewsletter->template) ? $objNewsletter->template : 'mail_default');
         $objTemplate->setData($objNewsletter->row());
         $objTemplate->title = $objNewsletter->subject;
         $objTemplate->body = $this->parseSimpleTokens($html, $arrRecipient);
         $objTemplate->charset = $GLOBALS['TL_CONFIG']['characterSet'];
         $objTemplate->css = $css;
         // Parse template
         $objEmail->html = $objTemplate->parse();
         $objEmail->imageDir = TL_ROOT . '/';
     }
     // Deactivate invalid addresses
     try {
         $objEmail->sendTo($arrRecipient['email']);
     } catch (Swift_RfcComplianceException $e) {
         $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
     }
     // Rejected recipients
     if (count($objEmail->failures)) {
         $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
     }
 }
Exemplo n.º 17
0
 /**
  * Set the current record from a database result row
  * @param Database_Result
  * @param string
  * @param string
  */
 public function setFromRow(Database_Result $resResult, $strTable, $strRefField)
 {
     $this->strTable = $strTable;
     $this->strRefField = $strRefField;
     $this->varRefId = $resResult->{$strRefField};
     $this->resResult = $resResult;
     $this->arrData = $resResult->row();
     $this->blnRecordExists = true;
 }
Exemplo n.º 18
0
 public function __construct($result, $sql, $as_object)
 {
     parent::__construct($result, $sql, $as_object);
     $this->_total_rows = mysql_num_rows($result);
 }
Exemplo n.º 19
0
 public function __construct(array $result, $sql, $as_object = NULL)
 {
     parent::__construct($result, $sql, $as_object);
     $this->_total_rows = count($result);
 }
Exemplo n.º 20
0
 /**
  * Generate clustered GEOJSON from incidents
  * 
  * @param ORM_Iterator|Database_Result|array $incidents collection of incidents
  * @param int $category_id
  * @param string $color
  * @param string $icon
  * @return array $json_features geojson features array
  **/
 protected function clusters_geojson($incidents, $category_id, $color, $icon)
 {
     $json_features = array();
     // Extra params for clustering
     // Start date
     $start_date = (isset($_GET['s']) and intval($_GET['s']) > 0) ? intval($_GET['s']) : NULL;
     // End date
     $end_date = (isset($_GET['e']) and intval($_GET['e']) > 0) ? intval($_GET['e']) : NULL;
     // Get Zoom Level
     $zoomLevel = (isset($_GET['z']) and !empty($_GET['z'])) ? (int) $_GET['z'] : 8;
     $distance = (10000000 >> $zoomLevel) / 100000;
     // Get markers array
     if ($incidents instanceof ORM_Iterator) {
         $markers = $incidents->as_array();
     } elseif ($incidents instanceof Database_Result) {
         $markers = $incidents->result_array();
     } else {
         $markers = $incidents;
     }
     $clusters = array();
     // Clustered
     $singles = array();
     // Non Clustered
     // Loop until all markers have been compared
     while (count($markers)) {
         $marker = array_pop($markers);
         $cluster = array();
         // Handle both reports::fetch_incidents() response and actual ORM objects
         $marker->id = isset($marker->incident_id) ? $marker->incident_id : $marker->id;
         if (isset($marker->latitude) and isset($marker->longitude)) {
             $marker_latitude = $marker->latitude;
             $marker_longitude = $marker->longitude;
         } elseif (isset($marker->location) and isset($marker->location->latitude) and isset($marker->location->longitude)) {
             $marker_latitude = $marker->location->latitude;
             $marker_longitude = $marker->location->longitude;
         } else {
             // No location - skip this report
             continue;
         }
         // Compare marker against all remaining markers.
         foreach ($markers as $key => $target) {
             // Handle both reports::fetch_incidents() response and actual ORM objects
             if (isset($target->latitude) and isset($target->longitude)) {
                 $target_latitude = $target->latitude;
                 $target_longitude = $target->longitude;
             } elseif (isset($target->location) and isset($target->location->latitude) and isset($target->location->longitude)) {
                 $target_latitude = $target->location->latitude;
                 $target_longitude = $target->location->longitude;
             } else {
                 // No location - skip this report
                 continue;
             }
             // This function returns the distance between two markers, at a defined zoom level.
             // $pixels = $this->_pixelDistance($marker['latitude'], $marker['longitude'],
             // $target['latitude'], $target['longitude'], $zoomLevel);
             $pixels = abs($marker_longitude - $target_longitude) + abs($marker_latitude - $target_latitude);
             // If two markers are closer than defined distance, remove compareMarker from array and add to cluster.
             if ($pixels < $distance) {
                 unset($markers[$key]);
                 $cluster[] = $target;
             }
         }
         // If a marker was added to cluster, also add the marker we were comparing to.
         if (count($cluster) > 0) {
             $cluster[] = $marker;
             $clusters[] = $cluster;
         } else {
             $singles[] = $marker;
         }
     }
     // Create Json
     foreach ($clusters as $cluster) {
         // Calculate cluster center
         $bounds = $this->calculate_center($cluster);
         $cluster_center = array_values($bounds['center']);
         $southwest = $bounds['sw']['longitude'] . ',' . $bounds['sw']['latitude'];
         $northeast = $bounds['ne']['longitude'] . ',' . $bounds['ne']['latitude'];
         // Number of Items in Cluster
         $cluster_count = count($cluster);
         // Get the time filter
         $time_filter = (!empty($start_date) and !empty($end_date)) ? "&s=" . $start_date . "&e=" . $end_date : "";
         // Build query string for title link, passing through any GET params
         // This allows plugins to extend more easily
         $query = http_build_query(array_merge(array('sw' => $southwest, 'ne' => $northeast), $_GET));
         // Build out the JSON string
         $link = url::site("reports/index/?{$query}");
         $item_name = $this->get_title(Kohana::lang('ui_main.reports_count', $cluster_count), $link);
         $json_item = array();
         $json_item['type'] = 'Feature';
         $json_item['properties'] = array('name' => $item_name, 'link' => $link, 'category' => array($category_id), 'color' => $color, 'icon' => $icon, 'thumb' => '', 'timestamp' => 0, 'count' => $cluster_count);
         $json_item['geometry'] = array('type' => 'Point', 'coordinates' => $cluster_center);
         array_push($json_features, $json_item);
     }
     // Pass single points to standard markers json
     $json_features = array_merge($json_features, $this->markers_geojson($singles, $category_id, $color, $icon, FALSE));
     //
     // E.Kala July 27, 2011
     // @todo Parking this geometry business for review
     //
     /*
     //Get Incident Geometries
     $geometry = $this->_get_geometry($marker->incident_id, $marker->incident_title, $marker->incident_date);
     if (count($geometry))
     {
     	foreach ($geometry as $g)
     	{
     		array_push($json_features, $g);
     	}
     }
     */
     Event::run('ushahidi_filter.json_cluster_features', $json_features);
     return $json_features;
 }
Exemplo n.º 21
0
	/**
	 * Add a data row to the XML document
	 * @param DOMDocument
	 * @param DOMElement
	 * @param Database_Result
	 */
	protected function addDataRow(DOMDocument $xml, DOMElement $table, Database_Result $objData)
	{
		$row = $xml->createElement('row');
		$row = $table->appendChild($row);

		foreach ($objData->row() as $k=>$v)
		{
			$field = $xml->createElement('field');
			$field->setAttribute('name', $k);
			$field = $row->appendChild($field);

			if ($v === null)
			{
				$v = 'NULL';
			}

			$value = $xml->createTextNode($v);
			$value = $field->appendChild($value);
		}
	}
Exemplo n.º 22
0
 /**
  * Compile the newsletter and send it
  * @param \Email
  * @param \Database_Result
  * @param array
  * @param string
  * @param string
  * @param string
  * @return string
  */
 protected function sendNewsletter(\Email $objEmail, \Database_Result $objNewsletter, $arrRecipient, $text, $html, $css = null)
 {
     // Prepare the text content
     $objEmail->text = \String::parseSimpleTokens($text, $arrRecipient);
     // Add the HTML content
     if (!$objNewsletter->sendText) {
         // Default template
         if ($objNewsletter->template == '') {
             $objNewsletter->template = 'mail_default';
         }
         // Load the mail template
         $objTemplate = new \BackendTemplate($objNewsletter->template);
         $objTemplate->setData($objNewsletter->row());
         $objTemplate->title = $objNewsletter->subject;
         $objTemplate->body = \String::parseSimpleTokens($html, $arrRecipient);
         $objTemplate->charset = $GLOBALS['TL_CONFIG']['characterSet'];
         $objTemplate->css = $css;
         // Backwards compatibility
         // Parse template
         $objEmail->html = $objTemplate->parse();
         $objEmail->imageDir = TL_ROOT . '/';
     }
     // Deactivate invalid addresses
     try {
         $objEmail->sendTo($arrRecipient['email']);
     } catch (Swift_RfcComplianceException $e) {
         $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
     }
     // Rejected recipients
     if ($objEmail->hasFailures()) {
         $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
     }
 }
Exemplo n.º 23
0
 public function seek($position)
 {
     return parent::seek($position);
 }
Exemplo n.º 24
0
 /**
  * Parse one or more items and return them as array
  *
  * @param Database_Result $objArticles
  * @param bool|Template $objTemplate
  * @return array
  */
 protected function parseArticles(Database_Result $objArticles, $objTemplate = false)
 {
     if ($objArticles->numRows < 1) {
         return array();
     }
     global $objPage;
     $this->import('String');
     $this->import('News4wardHelper');
     $arrArticles = array();
     $limit = $objArticles->numRows;
     $count = 0;
     while ($objArticles->next()) {
         // init FrontendTemplate if theres no object given
         if (!$objTemplate) {
             $objTemplate = new FrontendTemplate($this->news4ward_template);
         }
         $objTemplate->setData($objArticles->row());
         $objTemplate->count = ++$count;
         $objTemplate->class = (strlen($objArticles->cssClass) ? ' ' . $objArticles->cssClass : '') . ($count == 1 ? ' first' : '') . ($count == $limit ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even') . ($objArticles->highlight ? ' highlight' : '');
         $objTemplate->link = $this->News4wardHelper->generateUrl($objArticles);
         $objTemplate->archive = $objArticles->archive;
         // Clean the RTE output for the TEASER
         if ($objArticles->teaser != '') {
             if ($objPage->outputFormat == 'xhtml') {
                 $objArticles->teaser = $this->String->toXhtml($objArticles->teaser);
             } else {
                 $objArticles->teaser = $this->String->toHtml5($objArticles->teaser);
             }
             $objTemplate->teaser = $this->String->encodeEmail($objArticles->teaser);
         }
         // Generate ContentElements
         $objContentelements = $this->Database->prepare('SELECT id FROM tl_content WHERE pid=? AND do="news4ward" ' . (!BE_USER_LOGGED_IN ? " AND invisible=''" : "") . ' ORDER BY sorting ')->execute($objArticles->id);
         $strContent = '';
         while ($objContentelements->next()) {
             $strContent .= $this->getContentElement($objContentelements->id);
         }
         // Clean the RTE output for the CONTENT
         if ($strContent != '') {
             // Clean the RTE output
             if ($objPage->outputFormat == 'xhtml') {
                 $strContent = $this->String->toXhtml($strContent);
             } else {
                 $strContent = $this->String->toHtml5($strContent);
             }
             $strContent = $this->String->encodeEmail($strContent);
         }
         $objTemplate->content = $strContent;
         // Add meta information
         $arrMeta = $this->getMetaFields($objArticles);
         $objTemplate->date = $arrMeta['date'];
         $objTemplate->hasMetaFields = count($arrMeta) ? true : false;
         $objTemplate->timestamp = $objArticles->start;
         $objTemplate->author = $arrMeta['author'];
         $objTemplate->datetime = date('Y-m-d\\TH:i:sP', $objArticles->start);
         // Add teaser image
         if ($objArticles->teaserImage && is_file(TL_ROOT . '/' . $objArticles->teaserImage)) {
             $imgSize = deserialize($this->imgSize, true);
             $objTemplate->arrSize = $imgSize;
             if (count($imgSize) > 1) {
                 $objTemplate->teaserImage = $this->getImage($objArticles->teaserImage, $imgSize[0], $imgSize[1], $imgSize[2]);
             } else {
                 $objTemplate->teaserImage = $objArticles->teaserImage;
             }
             $objTemplate->teaserImageRaw = $objTemplate->teaserImag;
         }
         // HOOK: add custom logic
         if (isset($GLOBALS['TL_HOOKS']['News4wardParseArticle']) && is_array($GLOBALS['TL_HOOKS']['News4wardParseArticle'])) {
             foreach ($GLOBALS['TL_HOOKS']['News4wardParseArticle'] as $callback) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]($this, $objArticles, $objTemplate);
             }
         }
         $arrArticles[] = $objTemplate->parse();
     }
     return $arrArticles;
 }
Exemplo n.º 25
0
 /**
  * Add an event to the array of active events
  * @param Database_Result
  * @param integer
  * @param integer
  * @param string
  * @param integer
  * @param integer
  * @param integer
  */
 protected function addEvent(Database_Result $objEvents, $intStart, $intEnd, $strUrl, $intBegin, $intLimit, $intCalendar)
 {
     global $objPage;
     $intDate = $intStart;
     $intKey = date('Ymd', $intStart);
     $span = Calendar::calculateSpan($intStart, $intEnd);
     $strDate = $this->parseDate($objPage->dateFormat, $intStart);
     $strDay = $GLOBALS['TL_LANG']['DAYS'][date('w', $intStart)];
     $strMonth = $GLOBALS['TL_LANG']['MONTHS'][date('n', $intStart) - 1];
     if ($span > 0) {
         $strDate = $this->parseDate($objPage->dateFormat, $intStart) . ' - ' . $this->parseDate($objPage->dateFormat, $intEnd);
         $strDay = '';
     }
     $strTime = '';
     if ($objEvents->addTime) {
         if ($span > 0) {
             $strDate = $this->parseDate($objPage->datimFormat, $intStart) . ' - ' . $this->parseDate($objPage->datimFormat, $intEnd);
         } elseif ($intStart == $intEnd) {
             $strTime = $this->parseDate($objPage->timeFormat, $intStart);
         } else {
             $strTime = $this->parseDate($objPage->timeFormat, $intStart) . ' - ' . $this->parseDate($objPage->timeFormat, $intEnd);
         }
     }
     // Store raw data
     $arrEvent = $objEvents->row();
     // Overwrite some settings
     $arrEvent['time'] = $strTime;
     $arrEvent['date'] = $strDate;
     $arrEvent['day'] = $strDay;
     $arrEvent['month'] = $strMonth;
     $arrEvent['parent'] = $intCalendar;
     $arrEvent['link'] = $objEvents->title;
     $arrEvent['target'] = '';
     $arrEvent['title'] = specialchars($objEvents->title, true);
     $arrEvent['href'] = $this->generateEventUrl($objEvents, $strUrl);
     $arrEvent['class'] = $objEvents->cssClass != '' ? ' ' . $objEvents->cssClass : '';
     $arrEvent['details'] = $this->String->encodeEmail($objEvents->details);
     $arrEvent['start'] = $intStart;
     $arrEvent['end'] = $intEnd;
     // Override the link target
     if ($objEvents->source == 'external' && $objEvents->target) {
         $arrEvent['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
     }
     // Clean the RTE output
     if ($arrEvent['teaser'] != '') {
         if ($objPage->outputFormat == 'xhtml') {
             $arrEvent['teaser'] = $this->String->toXhtml($arrEvent['teaser']);
         } else {
             $arrEvent['teaser'] = $this->String->toHtml5($arrEvent['teaser']);
         }
     }
     // Display the "read more" button for external/article links
     if ($objEvents->source != 'default' && $objEvents->details == '') {
         $arrEvent['details'] = true;
     } else {
         if ($objPage->outputFormat == 'xhtml') {
             $arrEvent['details'] = $this->String->toXhtml($arrEvent['details']);
         } else {
             $arrEvent['details'] = $this->String->toHtml5($arrEvent['details']);
         }
     }
     // Get todays start and end timestamp
     if ($this->intTodayBegin === null) {
         $this->intTodayBegin = strtotime('00:00:00');
     }
     if ($this->intTodayEnd === null) {
         $this->intTodayEnd = strtotime('23:59:59');
     }
     // Mark past and upcoming events (see #3692)
     if ($intEnd < $this->intTodayBegin) {
         $arrEvent['class'] .= ' bygone';
     } elseif ($intStart > $this->intTodayEnd) {
         $arrEvent['class'] .= ' upcoming';
     } else {
         $arrEvent['class'] .= ' current';
     }
     $this->arrEvents[$intKey][$intStart][] = $arrEvent;
     // Multi-day event
     for ($i = 1; $i <= $span && $intDate <= $intLimit; $i++) {
         // Only show first occurrence
         if ($this->cal_noSpan && $intDate >= $intBegin) {
             break;
         }
         $intDate = strtotime('+ 1 day', $intDate);
         $intNextKey = date('Ymd', $intDate);
         $this->arrEvents[$intNextKey][$intDate][] = $arrEvent;
     }
 }
Exemplo n.º 26
0
 function __construct(Database_Result $resultSet = null)
 {
     foreach ($resultSet->row() as $name => $value) {
         $this->{$name} = $value;
     }
 }
Exemplo n.º 27
0
 /**
  * Get rows
  *
  * @param \Database_Result $objRecords
  *
  * @return array
  */
 public function getRows($objRecords)
 {
     if (!$objRecords->numRows) {
         return array();
     }
     $arrRows = array();
     $objRecords->reset();
     while ($objRecords->next()) {
         $arrField = $objRecords->row();
         foreach ($this->fields as $field) {
             $arrField[$field] = Format::dcaValue($this->foreignTable, $field, $objRecords->{$field});
         }
         $arrRows[] = $arrField;
     }
     return $arrRows;
 }
Exemplo n.º 28
0
	/**
	 * Parse one or more items and return them as array
	 * @param Database_Result
	 * @param boolean
	 * @return array
	 */
	protected function parseArticles(Database_Result $objArticles, $blnAddArchive=false)
	{
		if ($objArticles->numRows < 1)
		{
			return array();
		}

		global $objPage;
		$this->import('String');

		$arrArticles = array();
		$limit = $objArticles->numRows;
		$count = 0;
		$imgSize = false;

		// Override the default image size
		if ($this->imgSize != '')
		{
			$size = deserialize($this->imgSize);

			if ($size[0] > 0 || $size[1] > 0)
			{
				$imgSize = $this->imgSize;
			}
		}

		while ($objArticles->next())
		{
			$objTemplate = new FrontendTemplate($this->news_template);
			$objTemplate->setData($objArticles->row());

			$objTemplate->count = ++$count;
			$objTemplate->class = (($objArticles->cssClass != '') ? ' ' . $objArticles->cssClass : '') . (($count == 1) ? ' first' : '') . (($count == $limit) ? ' last' : '') . ((($count % 2) == 0) ? ' odd' : ' even');
			$objTemplate->newsHeadline = $objArticles->headline;
			$objTemplate->subHeadline = $objArticles->subheadline;
			$objTemplate->hasSubHeadline = $objArticles->subheadline ? true : false;
			$objTemplate->linkHeadline = $this->generateLink($objArticles->headline, $objArticles, $blnAddArchive);
			$objTemplate->more = $this->generateLink($GLOBALS['TL_LANG']['MSC']['more'], $objArticles, $blnAddArchive, true);
			$objTemplate->link = $this->generateNewsUrl($objArticles, $blnAddArchive);
			$objTemplate->archive = $objArticles->archive;

			// Clean the RTE output
			if ($objArticles->teaser != '')
			{
				if ($objPage->outputFormat == 'xhtml')
				{
					$objArticles->teaser = $this->String->toXhtml($objArticles->teaser);
				}
				else
				{
					$objArticles->teaser = $this->String->toHtml5($objArticles->teaser);
				}

				$objTemplate->teaser = $this->String->encodeEmail($objArticles->teaser);
			}

			// Display the "read more" button for external/article links
			if (($objArticles->source == 'external' || $objArticles->source == 'article') && $objArticles->text == '')
			{
				$objTemplate->text = true;
			}

			// Encode e-mail addresses
			else
			{
				// Clean the RTE output
				if ($objPage->outputFormat == 'xhtml')
				{
					$objArticles->text = $this->String->toXhtml($objArticles->text);
				}
				else
				{
					$objArticles->text = $this->String->toHtml5($objArticles->text);
				}

				$objTemplate->text = $this->String->encodeEmail($objArticles->text);
			}

			$arrMeta = $this->getMetaFields($objArticles);

			// Add meta information
			$objTemplate->date = $arrMeta['date'];
			$objTemplate->hasMetaFields = !empty($arrMeta);
			$objTemplate->numberOfComments = $arrMeta['ccount'];
			$objTemplate->commentCount = $arrMeta['comments'];
			$objTemplate->timestamp = $objArticles->date;
			$objTemplate->author = $arrMeta['author'];
			$objTemplate->datetime = date('Y-m-d\TH:i:sP', $objArticles->date);

			$objTemplate->addImage = false;

			// Add an image
			if ($objArticles->addImage && is_file(TL_ROOT . '/' . $objArticles->singleSRC))
			{
				if ($imgSize)
				{
					$objArticles->size = $imgSize;
				}

				$this->addImageToTemplate($objTemplate, $objArticles->row());
			}

			$objTemplate->enclosure = array();

			// Add enclosures
			if ($objArticles->addEnclosure)
			{
				$this->addEnclosuresToTemplate($objTemplate, $objArticles->row());
			}

			// HOOK: add custom logic
			if (isset($GLOBALS['TL_HOOKS']['parseArticles']) && is_array($GLOBALS['TL_HOOKS']['parseArticles']))
			{
				foreach ($GLOBALS['TL_HOOKS']['parseArticles'] as $callback)
				{
					$this->import($callback[0]);
					$this->$callback[0]->$callback[1]($objTemplate, $objArticles->row(), $this);
				}
			}

			$arrArticles[] = $objTemplate->parse();
		}

		return $arrArticles;
	}
Exemplo n.º 29
0
 /**
 * This method will delete the rows in the given tables, that matches the WHERE-clause.
 *
 * @param array|string      $m_table_names      the name of all updating tables in an array
 													(or simply one table as a string)
 * @param array             $a_table_alias      the alias of the tables (leave empty for no alias)
 * @param array             $a_where_clause     an array with the where clause params
 *                                              (column_name => column_value)
 *
 * @return  null|Database_Result        the result set of the statement
 */
 public static function delete($m_table_names, $a_where_clause, $a_table_alias = array())
 {
     try {
         return Database_Result::getInstance(Database_Connection::getInstance()->delete($m_table_names, $a_where_clause, $a_table_alias));
     } catch (LOGD_Exception $exc) {
         $exc->print_error();
         return null;
     }
 }