/** * Constructor.<br /> * Required for all subclasses.<br /> * Should be called from each subclass as the very first. * @param object &$content_obj - the content object instance that creates the contentblock * @param array $params - the parameters of that contentblock */ function __construct(&$content_obj, &$params = array()) { $this->content_obj = $content_obj; $AdvancedContent =& cms_utils::get_module('AdvancedContent'); $this->_block_properties['smarty'] = isset($params['smarty']) ? $params['smarty'] : false; $this->_block_properties['editor_groups'] = isset($params['editor_groups']) ? $params['editor_groups'] : ''; $this->_block_properties['editor_users'] = isset($params['editor_users']) ? $params['editor_users'] : ''; $this->_block_properties['type'] = isset($params['block_type']) ? $params['block_type'] : ''; $this->_block_properties['name'] = isset($params['block']) ? $params['block'] : 'content_en'; $this->_block_properties['id'] = preg_replace('/-+/', '_', munge_string_to_url($this->_block_properties['name'])); $this->_block_properties['label'] = isset($params['label']) ? $params['label'] : ucwords($this->_block_properties['name']); $this->_block_properties['translate_labels'] = isset($params['translate_labels']) && $this->content_obj->IsTrue($params['translate_labels']); $this->_block_properties['translate_values'] = isset($params['translate_values']) && $this->content_obj->IsTrue($params['translate_values']); $this->_block_properties['required'] = isset($params['required']) && $this->content_obj->IsTrue($params['required']); $this->_block_properties['default'] = isset($params['default']) ? $params['default'] : ''; $this->_block_properties['style'] = isset($params['style']) ? $params['style'] : ''; # deprecated $this->_block_properties['page_tab'] = isset($params['page_tab']) ? $params['page_tab'] : 'main'; $this->_block_properties['block_tab'] = isset($params['block_tab']) ? $params['block_tab'] : ''; $this->_block_properties['block_group'] = isset($params['block_group']) ? $params['block_group'] : ''; $this->_block_properties['allow_none'] = !(isset($params['allow_none']) && $this->content_obj->IsFalse($params['allow_none'])); $this->_block_properties['description'] = isset($params['description']) ? $params['description'] : ''; $this->_block_properties['no_collapse'] = isset($params['no_collapse']) && $this->content_obj->IsTrue($params['no_collapse']); $this->_block_properties['collapsible'] = !$this->_block_properties['no_collapse']; if (!$this->_block_properties['collapsible']) { $this->_block_properties['collapse'] = false; } else { $this->_block_properties['collapse'] = isset($params['collapse']) ? !$this->content_obj->IsFalse($params['collapse']) : $AdvancedContent->GetPreference('collapse_block_default', true); } $this->_block_properties['feu_access'] = isset($params['feu_access']) ? $params['feu_access'] : ''; $this->_block_properties['feu_action'] = isset($params['feu_action']) && $this->content_obj->IsTrue($params['feu_action']); $this->_block_properties['feu_hide'] = isset($params['feu_hide']) && $this->content_obj->IsTrue($params['feu_hide']); #$this->_block_properties['inherit'] = (isset($params['inherit']) && $this->content_obj->IsTrue($params['inherit'])); }
/** * Not part of the api */ private function _get_items_array($selItems = array()) { $AdvancedContent =& cms_utils::get_module('AdvancedContent'); $items = array(); if ($this->GetBlockProperty('items') != '') { foreach (explode($this->GetBlockProperty('delimiter'), $this->GetBlockProperty('items')) as $key => $val) { $items[$key]['id'] = munge_string_to_url(trim($val)); $items[$key]['label'] = trim($val); if ($this->GetBlockProperty('translate_labels')) { $items[$key]['label'] = $AdvancedContent->lang($items[$key]['label']); } $items[$key]['value'] = $items[$key]['label']; $items[$key]['selected'] = in_array($items[$key]['label'], $selItems); } } if ($this->GetBlockProperty('values') != '') { foreach (explode($this->GetBlockProperty('delimiter'), $this->GetBlockProperty('values')) as $key => $val) { $items[$key]['value'] = trim($val); if ($this->GetBlockProperty('translate_values')) { $items[$key]['value'] = $AdvancedContent->lang($items[$key]['value']); } $items[$key]['selected'] = in_array($items[$key]['value'], $selItems); if (!isset($items[$key]['label'])) { $items[$key]['label'] = $items[$key]['value']; } } } return $items; }
public function __get($key) { $fielddefs = news_ops::get_fielddefs(FALSE); switch ($key) { case 'alias': $alias = munge_string_to_url($this->name); return $alias; case 'id': case 'name': case 'type': case 'max_length': case 'create_date': case 'modified_date': case 'item_order': case 'public': case 'value': if (isset($this->_data[$key])) { return $this->_data[$key]; } break; case 'extra': if (isset($this->_data['extra'])) { if (!is_array($this->_data['extra'])) { $this->_data['extra'] = unserialize($this->_data['extra']); } return $this->_data['extra']; } break; case 'options': $extra = $this->extra; if (is_array($extra) && isset($extra['options'])) { return $extra['options']; } break; case 'displayvalue': if (!$this->_displayvalue) { if (isset($this->_data['value'])) { $value = $this->_data['value']; $this->_displayvalue = $value; if ($this->type == 'dropdown') { // dropdowns may have a different displayvalue than actual value. if (is_array($this->options) && isset($this->options[$value])) { $this->_displayvalue = $this->options[$value]; } } } } return $this->_displayvalue; break; case 'fielddef_id': return $this->_data['id']; } }
private function _get_canonical() { if (!isset($this->_meta['canonical'])) { $tmp = $this->news_url; if ($tmp == '') { $aliased_title = munge_string_to_url($this->title); $tmp = 'news/' . $this->id . '/' . $this->returnid . "/{$aliased_title}"; } $mod = cms_utils::get_module('News'); $canonical = $mod->create_url($this->_inid, 'detail', $this->returnid, $this->params, false, false, $tmp); $this->_meta['canonical'] = $canonical; } return $this->_meta['canonical']; }
public function __get($key) { switch ($key) { case 'alias': $alias = munge_string_to_url($this->name); return $alias; case 'id': case 'name': case 'type': case 'max_length': case 'create_date': case 'modified_date': case 'item_order': case 'public': case 'value': return $this->_data[$key]; } }
/** * A utility function to test if the supplied url path is valid for the supplied content id * * @param string The partial url path to test * @return boolean */ public static function is_valid_url($url, $content_id = '') { // check for starting or ending slashes if (startswith($url, '/') || endswith($url, '/')) { return FALSE; } // first check for invalid chars. $translated = munge_string_to_url($url, false, true); if (strtolower($translated) != strtolower($url)) { return FALSE; } cms_route_manager::load_routes(); $route = cms_route_manager::find_match($url); if (!$route) { return TRUE; } if ($route->is_content()) { if ($content_id == '' || $route->get_content() == $content_id) { return TRUE; } } return FALSE; }
# #------------------------------------------------------------------------------- if (!is_object(cmsms())) { exit; } if (!$this->CheckPermission('Manage AdvancedContent MultiInputs')) { return $this->DisplayErrorPage($id, $returnid, $this->Lang('error_permissions')); } if (isset($params['cancel'])) { $this->Redirect($id, 'defaultadmin', $returnid, array('active_tab' => 'multi_input')); } $error = false; $errormessage = ''; $input_id = ''; if (isset($params['input_id']) && !empty($params['input_id'])) { $input_id = preg_replace('/-+/', '_', munge_string_to_url(trim($params['input_id']))); } $multi_input = ac_admin_ops::GetMultiInputFull($input_id); if (isset($params['input_fields'])) { $multi_input[$input_id]['input_fields'] = trim($params['input_fields']); } if (isset($params['input_tpl'])) { $multi_input[$input_id]['tpl_name'] = $params['input_tpl']; } ### do action ################################################################## if (isset($params['submit'])) { if ($input_id == '') { $error = true; $errormessage .= $this->lang('error_input_id') . '<br />'; } if ($multi_input[$input_id]['input_fields'] == '') {
$module->SetError($this->Lang('error_missingparam')); $module->RedirectToTab($id, $this->_current_tab, '', $the_action); return; } if (isset($params['cancel'])) { $module->_current_tab = $this->_current_tab; $module->RedirectToTab($id, $this->_current_tab, '', $the_action); } $template = ""; if (isset($params['template'])) { $template = trim($params['template']); if ($template == '' || !preg_match('/^[a-zA-Z0-9\\_]+$/', $template)) { $module->SetError($this->Lang('error_templatenamebad')); $module->RedirectToTab($id, $this->_current_tab, '', $the_action); } $template = munge_string_to_url(trim($template)); } $prefix = ""; if (isset($params['prefix'])) { $prefix = trim($params['prefix']); } if (!isset($params['templatecontent']) || empty($params['templatecontent'])) { $module->SetError($this->Lang('error_missingparam')); $module->RedirectToTab($id, $this->_current_tab, '', $the_action); return; } if ($template == "" || $prefix == "") { $module->SetError($this->Lang('error_missingparam')); $module->RedirectToTab($id, $this->_current_tab, '', $the_action); return; }
# #------------------------------------------------------------------------------- if (!is_object(cmsms())) { exit; } if (!$this->CheckPermission('Manage AdvancedContent MultiInput Templates')) { return $this->DisplayErrorPage($id, $returnid, $this->Lang('error_permissions')); } if (isset($params['cancel'])) { $this->Redirect($id, 'defaultadmin', $returnid, array('active_tab' => 'multi_input_tpl')); } $error = false; $errormessage = ''; $tpl_name = ''; if (isset($params['tpl_name']) && !empty($params['tpl_name'])) { $tpl_name = preg_replace('/-+/', '_', munge_string_to_url(trim($params['tpl_name']))); } $template = ''; if (isset($params['template'])) { $template = trim($params['template']); } ### do action ################################################################## if (isset($params['submit'])) { if ($tpl_name == '') { $error = true; $errormessage .= $this->lang('error_tpl_name') . '<br />'; } if ($template == '') { $error = true; $errormessage .= $this->lang('error_template') . '<br />'; }
public static function expand_events($eventids, $returnid, $parameters, $limit = 10000, $startoffset = 0) { if (!is_array($eventids) || count($eventids) < 1) { return FALSE; } $module = cge_utils::get_module(MOD_CGCALENDAR); $gCms = CmsApp::get_instance(); $db = $gCms->GetDb(); $events_to_categories_table_name = $module->events_to_categories_table_name; $categories_table_name = $module->categories_table_name; $event_field_values_table_name = $module->event_field_values_table_name; $userops = $gCms->GetUserOperations(); $tmp = $userops->LoadUsers(); $users = array(); foreach ($tmp as $oneuser) { $users[$oneuser->id] = $oneuser; } $query = 'SELECT * FROM ' . $module->events_table_name . ' WHERE event_id IN (' . implode(',', $eventids) . ') ORDER BY event_date_start ASC'; $rs = $db->SelectLimit($query, $limit, $startoffset); $feu_users = array(); while (!$rs->EOF()) { $row = $rs->fields; $uid = $row['event_created_by']; if ($uid < 1 && !in_array($uid, $feu_users)) { $feu_users[] = $uid; } $rs->MoveNext(); } debug_display($feu_users); die; $rs->MoveFirst(); $events = array(); while ($rs && ($row = $rs->FetchRow())) { $titleSEO = munge_string_to_url($row['event_title']); $destpage = $module->GetPreference('defaultcalendarpage', -1); $destpage = $destpage > 0 ? $destpage : $returnid; //$destpage =$detailpage!=''?$detailpage:$destpage; $prefix = $module->GetPreference('url_prefix'); if (!$prefix) { $prefix = 'calendar'; } $prettyurl = sprintf($prefix . "/%d/%d-%s", $destpage, $row['event_id'], $titleSEO); $parms = array(); $parms['event_id'] = $row['event_id']; $parms['display'] = 'event'; if (isset($parameters['eventtemplate'])) { $parms['eventtemplate'] = $parameters['eventtemplate']; } $url = $module->CreateLink('cntnt01', 'default', $destpage, $contents = '', $parms, '', true, '', '', '', $prettyurl); $row['url'] = $url; $row['author'] = $users[$row['event_created_by']]->username; $row['authorname'] = $users[$row['event_created_by']]->firstname . ' ' . $users[$row['event_created_by']]->lastname; // Build the sql to retrieve the categories for this event. $sql = "SELECT category_name FROM {$events_to_categories_table_name}\n\t INNER JOIN {$categories_table_name} ON {$events_to_categories_table_name}.category_id = {$categories_table_name}.category_id\n\t WHERE event_id = ?"; $crs = $db->Execute($sql, array($row['event_id'])); // Get the field values $categories = array(); $categories_temp = array(); if ($crs) { // make sure there are results and assign to the $categories array $categories_temp = $crs->GetArray(); foreach ($categories_temp as $category) { $category_name = $category['category_name']; $categories[$category_name] = '1'; } } // Attach the custom fields to the event $row['categories'] = $categories; // Build the sql to retrieve the field values for this event. $sql = "SELECT field_name,field_value FROM {$event_field_values_table_name} WHERE event_id = ?"; $frs = $db->Execute($sql, array($row['event_id'])); // Get the field values $fields = array(); $fields_temp = array(); if ($frs) { // make sure there are results and assign to the $fields array $fields_temp = $frs->GetArray(); foreach ($fields_temp as $field) { $field_name = $field['field_name']; $field_value = $field['field_value']; $fields[$field_name] = $field_value; } } // Attach the custom fields to the event $row['fields'] = $fields; // End custom fields retrieval // and add it to the list of completed, expanded events. $events[] = $row; } if ($rs) { $rs->Close(); } return $events; }
$query = "SELECT fileid, filepath FROM " . cms_db_prefix() . "module_gallery WHERE galleryid=?"; $result = $db->Execute($query, array($params['gid'])); if ($result && $result->RecordCount() > 0) { while ($row = $result->FetchRow()) { Gallery_utils::DeleteFiles(str_replace('/', DIRECTORY_SEPARATOR, '../' . DEFAULT_GALLERYTHUMBS_PATH), $row['fileid'] . '-*', false); $filepath = $row['filepath']; } $filepath .= $filepath != '' ? '/' : ''; Gallery_utils::DeleteFiles(str_replace('/', DIRECTORY_SEPARATOR, '../' . DEFAULT_GALLERY_PATH . $filepath), IM_PREFIX . '*', false); } if ($result) { $params['module_message'] = $this->Lang('thumbsdeleted') . ' ' . $this->Lang('thumbsrecreated'); } } elseif (isset($params['directoryname'])) { // cleanup the directoryname, see reference-arrays in lib/replacement.php $params['directoryname'] = munge_string_to_url($params['directoryname']); // add subgallery if (empty($params['directoryname'])) { $params['module_error'] = $this->Lang('error_directorynameinvalid'); $this->Redirect($id, 'editgallery', '', $params); exit; } $params['gid'] = $params['moveto']; $galleryinfo = Gallery_utils::Getgalleryinfobyid($params['gid']); $gallerypath = $galleryinfo['filepath'] . $galleryinfo['filename']; if (is_dir($gallerypath . $params['directoryname'])) { $params['module_error'] = $this->Lang('error_directoryalreadyexists'); $this->Redirect($id, 'editgallery', '', $params); exit; } else { if (!mkdir('../' . DEFAULT_GALLERY_PATH . $gallerypath . $params['directoryname'])) {
$output = trim($method($params, cmsms()->GetSmarty())); } else { if (!function_exists('smarty_cms_function_content') && !function_exists('smarty_function_content')) { require_once $config['root_path'] . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'function.content.php'; } $method = function_exists('smarty_cms_function_content') ? 'smarty_cms_function_content' : 'smarty_function_content'; $output = trim($method($params, cmsms()->GetSmarty())); } } if (!isset($params['no_output']) || ac_utils::IsFalse($params['no_output'])) { echo $output; } return; } $output = ''; $block = isset($params['block']) ? preg_replace('/-+/', '_', munge_string_to_url($params['block'])) : 'content_en'; $id = ''; $modulename = ''; $action = ''; $inline = false; if (isset($_REQUEST['module'])) { $modulename = $_REQUEST['module']; } if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($_REQUEST['mact'])) { $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4); $modulename = isset($ary[0]) ? $ary[0] : ''; $id = isset($ary[1]) ? $ary[1] : ''; $action = isset($ary[2]) ? $ary[2] : ''; $inline = isset($ary[3]) && $ary[3] == 1 ? true : false;
// get the individual reviews. $dbr = $db->SelectLimit($query, $pagelimit, $startoffset, $qparms); if (!$dbr) { echo "DEBUG SUMMARY QUERY: SQL FAILED<br/>"; echo "QUERY: " . $db->sql . '<br/>'; echo "MESSAGE: " . $db->ErrorMsg() . '<br/>'; echo "SQUERY: " . $query . '<br/>'; print_r($qparms); die; } $parms = $params; $parms['feedback_origpage'] = $returnid; $data = array(); while ($dbr && ($row = $dbr->FetchRow())) { $prettyurl = "feedback/detail/{$row['id']}/{$detailpage}/"; $prettyurl .= munge_string_to_url(substr($row['title'], 0, 30)); $parms['cid'] = $row['id']; $row['detail_url'] = $this->CreateURL($id, 'detail', $detailpage, $parms, 0, $prettyurl); $sql = 'SELECT * FROM ' . CGFEEDBACK_TABLE_FIELDVALS . ' WHERE comment_id = ?'; $tmp = $db->GetArray($sql, array($row['id'])); if (is_array($tmp) && is_array($fields)) { for ($i = 0; $i < count($tmp); $i++) { $tmp[$i] = array_merge($tmp[$i], $fields[$tmp[$i]['field_id']]); } $row['fields'] = cge_array::to_hash($tmp, 'name'); } $tmp = $fields; $data[] = $row; } # # Give everything to smarty
private function _register_content_block(&$contentBlock) { $AdvancedContent =& cms_utils::get_module('AdvancedContent'); if ($contentBlock->GetBlockProperty('type') != '') { $this->_blockTypes[$contentBlock->GetBlockProperty('type')]['content_blocks'][$contentBlock->GetBlockProperty('id')] = $contentBlock->GetBlockProperty('id'); $this->_blockTypes[$contentBlock->GetBlockProperty('type')]['header_html_called'] = false; if ($this->_cms_access == 'backend') { # this block has been added to the template after page has been created? if (!in_array($contentBlock->GetBlockProperty('id'), $this->mProperties->mPropertyNames)) { $contentBlock->SetBlockProperty('new_block', true); } $pageTab = preg_replace('/-+/', '_', munge_string_to_url(strtolower(trim($contentBlock->GetBlockProperty('page_tab'))))); if (!isset($this->_pageTabs[$pageTab])) { $this->_pageTabs[$pageTab]['tab_id'] = $pageTab; $this->_pageTabs[$pageTab]['tab_name'] = $contentBlock->GetBlockProperty('page_tab'); $this->_pageTabs[$pageTab]['block_tabs'] = array(); $this->_pageTabs[$pageTab]['block_groups'] = array(); $contentBlock->SetBlockProperty('page_tab', $pageTab); } $this->_pageTabs[$pageTab]['content_blocks'][$contentBlock->GetBlockProperty('id')] = $contentBlock->GetBlockProperty('id'); $blockTab = ''; if ($contentBlock->GetBlockProperty('block_tab') != '') { $blockTab = $pageTab . '_' . preg_replace('/-+/', '_', munge_string_to_url(strtolower(trim($contentBlock->GetBlockProperty('block_tab'))))); if (!isset($this->_blockTabs[$blockTab])) { $this->_blockTabs[$blockTab]['tab_id'] = $blockTab; $this->_blockTabs[$blockTab]['tab_name'] = $contentBlock->GetBlockProperty('block_tab'); $this->_blockTabs[$blockTab]['block_groups'] = array(); } $this->_blockTabs[$blockTab]['content_blocks'][$contentBlock->GetBlockProperty('id')] = $contentBlock->GetBlockProperty('id'); $this->_pageTabs[$pageTab]['block_tabs'][$blockTab] = $blockTab; $contentBlock->SetBlockProperty('block_tab', $blockTab); } $blockGroup = ''; if ($contentBlock->GetBlockProperty('block_group') != '') { $blockGroup = ($blockTab ? $blockTab : $pageTab) . '_' . preg_replace('/-+/', '_', munge_string_to_url(strtolower(trim($contentBlock->GetBlockProperty('block_group'))))); if (!isset($this->_blockGroups[$blockGroup])) { $this->_blockGroups[$blockGroup]['group_id'] = $blockGroup; $this->_blockGroups[$blockGroup]['group_name'] = $contentBlock->GetBlockProperty('block_group'); $this->_blockGroups[$blockGroup]['collapsible'] = $contentBlock->GetBlockProperty('collapsible'); if (!$this->_blockGroups[$blockGroup]['collapsible']) { $this->_blockGroups[$blockGroup]['collapse'] = false; } else { $this->_blockGroups[$blockGroup]['collapse'] = $AdvancedContent->GetPreference('collapse_group_default', 1); } $this->_pageTabs[$pageTab]['block_groups'][$blockGroup] = $blockGroup; } $this->_blockGroups[$blockGroup]['content_blocks'][$contentBlock->GetBlockProperty('id')] = $contentBlock->GetBlockProperty('id'); unset($this->_blockTabs[$blockTab]['content_blocks'][$contentBlock->GetBlockProperty('id')]); if ($blockTab) { $this->_blockTabs[$blockTab]['block_groups'][$blockGroup] = $blockGroup; } else { unset($this->_blockTabs[$blockTab]['block_groups'][$blockGroup]); } $contentBlock->SetBlockProperty('block_group', $blockGroup); } } #$AdvancedContent =& cms_utils::get_module('AdvancedContent'); #$AdvancedContent->SetAllowedParam($contentBlock->GetBlockProperty('id'), CLEAN_NONE); #foreach($contentBlock->GetBlockProperties() as $paramName => $paramValue) #{ # if(is_string($paramValue)) # { # $AdvancedContent->SetAllowedParam($paramName, CLEAN_STRING); # continue; # } # if(is_bool($paramValue) || is_int($paramValue)) # { # $AdvancedContent->SetAllowedParam($paramName, CLEAN_INT); # continue; # } # if(is_float($paramValue) || is_double($paramValue)) # { # $AdvancedContent->SetAllowedParam($paramName, CLEAN_FLOAT); # continue; # } # $AdvancedContent->SetAllowedParam($paramName, CLEAN_NONE); #} $this->_blockTypes[$contentBlock->GetBlockProperty('type')]['props'] = $contentBlock->GetBlockTypeProperties($this->_cms_access); $this->AddExtraProperty($contentBlock->GetBlockProperty('id')); #if($contentBlock->GetBlockProperty('inherit')) #{ # $this->_inheritables[$contentBlock->GetBlockProperty('id')] = -1; # $this->SetPropertyValueNoLoad($contentBlock->GetBlockProperty('id'), -1); #} } $this->_contentBlocks[$contentBlock->GetBlockProperty('id')] = $contentBlock; }
$this->Redirect($id, $the_action, $returnid, $params); return; } $module = $this->GetModuleInstance($params['modname']); if (!$module) { $params['errors'] = $this->Lang('error_insufficientparams'); $this->Redirect($id, $the_action, $returnid, $params); return; } if (isset($params['cancel'])) { $module->_current_tab = $this->_current_tab; $module->RedirectToTab($id, $this->_current_tab, '', $the_action); } $template = ""; if (isset($params['template'])) { $template = munge_string_to_url(trim($params['template'])); } $prefix = ""; if (isset($params['prefix'])) { $prefix = trim($params['prefix']); } if (!isset($params['templatecontent'])) { $params['errors'] = $this->Lang('error_insufficientparams'); $module->Redirect($id, $params['origaction'], '', $params); return; } if ($template == "" || $prefix == "") { $params['errors'] = $this->Lang('error_insufficientparams'); $module->Redirect($id, $params['origaction'], '', $params); return; }
public function postprocess($html) { $smarty = cmsms()->GetSmarty(); $otd = $smarty->template_dir; $smarty->template_dir = dirname(__FILE__) . '/templates'; $module_help_type = $this->get_value('module_help_type'); // get a page title $title = $this->get_value('pagetitle'); $alias = $this->get_value('pagetitle'); if ($title) { if (!$module_help_type) { // if not doing module help, translate the string. $extra = $this->get_value('extra_lang_params'); if (!$extra) { $extra = array(); } $title = lang($title, $extra); } } else { // no title, get one from the breadcrumbs. $bc = $this->get_breadcrumbs(); if (is_array($bc) && count($bc)) { $title = $bc[count($bc) - 1]['title']; } } // page title and alias $smarty->assign('pagetitle', $title); $smarty->assign('pagealias', munge_string_to_url($alias)); // module name? if ($module_name = $this->get_value('module_name')) { $smarty->assign('module_name', $module_name); } // module icon? if ($module_icon_url = $this->get_value('module_icon_url')) { $smarty->assign('module_icon_url', $module_icon_url); } // module_help_url if (!get_preference(get_userid(), 'hide_help_links', 0)) { if ($module_help_url = $this->get_value('module_help_url')) { $smarty->assign('module_help_url', $module_help_url); } } // if bookmarks if (get_preference(get_userid(), 'bookmarks')) { $marks = $this->get_bookmarks(); $smarty->assign('marks', $marks); } $headtext = $this->get_value('headertext'); $smarty->assign('headertext', $headtext); // and some other common variables,. $smarty->assign('content', str_replace('</body></html>', '', $html)); $smarty->assign('config', cmsms()->GetConfig()); $smarty->assign('theme', $this); $smarty->assign('secureparam', CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY]); $userops = cmsms()->GetUserOperations(); $smarty->assign('user', $userops->LoadUserByID(get_userid())); // get user selected language $smarty->assign('lang', get_preference(get_userid(), 'default_cms_language')); // get language direction $lang = CmsNlsOperations::get_current_language(); $info = CmsNlsOperations::get_language_info($lang); $smarty->assign('lang_dir', $info->direction()); if (is_array($this->_errors) && count($this->_errors)) { $smarty->assign('errors', $this->_errors); } if (is_array($this->_messages) && count($this->_messages)) { $smarty->assign('messages', $this->_messages); } $_contents = $smarty->fetch('pagetemplate.tpl'); $smarty->template_dir = $otd; return $_contents; }
public function get_events() { $gCms = cmsms(); $sorting = $this->_reverse ? 'DESC' : 'ASC'; $query = 'SELECT * FROM ' . cms_db_prefix() . 'module_cgcalendar_events WHERE event_id IN ('; $query .= implode(',', $this->_idlist) . ')'; $query .= " ORDER BY event_date_start {$sorting}"; $db = cmsms()->GetDb(); // get the parent ids and events. $events = $db->GetArray($query); $parent_ids = $this->_idlist; if (!is_array($events) || count($events) == 0) { return; } foreach ($events as $row) { if ($row['event_parent_id'] > 0) { $parent_ids[] = $row['event_parent_id']; } } $parent_ids = array_unique($parent_ids); $customfields = array(); $query = 'SELECT * FROM ' . cms_db_prefix() . 'module_cgcalendar_event_field_values WHERE event_id IN (' . implode(',', $parent_ids) . ') ORDER BY event_id'; $frs = $db->GetArray($query); foreach ($frs as $row) { $customfields[$row['event_id']][] = $row; } $allcategories = array(); $query = 'SELECT * FROM ' . cms_db_prefix() . 'module_cgcalendar_events_to_categories WHERE event_id IN (' . implode(',', $this->_idlist) . ') ORDER BY event_id'; $crs = $db->Execute($query); while ($crs && !$crs->EOF()) { $row = $crs->fields; $allcategories[$row['event_id']][] = $row; $crs->MoveNext(); } if (count($allcategories)) { \CGCalendar\category::get_categories(); } // forces preload. $users = array(); $userops = $gCms->GetUserOperations(); $userlist = $userops->LoadUsers(); foreach ($userlist as $oneuser) { $users[$oneuser->id] = $oneuser; } $module = cms_utils::get_module('CGCalendar'); foreach ($events as &$row) { $titleSEO = munge_string_to_url($row['event_title']); $prettyurl = sprintf($this->_url_prefix . '/%d/%d-%s', $this->_destpage, $row['event_id'], $titleSEO); $parms = array(); $parms['event_id'] = $row['event_id']; $parms['display'] = 'event'; if ($this->_eventtemplate) { $parms['eventtemplate'] = $this->_eventtemplate; } $row['url'] = $module->create_url($this->_actionid, 'default', $this->_destpage, $parms, false, false, $prettyurl); $ptr = null; if (isset($allcategories[$row['event_id']])) { $ptr = $allcategories[$row['event_id']]; } else { if ($row['event_parent_id'] > 0 && isset($allcategories[$row['event_parent_id']])) { $ptr = $allcategories[$row['event_parent_id']]; } } $row['bgcolor'] = $row['fgcolor'] = null; if ($ptr) { $categories = array(); foreach ($ptr as $cat) { $categories[] = $cat['category_id']; if (!$row['bgcolor']) { // get colors for this event... $cat_obj = \CGCalendar\category::load($cat['category_id']); $row['fgcolor'] = $cat_obj['fgcolor']; $row['bgcolor'] = $cat_obj['bgcolor']; } } $row['categories'] = $categories; $row['category_names'] = $module->GetCategoryNames($categories); } $ptr = null; if (isset($customfields[$row['event_id']])) { $ptr = $customfields[$row['event_id']]; } else { if ($row['event_parent_id'] > 0 && isset($customfields[$row['event_parent_id']])) { $ptr = $customfields[$row['event_parent_id']]; } } if ($ptr) { $fields = array(); $fieldinfo = array(); foreach ($ptr as $key => $rec) { $fields[$rec['field_name']] = $rec['field_value']; $fieldinfo[$rec['field_name']] = $rec; } $row['fields'] = $fields; // deprecated $row['fieldinfo'] = $fieldinfo; } if ($row['event_created_by'] < 0) { // negative values (smaller than -100) indicate an admin user account $uid = $row['event_created_by'] + 100 * -1; $row['admin_uid'] = $uid; if (isset($users[$uid])) { $row['author'] = $users[$uid]->username; } } $row['is_parent'] = $row['event_recur_interval'] != 'none' && $row['event_recur_interval'] != ''; } return $events; }
function SearchResult($returnid, $event_id, $attr = '') { $result = array(); if ($attr != 'event') { return $result; } $db = $this->GetDb(); $query = 'SELECT event_title FROM ' . $this->events_table_name . ' WHERE event_id = ?'; $title = $db->GetOne($query, array($event_id)); $result[0] = $this->GetFriendlyName(); $result[1] = $title; $titleSEO = munge_string_to_url($title); $destpage = $this->GetPreference('defaultcalendarpage', -1); $destpage = $destpage != -1 ? $destpage : $returnid; $destpage = $detailpage != '' ? $detailpage : $destpage; $prefix = $this->GetPreference('url_prefix'); if (!$prefix) { $prefix = 'calendar'; } $prettyurl = sprintf($prefix . "/%d/%d-%s", $destpage, $event_id, $titleSEO); $result[2] = $this->CreateLink($id, 'default', $destpage, '', array('event_id' => $event_id, 'display' => 'event', 'detailpage' => $destpage, 'return_id' => $returnid), '', true, '', '', $prettyurl); return $result; }
$simpletypes[] = $typeid; } if (isset($_POST["addaliases"])) { //$contentops->SetAllHierarchyPositions(); $count = 0; $query = "SELECT * FROM " . cms_db_prefix() . "content"; $allcontent = $db->Execute($query); while ($contentpiece = $allcontent->FetchRow()) { $content_id = $contentpiece["content_id"]; if (trim($contentpiece["content_alias"]) == '' && $contentpiece['type'] != 'separator') { $alias = trim($contentpiece["menu_text"]); if ($alias == '') { $alias = trim($contentpiece["content_name"]); } $tolower = true; $alias = munge_string_to_url($alias, $tolower); if ($contentops->CheckAliasError($alias, $content_id)) { $alias_num_add = 2; // If a '-2' version of the alias already exists // Check the '-3' version etc. while ($contentops->CheckAliasError($alias . '-' . $alias_num_add) !== FALSE) { $alias_num_add++; } $alias .= '-' . $alias_num_add; } $query2 = "UPDATE " . cms_db_prefix() . "content SET content_alias=? WHERE content_id=?"; $params2 = array($alias, $content_id); $dbresult = $db->Execute($query2, $params2); $count++; } }
/** * @ignore * @internal * @access private */ public static function CleanStrId($str) { return preg_replace('/-+/', '_', munge_string_to_url(strtolower(trim($str)))); }
/** * Set the page alias for this content page. * If an empty alias is supplied, and depending upon the doAutoAliasIfEnabled flag, and config entries * a suitable alias may be calculated from other data in the page object * This method relies on the menutext and the name of the content page already being set. * * @param string The alias * @param boolean Wether an alias should be calculated or not. */ public function SetAlias($alias, $doAutoAliasIfEnabled = true) { $this->DoReadyForEdit(); $gCms = cmsms(); $config = $gCms->GetConfig(); $tolower = false; if ($alias == '' && $doAutoAliasIfEnabled && $config['auto_alias_content'] == true) { $alias = trim($this->mMenuText); if ($alias == '') { $alias = trim($this->mName); } $tolower = true; $alias = munge_string_to_url($alias, $tolower); // Make sure auto-generated new alias is not already in use on a different page, if it does, add "-2" to the alias $contentops = $gCms->GetContentOperations(); $error = $contentops->CheckAliasError($alias, $this->Id()); if ($error !== FALSE) { if (FALSE == empty($alias)) { $alias_num_add = 2; // If a '-2' version of the alias already exists // Check the '-3' version etc. while ($contentops->CheckAliasError($alias . '-' . $alias_num_add) !== FALSE) { $alias_num_add++; } $alias .= '-' . $alias_num_add; } else { $alias = ''; } } } $this->mAlias = munge_string_to_url($alias, $tolower); }
function SearchResultWithParams($returnid, $articleid, $attr = '', $params = '') { $gCms = cmsms(); $result = array(); if ($attr == 'article') { $db = $this->GetDb(); $q = "SELECT news_title,news_url FROM " . cms_db_prefix() . "module_news WHERE news_id = ?"; $row = $db->GetRow($q, array($articleid)); if ($row) { //0 position is the prefix displayed in the list results. $result[0] = $this->GetFriendlyName(); //1 position is the title $result[1] = $row['news_title']; //2 position is the URL to the title. $detailpage = $returnid; if (isset($params['detailpage'])) { $manager = $gCms->GetHierarchyManager(); $node = $manager->sureGetNodeByAlias($params['detailpage']); if (isset($node)) { $detailpage = $node->getID(); } else { $node = $manager->sureGetNodeById($params['detailpage']); if (isset($node)) { $detailpage = $params['detailpage']; } } } if ($detailpage == '') { $detailpage = $returnid; } $detailtemplate = ''; if (isset($params['detailtemplate'])) { $manager = $gCms->GetHierarchyManager(); $node = $manager->sureGetNodeByAlias($params['detailtemplate']); if (isset($node)) { $detailtemplate = '/d,' . $params['detailtemplate']; } } if ($row['news_url'] != '') { $aliased_title = munge_string_to_url($row['news_title']); $prettyurl = 'news/' . $articleid . '/' . $detailpage . "/{$aliased_title}" . $detailtemplate; } else { $prettyurl = $row['news_url']; } $parms = array(); $parms['articleid'] = $articleid; if (isset($params['detailtemplate'])) { $parms['detailtemplate'] = $params['detailtemplate']; } $result[2] = $this->CreateLink('cntnt01', 'detail', $detailpage, '', $parms, '', true, false, '', true, $prettyurl); } } return $result; }
/** * A utility function to test if the supplied url path is valid for the supplied content id * * @param string The partial url path to test * @return boolean */ public static function is_valid_url($url, $content_id = '') { // check for starting or ending slashes if (startswith($url, '/') || endswith($url, '/')) { return FALSE; } // first check for invalid chars. // strip off any extension (that is like 5 chars or less) $pos = strrpos($url, '.'); if ($pos !== FALSE) { // have an extension. $ext = substr($url, $pos + 1); if (strlen($ext) >= 5 || munge_string_to_url($ext, false, true) != strtolower($ext)) { return FALSE; } $tmp = substr($url, 0, $pos); if (munge_string_to_url($tmp, false, true) != strtolower($tmp)) { return FALSE; } } else { $translated = munge_string_to_url($url, false, true); if (strtolower($translated) != strtolower($url)) { return FALSE; } } cms_route_manager::load_routes(); $route = cms_route_manager::find_match($url, TRUE); if (!$route) { return TRUE; } if ($route->is_content()) { if ($content_id == '' || $route->get_content() == $content_id) { return TRUE; } } return FALSE; }
} else { if ($useexp == 1) { if ($startdate >= $enddate) { $error = $this->ShowErrors($this->Lang('error_invaliddates')); } } } } if (empty($error) && $news_url != '') { // check for starting or ending slashes if (startswith($news_url, '/') || endswith($news_url, '/')) { $error = $this->ShowErrors($this->Lang('error_invalidurl')); } if ($error === FALSE) { // check for invalid chars. $translated = munge_string_to_url($news_url, false, true); if (strtolower($translated) != strtolower($news_url)) { $error = $this->ShowErrors($this->Lang('error_invalidurl')); } } if ($error === FALSE) { // make sure this url isn't taken. $news_url = trim($news_url, " /\t\r\n"); cms_route_manager::load_routes(); $route = cms_route_manager::find_match($news_url); if ($route) { // we're adding an article, not editing... any matching route is bad. $error = $this->ShowErrors($this->Lang('error_invalidurl')); } } }
public static function CreateContentBlock(&$content_obj, $params) { $params['smarty'] = isset($params['smarty']) && (ac_utils::IsTrue($params['smarty']) || $params['smarty'] == 'both' || $params['smarty'] == ac_utils::cms_access()); # block active ? $params['active'] = isset($params['active']) ? $params['active'] : true; if ($params['smarty']) { $params['active'] = ac_utils::DoSmarty($content_obj, $params['active']); } if (ac_utils::IsFalse($params['active'])) { return false; } # do not process inactive blocks #--- # additional editors $params['editor_groups'] = isset($params['editor_groups']) ? $params['editor_groups'] : NULL; $params['editor_users'] = isset($params['editor_users']) ? $params['editor_users'] : NULL; if (!ac_utils::is_frontend_request() && ($params['editor_groups'] || $params['editor_users']) && !ac_admin_ops::CheckBlockPermission($params['editor_users'], $params['editor_groups'])) { return false; # do not process blocks without permission to edit } #--- # valid block type? $params['block_type'] = isset($params['block_type']) ? strtolower($params['block_type']) : 'text'; $classname = 'acBlockType_' . $params['block_type']; if (!class_exists($classname)) { if (!ac_utils::is_frontend_request()) { $classname = 'acBlockTypePlaceholder'; } else { return false; } } #--- # valid block id? $params['block_id'] = isset($params['block']) ? preg_replace('/-+/', '_', munge_string_to_url($params['block'])) : 'content_en'; if (!$params['block_id'] || $content_obj->IsKnownProperty($params['block_id'])) { if (!ac_utils::is_frontend_request()) { $params['block_id'] = md5($params['block_id'] . '_' . @count(self::$_content_blocks[$content_obj->Id()])); # count shouldn't be needed since CMSms 1.11 (multiple blocks with same id are just not possible anymore) $classname = 'acBlockTypePlaceholder'; } else { return false; } } #--- return new $classname($content_obj, $params); }
if (isset($defn['attribs']) && !empty($defn['attribs'])) { $attribs = unserialize($defn['attribs']); } } if (isset($params['input_type'])) { $defn['type'] = (int) $params['input_type']; } if (isset($params['input_length'])) { $defn['length'] = (int) $params['input_length']; } if (isset($params['input_maxlength'])) { $defn['maxlength'] = (int) $params['input_maxlength']; } if (isset($params['input_name'])) { $defn['name'] = strtolower(trim($params['input_name'])); $defn['name'] = munge_string_to_url($defn['name']); $defn['name'] = str_replace('-', '_', $defn['name']); } if (isset($params['input_prompt'])) { $defn['prompt'] = trim($params['input_prompt']); } if (isset($params['input_force_unique'])) { $defn['force_unique'] = (int) $params['input_force_unique']; } if (isset($params['input_encrypt'])) { $defn['encrypt'] = (int) $params['input_encrypt']; } if (isset($params['input_seloptions'])) { $seloptions = $params['input_seloptions']; } if (isset($params['input_radiooptions'])) {
$fieldsbyname[$alias] = $obj; } $onerow->fieldsbyname = $fieldsbyname; $onerow->fields = $fields; $onerow->file_location = $config['uploads_url'] . '/news/id' . $row['news_id']; $moretext = isset($params['moretext']) ? $params['moretext'] : $this->Lang('more'); $sendtodetail = array('articleid' => $row['news_id']); if (isset($params['detailpage'])) { $sendtodetail['origid'] = $returnid; } if (isset($params['detailtemplate'])) { $sendtodetail['detailtemplate'] = $params['detailtemplate']; } $prettyurl = $row['news_url']; if ($prettyurl == '') { $aliased_title = munge_string_to_url($row['news_title']); $prettyurl = 'news/' . $row['news_id'] . '/' . ($detailpage != '' ? $detailpage : $returnid) . "/{$aliased_title}"; if (isset($sendtodetail['detailtemplate'])) { $prettyurl .= '/d,' . $sendtodetail['detailtemplate']; } } $sendtoprint = array('articleid' => $row['news_id'], 'showtemplate' => 'false'); if (isset($params['lang'])) { $sendtodetail['lang'] = $params['lang']; $sendtoprint['lang'] = $params['lang']; } if (isset($params['category_id'])) { $sendtodetail['category_id'] = $params['category_id']; $sendtoprint['category_id'] = $params['category_id']; } if (isset($params['pagelimit'])) {
/** * Get this object's alias * If not explicitly specified, an alias will be automatically generated. * * @return string */ public function get_alias() { $alias = $this->_alias; if (!$alias) { $alias = $this->report()->get_title(); $alias = munge_string_to_url($alias); $this->set_alias($alias); } return $alias; }
<?php if (!isset($gCms)) { exit; } if (!$this->CheckPermission('Modify Site Preferences')) { echo $this->ShowErrors(lang('needpermissionto', 'Modify Site Preferences')); return; } if (!empty($params['urlprefix'])) { $this->SetPreference('urlprefix', munge_string_to_url($params['urlprefix'])); } $this->SetPreference('allowed_extensions', $params['allowed_extensions']); if (ctype_digit($params['maximagewidth'])) { $this->SetPreference("maximagewidth", $params['maximagewidth']); } if (ctype_digit($params['maximageheight'])) { $this->SetPreference("maximageheight", $params['maximageheight']); } if (ctype_digit($params['imagejpgquality']) && $params['imagejpgquality'] <= 100) { $this->SetPreference('imagejpgquality', $params['imagejpgquality']); } if (ctype_digit($params['thumbjpgquality']) && $params['thumbjpgquality'] <= 100) { $this->SetPreference('thumbjpgquality', $params['thumbjpgquality']); } $this->SetPreference('use_permissions', isset($params['use_permissions']) ? $params['use_permissions'] : false); $this->SetPreference('newgalleries_active', isset($params['newgalleries_active']) ? $params['newgalleries_active'] : false); $this->SetPreference('use_comment_wysiwyg', isset($params['use_comment_wysiwyg']) ? $params['use_comment_wysiwyg'] : false); $this->SetPreference('editdirdates', isset($params['editdirdates']) ? $params['editdirdates'] : false); $this->SetPreference('editfiledates', isset($params['editfiledates']) ? $params['editfiledates'] : false); $this->SetPreference('fe_folderpath', empty($params['fe_folderpath']) ? 'modules/Gallery/images/folder.png' : $params['fe_folderpath']);
$item = $items[$params["typeid"]]; } // CHECK IF THE FORM IS BEING SUBMITTED : if (isset($params["submit"]) || isset($params["apply"])) { // RETRIEVING THE FORM VALUES (and escaping it, if needed) if (!isset($item)) { $item = new stdClass(); } $variables = array('typename', 'iscore', 'destonly', 'type_retrievecombo', 'type_retrieveitem', 'type_activecheck'); foreach ($variables as $onevar) { $item->{$onevar} = isset($params[$onevar]) ? $params[$onevar] : 0; } if (!isset($item->active)) { $item->active = 1; } $item->typename = munge_string_to_url($item->typename, false); $errors = $this->testcode($item); if (!isset($params["typename"]) || $params["typename"] == "") { $errors[] = array("Name", $this->Lang("error_nonamegiven")); } if (count($errors) > 0) { foreach ($errors as $error) { if ($error[0] == "Name") { $errortext = $error[1]; } else { $errortext = $this->Lang("error_invalidcode") . $error[0] . ': ' . $error[1]; } echo $this->ShowErrors($errortext); } } else { ############ DOING THE UPDATE