function smarty_function_pageHeader($params, &$smarty) { global $berta; return $berta->security->userLoggedIn ? BertaEditor::getTopPanelHTML('site') : ''; }
// delete a section if (!BertaEditor::deleteSection($decoded['value'])) { $returnError = 'Section cannot be deleted! Check permissions.'; } } else { $returnUpdate = $returnReal = trim($decoded['value']); $sName = trim($decoded['section']); if (strtolower($sName) != 'title' && strtolower($sName) != 'name') { $sectionsList = BertaEditor::getSections(); foreach ($sectionsList as $sN => $s) { if ((string) $sN === $sName) { $sectionsList[$sN][$property] = array('value' => $returnUpdate); break; } } BertaEditor::saveSections($sectionsList); } else { $returnError = 'Template-specific properties cannot override system properties! Check template settings.'; } } } } } } } } } } } } }
else $returnError = "the currently selected template does not support this setting!\nplease reload the page and try again."; } if(!$returnError) { if($propPath[0] == 'siteTexts' || !empty($settings->settingsDefinition[$propPath[0]][$propPath[1]])) { $decoded['value'] = trim($decoded['value']); if($decoded['params'] == 'delete') { $decoded['value'] = ''; $format = $settings->getDefinitionParam($propPath[0], $propPath[1], 'format'); if($propPath[0] == 'siteTexts' && !$format) $format = 'image'; if($format == 'image') { $oldF = $settings->get($propPath[0], $propPath[1]); @unlink($options['MEDIA_ROOT'] . $oldF); BertaEditor::images_deleteDerivatives($options['MEDIA_ROOT'], $oldF); } } if($decoded['value'] === '') $decoded['value'] = $settings->getDefinitionParam($propPath[0], $propPath[1], 'allow_blank') ? '' : $settings->getDefinitionParam($propPath[0], $propPath[1], 'default'); if($settings->getDefinitionParam($propPath[0], $propPath[1], 'validator')) { BertaUtils::validate($decoded['value'], $returnError, $settings->getDefinitionParam($propPath[0], $propPath[1], 'validator')); } $settings->update($propPath[0], $propPath[1], $decoded['value']); $returnUpdate = $decoded['value']; } else { $returnError = "the setting is not properly defined in the configuration!\n";
<p>2. <?php echo I18n::_('What is your name?'); ?> </p> <p class="subInfo"><?php echo I18n::_('It will appear in the copyright notice in the footer. You may leave it blank.'); ?> </p> <?php /* OLD: <p class="xFirstTimeField <?php echo $xEditSelectorSimple ?> xProperty-texts/ownerName xRequired-<?php echo $berta->settings->isRequired('texts', 'ownerName') ? '1': '0' ?>"><?php echo $berta->settings->get('texts', 'ownerName', true) ?></p>*/ ?> <?php echo BertaEditor::getSettingsItemEditHTML('texts/ownerName', $berta->settings->getDefinition('texts', 'ownerName'), $berta->settings->get('texts', 'ownerName', false), array('xCaption' => str_replace(' ', '+', $berta->settings->getDefinitionParam('texts', 'ownerName', 'title'))), "p"); ?> <p>3. <?php echo I18n::_('What is this website about?'); ?> </p> <p class="subInfo"><?php echo I18n::_('It will appear under your site name in search engine results.'); ?> </p> <p class="subInfo"><?php echo I18n::_('Note: the fields that already have value appear yellow only when you roll over them with your mouse. Click on the text below to edit.'); ?> </p>
//$possibleBehaviors = foreach($allSections as $sN => $s) { $type = !empty($s['@attributes']['type']) ? $s['@attributes']['type'] : 'default'; $typeTitle = isset($typeValues[$type]) ? $typeValues[$type] : $type; echo '<li class="xSection-' . $sN . '">'; echo '<div class="csHandle"><span class="handle"></span></div>'; echo '<div class="csTitle"><span class="' . $xEditSelectorSimple . ' xProperty-title xNoHTMLEntities xSection-' . $sN . ' xSectionField">' . (!empty($s['title']['value']) ? htmlspecialchars($s['title']['value']) : '') . '</span></div>'; echo '<div class="csBehaviour"><span class="' . $xEditSelectorSelectRC . ' xProperty-type xSection-' . $sN . ' xSectionField" x_options="' . $possibleTypes . '">' . htmlspecialchars($typeTitle) . '</span></div>'; echo '<div class="csDetails">'; if(!empty($typeParams[$type])) { foreach($typeParams[$type] as $pName => $p) { $value = !empty($s[$pName]['value']) ? $s[$pName]['value'] : ''; if(!$value && $p['default']) $value = $p['default']; echo BertaEditor::getSettingsItemEditHTML($pName, $p, $value, array('xSection' => $sN, 'xSectionField')); } } //if($behaviour == 'external link') // echo '<span class="' . $xEditSelectorSimple . ' xProperty-sectionsEditor/link xNoHTMLEntities xParam-' . $sN . ' xSectionField" title="">' . (!empty($s['link']['value']) ? htmlspecialchars($s['link']['value']) : '') . '</span>'; echo '</div>'; echo '<div class="csPub"><span class="' . $xEditSelectorYesNo . ' xProperty-published xSection-' . $sN . ' xSectionField">' . (!empty($s['@attributes']['published']) ? '1' : '0') . '</span></div>'; echo '<div class="csDelete"><a href="#" class="xSectionDelete">'.I18n::_('delete').'</a></div>'; echo '</li>'; } ?></ul><br class="clear" /> <a id="xCreateNewSection" class="xPanel" href="#" class="xAction-sectionCreateNew"><span><?php
if (count($entryCache)) { Array_XML::makeListIfNotList($entryCache['file']); foreach ($entryCache['file'] as $cacheIndex => $cacheIm) { $origSrc = '_orig_' . $cacheIm['@attributes']['src']; if (file_exists($mFolder . $origSrc)) { if (@unlink($mFolder . $cacheIm['@attributes']['src'])) { @rename($mFolder . $origSrc, $mFolder . $cacheIm['@attributes']['src']); } } } } } } // set version $blog['@attributes']['version'] = $options['version']; } // update some old settings ... $g = $berta->settings->get('settings', 'google-analytics-id'); if ($g) { $berta->settings->delete('settings', 'google-analytics-id'); $berta->settings->update('settings', 'googleAnalyticsId', $g); $berta->settings->save(); } // ------------------------------- ... // clean-up and files organisation ... BertaEditor::populateTags($sName, $blog); BertaEditor::updateImageCacheFor($blog); BertaEditor::saveBlog($sName, $blog); } } }
$tabCaption = !empty($sSection['_']['title']) ? htmlspecialchars($sSection['_']['title']) : "<em>$sSectionKey</em>"; $tabsHTML .= "<li><a href=\"#\" class=\"settingsTab\">$tabCaption</a></li>"; $contentHTML .= "<div class=\"settingsContent\">\n"; foreach($sSection as $sKey => $s) { // Dont render keys that start with an underscore if(substr($sKey, 0, 1) != '_') { $contentHTML .= ' <div class="entry">' . "\n"; // caption $contentHTML .= ' <div class="caption">' . ($s['title'] ? ($s['title']) : "<em>$sKey</em>") . '</div>'; // value $value = $settings->get($sSectionKey, $sKey, false, false); // don't use empty + don't inherit from base $contentHTML .= BertaEditor::getSettingsItemEditHTML($propertyPrefix . $sSectionKey . '/' . $sKey, $s, $value) . "\n"; // description if(!empty($s['description'])) { $contentHTML .= ' <div class="description">' . $s['description'] . '</div>' . "\n"; } $contentHTML .= ' <br class="clear" />' . "\n"; $contentHTML .= " </div>\n"; } } $contentHTML .= "</div>\n"; } } echo "<div id=\"settingsContentContainer\" class=\"settingsContentContainer\">
} } // Updates for 0.8.2 if (empty($berta->content['@attributes']['last_upd_ver']) || $berta->content['@attributes']['last_upd_ver'] < 1082) { switch ($tplName) { case 'messy': foreach ($berta->content['entry'] as $eKey => $e) { $galleryType = $e['mediaCacheData']['@attributes']['type']; if ($galleryType == 'row') { $berta->content['entry'][$eKey]['mediaCacheData']['@attributes']['type'] = 'pile'; $berta->allContent[$berta->sectionName]['entry'][$eKey]['mediaCacheData']['@attributes']['type'] = 'pile'; } } break; case 'mashup': case 'white': foreach ($berta->content['entry'] as $eKey => $e) { $galleryType = $e['mediaCacheData']['@attributes']['type']; if ($galleryType == 'row') { $berta->content['entry'][$eKey]['mediaCacheData']['@attributes']['type'] = 'column'; $berta->allContent[$berta->sectionName]['entry'][$eKey]['mediaCacheData']['@attributes']['type'] = 'column'; } } break; } $berta->content['@attributes']['last_upd_ver'] = $options['int_version']; $berta->allContent[$berta->sectionName]['@attributes']['last_upd_ver'] = $options['int_version']; $berta->template->addContent($berta->requestURI, $berta->sectionName, $berta->sections, $berta->tagName, $berta->tags, $berta->content, $berta->allContent); BertaEditor::saveBlog($berta->sectionName, $berta->content); } }
$returnUpdate .= '<div class="csDelete"><a href="#" class="xSiteDelete">delete</a></div>'; $returnReal = $sName; $sitesList = BertaEditor::getSites(); $sitesList[$sName] = array('@attributes' => array('published' => 0), 'name' => $sName, 'title' => array('value' => '')); BertaEditor::saveSites($sitesList); } else { if ($decoded['action'] == 'DELETE_SITE') { // delete a section if (!BertaEditor::deleteSite($decoded['value'])) { $returnError = 'Site cannot be deleted! Check permissions.'; } } else { $returnUpdate = $returnReal = trim($decoded['value']); $sName = (string) $decoded['site']; if (strtolower($sName) != 'title') { $sitesList = BertaEditor::getSites(); foreach ($sitesList as $sN => $s) { if ((string) $sN === $sName) { $sitesList[$sN][$property] = array('value' => $returnUpdate); break; } } BertaEditor::saveSites($sitesList); } else { $returnError = 'Hacker or what?'; } } } } } }
function smarty_function_intercomScript($params, &$smarty) { return class_exists('BertaEditor') ? BertaEditor::intercomScript() : ''; }
function smarty_function_videoTutorials($params, &$smarty) { global $berta; return $berta->security->userLoggedIn ? BertaEditor::getBertaVideoLinks() : ''; }
public static function intercomScript() { $content = ''; $options = self::$options; if ($options['INTERCOM_APP_ID'] && $options['logged_in'] && BertaEditor::getSections()) { $user_hash = hash_hmac("sha256", $options['AUTH_user'], $options['INTERCOM_SECRET_KEY']); $content = <<<DOC <script> window.intercomSettings = { app_id: "{$options['INTERCOM_APP_ID']}", email: "{$options['AUTH_user']}", user_hash: "{$user_hash}" }; </script> <script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/fsnigfh';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})() </script> DOC; } return $content; }
private function getEntriesLists($sName, $tagName, &$content) { $haveToSave = false; $entries = array(); $entriesForTag = array(); if (!empty($content['entry'])) { foreach ($content['entry'] as $idx => $p) { if ((string) $idx == '@attributes') { continue; } if (!empty($p['id']) && !empty($p['id']['value']) && !empty($p['uniqid']) && !empty($p['uniqid']['value']) && !empty($p['mediafolder']) && !empty($p['mediafolder']['value'])) { $id = $p['id']['value']; $entries[$id] = BertaTemplate::entryForTemplate($p, array('section' => $this->sections[$sName])); //var_dump($entries[$id]['tags'], $tagName); if (!$tagName && ($this->environment == 'engine' || !$entries[$id]['tags']) || $tagName && isset($entries[$id]['tags'][$tagName])) { $entriesForTag[$id] = $entries[$id]; } } else { unset($this->content['entry'][$idx]); $haveToSave = true; } } } if ($haveToSave && class_exists('BertaEditor')) { //echo dirname(__FILE__) . '/class.bertaeditor.php'; //include_once dirname(__FILE__) . 'class.bertaeditor.php'; BertaEditor::saveBlog($this->sectionName, $this->content); } return array($entries, $entriesForTag); }
private function getEntriesLists($sName, $tagName, &$content) { $haveToSave = false; $entries = array(); $entriesForTag = array(); if (!empty($content['entry'])) { foreach ($content['entry'] as $idx => $p) { if ((string) $idx == '@attributes') { continue; } if (!empty($p['id']) && !empty($p['id']['value']) && !empty($p['uniqid']) && !empty($p['uniqid']['value']) && !empty($p['mediafolder']) && !empty($p['mediafolder']['value'])) { $id = $p['id']['value']; $entries[$id] = BertaTemplate::entryForTemplate($p, array('section' => $this->sections[$sName])); if (!$tagName && !$entries[$id]['tags'] || $tagName && isset($entries[$id]['tags'][$tagName])) { $entriesForTag[$id] = $entries[$id]; } } else { unset($this->content['entry'][$idx]); $haveToSave = true; } } } if ($haveToSave && class_exists('BertaEditor')) { BertaEditor::saveBlog($this->sectionName, $this->content); } return array($entries, $entriesForTag); }
if($firstEntryStarts !== false) // if an existing entry is found, then insert the new one before it $xmlStr = substr($xmlStr, 0, $firstEntryStarts) . $insertXML . substr($xmlStr, $firstEntryStarts); else // otherwise - assume the new one will be the first entry $xmlStr = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . "<blog>\n{$insertXML}</blog>"; file_put_contents($fileName, $xmlStr); @chmod($fileName, 0666); } else { $xmlStr = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . "<blog>\n{$insertXML}</blog>"; file_put_contents($fileName, $xmlStr); @chmod($fileName, 0666); } $blog = BertaEditor::loadBlog($decoded['section']); BertaEditor::updateSectionEntryCount($decoded['section'], $blog); $returnUpdate['mediafolder'] = $mediafolder; $returnUpdate['entryid'] = $entryId; } } else { $returnError = 'cannot create media folder! check permissions.'; } } ?>
public static function updateImageCacheFor(&$blog, $entryId = false) { if (!empty($blog['entry'])) { foreach ($blog['entry'] as $eId => $e) { if ((string) $eId == '@attributes') { continue; } if (!$entryId || !empty($e['id']['value']) && $entryId == $e['id']['value']) { $mediaFiles = array(); if (!empty($e['mediafolder']['value'])) { $mediaFiles = BertaEditor::gatherMediaFilesIn($e['mediafolder']['value']); } //var_dump($mediaFiles); if ($mediaFiles) { $entryCache =& $blog['entry'][$eId]['mediaCacheData']; if (!count($entryCache) || empty($entryCache['file'])) { // if the media cache is empty, create a fresh array $mediaCacheData = array('file' => array()); if (isset($blog['entry'][$eId]['mediaCacheData'])) { $mediaCacheData = array_merge($blog['entry'][$eId]['mediaCacheData'], $mediaCacheData); } $blog['entry'][$eId]['mediaCacheData'] = $mediaCacheData; $entryCache =& $blog['entry'][$eId]['mediaCacheData']; foreach ($mediaFiles as $im) { $attr = array('type' => $im['type'], 'src' => $im['src']); if (!empty($im['poster_frame'])) { $attr['poster_frame'] = $im['poster_frame']; } if (!empty($im['width'])) { $attr['width'] = $im['width']; } if (!empty($im['height'])) { $attr['height'] = $im['height']; } $entryCache['file'][] = array('value' => '', '@attributes' => $attr); } // if moving from an older version of XML unset($entryCache['images']); unset($entryCache['videos']); //echo "\n\n-----\n\n"; var_dump($entryCache); } else { Array_XML::makeListIfNotList($entryCache['file']); //echo "\n\n-----\n\n"; var_dump($entryCache); // first check if all items in cache are still inside the folder foreach ($entryCache['file'] as $cacheIndex => $cacheIm) { // try to find the entry among the files in the folder $foundIndex = false; foreach ($mediaFiles as $i => $im) { // *** compatibility with versions <= 0.5.5b $isFromOldVersion = empty($cacheIm['@attributes']['src']); $srcFromCache = $isFromOldVersion ? $cacheIm['value'] : $cacheIm['@attributes']['src']; // if image found in cache, update cache entry if ($srcFromCache == $im['src']) { $foundIndex = true; $entry = array('@attributes' => array()); if (!$isFromOldVersion) { $entry['value'] = !empty($cacheIm['value']) ? $cacheIm['value'] : ''; } if (!empty($cacheIm['@attributes'])) { $entry['@attributes'] = $cacheIm['@attributes']; } $entry['@attributes']['src'] = $im['src']; $entry['@attributes']['type'] = $im['type']; if (!empty($im['poster_frame'])) { $entry['@attributes']['poster_frame'] = $im['poster_frame']; } if (!empty($im['width'])) { $entry['@attributes']['width'] = $im['width']; } if (!empty($im['height'])) { $entry['@attributes']['height'] = $im['height']; } $entryCache['file'][$cacheIndex] = $entry; unset($mediaFiles[$i]); break; } } // if the file was not found in the folder, delete the entry if (!$foundIndex) { unset($entryCache['file'][$cacheIndex]); } } // loop through the rest of real files and add them to cache foreach ($mediaFiles as $im) { $attr = array('type' => $im['type'], 'src' => $im['src']); if (!empty($im['poster_frame'])) { $attr['poster_frame'] = $im['poster_frame']; } if (!empty($im['width'])) { $attr['width'] = $im['width']; } if (!empty($im['height'])) { $attr['height'] = $im['height']; } $entryCache['file'][] = array('value' => '', '@attributes' => $attr); } //echo "\n\n-----\n\n"; var_dump($entryCache); // compact arrays $entryCache['file'] = array_values($entryCache['file']); // if moving from an older version of XML unset($entryCache['images']); unset($entryCache['videos']); //echo "\n\n-----\n\n"; var_dump($entryCache); } } else { $mediaCacheData = array('file' => array()); if (isset($blog['entry'][$eId]['mediaCacheData'])) { $mediaCacheData = array_merge($blog['entry'][$eId]['mediaCacheData'], $mediaCacheData); } $blog['entry'][$eId]['mediaCacheData'] = $mediaCacheData; } } } } }
echo I18n::_('What are sections?'); ?> </div> <div class="value value-long"> <?php echo I18n::_('sections_help_text'); ?> </div> </div> <div class="entry"> <div class="caption"><?php echo I18n::_('What is the "external link"?'); ?> </div> <div class="value value-long"> <?php echo I18n::_('external_link_help_text'); ?> </div> </div> <br class="clear" /> <p> </p> </div> </div> </div> <?php echo BertaEditor::intercomScript(); ?> </body> </html>
<?php define('AUTH_AUTHREQUIRED', true); define('BERTA_ENVIRONMENT', 'engine'); include 'inc.page.php'; if ($options['HOSTING_PROFILE']) { header('location:' . $options['HOSTING_PROFILE']); exit; } $loggedIn = $berta->security->userLoggedIn; include_once $ENGINE_ROOT . '_classes/class.bertaeditor.php'; $allSections = BertaContent::getSections(); $topPanelHTML = BertaEditor::getTopPanelHTML('profile'); $int_version = BertaEditor::$options['int_version']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo $berta->settings->get('texts', 'pageTitle'); ?> / <?php echo I18n::_('Profile'); ?> </title> <link rel="SHORTCUT ICON" href="favicon.ico"/> <link rel="stylesheet" href="<?php echo $ENGINE_ABS_ROOT; ?> css/backend.min.css?<?php
echo '<li class="video" filename="' . (string) $im['@attributes']['src'] . '" fileinfo="' . '' . '">'; echo '<div class="placeholderContainer" style="background-image: ' . ($imageThumbSrc ? ('url(' . $imageThumbSrc . '?no_cache=' . rand() . ')') : 'none') . '; width: ' . $imageWidth . ';"><div class="placeholder"></div></div>'; echo '<span class="grabHandle xMAlign-container"><span class="xMAlign-outer"><a class="xMAlign-inner" title="click and drag to move"><span></span></a></span></span>'; echo '<a href="#" class="delete"></a>'; echo '<div class="dimsForm">' . '<div class="posterContainer"></div><a class="poster" href="#">' . ($imageThumbSrc ? 'change' : 'upload') . ' poster frame</a>' . /*'<span class="dim" property="width" x_params="' . $im['value'] . '">' . (!empty($im['@attributes']['width']) ? $im['@attributes']['width'] : BertaEditor::getXEmpty('width')) . '</span> x ' . '<span class="dim" property="height" x_params="' . $im['value'] . '">' . (!empty($im['@attributes']['height']) ? $im['@attributes']['height'] : BertaEditor::getXEmpty('height')) . '</span>' . */ '</div>'; echo '<div class="xEGEImageCaption ' . $xEditSelectorMCESimple . ' xProperty-galleryImageCaption xCaption-caption xParam-' . $im['@attributes']['src'] . '">', !empty($im['value']) ? $im['value'] : '', '</div>'; echo '</li>'; echo "\n"; } else { $imSrc = $options['MEDIA_ROOT'] . $entry['mediafolder']['value'] . '/' . (string) $im['@attributes']['src']; $imageThumbSrc = BertaEditor::images_getSmallThumbFor($imSrc); if($imageThumbSrc) { echo '<li filename="' . (string) $im['@attributes']['src'] . '" fileinfo="' . '' . '">'; echo '<img class="img" src="' . $imageThumbSrc . '" />'; echo '<span class="grabHandle xMAlign-container"><span class="xMAlign-outer"><a class="xMAlign-inner" title="click and drag to move"><span></span></a></span></span>'; echo '<a href="#" class="delete"></a>'; echo '<div class="xEGEImageCaption ' . $xEditSelectorMCESimple . ' xProperty-galleryImageCaption xCaption-caption xParam-' . $im['@attributes']['src'] . '">', !empty($im['value']) ? $im['value'] : '', '</div>'; echo '</li>'; } } } } else { //echo '<li class="placeholder"><img src="' . $ENGINE_ROOT . 'layout/gallery-placeholder.gif" /></li>'; }
$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 { // update image cache $blog = BertaEditor::loadBlog($sectionName); BertaEditor::updateImageCacheFor($blog, $entryId); BertaEditor::saveBlog($sectionName, $blog); } // write response $result['status'] = 1; $result['hash'] = md5_file($fileFolder . $fName); $result['type'] = $fileType; // image $result['smallthumb_path'] = $smallThumbPath; $result['smallthumb_width'] = $smallThumbInfo[0]; $result['smallthumb_height'] = $smallThumbInfo[1]; $result['path'] = $fileFolder . $fName; $result['path_orig'] = $fileFolder . $fName; //$origVersionPath; $result['filename'] = $fName; $result['size'] = $_FILES['Filedata']['size']; $result['width'] = $imInfo[0];