function smarty_function_selectMarkedEntries($params, &$smarty) { global $berta; $settings = $berta->template->settings; $count = !empty($params['count']) ? $params['count'] : 1000; $order = !empty($params['order']) ? $params['order'] : 'random'; $return = array(); foreach($berta->sections as $sName => $s) { if($sName != $berta->sectionName) { $entries = BertaContent::loadBlog($sName); if(!empty($entries['entry'])) { foreach($entries['entry'] as $idx => $e) { if($idx === '@attributes') continue; if(!empty($e['marked']['value'])) { $e['__section'] = $berta->sections[$sName]; array_push($return, $e); } } } } } if($order == 'random') { shuffle($return); } if(count($return) > $count) { $return = array_slice($return, 0, $count); } $returnFinal = array(); reset($return); while(list($i, $p) = each($return)) { if(!empty($p['id']) && !empty($p['id']['value']) && !empty($p['uniqid']) && !empty($p['uniqid']['value']) && !empty($p['mediafolder']) && !empty($p['mediafolder']['value'])) { $returnFinal[$p['uniqid']['value']] = BertaTemplate::entryForTemplate($p, array('section' => $p['__section'])); } } if(!empty($params['assign'])) { $berta->template->addVariable($params['assign'], $returnFinal); } else { return $returnFinal; } }
public function initContent($full_url, $sectionName, $tagName) { $this->requestURI = $this->apacheRewriteUsed ? $full_url : false; // seciton ... $this->sections = BertaContent::getSections(); if (!$sectionName || empty($this->sections[$sectionName])) { if ($this->environment == 'engine') { list($sectionName, ) = each($this->sections); } else { foreach ($this->sections as $sName => $s) { if (!empty($s['@attributes']['published'])) { $sectionName = $sName; break; } } } } $this->sectionName = $sectionName; // content ... $this->content = BertaContent::loadBlog($sectionName); $this->allContent = array($this->sectionName => $this->content); //var_dump($this->sectionName, $this->sections[$this->sectionName]['get_all_entries_by_section']); if (!empty($this->sections[$this->sectionName]['get_all_entries_by_section']) && $this->sections[$this->sectionName]['get_all_entries_by_section']['value'] == 'yes') { foreach ($this->sections as $sName => $s) { if ($this->sectionName != $sName) { $this->allContent[$sName] = BertaContent::loadBlog($sName); } } } //BertaEditor::populateSubSections($this->sectionName, $this->content); // subsections ... $this->tags = BertaContent::getTags(); $this->tagName = $tagName; if (!isset($this->tags[$this->sectionName][$this->tagName])) { $this->tagName = false; } // in the engine mode one can view all entries for a section, even if the section has subsections // but in the front-ends mode, if there are subsections, the first of them is automatically selected. if ($this->environment != 'engine' && !empty($this->tags[$this->sectionName]) && empty($this->tagName) && empty($this->sections[$this->sectionName]['@attributes']['has_direct_content']) && $this->settings->get('navigation', 'alwaysSelectTag') == 'yes') { $this->tagName = reset(array_keys($this->tags[$this->sectionName])); } // tags .... /*$this->tags = BertaContent::getTags($sectionName); //asort($this->tags); $this->tagName = $tagName; if(!isset($this->tags[$this->tagName])) $this->tagName = false;*/ // template ... $this->template->addContent($this->requestURI, $this->sectionName, $this->sections, $this->tagName, $this->tags, $this->content, $this->allContent); }
header('Content-Type: text/plain; charset=utf8'); $jsonRequest = !empty($_REQUEST['json']) ? stripslashes($_REQUEST['json']) : false; if($jsonRequest) { //var_dump($_REQUEST); //echo str_replace(array("\n", "\r"), array('\n', ''), $jsonRequest) . "\n\n"; $decoded = $result = Zend_Json::decode(str_replace(array("\n", "\r"), array('\n', ''), $jsonRequest)); // var_dump($decoded); switch($decoded['property']) { case 'gallery': if($decoded['section'] && $decoded['entry']) { $blog = BertaContent::loadBlog($decoded['section']); $entry = BertaContent::getEntry($decoded['entry'], $blog); echo BertaGallery::getHTMLForEntry($entry, true); } break; case 'galleryEditor': if($decoded['section'] && $decoded['entry']) { $blog = BertaEditor::loadBlog($decoded['section']); $entry = BertaEditor::getEntry($decoded['entry'], $blog);
} while (file_exists($fName)); $emptyXML = '<?xml version="1.0" encoding="utf-8"?><blog></blog>'; if (!@file_put_contents($fName, $emptyXML)) { $returnError = 'section cannot be created! the storage file cannot be created. check permissions and be sure the name of the section is not TOO fancy.'; } else { @chmod($fName, 0666); $published = 1; $sectionsList = BertaEditor::getSections(); if ($isClone) { $cloneSection = $sectionsList[$decoded['cloneSection']]; $published = $cloneSection['@attributes']['published']; $cloneSection['name'] = $sName; $cloneSection['title'] = $sTitle; unset($cloneSection['positionXY']); $sectionsList[$sName] = $cloneSection; $cloneContent = BertaContent::loadBlog($decoded['cloneSection']); if ($cloneContent) { $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']); } }