<?php include_once '_classes/class.bertaeditor.php'; $sections = BertaEditor::getSections(); if (is_array($sections)) { foreach ($sections as $sName => $sTitle) { $blog = BertaEditor::loadBlog($sName); if ($blog) { // ------- ... // updates ... if (empty($blog['@attributes']['version']) && $blog['@attributes']['version'] != $options['version']) { $ver = array(0, 5, 0); if (!empty($blog['@attributes']['version'])) { $ver = explode('.', $blog['@attributes']['version']); } // "updated" field for all entries if ($ver[1] < 6) { BertaEditor::setUpdateTimesForAll($blog); } if ($ver[1] = 6 && $ver[2] < 6) { // replace files with their _orig_ versions. BertaEditor::updateImageCacheFor($blog); foreach ($blog['entry'] as $eId => $e) { if ((string) $eId == '@attributes') { continue; } $mFolder = Berta::$options['MEDIA_ROOT'] . $e['mediafolder']['value'] . '/'; $entryCache =& $blog['entry'][$eId]['mediaCacheData']; if (count($entryCache)) { Array_XML::makeListIfNotList($entryCache['file']); foreach ($entryCache['file'] as $cacheIndex => $cacheIm) {
BertaEditor::saveSections($sectionsList); if ($isClone) { BertaEditor::populateTags($sName, $cloneContent); } } } else { if ($decoded['action'] == 'DELETE_SECTION') { // 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.'; } } } } } }
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; }
public static function updateSectionEntryCount($sectionName, &$blog) { $numEntries = !empty($blog['entry']) ? count($blog['entry']) : 0; $sectionsList = BertaEditor::getSections(); if (!empty($sectionsList[$sectionName])) { if (empty($sectionsList[$sectionName]['@attributes'])) { $sectionsList[$sectionName]['@attributes'] = array(); } $sectionsList[$sectionName]['@attributes']['entry_count'] = $numEntries; } BertaEditor::saveSections($sectionsList); }
// 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 { // update image cache $blog = BertaEditor::loadBlog($sectionName); BertaEditor::updateImageCacheFor($blog, $entryId); BertaEditor::saveBlog($sectionName, $blog); } // write response