$cloneSectionName = isset($cloneContent['@attributes']['section']) ? $cloneContent['@attributes']['section'] : $sName; $cloneContent['@attributes']['section'] = $sName; if (isset($cloneContent['entry'])) { foreach ($cloneContent['entry'] as $k => $entry) { $cloneContent['entry'][$k]['uniqid'] = uniqid(); $cloneContent['entry'][$k]['date'] = date('d.m.Y H:i:s'); $cloneContent['entry'][$k]['updated'] = date('d.m.Y H:i:s'); if (isset($entry['mediafolder'])) { $cloneMediafolder = $entry['mediafolder']['value']; $cloneContent['entry'][$k]['mediafolder'] = str_replace($cloneSectionName, $sName, $cloneMediafolder); //clone media folder BertaUtils::copyFolder(realpath($options['MEDIA_ROOT']) . '/' . $cloneMediafolder, realpath($options['MEDIA_ROOT']) . '/' . $cloneContent['entry'][$k]['mediafolder']); } } } BertaEditor::saveBlog($sName, $cloneContent); } } $possibleTypes = 'default|Default'; $typeParams = array(); if (!empty($berta->template->sectionTypes)) { $possibleTypes = array(); foreach ($berta->template->sectionTypes as $sT => $sTParams) { $possibleTypes[] = "{$sT}|{$sTParams['title']}"; if (!empty($sTParams['params'])) { $typeParams[$sT] = $sTParams['params']; } } $possibleTypes = implode('||', $possibleTypes); } $allTypes = array();
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); } } }
$newEntriesList[] = $ie; } } if($hasEntries && !$entryPut) $newEntriesList[] = $e; $blog['entry'] = $newEntriesList; // var_dump($blog['entry']); } } else { // all other properties go straight forward into the xml if(empty($e['content'])) $e['content'] = array(); $e['content'][$decoded['property']] = trim($returnReal) ? array('value' => $returnReal) : NULL; $allowFormatModifier = true; } $e['updated'] = array('value' => date('d.m.Y H:i:s')); BertaEditor::saveBlog($decoded['section'], $blog); if($decoded['property'] == 'tags') BertaEditor::populateTags($decoded['section'], $blog); } else if($decoded['action'] == 'CREATE_NEW_ENTRY') { // create new entry on the spot $returnUpdate['entrynum'] = count($blog['entry']) + (isset($blog['@attributes']) ? -1 : 0); } else if($decoded['action'] == 'ORDER_ENTRIES') { // apply the new order //print_r($blog['entry']); $blog = BertaEditor::loadBlog($decoded['section']); $newEntriesList = array(); foreach($decoded['value'] as $oIdx => $oId) { $newEntriesList[$oIdx] = BertaEditor::getEntry($oId, $blog); }
} } // 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); } }
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); }
$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];