Esempio n. 1
0
 public static function getHTML($imgs, $mediaFolderName, $galleryType, $isAdminMode = false, $bReturnFullInfo = false, $sizeRatio = 1, $galleryFullScreen = false, $imageSize = 'large')
 {
     global $berta;
     $strOut = '';
     $mFolder = self::$options['MEDIA_ROOT'] . $mediaFolderName . '/';
     $mFolderABS = self::$options['MEDIA_ABS_ROOT'] . $mediaFolderName . '/';
     $imageTargetWidth = $berta->template->settings->get('media', 'images' . ucfirst($imageSize) . 'Width', false, true);
     $imageTargetHeight = $berta->template->settings->get('media', 'images' . ucfirst($imageSize) . 'Width', false, true);
     // print output ...
     if ($imgs && count($imgs) > 0) {
         list($firstImageHTML, $firstImageWidth, $firstImageHeight) = BertaGallery::getImageHTML($imgs[0], $mediaFolderName, $isAdminMode, $sizeRatio, $imageTargetWidth, $imageTargetHeight);
         $strOut = '<div class="xGalleryContainer xGalleryHasImages xGalleryType-' . $galleryType . '">';
         $strOut .= "<div class=\"xGallery\" style=\"width: {$firstImageWidth}px; height: {$firstImageHeight}px;\">";
         $strOut .= $firstImageHTML;
         if ($isAdminMode) {
             $strOut .= '<a href="#" class="xGalleryEditButton xEditorLink xSysCaption xMAlign-container"><span class="xMAlign-outer"><span class="xMAlign-inner">edit gallery</span></span></a>';
         }
         $strOut .= '</div>';
         $strOut .= BertaGallery::getNavHTML($imgs, $galleryType, $mFolder, $mFolderABS, $isAdminMode, $sizeRatio, $imageTargetWidth, $imageTargetHeight, $galleryFullScreen);
         $strOut .= '</div>';
     } elseif ($isAdminMode) {
         $strOut = '<div class="xGalleryContainer">';
         //.
         //'<img src="' . $options['MEDIA_ROOT'] . $p['mediafolder']['value'] . '/' . $imgs[0] . '" alt="' . (!empty($p['title']['value']) ? htmlspecialchars($p['title']['value']) : '') . '" />' .
         //'</div>';
         $strOut .= '<div class="imageEmpty">';
         if ($isAdminMode) {
             $strOut .= '<a href="#" class="xGalleryEditButton">' . BertaContent::getXEmpty('gallery') . '</a>';
         }
         $strOut .= '</div>';
         $strOut .= '</div>';
     }
     return $bReturnFullInfo ? array($strOut, $firstImageWidth, $firstImageHeight) : $strOut;
 }
