foreach ($newBlog['entry'] as $k => $entry) { if (isset($entry['mediafolder']['value'])) { if (@rename($options['MEDIA_ROOT'] . '/' . $entry['mediafolder']['value'], $options['MEDIA_ROOT'] . '/' . $sNewName . $entry['id']['value'])) { $newBlog['entry'][$k]['mediafolder'] = $sNewName . $entry['id']['value']; } } } } } BertaEditor::saveBlog($sNewName, $newBlog); $ssArr = BertaEditor::getTags(); if (isset($ssArr[$sName])) { $ssArr[$sNewName] = $ssArr[$sName]; unset($ssArr[$sName]); } BertaEditor::saveTags($ssArr); BertaEditor::populateTags($sNewName, $newBlog); } } } else { if ($property == 'type') { // section external link $sectionsList = BertaEditor::getSections(); $returnUpdate = $returnReal = trim($decoded['value']); $sName = $decoded['section']; foreach ($sectionsList as $sN => $s) { if ((string) $sN === $sName) { $sectionsList[$sN]['@attributes']['type'] = $returnUpdate; if (!empty($berta->template->sectionTypes)) { foreach ($berta->template->sectionTypes as $sT => $sTParams) { if ($returnUpdate == $sT) {
public static function populateTags($sectionName, &$blog) { $tagsArr = BertaEditor::getTags(); $newCache = array(); $allHaveTags = true; if (!empty($blog['entry'])) { foreach ($blog['entry'] as $eId => $e) { if ($eId === '@attributes') { continue; } //echo '<p>'; print_r($e['subsections']); $hasTags = false; if (isset($e['tags'])) { Array_XML::makeListIfNotList($e['tags']['tag']); foreach ($e['tags']['tag'] as $t) { if ($tName = trim((string) $t['value'])) { $tName = strtolower(BertaUtils::canonizeString($tName, '-', '-')); $c = isset($newCache[$tName]) ? $newCache[$tName]['entry_count'] : 0; $newCache[$tName] = array('title' => $t['value'], 'entry_count' => ++$c); $hasTags = true; } } } $allHaveTags &= $hasTags; } } $tagsArr[$sectionName] = $newCache; // update direct content property $sectionsList = BertaEditor::getSections(); if (!empty($sectionsList[$sectionName])) { if (empty($sectionsList[$sectionName]['@attributes'])) { $sectionsList[$sectionName]['@attributes'] = array(); } $sectionsList[$sectionName]['@attributes']['has_direct_content'] = !$allHaveTags ? '1' : '0'; } BertaEditor::saveSections($sectionsList); // save subsections list BertaEditor::saveTags($tagsArr, $sectionsList); return $tagsArr; }
$newSectionTags = array(); foreach ($currentSectionTags as $tName => $t) { $hasTags = true; if ($tName == $decoded['value']) { $newSectionTags[$decoded['tag']] = $movedTag; $tagPut = true; } if ($tName != $decoded['tag']) { $newSectionTags[$tName] = $t; } } if ($hasTags && !$tagPut) { $newSectionTags[$decoded['tag']] = $movedTag; } $tags[$decoded['section']] = $newSectionTags; BertaEditor::saveTags($tags); } else { // section property include 'update/inc.update.sections_editor.php'; } } } } } else { if ($decoded['action'] != 'SAVE') { // parse global actions (which require no section) switch ($decoded['action']) { case 'RECREATE_MEDIA_CACHE': $sections = BertaEditor::getSections(); if (is_array($sections)) { foreach ($sections as $sName => $sTitle) {
public static function populateTags($sectionName, &$blog) { $tagsArr = BertaEditor::getTags(); $newCache = array(); $allHaveTags = true; if (isset($blog['entry']) && !empty($blog['entry'])) { foreach ($blog['entry'] as $eId => $e) { if ($eId === '@attributes') { continue; } $hasTags = false; if (isset($e['tags'])) { Array_XML::makeListIfNotList($e['tags']['tag']); foreach ($e['tags']['tag'] as $t) { if ($tName = trim((string) $t['value'])) { $tName = strtolower(BertaUtils::canonizeString($tName, '-', '-')); $c = isset($newCache[$tName]) ? $newCache[$tName]['entry_count'] : 0; $newCache[$tName] = array('title' => $t['value'], 'entry_count' => ++$c); $hasTags = true; } } } $allHaveTags &= $hasTags; } } //to keep sorting order, we need to check old and new tag arrays //loop through old and check if exists and update, else do not add $tempCache = array(); if (isset($tagsArr[$sectionName])) { foreach ($tagsArr[$sectionName] as $tag => $tagVars) { if (isset($newCache[$tag])) { $tempCache[$tag] = $newCache[$tag]; } } } //loop through new and check if exists, if not - add at bottom foreach ($newCache as $tag => $tagVars) { if (!isset($tagsArr[$sectionName][$tag])) { $tempCache[$tag] = $tagVars; } } $tagsArr[$sectionName] = $tempCache; // update direct content property $sectionsList = BertaEditor::getSections(); if (!empty($sectionsList[$sectionName])) { if (empty($sectionsList[$sectionName]['@attributes'])) { $sectionsList[$sectionName]['@attributes'] = array(); } $sectionsList[$sectionName]['@attributes']['has_direct_content'] = !$allHaveTags ? '1' : '0'; } BertaEditor::saveSections($sectionsList); // save subsections list BertaEditor::saveTags($tagsArr, $sectionsList); return $tagsArr; }