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


PHP General::createXMLDateObject方法代码示例

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


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

示例1: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false)
 {
     return;
     if (isset($data['gmt']) && !is_null($data['gmt'])) {
         $wrapper->appendChild(General::createXMLDateObject($data['local'], $this->get('element_name')));
     }
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:7,代码来源:field.systemdate.php

示例2: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false, $mode = NULL, $entry_id = NULL)
 {
     $row = self::__dateFromEntryID($entry_id);
     if (isset($row['local']) && !is_null($row['local'])) {
         $wrapper->appendChild(General::createXMLDateObject($data['local'], $this->get('element_name')));
     }
 }
开发者ID:pointybeard,项目名称:system_date_field,代码行数:7,代码来源:field.systemdate.php

示例3: appendFormattedElement

 /**
  * Append the formatted xml output of this field as utilized as a data source.
  *
  * @param XMLElement $wrapper
  *	the xml element to append the xml representation of this to.
  * @param array $data
  *	the current set of values for this field. the values are structured as
  *	for displayPublishPanel.
  * @param boolean $encode (optional)
  *	flag as to whether this should be html encoded prior to output. this
  *	defaults to false.
  * @param string $mode
  *	 A field can provide ways to output this field's data. For instance a mode
  *  could be 'items' or 'full' and then the function would display the data
  *  in a different way depending on what was selected in the datasource
  *  included elements.
  * @param integer $entry_id (optional)
  *	the identifier of this field entry instance. defaults to null.
  */
 public function appendFormattedElement($wrapper, $data, $encode = false)
 {
     $dates = $this->_driver->getEntryDates($data, $this->get('id'), $this->filter);
     $element = new XMLElement($this->get('element_name'));
     $element->appendChild(General::createXMLDateObject($data['start'], 'start'));
     foreach ($dates[0] as $index => $date) {
         $element->appendChild(General::createXMLDateObject($date['value'], 'before'));
     }
     foreach ($dates[1] as $index => $date) {
         $element->appendChild(General::createXMLDateObject($date['value'], $index == 0 ? 'current' : 'after'));
     }
     $element->appendChild(General::createXMLDateObject($data['end'], 'end'));
     $element->setAttribute('date-mode', isset($data['mode']) ? $data['mode'] : null);
     $element->setAttribute('date-units', isset($data['units']) ? $data['units'] : null);
     $wrapper->appendChild($element);
 }
开发者ID:symphonists,项目名称:repeating_date_field,代码行数:35,代码来源:field.repeating_date.php

示例4: __search

 private function __search($query)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     if (strlen(trim($query)) == 0) {
         return $this->emptyXMLSet($result);
     }
     $db = ASDCLoader::instance();
     $result->appendChild(new XMLElement('query-string', General::sanitize($query), array('encoded' => urlencode($query))));
     $sql = "SELECT SQL_CALC_FOUND_ROWS \n\t\t\t\t\t\tMATCH(comment.value) AGAINST ('%6\$s') AS `score`,\n\t\t\t\t\t\tcomment.entry_id AS `id`,\n\t\t\t\t\t\tdate.local AS `date`,\n\t\t\t\t\t\tcomment.value_formatted AS `description`,\n\t\t\t\t\t\tmember.member_id AS `member-id`, \n\t\t\t\t\t\tmember.username AS `username`,\n\t\t\t\t\t\ttopic.value AS `topic`,\n\t\t\t\t\t\tparent.relation_id AS `discussion-id`\n\t\t\t\t\t\t\n\t\t\t\t\tFROM `tbl_entries_data_%1\$d` AS `date`\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%2\$d` AS `comment` ON date.entry_id = comment.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%3\$d` AS `member` ON date.entry_id = member.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%4\$d` AS `parent` ON date.entry_id = parent.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%5\$d` AS `topic` ON parent.relation_id = topic.entry_id\n\n\t\t\t\t\tWHERE MATCH(comment.value) AGAINST ('%6\$s')\n\t\t\t\t\tORDER BY `score` DESC\n\t\t\t\t\tLIMIT %7\$d, %8\$d";
     //MATCH(comment.value) AGAINST ('%s') AS `score`,
     //OR MATCH(comment.value) AGAINST ('%1\$s')
     //WITH QUERY EXPANSION
     //member.username = '%6\$s' OR comment.value LIKE '%%%6\$s%%' OR topic.value LIKE '%%%6\$s%%'
     try {
         $rows = $db->query(sprintf($sql, self::findFieldID('date', 'comments'), self::findFieldID('comment', 'comments'), self::findFieldID('created-by', 'comments'), self::findFieldID('parent-id', 'comments'), self::findFieldID('topic', 'discussions'), $db->escape($query), max(0, ($this->dsParamSTARTPAGE - 1) * $this->dsParamLIMIT), $this->dsParamLIMIT));
     } catch (Exception $e) {
         $result->appendChild(new XMLElement('error', General::sanitize(vsprintf('%d: %s on query %s', $db->lastError()))));
         return $result;
     }
     if ($rows->length() == 0) {
         return $this->emptyXMLSet($result);
     }
     $total = $db->query('SELECT FOUND_ROWS() AS `total`;')->current()->total;
     $result->prependChild(General::buildPaginationElement($total, ceil($total * (1 / $this->dsParamLIMIT)), $this->dsParamLIMIT, $this->dsParamSTARTPAGE));
     /*
     
     		        <entry id="19753">
     		            <name>Section Schema</name>
     		            <member id="2101">Allen</member>
     		            <description><p>Sect ... ollow).</p></description>
     		        </entry>
     */
     foreach ($rows as $r) {
         $entry = new XMLElement('entry', NULL, array('discussion-id' => $r->{'discussion-id'}, 'id' => $r->id, 'score' => number_format($r->score, 3)));
         // Topic
         $entry->appendChild(new XMLElement('topic', General::sanitize($r->topic)));
         // Date
         $entry->appendChild(General::createXMLDateObject($r->date, 'date'));
         // Member
         $entry->appendChild(new XMLElement('member', General::sanitize($r->{'username'}), array('id' => $r->{'member-id'})));
         // Comment
         $entry->appendChild(new XMLElement('comment', trim($r->description)));
         $result->appendChild($entry);
     }
     return $result;
 }