function smarty_function_entryGalleryFirstImage($params, &$smarty)
{
    if (!empty($params['entry'])) {
        return BertaGallery::getFirstImage($params['entry']['__raw']);
    }
    return '';
}
function smarty_function_white_firstPageMarkedEntry($params, &$smarty) {
	global $berta;

	$viewportWidth = 980;
	$viewportHeight = 800;
	

	if(!empty($params['entry'])) {
		$entry = $params['entry'];
		$imageSelect = !empty($params['imageselect']) ? $params['imageselect'] : 'random';
		$wiggleClass = $berta->template->settings->get('firstPage', 'hoverWiggle') == 'yes' ? 'firstPageWiggle' : ''; 
		
		$imgs = BertaGallery::getImagesArray($params['entry']['__raw']);
		
		if($imgs) {
			$img = $imageSelect == 'first' ? reset($imgs) : $imgs[array_rand($imgs)];
			$sizeRatio = $berta->template->settings->get('firstPage', 'imageSizeRatio');
			if($sizeRatio <= 0) $sizeRatio = 1;
			
			list($html, $w, $h) = BertaGallery::getHTML(array(0 => $img), $params['entry']['__raw']['mediafolder']['value'], 'slideshow', false, true, $sizeRatio);
			//BertaGallery::getHTML($img, $params['entry']['__raw']['mediafolder']['value']);
			
			$link = '';
			if($berta->environment != 'engine' && $img['@attributes']['type'] == 'image') {
				$link = smarty_function_bertaLink(array(
					'section' => $params['entry']['section']['name']['value'], 
					'tag' => !empty($params['entry']['tags']) ? reset($params['entry']['tags']) : null
				), $smarty);
				$link = "<a class=\"firstPagePicLink\" href=\"$link\" style=\"width:{$w}px;height:{$h}px;\"></a>";
			}
			
			$pos = !empty($entry['positionXY']) ? explode(',', $entry['positionXY']) : array(rand(0, $viewportWidth - $w), rand(0, $viewportHeight - $h));
			$entryClasses = smarty_function_entryClasses(array('entry' => $params['entry']), $smarty);
			$html = "<div class=\"firstPagePic $wiggleClass $entryClasses xEditableDragXY xProperty-positionXY \" style=\"left:{$pos[0]}px;top:{$pos[1]}px;\">" . 
						$html .
						($berta->environment == 'engine' ? "<div class=\"xHandle\" style=\"width:{$w}px;height:{$h}px;\"></div>" : '') .
						$link .
					'</div>';
		
			return $html;
		
		} else {
			
			$html = !empty($entry['description']) ? $entry['description'] : '';
			if($html) {
				$pos = !empty($entry['positionXY']) ? explode(',', $entry['positionXY']) : array(rand(0, $viewportWidth - $w), rand(0, $viewportHeight - $h));
				$entryClasses = smarty_function_entryClasses(array('entry' => $params['entry']), $smarty);
				$html = "<div class=\"firstPagePic $wiggleClass $entryClasses xEditableDragXY xProperty-positionXY \" style=\"left:{$pos[0]}px;top:{$pos[1]}px;\">" . 
							$html .
							($berta->environment == 'engine' ? "<div class=\"xHandle\" style=\"width:100%;height:100%;\"></div>" : '') .
						'</div>';
		
				return $html;
			}
		}
	}
	
	return '';
}
function smarty_function_entryGallery($params, &$smarty)
{
    global $berta;
    if (!empty($params['entry'])) {
        return BertaGallery::getHTMLForEntry($params['entry']['__raw'], $berta->environment == 'engine');
    }
    return '';
}
Esempio n. 5
0
function smarty_function_gridView($params)
{
    global $berta;
    if (!empty($params['section'])) {
        return BertaGallery::getHTMLForGridView($params['section'], !empty($params['tag']) ? $params['tag'] : null);
    }
    return '';
}
Esempio n. 6
0
if($jsonRequest) {
    //var_dump($_REQUEST);
	//echo str_replace(array("\n", "\r"), array('\n', ''), $jsonRequest) . "\n\n";
	$decoded = $result = Zend_Json::decode(str_replace(array("\n", "\r"), array('\n', ''), $jsonRequest));
	//	var_dump($decoded);
	
	switch($decoded['property']) {
		
		case 'gallery':
		
			if($decoded['section'] && $decoded['entry']) {
				$blog = BertaContent::loadBlog($decoded['section']);
				$entry = BertaContent::getEntry($decoded['entry'], $blog);
				
				echo BertaGallery::getHTMLForEntry($entry, true);
				
				
			}
			
			break;


		case 'galleryEditor':
		
			if($decoded['section'] && $decoded['entry']) {
				$blog = BertaEditor::loadBlog($decoded['section']);
				$entry = BertaEditor::getEntry($decoded['entry'], $blog);
				
				if($entry) {
Esempio n. 7
0
 public static function images_getSmallThumbFor($imagePath)
 {
     $fileName = basename($imagePath);
     $dirName = dirname($imagePath);
     if ($dirName) {
         $dirName .= '/';
     }
     $thumbPath = $dirName . self::$options['images']['small_thumb_prefix'] . $fileName;
     if (file_exists($thumbPath)) {
         return $thumbPath;
     } elseif (BertaGallery::createThumbnail($imagePath, $thumbPath, self::$options['images']['small_thumb_width'], self::$options['images']['small_thumb_height'])) {
         return $thumbPath;
     }
     return false;
 }
Esempio n. 8
0
 public static function getHTMLForGridView($section, $tag)
 {
     global $berta;
     $imgs = BertaGallery::getImagesArray($section);
     $mediaFolder = $section['mediafolder'];
     $mFolder = self::$options['MEDIA_ROOT'] . $mediaFolder . '/';
     $mFolderABS = self::$options['MEDIA_ABS_ROOT'] . $mediaFolder . '/';
     $alwaysSelectTag = $berta->settings->get('navigation', 'alwaysSelectTag') == 'yes';
     $tagKeys = array_keys($berta->tags[$section['name']]);
     $notFirstTag = $tag != reset($tagKeys);
     $sectionKeys = array_keys($berta->sections);
     $firstSection = $section['name'] == reset($sectionKeys);
     if (($berta->environment == 'engine' || $berta->environment == 'site' && !$berta->apacheRewriteUsed) && !$firstSection) {
         $linkHref = '?section=' . $section['name'];
         if ($tag != null && ($alwaysSelectTag && $notFirstTag || !$alwaysSelectTag)) {
             $linkHref .= '&tag=' . $tag;
         }
     } elseif (($berta->environment == 'engine' || $berta->environment == 'site' && !$berta->apacheRewriteUsed) && $firstSection) {
         $linkHref = self::$options['SITE_ABS_ROOT'];
         if ($tag != null && ($alwaysSelectTag && $notFirstTag || !$alwaysSelectTag)) {
             $linkHref .= '?section=' . $section['name'] . '&tag=' . $tag;
         }
     } elseif ($berta->environment == 'site' && $berta->apacheRewriteUsed && !$firstSection) {
         $linkHref = self::$options['SITE_ABS_ROOT'] . $section['name'] . '/';
         if ($tag != null && ($alwaysSelectTag && $notFirstTag || !$alwaysSelectTag)) {
             $linkHref .= $tag . '/';
         }
     } elseif ($berta->environment == 'site' && $berta->apacheRewriteUsed && $firstSection) {
         $linkHref = self::$options['SITE_ABS_ROOT'];
         if ($tag != null && ($alwaysSelectTag && $notFirstTag || !$alwaysSelectTag)) {
             $linkHref .= $section['name'] . '/' . $tag . '/';
         }
     }
     if ($imgs && count($imgs) > 0) {
         foreach ($imgs as $img) {
             if ($img['@attributes']['type'] == 'image') {
                 $imgSrc = $img['@attributes']['src'];
                 $imgSrc = self::images_getGridImageFor($mFolder . $imgSrc);
                 $returnImages .= '<div class="box"><a href="' . $linkHref . '"><img class="xGridItem" src="' . $mFolderABS . $imgSrc . '" /></a></div>';
             }
         }
     }
     return $returnImages;
 }
Esempio n. 9
0
 public static function images_getBgImageFor($imagePath)
 {
     $fileName = basename($imagePath);
     $dirName = dirname($imagePath);
     if ($dirName) {
         $dirName .= '/';
     }
     $bgImagePath = $dirName . self::$options['images']['bg_image_prefix'] . $fileName;
     list($width, $height) = getimagesize($imagePath);
     if (file_exists($bgImagePath)) {
         return $bgImagePath;
     } elseif (BertaGallery::createThumbnail($imagePath, $bgImagePath, $width, $height)) {
         return $bgImagePath;
     }
     return false;
 }
Esempio n. 10
0
     $gridImageSrc = BertaGallery::images_getGridImageFor($fileFolder . $fName);
     if ($gridImageSrc) {
         $gridImageInfo = getimagesize($fileFolder . $gridImageSrc);
     }
 }
 if ($settingsProperty) {
     // update setings value
     if ($settings->get($settingsProperty[0], $settingsProperty[1])) {
         $oldF = $settings->get($settingsProperty[0], $settingsProperty[1]);
         @unlink($fileFolder . $oldF);
         BertaEditor::images_deleteDerivatives($fileFolder, $oldF);
     }
     //generate 2x smaller image here, original will be for retina displays @2x
     $imInfo[0] = round($imInfo[0] / 2);
     $imInfo[1] = round($imInfo[1] / 2);
     BertaGallery::getResizedSrc($fileFolder, $fName, $imInfo[0], $imInfo[1]);
     $settings->update($settingsProperty[0], $settingsProperty[1], $fName);
     $settings->update($settingsProperty[0], $settingsProperty[1] . '_width', $imInfo[0]);
     $settings->update($settingsProperty[0], $settingsProperty[1] . '_height', $imInfo[1]);
     $settings->save();
 } elseif ($sectionBackground) {
     $sectionsToEdit = BertaEditor::getSections();
     if (empty($sectionsToEdit[$sectionName]['mediafolder'])) {
         $sectionsToEdit[$sectionName]['mediafolder'] = array();
     }
     if (empty($sectionsToEdit[$sectionName]['mediafolder']['value'])) {
         $sectionsToEdit[$sectionName]['mediafolder']['value'] = $mediaFolder;
     }
     BertaEditor::updateImageCacheForSection($sectionsToEdit[$sectionName]);
     BertaEditor::saveSections($sectionsToEdit);
 } else {