public function testNamedExpression() { $m = Masonry::test('1', '2'); $this->assertEquals('test', $m->getExpression()); $this->assertFalse($m->isPlain()); $this->assertEquals(array('1', '2'), $m->getArguments()); }
/** * Generate the content element */ protected function compile() { if (TL_MODE == 'FE') { // --- create FE template for masonry element $this->Template = new \FrontendTemplate($this->strTemplate); $this->Template->setData($this->arrData); // --- create FE template for javascript caller $objTemplateJs = new \FrontendTemplate($this->dk_msryJsTpl); $objTemplateJs->id = $this->id; $masonry = new Masonry(); $masonry->createTemplateData($this->Template, $objTemplateJs); } else { $this->strTemplate = 'be_wildcard'; $this->Template = new \BackendTemplate($this->strTemplate); $this->Template->title = $this->headline; } }
public static function get_component($component, $data) { $display = ""; switch ($component) { case 'carousel': $display .= Carousel::display_carousel($data, true); break; case 'grid': $display .= Grid::display_grid($data, true); break; case 'card': $display .= Card::display_card_simple($data, true); break; case 'button': $display .= Button::display_buttons($data, true); break; case 'masonry': $display .= Masonry::display_masonry($data, true); break; case 'flex-layout': $display .= Freewall::display_flex_layout($data, true); break; case 'windows': $display .= Freewall::display_win8_layout($data, true); break; case 'img-layout': $display .= Freewall::display_image_layout($data, true); break; case 'pinterest': $display .= Freewall::display_pinterest_layout($data, true); break; default: $display .= Grid::display_grid($data, true); break; } return $display; }
//echo $component; switch ($component) { case 'carousel': Carousel::display_carousel($countries); break; case 'grid': Grid::display_grid($countries); break; case 'card': echo 'Display cards'; break; case 'button': echo 'Display buttons'; break; case 'masonry': Masonry::display_masonry($countries); break; case 'flex-layout': Freewall::display_flex_layout($countries); break; case 'windows': Freewall::display_win8_layout($countries); break; case 'img-layout': Freewall::display_image_layout($countries); break; case 'pinterest': Freewall::display_pinterest_layout($countries); break; default: Grid::display_grid($countries);
} switch ($component) { case 'carousel': Carousel::display_carousel($locations); break; case 'grid': Grid::display_grid($locations); break; case 'card': Card::display_card_simple($locations); break; case 'button': Button::display_buttons($locations); break; case 'masonry': Masonry::display_masonry($locations); break; case 'flex-layout': Freewall::display_flex_layout($locations); break; case 'windows': Freewall::display_win8_layout($locations); break; case 'img-layout': Freewall::display_image_layout($locations); break; case 'pinterest': Freewall::display_pinterest_layout($locations); break; default: Grid::display_grid($locations);
/** * Generate the content element */ protected function compile() { global $objPage; $images = array(); $auxDate = array(); $objFiles = $this->objFiles; // Get all images while ($objFiles->next()) { // Continue if the files has been processed or does not exist if (isset($images[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) { continue; } // Single files if ($objFiles->type == 'file') { $objFile = new \File($objFiles->path, true); if (!$objFile->isGdImage) { continue; } $arrMeta = $this->getMetaData($objFiles->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars(str_replace('_', ' ', $objFile->filename)); } // Add the image $images[$objFiles->path] = array('id' => $objFiles->id, 'uuid' => $objFiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objFiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']); $auxDate[] = $objFile->mtime; } else { $objSubfiles = \FilesModel::findByPid($objFiles->uuid); if ($objSubfiles === null) { continue; } while ($objSubfiles->next()) { // Skip subfolders if ($objSubfiles->type == 'folder') { continue; } $objFile = new \File($objSubfiles->path, true); if (!$objFile->isGdImage) { continue; } $arrMeta = $this->getMetaData($objSubfiles->meta, $objPage->language); // Use the file name as title if none is given if ($arrMeta['title'] == '') { $arrMeta['title'] = specialchars(str_replace('_', ' ', $objFile->filename)); } // Add the image $images[$objSubfiles->path] = array('id' => $objSubfiles->id, 'uuid' => $objSubfiles->uuid, 'name' => $objFile->basename, 'singleSRC' => $objSubfiles->path, 'alt' => $arrMeta['title'], 'imageUrl' => $arrMeta['link'], 'caption' => $arrMeta['caption']); $auxDate[] = $objFile->mtime; } } } // Sort array switch ($this->dk_msrySortBy) { default: case 'name_asc': uksort($images, 'basename_natcasecmp'); break; case 'name_desc': uksort($images, 'basename_natcasercmp'); break; case 'date_asc': array_multisort($images, SORT_NUMERIC, $auxDate, SORT_ASC); break; case 'date_desc': array_multisort($images, SORT_NUMERIC, $auxDate, SORT_DESC); break; case 'meta': // Backwards compatibility // Backwards compatibility case 'custom': if ($this->orderSRC != '') { $tmp = deserialize($this->orderSRC); if (!empty($tmp) && is_array($tmp)) { // Remove all values $arrOrder = array_map(function () { }, array_flip($tmp)); // Move the matching elements to their position in $arrOrder foreach ($images as $k => $v) { if (array_key_exists($v['uuid'], $arrOrder)) { $arrOrder[$v['uuid']] = $v; unset($images[$k]); } } // Append the left-over images at the end if (!empty($images)) { $arrOrder = array_merge($arrOrder, array_values($images)); } // Remove empty (unreplaced) entries $images = array_values(array_filter($arrOrder)); unset($arrOrder); } } break; case 'random': shuffle($images); break; } $images = array_values($images); // Limit the total number of items if ($this->dk_msryNumberOfItems > 0) { $images = array_slice($images, 0, $this->dk_msryNumberOfItems); } $intMaxWidth = TL_MODE == 'BE' ? 160 : $GLOBALS['TL_CONFIG']['maxImageWidth']; $strLightboxId = 'lightbox[lb' . $this->id . ']'; $body = array(); // create images for ($i = 0; $i < count($images); $i++) { $objCell = new \stdClass(); // Add size $images[$i]['size'] = $this->dk_msryImageSize; $images[$i]['fullsize'] = $this->dk_msryFullsize; $this->addImageToTemplate($objCell, $images[$i], $intMaxWidth, $strLightboxId); $body[$i] = $objCell; } $objTemplate = new \FrontendTemplate($this->strTemplateGallery); $objTemplate->setData($this->arrData); $objTemplate->body = $body; if (TL_MODE == 'FE') { $this->Template->images = $objTemplate->parse(); // --- create FE template for javascript caller $objTemplateJs = new \FrontendTemplate($this->strTemplateJs); // (unique) Element id will be used for unique HTML id element $objTemplateJs->id = $this->id; $objMasonry = new Masonry(); $objMasonry->createTemplateData($this->Template, $objTemplateJs); } else { $this->strTemplate = 'be_masonry'; $this->Template = new \BackendTemplate($this->strTemplate); $this->Template->images = $objTemplate->parse(); // for BE styling include masonry CSS file $GLOBALS['TL_CSS'][] = 'system/modules/dk_masonry/assets/css/masonry.css'; } }
echo "</pre>";*/ switch ($component) { case 'carousel': Carousel::display_carousel($themes); break; case 'grid': Grid::display_grid($themes); break; case 'card': Card::display_card_simple($themes); break; case 'button': Button::display_buttons($themes); break; case 'masonry': Masonry::display_masonry($themes); break; case 'flex-layout': Freewall::display_flex_layout($themes); break; case 'windows': Freewall::display_win8_layout($themes); break; case 'img-layout': Freewall::display_image_layout($themes); break; case 'pinterest': Freewall::display_pinterest_layout($themes); break; default: Grid::display_grid($themes);
<meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="css/style.css"> </head> <body> <a href="https://github.com/hongaar/php-masonry"><img style="position: fixed; z-index: 2; top: 0; left: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_white_ffffff.png" alt="Fork me on GitHub"></a> <div id="main"> <?php require_once 'lib/Masonry.php'; // create images array $images = glob('images/*'); shuffle($images); $masonry = new Masonry(); if (isset($_REQUEST['small'])) { $masonry->minWidth = 5; $masonry->maxWidth = 15; $masonry->minHeight = 10; $masonry->maxHeight = 30; $masonry->fillTopProbability = 5; $masonry->fillHalfwayProbability = 2; } else { $masonry->multiplier = 10; $masonry->ysize = 10; $masonry->minWidth = 1; $masonry->maxWidth = 4; $masonry->minHeight = 3; $masonry->maxHeight = 7; }