开发者ID:bauhouse,项目名称:sym-forum-ensemble,代码行数:46,代码来源:data.search_comments.php

示例5: grab

 public function grab(&$param_pool)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     self::__init();
     $db = ASDCLoader::instance();
     $sql = "SELECT \n\t\t\t\t\t\te.id,\n\t\t\t\t\t\te.creation_date_gmt AS `date`,\n\t\t\t\t\t\tname.value AS `name`,\n\t\t\t\t\t\trole.name AS `role`,\n\t\t\t\t\t\twebsite.value AS `website`,\n\t\t\t\t\t\tcity.value AS `city`,\n\t\t\t\t\t\ttimezone_offset.value AS `timezone-offset`,\t\t\t\t\t\t\n\t\t\t\t\t\tusername.username AS `username`,\n\t\t\t\t\t\temail.value AS `email`,\n\t\t\t\t\t\tMD5(email.value) AS `hash`\n\t\t\t\t\t\t\n\t\t\t\t\tFROM `tbl_entries_data_%d` AS `name`\n\t\t\t\t\tLEFT JOIN `tbl_entries` AS `e` ON name.entry_id = e.id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `r` ON e.id = r.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_members_roles` AS `role` ON r.role_id = role.id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `username` ON e.id = username.entry_id\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `email` ON e.id = email.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `city` ON e.id = city.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `website` ON e.id = website.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `timezone_offset` ON e.id = timezone_offset.entry_id\n\t\t\t\t\t\n\t\t\t\t\tWHERE username.username = '%s'\n\t\t\t\t\tLIMIT 0, 1";
     try {
         $member = $db->query(sprintf($sql, self::findFieldID('name', 'members'), self::findFieldID('role', 'members'), self::findFieldID('username-and-password', 'members'), self::findFieldID('email-address', 'members'), self::findFieldID('city', 'members'), self::findFieldID('website', 'members'), self::findFieldID('timezone-offset', 'members'), $db->escape($this->dsParamFILTERS['username'])))->current();
     } catch (Exception $e) {
         $result->appendChild(new XMLElement('error', $e->getMessage()));
         return $result;
     }
     if (!$member instanceof StdClass || is_null($member)) {
         $this->__redirectToErrorPage();
     }
     /*
     
     			  	<entry id="2101">
     		            <creation-date time="19:31" weekday="3">2009-01-07</creation-date>			
     		            <name handle="allen-chang">Allen Chang</name>
     		            <role id="2">Administrator</role>
     		            <username-and-password username="Allen" password="86b100a6c3a0d856be4e630959df6de9" />
     		        </entry>
     */
     $entry = new XMLElement('entry', NULL, array('id' => $member->id, 'email-hash' => $member->hash));
     $entry->appendChild(new XMLElement('name', General::sanitize($member->name)));
     if (isset($member->website) && strlen(trim($member->website)) > 0) {
         $entry->appendChild(new XMLElement('website', General::sanitize($member->website)));
     }
     if (isset($member->city) && strlen(trim($member->city)) > 0) {
         $entry->appendChild(new XMLElement('city', General::sanitize($member->city)));
     }
     $offset = !is_null($member->{'timezone-offset'}) ? min(max($member->{'timezone-offset'}, -12), 12) : 0;
     $entry->appendChild(new XMLElement('timezone-offset', $offset));
     $entry->appendChild(new XMLElement('role', General::sanitize($member->role)));
     $entry->appendChild(new XMLElement('username', General::sanitize($member->username)));
     $entry->appendChild(General::createXMLDateObject(strtotime($member->date . '+00:00'), 'date-joined'));
     $result->appendChild($entry);
     return $result;
 }
