• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DataObjectSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: UnsentSubscribers

 /**
  * Returns a DataObjectSet containing the subscribers who have never been sent this Newsletter
  *
  */
 function UnsentSubscribers()
 {
     // Get a list of everyone who has been sent this newsletter
     $sent_recipients = DataObject::get("Newsletter_SentRecipient", "ParentID='" . $this->ID . "'");
     // If this Newsletter has not been sent to anyone yet, $sent_recipients will be null
     if ($sent_recipients != null) {
         $sent_recipients_array = $sent_recipients->toNestedArray('MemberID');
     } else {
         $sent_recipients_array = array();
     }
     // Get a list of all the subscribers to this newsletter
     $subscribers = DataObject::get('Member', "`GroupID`='" . $this->Parent()->GroupID . "'", null, "INNER JOIN `Group_Members` ON `MemberID`=`Member`.`ID`");
     // If this Newsletter has no subscribers, $subscribers will be null
     if ($subscribers != null) {
         $subscribers_array = $subscribers->toNestedArray();
     } else {
         $subscribers_array = array();
     }
     // Get list of subscribers who have not been sent this newsletter:
     $unsent_subscribers_array = array_diff_key($subscribers_array, $sent_recipients_array);
     // Create new data object set containing the subscribers who have not been sent this newsletter:
     $unsent_subscribers = new DataObjectSet();
     foreach ($unsent_subscribers_array as $key => $data) {
         $unsent_subscribers->push(new ArrayData($data));
     }
     return $unsent_subscribers;
 }
开发者ID:ramziammar,项目名称:websites,代码行数:31,代码来源:Newsletter.php


