function testThereIsNoPaginatorWhenOnlyOnePage() { // We set the itemsPerPage to an reasonably big number so as to avoid test broke from small changes on the fixture YML file $total = $this->list->count(); $this->gridField->getConfig()->getComponentByType("GridFieldPaginator")->setItemsPerPage($total); $fieldHolder = $this->gridField->FieldHolder(); $content = new CSSContentParser($fieldHolder); // Check that there is no paginator render into the footer $this->assertEquals(0, count($content->getBySelector('.datagrid-pagination'))); // Check that there is still 'View 1 - 4 of 4' part on the left of the paginator $this->assertEquals(1, count($content->getBySelector('.pagination-records-number'))); }
public function testRelationList() { $list = new ArrayList(); $this->loader->transforms['Course.Title'] = array('create' => true, 'link' => true, 'list' => $list); $results = $this->loader->load(); $this->assertEquals(3, $results->CreatedCount(), "3 records created"); $this->assertEquals(3, $list->count(), "3 relations created"); //make sure re-run doesn't change relation list $results = $this->loader->load(); $this->assertEquals(3, $results->CreatedCount(), "3 more records created"); $this->assertEquals(3, $list->count(), "relation list count remains the same"); }
public function testDeleteActionRemoveRelation() { $this->logInWithPermission('ADMIN'); $config = GridFieldConfig::create()->addComponent(new GridFieldDeleteAction(true)); $gridField = new GridField('testfield', 'testfield', $this->list, $config); $form = new Form(new Controller(), 'mockform', new FieldList(array($this->gridField)), new FieldList()); $stateID = 'testGridStateActionField'; Session::set($stateID, array('grid' => '', 'actionName' => 'deleterecord', 'args' => array('RecordID' => $this->idFromFixture('GridFieldAction_Delete_Team', 'team1')))); $request = new SS_HTTPRequest('POST', 'url', array(), array('action_gridFieldAlterAction?StateID=' . $stateID => true)); $this->gridField->gridFieldAlterAction(array('StateID' => $stateID), $this->form, $request); $this->assertEquals(2, $this->list->count(), 'User should be able to delete records with ADMIN permission.'); }
public function testPaginationAvoidsIllegalOffsets() { $grid = $this->gridField; $total = $this->list->count(); $perPage = $grid->getConfig()->getComponentByType('GridFieldPaginator')->getItemsPerPage(); // Get the last page that will contain results $lastPage = ceil($total / $perPage); // Set the paginator state to point to an 'invalid' page $grid->State->GridFieldPaginator->currentPage = $lastPage + 1; // Get the paginated list $list = $grid->getManipulatedList(); // Assert that the paginator state has been corrected and the list contains items $this->assertEquals(1, $grid->State->GridFieldPaginator->currentPage); $this->assertEquals($perPage, $list->count()); }
public function index() { $featured_news = new ArrayList($this->news_repository->getFeaturedNews(true, 3)); $recent_news = new ArrayList($this->news_repository->getRecentNews()); $slide_news = new ArrayList($this->news_repository->getSlideNews()); return $this->renderWith(array('NewsPage', 'Page'), array('FeaturedNews' => $featured_news, 'RecentNews' => $recent_news, 'SlideNews' => $slide_news, 'SlideNewsCount' => $slide_news->count())); }
/** * This may need to be optimised. We'll just have to see how it performs. * * @param SS_HTTPRequest $req * @return array */ public function downloads(SS_HTTPRequest $req) { $downloads = new ArrayList(); $member = Member::currentUser(); if (!$member || !$member->exists()) { $this->httpError(401); } // create a dropdown for sorting $sortOptions = Config::inst()->get('DownloadableAccountPageController', 'sort_options'); if ($sortOptions) { $sort = $req->requestVar('sort'); if (empty($sort)) { reset($sortOptions); $sort = key($sortOptions); } $sortControl = new DropdownField('download-sort', 'Sort By:', $sortOptions, $sort); } else { $sort = 'PurchaseDate'; $sortControl = ''; } // create a list of downloads $orders = $member->getPastOrders(); if (!empty($orders)) { foreach ($orders as $order) { if ($order->DownloadsAvailable()) { $downloads->merge($order->getDownloads()); } } } Requirements::javascript(SHOP_DOWNLOADABLE_FOLDER . '/javascript/AccountPage_downloads.js'); return array('Title' => 'Digital Purchases', 'Content' => '', 'SortControl' => $sortControl, 'HasDownloads' => $downloads->count() > 0, 'Downloads' => $downloads->sort($sort)); }
public function testCount() { $list = new ArrayList(); $this->assertEquals(0, $list->count()); $list = new ArrayList(array(1, 2, 3)); $this->assertEquals(3, $list->count()); }
public function testRetainAll() { // Remove the following lines when you implement this test. $this->assertTrue($this->object->retainAll($list = $this->object->subList(2, 8))); $this->assertTrue($this->object->count() == 6); $this->assertTrue($this->object->get(0) == 2); $list = $this->object->subList(2, 4); $list->add(5468); $this->assertFalse($this->object->retainAll($list)); }
function FindChildrenOfType($objectType, $all = false, $limit = null) { $result = new ArrayList(); $children = $all ? $this->owner->AllChildren() : $this->owner->Children(); foreach ($children as $child) { if (!is_null($limit) && $result->count() >= $limit) { break; } if ($child->ClassName == $objectType) { $result->add($child); } if ($child->hasMethod('FindChildrenOfType')) { $result->merge($child->FindChildrenOfType($objectType, $all, is_null($limit) ? null : $limit - $result->count())); } } return $result; }
/** * Get the latest posts * * @param int $limit Number of posts to return * @param int $forumID - Forum ID to limit it to * @param int $threadID - Thread ID to limit it to * @param int $lastVisit Optional: Unix timestamp of the last visit (GMT) * @param int $lastPostID Optional: ID of the last read post */ function getRecentPosts($limit = 50, $forumID = null, $threadID = null, $lastVisit = null, $lastPostID = null) { $filter = array(); if ($lastVisit) { $lastVisit = @date('Y-m-d H:i:s', $lastVisit); } $lastPostID = (int) $lastPostID; // last post viewed if ($lastPostID > 0) { $filter[] = "\"Post\".\"ID\" > '" . Convert::raw2sql($lastPostID) . "'"; } // last time visited if ($lastVisit) { $filter[] = "\"Post\".\"Created\" > '" . Convert::raw2sql($lastVisit) . "'"; } // limit to a forum if ($forumID) { $filter[] = "\"Post\".\"ForumID\" = '" . Convert::raw2sql($forumID) . "'"; } // limit to a thread if ($threadID) { $filter[] = "\"Post\".\"ThreadID\" = '" . Convert::raw2sql($threadID) . "'"; } // limit to just this forum install $filter[] = "\"ForumPage\".\"ParentID\"='{$this->ID}'"; $posts = Post::get()->leftJoin('ForumThread', '"Post"."ThreadID" = "ForumThread"."ID"')->leftJoin(ForumHolder::baseForumTable(), '"ForumPage"."ID" = "Post"."ForumID"', 'ForumPage')->limit($limit)->sort('"Post"."ID"', 'DESC')->where($filter); $recentPosts = new ArrayList(); foreach ($posts as $post) { $recentPosts->push($post); } if ($recentPosts->count() > 0) { return $recentPosts; } return null; }
function DataList() { $list = new ArrayList(); if (!$this->value) { return $list; } $val = $this->value; $cols = array_keys($this->columns); $subcols = array_keys($this->subColumns); $i = 0; foreach ($val as $data) { $i++; $arr = $data; if (is_object($arr)) { $arr = get_object_vars($arr); } $rows = new ArrayList(); $subcolumnsToAdd = array(); $subcolumnsHaveValues = false; foreach ($arr as $k => $v) { if (in_array($k, $subcols)) { if ($v) { $subcolumnsHaveValues = true; } $subcolumnsToAdd[] = array('Name' => $k, 'Label' => $this->subColumns[$k][self::KEY_HEADER], 'Value' => $v); } // Ignore unknown columns if (!in_array($k, $cols)) { continue; } $rows->push(new ArrayData(array('Name' => $k, 'Value' => $v))); } $list->push(new ArrayData(array('ID' => $i, 'Rows' => $rows))); foreach ($subcolumnsToAdd as $subcolumnToAdd) { $list->push(new ArrayData(array('ID' => $i, 'SubColumn' => 1, 'SubcolumnsHaveValues' => $v, 'ColSpan' => $rows->count(), 'Rows' => new ArrayData($subcolumnToAdd)))); } } return $list; }
/** * init runs on start of a new Order (@see onAfterWrite) * it adds all the modifiers to the orders and the starting OrderStep * * @param Boolean $recalculate * @return DataObject (Order) **/ public function init($recalculate = false) { if ($this->IsSubmitted()) { user_error("Can not init an order that has been submitted", E_USER_NOTICE); } else { //to do: check if shop is open.... if ($this->StatusID || $recalculate) { if (!$this->StatusID) { $createdOrderStatus = OrderStep::get()->First(); if (!$createdOrderStatus) { user_error("No ordersteps have been created", E_USER_WARNING); } $this->StatusID = $createdOrderStatus->ID; } $createdModifiersClassNames = array(); $modifiersAsArrayList = new ArrayList(); $modifiers = $this->modifiersFromDatabase($includingRemoved = true); if ($modifiers->count()) { foreach ($modifiers as $modifier) { $modifiersAsArrayList->push($modifier); } } if ($modifiersAsArrayList->count()) { foreach ($modifiersAsArrayList as $modifier) { $createdModifiersClassNames[$modifier->ID] = $modifier->ClassName; } } else { } $modifiersToAdd = EcommerceConfig::get("Order", "modifiers"); if (is_array($modifiersToAdd) && count($modifiersToAdd) > 0) { foreach ($modifiersToAdd as $numericKey => $className) { if (!in_array($className, $createdModifiersClassNames)) { if (class_exists($className)) { $modifier = new $className(); //only add the ones that should be added automatically if (!$modifier->DoNotAddAutomatically()) { if (is_a($modifier, "OrderModifier")) { $modifier->OrderID = $this->ID; $modifier->Sort = $numericKey; //init method includes a WRITE $modifier->init(); //IMPORTANT - add as has_many relationship (Attributes can be a modifier OR an OrderItem) $this->Attributes()->add($modifier); $modifiersAsArrayList->push($modifier); } } } else { user_error("reference to a non-existing class: " . $className . " in modifiers", E_USER_NOTICE); } } } } $this->extend('onInit', $this); //careful - this will call "onAfterWrite" again $this->write(); } } return $this; }
/** * All viewable product groups of this group. * * @param int $numberOfProductGroups Number of product groups to display * * @return PaginatedList * * @author Sebastian Diel <*****@*****.**>, Ramon Kupper <*****@*****.**> * @since 04.01.2014 */ public function getViewableChildren($numberOfProductGroups = false) { if ($this->viewableChildren === null) { $viewableChildren = new ArrayList(); foreach ($this->Children() as $child) { if ($child->hasProductsOrChildren()) { $viewableChildren->push($child); } } if ($viewableChildren->count() > 0) { if ($numberOfProductGroups == false) { if ($this->productGroupsPerPage) { $pageLength = $this->productGroupsPerPage; } else { $pageLength = SilvercartConfig::ProductGroupsPerPage(); } } else { $pageLength = $numberOfProductGroups; } $pageStart = $this->getSqlOffsetForProductGroups($numberOfProductGroups); $viewableChildrenPage = new PaginatedList($viewableChildren, $this->getRequest()); $viewableChildrenPage->setPaginationGetVar('groupStart'); $viewableChildrenPage->setPageStart($pageStart); $viewableChildrenPage->setPageLength($pageLength); $this->viewableChildren = $viewableChildrenPage; } else { return false; } } return $this->viewableChildren; }
/** * $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude all Bob that has Age 21 */ public function testExcludeWithTwoArrays() { $list = new ArrayList(array( 0=>array('Name' => 'Bob' , 'Age' => 21), 1=>array('Name' => 'Bob' , 'Age' => 32), 2=>array('Name' => 'John', 'Age' => 21) )); $list->exclude(array('Name' => 'Bob', 'Age' => 21)); $expected = array( 1=>array('Name' => 'Bob', 'Age' => 32), 2=>array('Name' => 'John', 'Age' => 21) ); $this->assertEquals(2, $list->count()); $this->assertEquals($expected, $list->toArray(), 'List should only contain John and Bob'); }
} catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } try { echo "Removing using unset\n"; unset($list[1]); } catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } // IList::indexOf() echo "indexOf Jack:\n"; Debug::dump($list->indexOf($jack)); echo "indexOf Mary:\n"; Debug::dump($list->indexOf($mary)); // IList::count echo "Count: ", $list->count(), "\n"; echo "Count: ", count($list), "\n"; // IList::getIterator echo "Get Interator:\n"; foreach ($list as $key => $person) { echo $key, ' => ', $person->sayHi(); } // IList::clear echo "Clearing\n"; $list->clear(); foreach ($list as $person) { $person->sayHi(); } // ArrayList::__construct() $arr = array('a' => $jack, 'b' => $mary, 'c' => $foo); try {
/** * Add the member to the order, in case the member is not an admin. * @param Order $order * @return Boolean **/ public function doStep(Order $order) { $logClassName = $this->getRelevantLogEntryClassName(); $obj = $logClassName::get()->filter(array("OrderID" => $order->ID))->first(); if (!$obj) { $files = new ArrayList(); $items = $order->Items(); if ($items && $items->count()) { foreach ($items as $item) { $buyable = $item->Buyable(); if ($buyable) { $method = $this->Config()->get("download_method_in_byable"); if ($buyable->hasMethod($method)) { $itemDownloadFiles = $buyable->{$method}(); if ($itemDownloadFiles) { if ($itemDownloadFiles instanceof DataList) { if ($itemDownloadFiles->count()) { foreach ($itemDownloadFiles as $itemDownloadFile) { $files->push($itemDownloadFile); } } } else { user_error("{$method} should return a Datalist. Specifically watch for has_one methods as they return a DataObject.", E_USER_NOTICE); } } } } } } if ($files->count()) { //additional files ar only added to orders //with downloads $additionalFiles = $this->AdditionalFiles(); foreach ($additionalFiles as $additionalFile) { $files->push($additionalFile); } //create log with information... $obj = $logClassName::create(); $obj->OrderID = $order->ID; $obj->AuthorID = $order->MemberID; $obj->NumberOfHoursBeforeDownloadGetsDeleted = $this->NumberOfHoursBeforeDownloadGetsDeleted; $obj->write(); $obj->AddFiles($files); } else { //do nothingh.... } } return true; }
/** * Returns top level navigation of projects. * * @param int $limit * * @return ArrayList */ public function Navigation($limit = 5) { $navigation = new ArrayList(); $currentProject = $this->getCurrentProject(); $currentEnvironment = $this->getCurrentEnvironment(); $actionType = $this->getCurrentActionType(); $projects = $this->getStarredProjects(); if ($projects->count() < 1) { $projects = $this->DNProjectList(); } else { $limit = -1; } if ($projects->count() > 0) { $activeProject = false; if ($limit > 0) { $limitedProjects = $projects->limit($limit); } else { $limitedProjects = $projects; } foreach ($limitedProjects as $project) { $isActive = $currentProject && $currentProject->ID == $project->ID; if ($isActive) { $activeProject = true; } $isCurrentEnvironment = false; if ($project && $currentEnvironment) { $isCurrentEnvironment = (bool) $project->DNEnvironmentList()->find('ID', $currentEnvironment->ID); } $navigation->push(['Project' => $project, 'IsCurrentEnvironment' => $isCurrentEnvironment, 'IsActive' => $currentProject && $currentProject->ID == $project->ID, 'IsOverview' => $actionType == self::PROJECT_OVERVIEW && !$isCurrentEnvironment && $currentProject->ID == $project->ID]); } // Ensure the current project is in the list if (!$activeProject && $currentProject) { $navigation->unshift(['Project' => $currentProject, 'IsActive' => true, 'IsCurrentEnvironment' => $currentEnvironment, 'IsOverview' => $actionType == self::PROJECT_OVERVIEW && !$currentEnvironment]); if ($limit > 0 && $navigation->count() > $limit) { $navigation->pop(); } } } return $navigation; }
function generateExportFileData(&$numColumns, &$numRows) { $separator = $this->csvSeparator; $csvColumns = $this->fieldListCsv ? $this->fieldListCsv : $this->fieldList; $fileData = ''; $columnData = array(); $fieldItems = new ArrayList(); if ($this->csvHasHeader) { $fileData .= "\"" . implode("\"{$separator}\"", array_values($csvColumns)) . "\""; $fileData .= "\n"; } if (isset($this->customSourceItems)) { $items = $this->customSourceItems; } else { $dataQuery = $this->getCsvQuery(); $items = $dataQuery->execute(); } // temporary override to adjust TableListField_Item behaviour $this->setFieldFormatting(array()); $this->fieldList = $csvColumns; if ($items) { foreach ($items as $item) { if (is_array($item)) { $className = isset($item['RecordClassName']) ? $item['RecordClassName'] : $item['ClassName']; $item = new $className($item); } $fieldItem = new $this->itemClass($item, $this); $fields = $fieldItem->Fields(false); $columnData = array(); if ($fields) { foreach ($fields as $field) { $value = $field->Value; // TODO This should be replaced with casting if (array_key_exists($field->Name, $this->csvFieldFormatting)) { $format = str_replace('$value', "__VAL__", $this->csvFieldFormatting[$field->Name]); $format = preg_replace('/\\$([A-Za-z0-9-_]+)/', '$item->$1', $format); $format = str_replace('__VAL__', '$value', $format); eval('$value = "' . $format . '";'); } $value = str_replace(array("\r", "\n"), "\n", $value); $tmpColumnData = '"' . str_replace('"', '\\"', $value) . '"'; $columnData[] = $tmpColumnData; } } $fileData .= implode($separator, $columnData); $fileData .= "\n"; $item->destroy(); unset($item); unset($fieldItem); } $numColumns = count($columnData); $numRows = $fieldItems->count(); return $fileData; } else { return null; } }
function NewsItems($limit = 20) { $repository = new SapphireRssNewsRepository(); $tx_manager = SapphireTransactionManager::getInstance(); $rss_news_manager = new RssNewsManager($repository, $tx_manager); $return_array = new ArrayList(); $group_array = $rss_news_manager->getNewsItemsFromDatabaseGroupedByCategory(); for ($i = 0; $i < 7 && $i < count($group_array[RssNews::SuperUser]); $i++) { $item = $group_array[RssNews::SuperUser][$i]; $return_array->push(array('type' => $item->Category, 'link' => $item->Link, 'title' => $item->Headline, 'pubdate' => date('D, M jS Y', strtotime($item->Date)), 'rawpubdate' => $item->Date)); } for ($i = 0; $i < 3 && $i < count($group_array[RssNews::Planet]); $i++) { $item = $group_array[RssNews::Planet][$i]; $return_array->push(array('type' => $item->Category, 'link' => $item->Link, 'title' => $item->Headline, 'pubdate' => date('D, M jS Y', strtotime($item->Date)), 'rawpubdate' => $item->Date)); } /*for ($i = 0; $i < 3 && $i < count($group_array[RssNews::Blog]); $i++ ) { $item = $group_array[RssNews::Blog][$i]; $return_array->push(array('type' => $item->Category, 'link' => $item->Link, 'title' => $item->Headline, 'pubdate' => date('D, M jS Y', strtotime($item->Date)), 'rawpubdate' => $item->Date)); }*/ $rss_count = $return_array->count(); $openstack_news = DataObject::get('News', "Approved = 1", "Date DESC", "", $limit - $rss_count)->toArray(); foreach ($openstack_news as $item) { $art_link = 'news/view/' . $item->ID . '/' . $item->HeadlineForUrl; $return_array->push(array('type' => 'News', 'link' => $art_link, 'title' => $item->Headline, 'pubdate' => date('D, M jS Y', strtotime($item->Date)), 'rawpubdate' => $item->Date)); } return $return_array->sort('rawpubdate', 'DESC')->limit($limit, 0); }
function run($request) { $productVariationArrayID = array(); if (empty($_GET["silent"])) { $this->verbose = true; } else { $this->verbose = intval($_GET["silent"]) == 1 ? false : true; } if (empty($_GET["productid"])) { $productID = 0; } elseif ($_GET["productid"] == 'all') { $productID = -1; } else { $productID = intval($_GET["productid"]); } if (empty($_GET["live"])) { $live = false; } else { $live = intval($_GET["live"]) == 1 ? true : false; } if ($live) { if ($this->verbose) { DB::alteration_message("this is a live task", "deleted"); } } else { if ($this->verbose) { DB::alteration_message("this is a test only. If you add a live=1 get variable then you can make it for real ;-)", "created"); } } if ($productID == -1) { $products = Product::get(); } else { $products = null; $product = Product::get()->byID($productID); if ($product) { $products = new ArrayList(); $products->push($product); } } if ($products && $products->count()) { foreach ($products as $product) { $productID = $product->ID; if ($products->count()) { if ($this->verbose) { DB::alteration_message("Deleting variations for " . $product->Title, "deleted"); } $variations = ProductVariation::get()->filter(array("ProductID" => $productID))->limit(100); if ($variations->count()) { if ($this->verbose) { DB::alteration_message("PRE DELETE COUNT: " . $variations->count()); } foreach ($variations as $variation) { if ($this->verbose) { DB::alteration_message(" Deleting Variation: " . $variation->Title(), "deleted"); } if ($live) { $variation->delete(); } $productVariationArrayID[$variation->ID] = $variation->ID; } $variations = ProductVariation::get()->filter(array("ProductID" => $productID))->limit(100); if ($live) { if ($variations->count()) { if ($this->verbose) { DB::alteration_message("POST DELETE COUNT: " . $variations->count()); } } else { if ($this->verbose) { DB::alteration_message("All variations have been deleted: ", "created"); } } } else { if ($this->verbose) { DB::alteration_message("This was a test only", "created"); } } } else { if ($this->verbose) { DB::alteration_message("There are no variations to delete", "created"); } } if ($this->verbose) { DB::alteration_message("Starting cleanup", "created"); } if ($live) { $sql = "\r\n\t\t\t\t\t\t\t\t\tDELETE\r\n\t\t\t\t\t\t\t\t\tFROM \"Product_VariationAttributes\"\r\n\t\t\t\t\t\t\t\t\tWHERE \"ProductID\" = " . $productID; if ($this->verbose) { DB::alteration_message("<pre>RUNNING<br />" . $sql . "</pre>"); } DB::query($sql); $sql = "\r\n\t\t\t\t\t\t\t\t\tDELETE \"ProductVariation_AttributeValues\"\r\n\t\t\t\t\t\t\t\t\tFROM \"ProductVariation_AttributeValues\"\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN \"ProductVariation\"\r\n\t\t\t\t\t\t\t\t\t\t\tON \"ProductVariation_AttributeValues\".\"ProductVariationID\" = \"ProductVariation\".\"ID\"\r\n\t\t\t\t\t\t\t\t\tWHERE \"ProductVariation\".\"ID\" IS NULL"; if ($this->verbose) { DB::alteration_message("<pre>RUNNING<br />" . $sql . "</pre>"); } DB::query($sql); } else { $sql = "\r\n\t\t\t\t\t\t\t\t\tSELECT COUNT(Product_VariationAttributes.ID)\r\n\t\t\t\t\t\t\t\t\tFROM \"Product_VariationAttributes\"\r\n\t\t\t\t\t\t\t\t\tWHERE \"ProductID\" = " . $productID; if ($this->verbose) { DB::alteration_message("<pre>RUNNING<br />" . $sql . "</pre>"); } $result = DB::query($sql); if ($this->verbose) { DB::alteration_message("Would have deleted " . $result->value() . " rows"); } $sql = "\r\n\t\t\t\t\t\t\t\t\tSELECT COUNT (\"ProductVariation_AttributeValues\".\"ID\")\r\n\t\t\t\t\t\t\t\t\tFROM \"ProductVariation_AttributeValues\"\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN \"ProductVariation\"\r\n\t\t\t\t\t\t\t\t\t\t\tON \"ProductVariation_AttributeValues\".\"ProductVariationID\" = \"ProductVariation\".\"ID\"\r\n\t\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\t\t\t\"ProductVariation\".\"ID\" IS NULL OR\r\n\t\t\t\t\t\t\t\t\t\t\"ProductVariation\".\"ID\" IN(" . implode(",", $productVariationArrayID) . ") "; if ($this->verbose) { DB::alteration_message("<pre>RUNNING<br />" . $sql . "</pre>"); } $result = DB::query($sql); if ($this->verbose) { DB::alteration_message("Would have deleted " . $result->value() . " rows"); } } } } } else { if ($this->verbose) { DB::alteration_message("Product does not exist. You can set the product by adding it productid=XXX as a GET variable. You can also add <i>all</i> to delete ALL product Variations.", "deleted"); } } DB::alteration_message("Completed", "created"); }
/** * Returns top level navigation of projects. * * @param int $limit * * @return ArrayList */ public function Navigation($limit = 5) { $navigation = new ArrayList(); $currentProject = $this->getCurrentProject(); $projects = $this->getStarredProjects(); if ($projects->count() < 1) { $projects = $this->DNProjectList(); } else { $limit = -1; } if ($projects->count() > 0) { $activeProject = false; if ($limit > 0) { $limitedProjects = $projects->limit($limit); } else { $limitedProjects = $projects; } foreach ($limitedProjects as $project) { $isActive = $currentProject && $currentProject->ID == $project->ID; if ($isActive) { $activeProject = true; } $navigation->push(array('Project' => $project, 'IsActive' => $currentProject && $currentProject->ID == $project->ID)); } // Ensure the current project is in the list if (!$activeProject && $currentProject) { $navigation->unshift(array('Project' => $currentProject, 'IsActive' => true)); if ($limit > 0 && $navigation->count() > $limit) { $navigation->pop(); } } } return $navigation; }
/** * manipulates the parts the pages breadcrumbs if a product detail view is * requested. * * @param int $maxDepth maximum depth level of shown pages in breadcrumbs * @param bool $unlinked true, if the breadcrumbs should be displayed without links * @param string $stopAtPageType name of pagetype to stop at * @param bool $showHidden true, if hidden pages should be displayed in breadcrumbs * * @return ArrayList * * @author Sebastian Diel <*****@*****.**>, Patrick Schneider <*****@*****.**> * @since 09.10.2012 */ public function BreadcrumbParts($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false) { $parts = new ArrayList(); $page = $this; while ($page && (!$maxDepth || $parts->count() < $maxDepth) && (!$stopAtPageType || $page->ClassName != $stopAtPageType)) { if ($showHidden || $page->ShowInMenus || $page->ID == $this->ID) { if ($page->hasMethod('OriginalLink')) { $link = $page->OriginalLink(); } else { $link = $page->Link(); } if ($page->ID == $this->ID) { $isActive = true; } else { $isActive = false; } $parts->unshift(new ArrayData(array('MenuTitle' => $page->MenuTitle, 'Title' => $page->Title, 'Link' => $link, 'Parent' => $page->Parent, 'IsActive' => $isActive))); } $page = $page->Parent; } return $parts; }