开发者ID:bauhouse,项目名称:sym-forum-ensemble,代码行数:40,代码来源:data.members.php

示例6: grab

    public function grab(&$param_pool)
    {
        $Members = Frontend::instance()->ExtensionManager->create('members');
        $Members->initialiseCookie();
        if ($Members->isLoggedIn() !== true) {
            // Oi! you can't be here
            redirect(URL . '/forbidden/');
            exit;
        }
        $result = new XMLElement($this->dsParamROOTELEMENT);
        self::__init();
        $db = ASDCLoader::instance();
        $sql = 'SELECT SQL_CALC_FOUND_ROWS 
						pinned.entry_id AS `id`, 
						pinned.value AS `pinned`, 
						closed.value AS `closed`, 
						creation_date.local AS `creation-date`,
						last_active.local AS `last-active`,							
						created_by.member_id AS `created-by-member-id`,
						created_by.username AS `created-by-username`,
						last_post.member_id AS `last-post-member-id`,
						last_post.username AS `last-post-username`,							
						topic.value AS `topic`
					
					FROM `tbl_entries_data_%d` AS `pinned`
					LEFT JOIN `tbl_entries_data_%d` AS `closed` ON pinned.entry_id = closed.entry_id
					LEFT JOIN `tbl_entries_data_%d` AS `creation_date` ON pinned.entry_id = creation_date.entry_id	
					LEFT JOIN `tbl_entries_data_%d` AS `last_active` ON pinned.entry_id = last_active.entry_id					
					LEFT JOIN `tbl_entries_data_%d` AS `created_by` ON pinned.entry_id = created_by.entry_id	
					LEFT JOIN `tbl_entries_data_%d` AS `last_post` ON pinned.entry_id = last_post.entry_id	
					LEFT JOIN `tbl_entries_data_%d` AS `topic` ON pinned.entry_id = topic.entry_id
					LEFT JOIN `tbl_entries_data_%d` AS `comments` ON pinned.entry_id = comments.relation_id
					LEFT JOIN `tbl_entries_data_%d` AS `discussion_comments_member` ON comments.entry_id = discussion_comments_member.entry_id	
					WHERE 1 %s
					AND (created_by.member_id = %11$d || discussion_comments_member.member_id = %11$d)
					GROUP BY pinned.entry_id
					ORDER BY pinned.value ASC, last_active.local DESC
					LIMIT %12$d, %13$d';
        try {
            $rows = $db->query(sprintf($sql, self::findFieldID('pinned', 'discussions'), self::findFieldID('closed', 'discussions'), self::findFieldID('creation-date', 'discussions'), self::findFieldID('last-active', 'discussions'), self::findFieldID('created-by', 'discussions'), self::findFieldID('last-post', 'discussions'), self::findFieldID('topic', 'discussions'), self::findFieldID('parent-id', 'comments'), self::findFieldID('created-by', 'comments'), isset($this->dsParamFILTERS['id']) && (int) $this->dsParamFILTERS['id'] > 0 ? " AND pinned.entry_id  = " . (int) $this->dsParamFILTERS['id'] : NULL, (int) $Members->Member->get('id'), max(0, ($this->dsParamSTARTPAGE - 1) * $this->dsParamLIMIT), $this->dsParamLIMIT));
        } catch (Exception $e) {
            $result->appendChild(new XMLElement('error', General::sanitize(vsprintf('%d: %s on query %s', $db->lastError()))));
            return $result;
        }
        if ($rows->length() == 0) {
            return $this->emptyXMLSet();
        }
        $total = $db->query('SELECT FOUND_ROWS() AS `total`;')->current()->total;
        $result->prependChild(General::buildPaginationElement($total, ceil($total * (1 / $this->dsParamLIMIT)), $this->dsParamLIMIT, $this->dsParamSTARTPAGE));
        /*
        	stdClass Object
        	(
        	    [id] => 666
        	    [pinned] => yes
        	    [closed] => no
        	    [creation-date] => 1233599808
        	    [last-active] => 1237161637
        	    [created-by-member-id] => 2126
        	    [created-by-username] => Lewis
        	    [last-post-member-id] => 2126
        	    [last-post-username] => Lewis
        	    [topic] => Symphony 2 Documentation
        	    [comments] => 18
        	)
        
           <entry id="595" comments="7">
        		            <created-by id="2150">newnomad</created-by>
        		            <closed>No</closed>
        		            <last-active time="18:30" weekday="1">2009-02-09</last-active>
        		            <last-post id="2150">newnomad</last-post>
        		            <pinned>No</pinned>
        		            <topic handle="viewing-feeds">viewing feeds</topic>
        		            <creation-date time="19:31" weekday="3">2009-01-07</creation-date>
            </entry>
        */
        $param_pool['ds-' . $this->dsParamROOTELEMENT] = DatabaseUtilities::resultColumn($rows, 'id');
        foreach ($rows as $r) {
            // Need to do a seperate query to find the comment counts.
            try {
                $comments = $db->query(sprintf("SELECT COUNT(*) AS `count` FROM `tbl_entries_data_%d` WHERE `relation_id` = %d ", self::findFieldID('parent-id', 'comments'), $r->id))->current()->count;
            } catch (Exception $e) {
                $result->appendChild(new XMLElement('error', General::sanitize(vsprintf('%d: %s on query %s', $db->lastError()))));
                return $result;
            }
            $entry = new XMLElement('entry', NULL, array('id' => $r->id, 'comments' => $comments));
            $entry->appendChild(new XMLElement('created-by', General::sanitize($r->{'created-by-username'}), array('id' => $r->{'created-by-member-id'})));
            $entry->appendChild(new XMLElement('last-post', General::sanitize($r->{'last-post-username'}), array('id' => $r->{'last-post-member-id'})));
            $entry->appendChild(new XMLElement('closed', ucfirst($r->closed)));
            $entry->appendChild(new XMLElement('pinned', ucfirst($r->pinned)));
            $entry->appendChild(new XMLElement('topic', General::sanitize($r->topic)));
            $entry->appendChild(General::createXMLDateObject($r->{'creation-date'}, 'creation-date'));
            $entry->appendChild(General::createXMLDateObject($r->{'last-active'}, 'last-active'));
            $result->appendChild($entry);
        }
        return $result;
    }