示例2: PublisherMembers

 /**
  * Returns a DataObjectSet of all the members that can publish this page
  */
 public function PublisherMembers()
 {
     if ($this->owner->CanPublishType == 'OnlyTheseUsers') {
         $groups = $this->owner->PublisherGroups();
         $members = new DataObjectSet();
         if ($groups) {
             foreach ($groups as $group) {
                 $members->merge($group->Members());
             }
         }
         // Default to ADMINs, if something goes wrong
         if (!$members->Count()) {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             $members = $group->Members();
         }
         return $members;
     } elseif ($this->owner->CanPublishType == 'Inherit') {
         if ($this->owner->Parent()->Exists()) {
             return $this->owner->Parent()->PublisherMembers();
         } else {
             return SiteConfig::current_site_config()->PublisherMembers();
         }
     } elseif ($this->owner->CanPublishType == 'LoggedInUsers') {
         return Permission::get_members_by_permission('CMS_ACCESS_CMSMain');
     } else {
         $group = Permission::get_groups_by_permission('ADMIN')->first();
         return $group->Members();
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:32,代码来源:SiteTreeCMSTwoStepWorkflow.php


示例3: sourceItems

 function sourceItems()
 {
     if ($this->sourceItems) {
         return $this->sourceItems;
     }
     $limitClause = '';
     if (isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) {
         $limitClause = $_REQUEST['ctf'][$this->Name()]['start'] . ", {$this->pageSize}";
     } else {
         $limitClause = "0, {$this->pageSize}";
     }
     $dataQuery = $this->getQuery($limitClause);
     $records = $dataQuery->execute();
     $items = new DataObjectSet();
     foreach ($records as $record) {
         if (!get_class($record)) {
             $record = new DataObject($record);
         }
         $items->push($record);
     }
     $dataQuery = $this->getQuery();
     $records = $dataQuery->execute();
     $unpagedItems = new DataObjectSet();
     foreach ($records as $record) {
         if (!get_class($record)) {
             $record = new DataObject($record);
         }
         $unpagedItems->push($record);
     }
     $this->unpagedSourceItems = $unpagedItems;
     $this->totalCount = $this->unpagedSourceItems ? $this->unpagedSourceItems->TotalItems() : null;
     return $items;
 }
开发者ID:ramziammar,项目名称:websites,代码行数:33,代码来源:HasManyComplexTableField.php


示例4: Dates

 function Dates()
 {
     Requirements::themedCSS('archivewidget');
     $results = new DataObjectSet();
     $container = BlogTree::current();
     $ids = $container->BlogHolderIDs();
     $stage = Versioned::current_stage();
     $suffix = !$stage || $stage == 'Stage' ? "" : "_{$stage}";
     $monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') : 'MONTH("Date")';
     $yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
     if ($this->DisplayMode == 'month') {
         $sqlResults = DB::query("\n\t\t\t\tSELECT DISTINCT CAST({$monthclause} AS " . DB::getConn()->dbDataType('unsigned integer') . ") AS \"Month\", {$yearclause} AS \"Year\"\n\t\t\t\tFROM \"SiteTree{$suffix}\" INNER JOIN \"BlogEntry{$suffix}\" ON \"SiteTree{$suffix}\".\"ID\" = \"BlogEntry{$suffix}\".\"ID\"\n\t\t\t\tWHERE \"ParentID\" IN (" . implode(', ', $ids) . ")\n\t\t\t\tORDER BY \"Year\" DESC, \"Month\" DESC;");
     } else {
         $sqlResults = DB::query("\n\t\t\t\tSELECT DISTINCT {$yearclause} AS \"Year\" \n\t\t\t\tFROM \"SiteTree{$suffix}\" INNER JOIN \"BlogEntry{$suffix}\" ON \"SiteTree{$suffix}\".\"ID\" = \"BlogEntry{$suffix}\".\"ID\"\n\t\t\t\tWHERE \"ParentID\" IN (" . implode(', ', $ids) . ")\n\t\t\t\tORDER BY \"Year\" DESC");
     }
     if ($sqlResults) {
         foreach ($sqlResults as $sqlResult) {
             $isMonthDisplay = $this->DisplayMode == 'month';
             $monthVal = isset($sqlResult['Month']) ? (int) $sqlResult['Month'] : 1;
             $month = $isMonthDisplay ? $monthVal : 1;
             $year = $sqlResult['Year'] ? (int) $sqlResult['Year'] : date('Y');
             $date = DBField::create('Date', array('Day' => 1, 'Month' => $month, 'Year' => $year));
             if ($isMonthDisplay) {
                 $link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal);
             } else {
                 $link = $container->Link('date') . '/' . $sqlResult['Year'];
             }
             $results->push(new ArrayData(array('Date' => $date, 'Link' => $link)));
         }
     }
     return $results;
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:32,代码来源:ArchiveWidget.php


示例5: get

 /**
  * Return Facebook events for the given username with a limit.
  * 
  * @param string $name Facebook username to get events from
  * @param int $limit Number of events to get
  * @param array Query parameters to filter events e.g. "since" => "yesterday" (future events) or "until" => "yesterday" (past events)
  */
 public static function get($name, $limit, $query = array())
 {
     $api = new FBAPI();
     $results = $api->graph($name, 'events', $query);
     if ($results instanceof FBAPI_Exception) {
         return false;
     }
     // return false when there's no data
     if (empty($results['data'])) {
         return false;
     }
     $output = new DataObjectSet();
     $count = 0;
     foreach ($results['data'] as $record) {
         if ($limit && $count >= $limit) {
             break;
         }
         // we have to do another request to get the detail of the event.
         $detail = $api->graph($record['id']);
         $record = array_merge($record, $detail);
         $output->push(new FBEvent($record));
         $count++;
     }
     return $output;
 }
开发者ID:halkyon,项目名称:silverstripe-facebook,代码行数:32,代码来源:FBEvent.php


示例6: displaytable

 /**
  * Returns the table of results to be displayed in the table of
  * details loaded from the file
  */
 function displaytable()
 {
     // Check that a file was uploaded
     $tempFile = fopen($_FILES['ImportFile']['tmp_name'], 'r');
     // display some error if the file cannot be opened
     if (!$tempFile) {
         return 'The selected file did not arrive at the server';
     }
     $this->clientFileName = $_FILES['ImportFile']['name'];
     $table = $sessionTable = array();
     while (($row = fgetcsv($tempFile)) !== false) {
         if (!$this->tableColumns) {
             $this->parseTableHeader($row);
         } else {
             $newRow = array();
             $newSessionTableRow = array();
             foreach ($row as $cell) {
                 $newRow[] = $this->parseCSVCell($cell);
                 $newSessionTableRow[] = $cell;
             }
             $cells = new DataObjectSet($newRow);
             $table[] = $cells->customise(array('Cells' => $cells));
             $sessionTable[] = $newSessionTableRow;
         }
     }
     fclose($tempFile);
     $this->table = new DataObjectSet($table);
     Session::set("ImportFile.{$_REQUEST['ID']}", $sessionTable);
     return $this->renderWith('Newsletter_RecipientImportField_Table');
 }
开发者ID:nyeholt,项目名称:silverstripe-newsletter,代码行数:34,代码来源:RecipientImportField.php


示例7: execute

 function execute()
 {
     set_error_handler('exception_error_handler');
     $results = false;
     $msg = array('text' => $this->type() == 'SELECT' ? 'no records' : 'no errors', 'type' => 'good');
     try {
         $results = DB::getConn()->query($this->query, E_USER_NOTICE);
     } catch (Exception $e) {
         $msg = array('text' => htmlentities($e->getMessage()), 'type' => 'error');
     }
     restore_error_handler();
     $fields = new DataObjectSet();
     $records = new DataObjectSet();
     if (isset($results) && $results instanceof SS_Query) {
         foreach ($results as $result) {
             $record = new DBP_Record();
             $data = array();
             foreach ($result as $field => $val) {
                 if (!$fields->find('Label', $field)) {
                     $fields->push(new DBP_Field($field));
                 }
                 $data[$field] = strlen($val) > 64 ? substr($val, 0, 63) . '<span class="truncated">&hellip;</span>' : $val;
             }
             $record->Data($data);
             $records->push($record);
         }
     }
     return array('Query' => $this->query, 'Fields' => $fields, 'Records' => $records, 'Message' => $msg);
 }
开发者ID:alapini,项目名称:silverstripe-dbplumber,代码行数:29,代码来源:DBP_Sql.php


示例8: updateMembers

 /**
  * @param DataObjectSet All members to check
  * @param Int
  * @return DataObjectSet
  */
 protected function updateMembers($members, $minSpamScore = 0)
 {
     $checker = $this->getChecker();
     $checks = $checker->update($members);
     $spamMembers = new DataObjectSet();
     if ($checks) {
         foreach ($checks as $id => $check) {
             // TODO More expressive error reporting - easy for the task to "get stuck" on one member
             if (!$id) {
                 continue;
             }
             $member = $members->find('ID', $id);
             // Its important to fall back to a rating of 0, to avoid querying the same members successively
             // (e.g. when service APIs fail to respond).
             // TODO Add a way to force re-checking of members
             $member->SpamCheckScore = $check['score'] ? $check['score'] : 0;
             $memberData = $member->SpamCheckData ? (array) json_decode($member->SpamCheckData) : array();
             $memberData[get_class($this)] = (array) $check['data'];
             $member->SpamCheckData = json_encode($memberData);
             $member->write();
             if ($member->SpamCheckScore > $minSpamScore) {
                 $spamMembers->push($member);
             }
         }
     }
     return $spamMembers;
 }
开发者ID:helpfulrobot,项目名称:chillu-memberspamcheck,代码行数:32,代码来源:MemberSpamCheckTask.php


示例9: get

 public static function get($name, $limit)
 {
     if (!$name) {
         return false;
     }
     $api = new FBAPI();
     $results = $api->graph($name, 'photos');
     // @todo figure out what to do with exceptions. Log them using SS_Log::log()?
     if ($results instanceof FBAPI_Exception) {
         return false;
     }
     // return false when there's no data
     if (empty($results['data'])) {
         return false;
     }
     $output = new DataObjectSet();
     $count = 0;
     foreach ($results['data'] as $record) {
         if ($limit && $count >= $limit) {
             break;
         }
         $output->push(new FBPhoto($record));
         $count++;
     }
     return $output;
 }
开发者ID:halkyon,项目名称:silverstripe-facebook,代码行数:26,代码来源:FBPhoto.php


示例10: Photos

 function Photos()
 {
     Requirements::javascript("flickrservice/javascript/prototype.js");
     Requirements::javascript("flickrservice/javascript/effects.js");
     Requirements::javascript("flickrservice/javascript/lightwindow.js");
     Requirements::css("flickrservice/css/FlickrGallery.css");
     Requirements::css("flickrservice/css/lightwindow.css");
     if ($pos = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
         $version = substr($_SERVER['HTTP_USER_AGENT'], $pos + 5, 3);
         if ($version < 7) {
             Requirements::css("flickrservice/css/lightwindowIE6.css");
         }
     }
     $flickr = new FlickrService();
     try {
         $photos = $flickr->getPhotos(NULL, $this->User, $this->NumberToShow, 1, $this->Sortby);
     } catch (Exception $e) {
         return false;
     }
     $output = new DataObjectSet();
     foreach ($photos->PhotoItems as $photo) {
         $output->push(new ArrayData(array("Title" => htmlentities($photo->title), "Link" => "http://farm1.static.flickr.com/" . $photo->image_path . ".jpg", "Image" => "http://farm1.static.flickr.com/" . $photo->image_path . "_s.jpg")));
     }
     return $output;
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:25,代码来源:FlickrWidget.php


示例11: getCMSFields

 function getCMSFields()
 {
     $subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
     if (!$subsites) {
         $subsites = new DataObjectSet();
     }
     if (Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
         $subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
     }
     if ($subsites->Count()) {
         $subsiteSelectionField = new DropdownField("CopyContentFromID_SubsiteID", "Subsite", $subsites->toDropdownMap('ID', 'Title'), $this->CopyContentFromID ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID'));
     }
     // Setup the linking to the original page.
     $pageSelectionField = new SubsitesTreeDropdownField("RelatedPageID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle");
     if (isset($_GET['RelatedPageID_SubsiteID'])) {
         $pageSelectionField->setSubsiteID($_GET['RelatedPageID_SubsiteID']);
     }
     $pageSelectionField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
     if ($subsites->Count()) {
         $fields = new FieldSet($subsiteSelectionField, $pageSelectionField);
     } else {
         $fields = new FieldSet($pageSelectionField);
     }
     return $fields;
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:25,代码来源:RelatedPageLink.php


示例12: PublisherMembers

 /**
  * Returns a DataObjectSet of all the members that can publish pages
  * on this site by default
  */
 public function PublisherMembers()
 {
     if ($this->owner->CanPublishType == 'OnlyTheseUsers') {
         $groups = $this->owner->PublisherGroups();
         $members = new DataObjectSet();
         if ($groups) {
             foreach ($groups as $group) {
                 $members->merge($group->Members());
             }
         }
         // Default to ADMINs, if something goes wrong
         if (!$members->Count()) {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             $members = $group->Members();
         }
         return $members;
     } else {
         if ($this->owner->CanPublishType == 'LoggedInUsers') {
             // We don't want to return every user in the CMS....
             return Permission::get_members_by_permission('CMS_ACCESS_CMSMain');
         } else {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             return $group->Members();
         }
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:30,代码来源:SiteConfigTwoStepWorkflow.php


示例13: getCMSFields

 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $subsites = DataObject::get('Subsite');
     if (!$subsites) {
         $subsites = new DataObjectSet();
     }
     $subsites->push(new ArrayData(array('Title' => 'Main site', 'ID' => 0)));
     $subsiteSelectionField = new DropdownField("CopyContentFromID_SubsiteID", "Subsite", $subsites->toDropdownMap('ID', 'Title'), $this->CopyContentFromID ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID'));
     $fields->addFieldToTab('Root.Content.Main', $subsiteSelectionField, 'CopyContentFromID');
     // Setup the linking to the original page.
     $pageSelectionField = new SubsitesTreeDropdownField("CopyContentFromID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle");
     $pageSelectionField->setFilterFunction(create_function('$item', 'return !($item instanceof VirtualPage);'));
     if (Controller::has_curr() && Controller::curr()->getRequest()) {
         $subsiteID = Controller::curr()->getRequest()->getVar('CopyContentFromID_SubsiteID');
         $pageSelectionField->setSubsiteID($subsiteID);
     }
     $fields->replaceField('CopyContentFromID', $pageSelectionField);
     // Create links back to the original object in the CMS
     if ($this->CopyContentFromID) {
         $editLink = "admin/show/{$this->CopyContentFromID}/?SubsiteID=" . $this->CopyContentFrom()->SubsiteID;
         $linkToContent = "\n\t\t\t\t<a class=\"cmsEditlink\" href=\"{$editLink}\">" . _t('VirtualPage.EDITCONTENT', 'Click here to edit the content') . "</a>";
         $fields->removeByName("VirtualPageContentLinkLabel");
         $fields->addFieldToTab("Root.Content.Main", $linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent), 'Title');
         $linkToContentLabelField->setAllowHTML(true);
     }
     $fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomMetaTitle', 'Title (overrides inherited value from the source)'), 'MetaTitle');
     $fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaKeywords', 'Keywords (overrides inherited value from the source)'), 'MetaKeywords');
     $fields->addFieldToTab('Root.Content.Metadata', new TextareaField('CustomMetaDescription', 'Description (overrides inherited value from the source)'), 'MetaDescription');
     $fields->addFieldToTab('Root.Content.Metadata', new TextField('CustomExtraMeta', 'Custom Meta Tags (overrides inherited value from the source)'), 'ExtraMeta');
     return $fields;
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:32,代码来源:SubsitesVirtualPage.php


示例14: Dates

 function Dates()
 {
     Requirements::themedCSS('archivewidget');
     $results = new DataObjectSet();
     $container = BlogTree::current();
     $ids = $container->BlogHolderIDs();
     $stage = Versioned::current_stage();
     $suffix = !$stage || $stage == 'Stage' ? "" : "_{$stage}";
     $monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') : 'MONTH("Date")';
     $yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
     $sqlResults = DB::query("\n\t\t\tSELECT DISTINCT CAST({$monthclause} AS " . DB::getConn()->dbDataType('unsigned integer') . ") AS \"Month\", {$yearclause} AS \"Year\"\n\t\t\tFROM \"SiteTree{$suffix}\" INNER JOIN \"BlogEntry{$suffix}\" ON \"SiteTree{$suffix}\".\"ID\" = \"BlogEntry{$suffix}\".\"ID\"\n\t\t\tWHERE \"ParentID\" IN (" . implode(', ', $ids) . ")\n\t\t\tORDER BY \"Year\" DESC, \"Month\" DESC;");
     if ($this->ShowLastYears == 0) {
         $cutOffYear = 0;
     } else {
         $cutOffYear = (int) date("Y") - $this->ShowLastYears;
     }
     $years = array();
     if (Director::get_current_page()->ClassName == 'BlogHolder') {
         $urlParams = Director::urlParams();
         $yearParam = $urlParams['ID'];
         $monthParam = $urlParams['OtherID'];
     } else {
         $date = new DateTime(Director::get_current_page()->Date);
         $yearParam = $date->format("Y");
         $monthParam = $date->format("m");
     }
     if ($sqlResults) {
         foreach ($sqlResults as $sqlResult) {
             $isMonthDisplay = true;
             $year = $sqlResult['Year'] ? (int) $sqlResult['Year'] : date('Y');
             $isMonthDisplay = $year > $cutOffYear;
             // $dateFormat = 'Month'; else $dateFormat = 'Year';
             $monthVal = isset($sqlResult['Month']) ? (int) $sqlResult['Month'] : 1;
             $month = $isMonthDisplay ? $monthVal : 1;
             $date = DBField::create('Date', array('Day' => 1, 'Month' => $month, 'Year' => $year));
             if ($isMonthDisplay) {
                 $link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal);
             } else {
                 $link = $container->Link('date') . '/' . $sqlResult['Year'];
             }
             if ($isMonthDisplay || !$isMonthDisplay && !in_array($year, $years)) {
                 $years[] = $year;
                 $current = false;
                 $children = new DataObjectSet();
                 $LinkingMode = "link";
                 if ($isMonthDisplay && $yearParam == $year && $monthParam == $month || !$isMonthDisplay && $yearParam == $year) {
                     $LinkingMode = "current";
                     $current = true;
                     if ($this->ShowChildren && $isMonthDisplay) {
                         $filter = $yearclause . ' = ' . $year . ' AND ' . $monthclause . ' = ' . $month;
                         $children = DataObject::get('BlogEntry', $filter, "Date DESC");
                     }
                 }
                 $results->push(new ArrayData(array('Date' => $date, 'Year' => $year, 'Link' => $link, 'NoMonth' => !$isMonthDisplay, 'LinkingMode' => $LinkingMode, 'Children' => $children)));
                 unset($children);
             }
         }
     }
     return $results;
 }
开发者ID:helpfulrobot,项目名称:exadium-blogarchivemenuwidget,代码行数:60,代码来源:BlogArchiveMenuWidget.php


示例15: testRSSFeed

 function testRSSFeed()
 {
     $list = new DataObjectSet();
     $list->push(new RSSFeedTest_ItemA());
     $list->push(new RSSFeedTest_ItemB());
     $list->push(new RSSFeedTest_ItemC());
     $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description");
     $content = $rssFeed->feedContent();
     //Debug::message($content);
     $this->assertContains('<link>http://www.example.org/item-a/</link>', $content);
     $this->assertContains('<link>http://www.example.com/item-b.html</link>', $content);
     $this->assertContains('<link>http://www.example.com/item-c.html</link>', $content);
     $this->assertContains('<title>ItemA</title>', $content);
     $this->assertContains('<title>ItemB</title>', $content);
     $this->assertContains('<title>ItemC</title>', $content);
     $this->assertContains('<description>ItemA Content</description>', $content);
     $this->assertContains('<description>ItemB Content</description>', $content);
     $this->assertContains('<description>ItemC Content</description>', $content);
     // Feed #2 - put Content() into <title> and AltContent() into <description>
     $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description", "Content", "AltContent");
     $content = $rssFeed->feedContent();
     $this->assertContains('<title>ItemA Content</title>', $content);
     $this->assertContains('<title>ItemB Content</title>', $content);
     $this->assertContains('<title>ItemC Content</title>', $content);
     $this->assertContains('<description>ItemA AltContent</description>', $content);
     $this->assertContains('<description>ItemB AltContent</description>', $content);
     $this->assertContains('<description>ItemC AltContent</description>', $content);
 }
开发者ID:comperio,项目名称:silverstripe-framework,代码行数:28,代码来源:RSSFeedTest.php


示例16: testRSSFeed

 function testRSSFeed()
 {
     $list = new DataObjectSet();
     $list->push(new RSSFeedTest_ItemA());
     $list->push(new RSSFeedTest_ItemB());
     $list->push(new RSSFeedTest_ItemC());
     $origServer = $_SERVER;
     $_SERVER['HTTP_HOST'] = 'www.example.org';
     Director::setBaseURL('/');
     $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description");
     $content = $rssFeed->feedContent();
     //Debug::message($content);
     $this->assertContains('<link>http://www.example.org/item-a/</link>', $content);
     $this->assertContains('<link>http://www.example.com/item-b.html</link>', $content);
     $this->assertContains('<link>http://www.example.com/item-c.html</link>', $content);
     $this->assertContains('<title>ItemA</title>', $content);
     $this->assertContains('<title>ItemB</title>', $content);
     $this->assertContains('<title>ItemC</title>', $content);
     $this->assertContains('<description>ItemA Content</description>', $content);
     $this->assertContains('<description>ItemB Content</description>', $content);
     $this->assertContains('<description>ItemC Content</description>', $content);
     // Feed #2 - put Content() into <title> and AltContent() into <description>
     $rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description", "Content", "AltContent");
     $content = $rssFeed->feedContent();
     $this->assertContains('<title>ItemA Content</title>', $content);
     $this->assertContains('<title>ItemB Content</title>', $content);
     $this->assertContains('<title>ItemC Content</title>', $content);
     $this->assertContains('<description>ItemA AltContent</description>', $content);
     $this->assertContains('<description>ItemB AltContent</description>', $content);
     $this->assertContains('<description>ItemC AltContent</description>', $content);
     Director::setBaseURL(null);
     $_SERVER = $origServer;
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:33,代码来源:RSSFeedTest.php


示例17: FeedItems

	function FeedItems() {
		$output = new DataObjectSet();
		
		include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
		
		$t1 = microtime(true);
		$this->feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
		$this->feed->init();
		if($items = $this->feed->get_items(0, $this->NumberToShow)) {
			foreach($items as $item) {
				
				// Cast the Date
				$date = new Date('Date');
				$date->setValue($item->get_date());

				// Cast the Title
				$title = new Text('Title');
				$title->setValue($item->get_title());

				$output->push(new ArrayData(array(
					'Title' => $title,
					'Date' => $date,
					'Link' => $item->get_link()
				)));
			}
			return $output;
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:28,代码来源:RSSWidget.php


示例18: Times

 function Times()
 {
     $output = new DataObjectSet();
     for ($i = 0; $i < $this->value; $i++) {
         $output->push(new ArrayData(array('Number' => $i + 1)));
     }
     return $output;
 }
开发者ID:comperio,项目名称:silverstripe-framework,代码行数:8,代码来源:Int.php


示例19: Fields

 function Fields()
 {
     $fields = new DataObjectSet();
     foreach (DB::fieldList($this->Name) as $name => $spec) {
         $fields->push(new DBP_Field($this->Name . '.' . $name));
     }
     return $fields;
 }
开发者ID:alapini,项目名称:silverstripe-dbplumber,代码行数:8,代码来源:DBP_Table.php


示例20: TagsCollection

 function TagsCollection()
 {
     Requirements::themedCSS("tagcloud");
     $allTags = array();
     $max = 0;
     $container = BlogTree::current();
     $entries = $container->Entries();
     if ($entries) {
         foreach ($entries as $entry) {
             $theseTags = split(" *, *", mb_strtolower(trim($entry->Tags)));
             foreach ($theseTags as $tag) {
                 if ($tag != "") {
                     $allTags[$tag] = isset($allTags[$tag]) ? $allTags[$tag] + 1 : 1;
                     //getting the count into key => value map
                     $max = $allTags[$tag] > $max ? $allTags[$tag] : $max;
                 }
             }
         }
         if ($allTags) {
             //TODO: move some or all of the sorts to the database for more efficiency
             if ($this->Limit > 0) {
                 $allTags = array_slice($allTags, 0, $this->Limit, true);
             }
             if ($this->Sortby == "alphabet") {
                 $this->natksort($allTags);
             } else {
                 uasort($allTags, array($this, "column_sort_by_popularity"));
                 // sort by frequency
             }
             $sizes = array();
             foreach ($allTags as $tag => $count) {
                 $sizes[$count] = true;
             }
             $offset = 0;
             $numsizes = count($sizes) - 1;
             //Work out the number of different sizes
             $buckets = count(self::$popularities) - 1;
             // If there are more frequencies than buckets, divide frequencies into buckets
             if ($numsizes > $buckets) {
                 $numsizes = $buckets;
             } else {
                 $offset = round(($buckets - $numsizes) / 2);
             }
             foreach ($allTags as $tag => $count) {
                 $popularity = round($count / $max * $numsizes) + $offset;
                 $popularity = min($buckets, $popularity);
                 $class = self::$popularities[$popularity];
                 $allTags[$tag] = array("Tag" => $tag, "Count" => $count, "Class" => $class, "Link" => $container->Link('tag') . '/' . urlencode($tag));
             }
         }
         $output = new DataObjectSet();
         foreach ($allTags as $tag => $fields) {
             $output->push(new ArrayData($fields));
         }
         return $output;
     }
     return;
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:58,代码来源:TagCloudWidget.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DataProvider类代码示例发布时间:2022-05-23
下一篇:
PHP DataObjectInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap