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 static function getSettingsItemEditHTML($property, $sDef, $value, $additionalParams = null, $tag = 'div') { global $editsForSettings; $pStr = ''; if ($additionalParams) { foreach ($additionalParams as $pN => $p) { $pStr .= $pN . (!is_null($p) ? '-' . $p : '') . ' '; } } $html = ''; if (!empty($sDef['html_before'])) { $html .= $sDef['html_before']; } $html .= '<' . $tag . ' class="value ' . (!empty($editsForSettings[$sDef['format']]) ? $editsForSettings[$sDef['format']] : '') . ' ' . 'xProperty-' . $property . ' ' . (empty($sDef['html_entities']) ? 'xNoHTMLEntities' : '') . ' ' . 'xCSSUnits-' . (empty($sDef['css_units']) ? '0' : '1') . ' ' . 'xRequired-' . (!empty($sDef['allow_blank']) ? '0' : '1') . ' ' . (!empty($sDef['validator']) ? 'xValidator-' . $sDef['validator'] . ' ' : '') . $pStr . '" title="' . htmlspecialchars($sDef['default']) . '"'; if ($sDef['format'] == 'select' || $sDef['format'] == 'fontselect') { $values = array(); if ($sDef['values'] == 'templates') { $values = BertaTemplate::getAllTemplates(); } else { // var_dump($sDef['values']); foreach ($sDef['values'] as $vK => $vV) { $values[$vK] = is_string($vK) ? $vK . '|' . $vV : $vV; } } $html .= ' x_options="' . htmlspecialchars(implode('||', $values)) . '"'; $value = isset($values[$value]) ? $sDef['values'][$value] : $value; } $html .= '>'; $html .= $value . '</' . $tag . '>'; if (!empty($sDef['html_after'])) { $html .= $sDef['html_after']; } return $html; }
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); }