开发者ID:bauhouse,项目名称:forum,代码行数:96,代码来源:data.forum_discussions_filtered.php

示例7: appendFormattedElement

 public function appendFormattedElement($wrapper, $data, $encode = false)
 {
     if (isset($data['gmt']) && !is_null($data['gmt'])) {
         // Get date
         if (is_array($data['local'])) {
             $date = current($data['local']);
         } else {
             $date = $data['local'];
         }
         // Append date
         $wrapper->appendChild(General::createXMLDateObject($date, $this->get('element_name')));
     }
 }
开发者ID:scottkf,项目名称:keepflippin--on-symphony,代码行数:13,代码来源:field.date.php

示例8: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false)
 {
     $dates = $this->_driver->getEntryDates($data, $this->get('id'), $this->_Parent->filter);
     $element = new XMLElement($this->get('element_name'));
     $element->appendChild(General::createXMLDateObject($data['start'], 'start'));
     // make sure not to print all the dates without a filter otherwise it pollutes the xml
     if ($this->_Parent->filter) {
         foreach ($dates[0] as $index => $date) {
             $element->appendChild(General::createXMLDateObject($date['value'], 'current'));
         }
     }
     // foreach ($dates[1] as $index => $date) {
     // 	$element->appendChild(General::createXMLDateObject($date['value'], ($index == 0 ? 'current' : 'after')));
     // }
     $element->appendChild(General::createXMLDateObject($data['end'], 'end'));
     $element->setAttribute('mode', @$data['mode']);
     $element->setAttribute('units', @$data['units']);
     $wrapper->appendChild($element);
 }
开发者ID:scottkf,项目名称:keepflippin--on-symphony,代码行数:19,代码来源:field.repeatingdate.php

示例9: processEntry

 /**
  * Given an Entry object, this function will generate an XML representation
  * of the Entry to be returned. It will also add any parameters selected
  * by this datasource to the parameter pool.
  *
  * @param Entry $entry
  * @return XMLElement|boolean
  *  Returns boolean when only parameters are to be returned.
  */
 public function processEntry(Entry $entry)
 {
     $data = $entry->getData();
     $xEntry = new XMLElement('entry');
     $xEntry->setAttribute('id', $entry->get('id'));
     if (!empty($this->_associated_sections)) {
         $this->setAssociatedEntryCounts($xEntry, $entry);
     }
     if ($this->_can_process_system_parameters) {
         $this->processSystemParameters($entry);
     }
     foreach ($data as $field_id => $values) {
         if (!isset(self::$_fieldPool[$field_id]) || !is_object(self::$_fieldPool[$field_id])) {
             self::$_fieldPool[$field_id] =& FieldManager::fetch($field_id);
         }
         $this->processOutputParameters($entry, $field_id, $values);
         if (!$this->_param_output_only) {
             foreach ($this->dsParamINCLUDEDELEMENTS as $handle) {
                 list($handle, $mode) = preg_split('/\\s*:\\s*/', $handle, 2);
                 if (self::$_fieldPool[$field_id]->get('element_name') == $handle) {
                     self::$_fieldPool[$field_id]->appendFormattedElement($xEntry, $values, $this->dsParamHTMLENCODE ? true : false, $mode, $entry->get('id'));
                 }
             }
         }
     }
     if ($this->_param_output_only) {
         return true;
     }
     if (in_array('system:date', $this->dsParamINCLUDEDELEMENTS)) {
         $xEntry->appendChild(General::createXMLDateObject(DateTimeObj::get('U', $entry->creationDate), 'system-date'));
     }
     return $xEntry;
 }
