// check if the maximum allowed amount of emtpy entries hasnt been reached
		//$maxEmptyEntriesAllowed = (int) $berta->settings->get('pageLayout', 'numEmptyEntriesAllowed');
		//if(!$maxEmptyEntriesAllowed) $maxEmptyEntriesAllowed = 3;
		$maxEmptyEntriesAllowed = 2;
		if($numEmptyEntries >= $maxEmptyEntriesAllowed) {
			$returnError = "hey, don't add too many empty entries in this section. you are allowed to create only $maxEmptyEntriesAllowed empty entries.\n\nnow please fill in some content!";
		} else {
		
			// entry basic params
			$entryId = $maxId + 1;
			$uniqId = uniqid();
			$date = date('d.m.Y H:i:s');
			$tags = '<tag/>';
			if(!empty($decoded['tag'])) {
				$allTags = BertaEditor::getTags();
				if(!empty($allTags[$decoded['section']][$decoded['tag']])) $tags = '<tag><![CDATA[' . $allTags[$decoded['section']][$decoded['tag']]['title'] . ']]></tag>'; 
			}
	
			// create xml entry
			$insertXML = <<<EOT
<entry>
	<id>{$entryId}</id>
	<uniqid>{$uniqId}</uniqid>
	<date><![CDATA[{$date}]]></date>
	<tags>{$tags}</tags>
	<content>
		<title/>
		<url/>
		<description/>
	</content>
Example #2
0
 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;
 }
            $newBlog = BertaEditor::loadBlog($sNewName);
            //rename mediafolders and attributes
            if ($newBlog) {
                $newBlog['@attributes']['section'] = $sNewName;
                if (isset($newBlog['entry'])) {
                    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) {
Example #4
0
 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;
 }