开发者ID:nickdunn,项目名称:elasticsearch-surfin-shakespeare,代码行数:42,代码来源:class.datasource.section.php

示例10: appendFormattedElement

 public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
 {
     if (isset($data['value'])) {
         // Get date
         if (is_array($data['value'])) {
             $date = current($data['value']);
         } else {
             $date = $data['value'];
         }
         // Append date
         $wrapper->appendChild(General::createXMLDateObject($date, $this->get('element_name')));
     }
 }
开发者ID:davjand,项目名称:codecept-symphonycms-db,代码行数:13,代码来源:field.date.php

示例11: appendFormattedElement

 public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
 {
     $pw = new XMLElement($this->get('element_name'));
     // If reset is set, return the recovery-code
     if ($data['reset'] == 'yes') {
         $pw->setAttribute('reset-requested', 'yes');
         $pw->appendChild(new XMLElement('recovery-code', $data['recovery-code']));
         // Add expiry timestamp, including how long the code is valid for
         $expiry = General::createXMLDateObject(strtotime($data['timestamp'] . ' + ' . $this->get('code_expiry')), 'expires');
         $expiry->setAttribute('expiry', $this->get('code_expiry'));
         $pw->appendChild($expiry);
     } else {
         if ($data['password']) {
             $pw->setValue($data['password']);
         }
     }
     $wrapper->appendChild($pw);
 }
开发者ID:andrewminton,项目名称:members,代码行数:18,代码来源:field.memberpassword.php

示例12: grab


//.........这里部分代码省略.........
     ##------------------------------
     ##Create the XML container
     $xml = new XMLElement("archive-entry-list");
     $xml->setAttribute("section", $this->getType());
     $xml->setAttribute("section-id", $section_id);
     ##Grab the records
     $entries = $this->_db->fetchCol("id", $sql);
     ##Populate the XML
     if (empty($entries) || !is_array($entries)) {
         $xml->addChild(new XMLElement("error", "No Records Found."));
         return $xml;
     } else {
         $bin = array();
         foreach ($entries as $id) {
             $row = $entryManager->fetchEntriesByID($id, false, true);
             list($dYear, $dMonth, $dDay) = explode("-", date("Y-m-d", $obDate->get(true, false, strtotime($row['publish_date_gmt']))));
             $bin[$dYear][$dMonth][$dDay][] = $row;
         }
         foreach ($bin as $year => $months) {
             $xYear = new XMLElement("year");
             $xYear->setAttribute("value", $year);
             foreach ($months as $month => $days) {
                 $xMonth = new XMLElement("month");
                 $xMonth->setAttribute("value", $month);
                 foreach ($days as $day => $entries) {
                     $xDay = new XMLElement("day");
                     $xDay->setAttribute("value", $day);
                     foreach ($entries as $row) {
                         $entry = new XMLElement("entry");
                         $entry->setAttribute("id", $row['id']);
                         $entry->setAttribute("handle", trim($row['fields'][$row['primary_field']]['handle']));
                         $entry->setAttribute('linked-count', '' . count($row['linked_entries']) . '');
                         $date_local = $obDate->get(true, false, $row['timestamp_gmt']);
                         $entry_fields = array("date" => General::createXMLDateObject($date_local), "time" => General::createXMLTimeObject($date_local), "rfc822-date" => date("D, d M Y H:i:s \\G\\M\\T", $obDate->get(false, false, $row['timestamp_gmt'])));
                         $this->__addChildFieldsToXML($entry_fields, $entry);
                         ##Author Details
                         $author_rec = $this->_db->fetchRow(0, "SELECT * FROM `tbl_authors` WHERE `id` = '" . $row['author_id'] . "' LIMIT 1");
                         $author = new XMLElement("author");
                         $author_fields = array("first-name" => $author_rec['firstname'], "last-name" => $author_rec['lastname'], "email" => $author_rec['email'], "username" => $author_rec['username']);
                         $this->__addChildFieldsToXML($author_fields, $author, "author");
                         $entry->addChild($author);
                         ##Custom Fields
                         $fields = $row['fields'];
                         if (is_array($fields) && !empty($fields)) {
                             $customFields = new XMLElement("fields");
                             foreach ($fields as $f) {
                                 if (@in_array($f['field_handle'], $this->_dsFilterXMLFIELDS)) {
                                     $newField = new XMLElement($f['field_handle']);
                                     if ($f['type'] == 'list' || $f['type'] == 'multiselect') {
                                         foreach ($f['value_raw'] as $val) {
                                             $item = new XMLElement("item", $val);
                                             $item->setAttribute("handle", Lang::createHandle($val, $this->_parent->getConfigVar('handle_length', 'admin')));
                                             $newField->addChild($item);
                                         }
                                     } elseif ($f['type'] == 'foreign') {
                                         $sid = $f['foreign_section'];
                                         $section_handle = $this->_db->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` WHERE `id` = '{$sid} ' LIMIT 1");
                                         $newField->setAttribute("handle", $f['handle']);
                                         $newField->setAttribute("type", 'foreign');
                                         $newField->setAttribute("section-id", $sid);
                                         $newField->setAttribute("section-handle", $sid);
                                         if (!is_array($f['value_raw'])) {
                                             $f['value_raw'] = array($f['value_raw']);
                                         }
                                         foreach ($f['value_raw'] as $h) {
                                             $entry_id = $entryManager->fetchEntryIDFromPrimaryFieldHandle($sid, $h);
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:67,代码来源:data.archive_entry_list.php

示例13: grab

 public function grab(&$param_pool)
 {
     $result = new XMLElement($this->dsParamROOTELEMENT);
     self::__init();
     $db = ASDCLoader::instance();
     $sql = "SELECT SQL_CALC_FOUND_ROWS \n\t\t\t\t\t\tpinned.entry_id AS `id`, \n\t\t\t\t\t\tpinned.value AS `pinned`, \n\t\t\t\t\t\tclosed.value AS `closed`, \n\t\t\t\t\t\tcreation_date.local AS `creation-date`,\n\t\t\t\t\t\tlast_active.local AS `last-active`,\t\t\t\t\t\t\t\n\t\t\t\t\t\tcreated_by.member_id AS `created-by-member-id`,\n\t\t\t\t\t\tcreated_by.username AS `created-by-username`,\n\t\t\t\t\t\tlast_post.member_id AS `last-post-member-id`,\n\t\t\t\t\t\tlast_post.username AS `last-post-username`,\t\t\t\t\t\t\t\n\t\t\t\t\t\ttopic.value AS `topic`,\n\t\t\t\t\t\tCOUNT(comments.relation_id) AS `comments`\n\t\t\t\t\t\n\t\t\t\t\tFROM `tbl_entries_data_%d` AS `pinned`\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `closed` ON pinned.entry_id = closed.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `creation_date` ON pinned.entry_id = creation_date.entry_id\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `last_active` ON pinned.entry_id = last_active.entry_id\t\t\t\t\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `created_by` ON pinned.entry_id = created_by.entry_id\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `last_post` ON pinned.entry_id = last_post.entry_id\t\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `topic` ON pinned.entry_id = topic.entry_id\n\t\t\t\t\tLEFT JOIN `tbl_entries_data_%d` AS `comments` ON pinned.entry_id = comments.relation_id\n\t\t\t\t\tWHERE 1 %s\n\t\t\t\t\tGROUP BY pinned.entry_id\n\t\t\t\t\tORDER BY pinned.value ASC, last_active.local DESC\n\t\t\t\t\tLIMIT %d, %d";
     try {
         $rows = $db->query(sprintf($sql, self::findFieldID('pinned', 'discussions'), self::findFieldID('closed', 'discussions'), self::findFieldID('creation-date', 'discussions'), self::findFieldID('last-active', 'discussions'), self::findFieldID('created-by', 'discussions'), self::findFieldID('last-post', 'discussions'), self::findFieldID('topic', 'discussions'), self::findFieldID('parent-id', 'comments'), isset($this->dsParamFILTERS['id']) && (int) $this->dsParamFILTERS['id'] > 0 ? " AND pinned.entry_id  = " . (int) $this->dsParamFILTERS['id'] : NULL, max(0, ($this->dsParamSTARTPAGE - 1) * $this->dsParamLIMIT), $this->dsParamLIMIT));
     } catch (Exception $e) {
         $result->appendChild(new XMLElement('error', General::sanitize(vsprintf('%d: %s on query %s', $db->lastError()))));
         return $result;
     }
     if ($rows->length() == 0 && strlen(trim($dsParamFILTERS['id'])) > 0) {
         $this->__redirectToErrorPage();
     } elseif ($rows->length() == 0) {
         return $this->emptyXMLSet();
     }
     $total = $db->query('SELECT FOUND_ROWS() AS `total`;')->current()->total;
     $result->prependChild(General::buildPaginationElement($total, ceil($total * (1 / $this->dsParamLIMIT)), $this->dsParamLIMIT, $this->dsParamSTARTPAGE));
     /*
     	stdClass Object
     	(
     	    [id] => 666
     	    [pinned] => yes
     	    [closed] => no
     	    [creation-date] => 1233599808
     	    [last-active] => 1237161637
     	    [created-by-member-id] => 2126
     	    [created-by-username] => Lewis
     	    [last-post-member-id] => 2126
     	    [last-post-username] => Lewis
     	    [topic] => Symphony 2 Documentation
     	    [comments] => 18
     	)
     
        <entry id="595" comments="7">
     		            <created-by id="2150">newnomad</created-by>
     		            <closed>No</closed>
     		            <last-active time="18:30" weekday="1">2009-02-09</last-active>
     		            <last-post id="2150">newnomad</last-post>
     		            <pinned>No</pinned>
     		            <topic handle="viewing-feeds">viewing feeds</topic>
     		            <creation-date time="19:31" weekday="3">2009-01-07</creation-date>
         </entry>
     */
     $param_pool['ds-' . $this->dsParamROOTELEMENT] = DatabaseUtilities::resultColumn($rows, 'id');
     foreach ($rows as $r) {
         $entry = new XMLElement('entry', NULL, array('id' => $r->id, 'comments' => $r->comments));
         $entry->appendChild(new XMLElement('created-by', General::sanitize($r->{'created-by-username'}), array('id' => $r->{'created-by-member-id'})));
         $entry->appendChild(new XMLElement('last-post', General::sanitize($r->{'last-post-username'}), array('id' => $r->{'last-post-member-id'})));
         $entry->appendChild(new XMLElement('closed', ucfirst($r->closed)));
         $entry->appendChild(new XMLElement('pinned', ucfirst($r->pinned)));
         $entry->appendChild(new XMLElement('topic', General::sanitize($r->topic)));
         $entry->appendChild(General::createXMLDateObject($r->{'creation-date'}, 'creation-date'));
         $entry->appendChild(General::createXMLDateObject($r->{'last-active'}, 'last-active'));
         $result->appendChild($entry);
     }
     return $result;
 }
开发者ID:bauhouse,项目名称:forum,代码行数:59,代码来源:data.forum_discussions.php

示例14: grab


//.........这里部分代码省略.........
             case "ASC":
                 ## Since this is assending, we need to start from 0. The DS editor will give us 1+
                 $max_months--;
                 $last_day = date('d', mktime(0, 0, 0, date('m', $relative_start) + 1, 0, date('Y', $relative_start)));
                 $end = mktime(23, 59, 59, date('m', $relative_start) + $max_months, $last_day, date('Y', $relative_start));
                 $comment_where .= " AND (UNIX_TIMESTAMP(t2.creation_date_gmt) >= '{$relative_start}' AND UNIX_TIMESTAMP(t2.creation_date_gmt) <= '{$end}')";
                 break;
         }
     } else {
         ##We are trying to preview
         if (isset($param['limit'])) {
             $limit = $param['limit'];
         } elseif ($this->_dsFilterLIMIT != '') {
             $limit = intval($this->_dsFilterLIMIT);
             ##Prevent things from getting too big
         } else {
             $limit = 50;
         }
     }
     $start = 0;
     $sql = "SELECT count(t1.id) AS `total-comments` " . "FROM `tbl_comments` AS t1 " . "LEFT JOIN `tbl_metadata` AS t2 ON t1.`id` = t2.`relation_id` AND t2.`class` = 'comment' " . "INNER JOIN `tbl_entries` as t3 ON t1.`entry_id` = t3.`id` " . "LEFT JOIN `tbl_entries2sections` AS t4 ON t3.`id` = t4.`entry_id` " . "WHERE 1 " . $comment_where;
     $kTotalCommentCount = $this->_db->fetchVar('total-comments', 0, $sql);
     if (isset($this->_dsFilterPAGENUMBER)) {
         $pagenumber = $this->__resolveDefine("dsFilterPAGENUMBER");
         $kPageNumber = max(1, intval($pagenumber));
         if (!$limit) {
             $limit = 50;
         }
         $kTotalPages = ceil($kTotalCommentCount * (1 / $limit));
         $start = $limit * ($kPageNumber - 1);
     }
     $sql = "SELECT  t1.*, UNIX_TIMESTAMP(t2.creation_date_gmt) as `creation_timestamp_gmt` " . "FROM `tbl_comments` as t1 " . "LEFT JOIN `tbl_metadata` AS t2 ON t1.`id` = t2.`relation_id` AND t2.`class` = 'comment' " . "INNER JOIN `tbl_entries` as t3 ON t1.`entry_id` = t3.`id` " . "LEFT JOIN `tbl_entries2sections` AS t4 ON t3.`id` = t4.`entry_id` " . "WHERE 1 " . $comment_where . "GROUP BY t1.`id` " . "ORDER BY `creation_timestamp_gmt` {$sort} " . ($limit ? " LIMIT {$start}, {$limit}" : '');
     ##Check Cache
     $hash_id = md5(get_class($this) . $sql);
     if ($param['caching'] && ($cache = $this->check_cache($hash_id))) {
         return $cache;
         exit;
     }
     ##------------------------------
     ##Create the XML container
     $xml = new XMLElement("comments");
     ##Grab the records
     $comments = $this->_db->fetch($sql);
     ##Populate the XML
     if (empty($comments) || !is_array($comments)) {
         $xml->addChild(new XMLElement("error", "No Records Found."));
         return $xml;
     } else {
         $entries = array();
         foreach ($comments as $c) {
             $entries[$c['entry_id']]['commenting'] = $c['commenting'];
             $entries[$c['entry_id']]['comments'][] = $c;
         }
         if (in_array("pagination-info", $this->_dsFilterXMLFIELDS)) {
             $pageinfo = new XMLElement("pagination-info");
             $pageinfo->setAttribute("total-comments", $kTotalCommentCount);
             $pageinfo->setAttribute("total-pages", $kTotalPages);
             $pageinfo->setAttribute("comment-per-page", $limit);
             $pageinfo->setAttribute("current-page", $kPageNumber);
             $xml->addChild($pageinfo);
         }
         foreach ($entries as $id => $row) {
             $entry_data = $entryManager->fetchEntriesByID($id, false, true);
             $entry = new XMLElement("entry");
             $entry->setAttribute("id", $id);
             $entry->setAttribute('section-id', $entry_data['section_id']);
             $entry->setAttribute("handle", trim($entry_data['fields'][$entry_data['primary_field']]['handle']));
             $entry->setAttribute("commenting", $row['commenting']);
             $entry->addChild(new XMLElement("entry-title", trim($entry_data['fields'][$entry_data['primary_field']]['value'])));
             $fields = $row['comments'];
             $entry->setAttribute("count", $kTotalCommentCount);
             if (is_array($fields) && !empty($fields)) {
                 foreach ($fields as $c) {
                     $comment = new XMLElement("comment");
                     $comment->setAttribute("id", $c['id']);
                     if ($c['author_id'] != NULL) {
                         $comment->setAttribute('authorised', 'yes');
                         $comment->setAttribute('author_id', $c['author_id']);
                     }
                     if (@in_array('spam', $this->_dsFilterXMLFIELDS)) {
                         $comment->setAttribute("spam", $c['spam']);
                     }
                     $date_local = $obDate->get(true, false, $c['creation_timestamp_gmt']);
                     $comment_fields = array("author" => $c['author_name'], "date" => General::createXMLDateObject($date_local), "time" => General::createXMLTimeObject($date_local), "rfc822-date" => date("D, d M Y H:i:s \\G\\M\\T", $obDate->get(false, false, $row['creation_timestamp_gmt'])), "message" => $this->_dsFilterENCODE != 'yes' ? $c['body'] : General::sanitize($c['body']), "url" => $c['author_url'], "email" => $c['author_email'], "email-hash" => md5($c['author_email']));
                     $this->__addChildFieldsToXML($comment_fields, $comment);
                     $entry->addChild($comment);
                 }
             }
             $xml->addChild($entry);
         }
     }
     ##------------------------------
     ##Write To Cache
     if ($param['caching']) {
         $result = $xml->generate($param['indent'], $param['indent-depth']);
         $this->write_to_cache($hash_id, $result, $this->_cache_sections);
         return $result;
     }
     return $xml;
 }
开发者ID:symphonycms,项目名称:symphony-1.7,代码行数:101,代码来源:data.comments.php

示例15: appendFormattedElement

 public function appendFormattedElement(&$wrapper, $data, $encode = false, $mode = null)
 {
     $element = new XMLElement($this->get('element_name'));
     if (!empty($data) and strlen(trim($data['from_value'])) != 0) {
         $value = General::sanitize(__('%s until %s', array(date(__SYM_DATE_FORMAT__, $data['from_date']), date(__SYM_DATE_FORMAT__, $data['to_date']))));
         if ($encode) {
             $value = General::sanitize($value);
         }
         $element->setAttribute('mode', $data['mode']);
         $element->setAttribute('value', $value);
         $date = General::createXMLDateObject($data['from_date'], 'from-date');
         $date->setAttribute('value', $data['from_value']);
         $element->appendChild($date);
         $date = General::createXMLDateObject($data['to_date'], 'to-date');
         $date->setAttribute('value', $data['to_value']);
         $element->appendChild($date);
     }
     $wrapper->appendChild($element);
 }
开发者ID:psychoticmeowArchives,项目名称:daterangefield,代码行数:19,代码来源:field.daterange.php


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