function WIDGET_mooslide($page_ids, $width = 550, $height = 160, $id = 'gl_', $slide_interval = 0) { global $_TABLES, $_CONF; if (count($page_ids) == 0) { return ''; } // Backwards Compatibility - if $id is still the old default 'gl_slide', change it. if ($id == 'gl_slide') { $id = 'gl_'; } $display = <<<EOJ <script type="text/javascript" src="{$_CONF['site_url']}/javascript/mootools/gl_mooslide.js"></script> <script type="text/javascript"> window.addEvent('load', function() { var myFilm = new gl_Slide(\$('{$id}'), { fx: { wait: true, duration: 1000 }, scrollFX: { transition: Fx.Transitions.Cubic.easeIn }, dimensions: { width: {$width}, height: {$height} }, \t\t\tcssvars: { \t\t\t\tcustomID: '{$id}' \t\t\t\t}, \t\t\tautoScroll: { \t\t\t\tinterval: {$slide_interval} // in ms, thus 1000 is 1 second, set to 0 to turn off. \t\t\t\t} }); }); </script> <div id="{$id}" class="{$id}slide"> EOJ; if (!is_array($page_ids[0])) { //we are in Static Pages Mode $sql = "SELECT sp_id, sp_content, sp_php, sp_title FROM {$_TABLES['staticpage']} WHERE sp_id in (" . implode(', ', array_map(create_function('$a', 'return "\'" . htmlspecialchars($a) . "\'";'), $page_ids)) . ')' . COM_getPermSQL('AND'); $res = DB_query($sql); $pages = array(); for ($i = 0; $A = DB_fetchArray($res); ++$i) { $content = SP_render_content(stripslashes($A['sp_content']), $A['sp_php']); $title = htmlspecialchars(stripslashes($A['sp_title'])); $order = array_search($A['sp_id'], $page_ids); // find proper order $pages[$order] = array('content' => $content, 'title' => $title, 'index' => $order + 1); } } else { //we have been passed pre-formatted pages $pages = array(); for ($i = 0; $i < sizeof($page_ids); ++$i) { $content = stripslashes($page_ids[$i]['content']); $title = htmlspecialchars(stripslashes($page_ids[$i]['title'])); $order = $i; $pages[$order] = array('content' => $content, 'title' => $title, 'index' => $order + 1); } } /* COM_errorLog(print_r($pages,true),1); */ if (count($pages) == 0) { return ''; } ksort($pages); foreach ($pages as $page) { extract($page); $display .= <<<EOS <div class="{$id}tab-pane" id="{$id}tab-{$index}-pane"> <h1 class="{$id}tab-title">{$title}</h1> <div>{$content}</div> </div> EOS; } $display .= '</div><div style="clear:both;"></div>'; return $display; }
/** * Get an existing static page * * @param array args Contains all the data provided by the client * @param string &output OUTPUT parameter containing the returned text * @param string &svc_msg OUTPUT parameter containing any service messages * @return int Response code as defined in lib-plugins.php */ function service_get_staticpages($args, &$output, &$svc_msg) { global $_CONF, $_TABLES, $LANG_ACCESS, $LANG12, $LANG_STATIC, $_SP_CONF, $topic; $output = ''; $svc_msg['output_fields'] = array('sp_hits', 'sp_format', 'draft_flag', 'cache_time', 'owner_id', 'group_id', 'perm_owner', 'perm_group', 'perm_members', 'perm_anon', 'sp_help', 'sp_php', 'sp_inblock', 'commentcode'); if (empty($args['sp_id']) && !empty($args['id'])) { $args['sp_id'] = $args['id']; } if ($args['gl_svc']) { if (isset($args['sp_id'])) { $args['sp_id'] = COM_applyBasicFilter($args['sp_id']); } if (isset($args['mode'])) { $args['mode'] = COM_applyBasicFilter($args['mode']); } if (empty($args['sp_id'])) { $svc_msg['gl_feed'] = true; } else { $svc_msg['gl_feed'] = false; } } else { $svc_msg['gl_feed'] = false; } if (!$svc_msg['gl_feed']) { $page = ''; if (isset($args['sp_id'])) { $page = $args['sp_id']; } $mode = ''; if (isset($args['mode'])) { $mode = $args['mode']; } $error = 0; if ($page == '') { $error = 1; } $perms = SP_getPerms(); if (!SEC_hasRights('staticpages.edit')) { if (!empty($perms)) { $perms .= ' AND'; } $perms .= '(draft_flag = 0)'; } if (!empty($perms)) { $perms = ' AND ' . $perms; } // Topic Permissions $topic_perms = COM_getTopicSQL('', 0, 'ta'); if ($topic_perms != "") { $topic_perms = " AND (" . $topic_perms . ""; if (COM_onFrontpage()) { $topic_perms .= " OR (ta.tid = '" . TOPIC_HOMEONLY_OPTION . "' OR ta.tid = '" . TOPIC_ALL_OPTION . "'))"; } else { // $topic_perms .= " OR ta.tid = '" . TOPIC_ALL_OPTION . "')"; $topic_perms .= " OR (ta.tid = '" . TOPIC_HOMEONLY_OPTION . "' OR ta.tid = '" . TOPIC_ALL_OPTION . "'))"; } } $topic_perms .= " GROUP BY sp_id"; $sql = array(); $sql['mysql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format," . "commentcode,meta_description,meta_keywords,template_flag,template_id,draft_flag," . "owner_id,group_id,perm_owner,perm_group," . "perm_members,perm_anon,sp_help,sp_php,sp_inblock,cache_time " . "FROM {$_TABLES['staticpage']}, {$_TABLES['topic_assignments']} ta " . "WHERE (sp_id = '{$page}')" . $perms . " AND ta.type = 'staticpages' AND ta.id = sp_id " . $topic_perms; $sql['pgsql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits," . "created,modified,sp_format," . "commentcode,meta_description,meta_keywords,template_flag,template_id,draft_flag," . "owner_id,group_id,perm_owner,perm_group," . "perm_members,perm_anon,sp_help,sp_php,sp_inblock,cache_time " . "sp_inblock FROM {$_TABLES['staticpage']}, {$_TABLES['topic_assignments']} ta " . "WHERE (sp_id = '{$page}')" . $perms . " AND ta.type = 'staticpages' AND ta.id = sp_id " . $topic_perms; $result = DB_query($sql); $count = DB_numRows($result); if ($count == 0 || $count > 1) { $error = 1; } if (!$error) { $output = DB_fetchArray($result, false); $page = $output['sp_id']; // reset page id so case mimics id perfectly since this affects the cache file and canonical link // WE ASSUME $output doesn't have any confidential fields // Generate output now (omly if not grabing a template since template is combined with variables first and then generated) if (!isset($args['template'])) { $output['sp_content'] = SP_render_content($page, $output['sp_content'], $output['sp_php'], $output['cache_time'], $output['template_id']); } } else { // an error occured (page not found, access denied, ...) /** * if the user has edit permissions and the page does not exist, * send them to the editor so they can create it "wiki style" */ $create_page = false; if ($mode !== 'autotag' && $count == 0 && SEC_hasRights('staticpages.edit')) { // check again without permissions if (DB_count($_TABLES['staticpage'], 'sp_id', $page) == 0) { $url = $_CONF['site_admin_url'] . '/plugins/staticpages/index.php?mode=edit&sp_new_id=' . $page . '&msg=21'; $output = COM_refresh($url); $create_page = true; } } if (!$create_page) { if (empty($page)) { $failflg = 0; } else { $failflg = DB_getItem($_TABLES['staticpage'], 'sp_nf', "sp_id = '{$page}'"); } if ($failflg) { $output .= SEC_loginRequiredForm(); if ($mode !== 'autotag') { $output = COM_createHTMLDocument($output, array('rightblock' => true)); } } else { if ($mode !== 'autotag') { COM_handle404(); } } } return PLG_RET_ERROR; } if ($args['gl_svc']) { // This date format is PHP 5 only, // but only the web-service uses the value $output['published'] = date('c', strtotime($output['created'])); $output['updated'] = date('c', strtotime($output['modified'])); $output['id'] = $page; $output['title'] = $output['sp_title']; $output['page_title'] = $output['sp_page_title']; $output['category'] = TOPIC_getTopicIdsForObject('staticpages', $page); $output['content'] = $output['sp_content']; $output['content_type'] = 'html'; $owner_data = SESS_getUserDataFromId($output['owner_id']); $output['author_name'] = $owner_data['username']; $output['link_edit'] = $page; } } else { $output = array(); $mode = ''; if (isset($args['mode'])) { $mode = $args['mode']; } $perms = SP_getPerms(); if (!empty($perms)) { $perms = ' WHERE ' . $perms; } $offset = 0; if (isset($args['offset'])) { $offset = COM_applyBasicFilter($args['offset'], true); } $max_items = $_SP_CONF['atom_max_items'] + 1; $limit = " LIMIT {$offset}, {$max_items}"; $order = " ORDER BY modified DESC"; $sql = array(); $sql['mysql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format,meta_description,meta_keywords,template_flag,template_id,draft_flag,owner_id," . "group_id,perm_owner,perm_group,perm_members,perm_anon,sp_help,sp_php,sp_inblock,cache_time " . " FROM {$_TABLES['staticpage']}" . $perms . $order . $limit; $sql['pgsql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format,meta_description,meta_keywords,template_flag,template_id,draft_flag,owner_id," . "group_id,perm_owner,perm_group,perm_members,perm_anon,sp_help,sp_php,sp_inblock,cache_time " . "FROM {$_TABLES['staticpage']}" . $perms . $order . $limit; $result = DB_query($sql); $count = 0; while (($output_item = DB_fetchArray($result, false)) !== false) { // WE ASSUME $output doesn't have any confidential fields $count++; if ($count == $max_items) { $svc_msg['offset'] = $offset + $_SP_CONF['atom_max_items']; break; } if ($args['gl_svc']) { // This date format is PHP 5 only, but only the web-service uses the value $output_item['published'] = date('c', strtotime($output_item['created'])); $output_item['updated'] = date('c', strtotime($output_item['modified'])); $output_item['id'] = $output_item['sp_id']; $output_item['title'] = $output_item['sp_title']; $output_item['page_title'] = $output_item['sp_page_title']; //$output_item['category'] = array($output_item['sp_tid']); $output_item['category'] = TOPIC_getTopicIdsForObject('staticpages', $page); //$output_item['content'] = $output_item['sp_content']; $output['content'] = SP_render_content($output['sp_id'], $output['sp_content'], $output['sp_php'], $output['cache_time'], $output['template_id']); $output_item['content_type'] = 'html'; $owner_data = SESS_getUserDataFromId($output_item['owner_id']); $output_item['author_name'] = $owner_data['username']; } $output[] = $output_item; } } return PLG_RET_OK; }
$sp_idarray = array(); if (isset($_POST['sp_idarray'])) { $sp_idarray = $_POST['sp_idarray']; } PAGE_toggleStatus($enabledstaticpages, $sp_idarray); // force a refresh to redisplay staticpage status header('Location: ' . $_CONF['site_admin_url'] . '/plugins/staticpages/index.php'); exit; } $preview_content = ''; $sp_php = ''; switch ($action) { case 'preview': $sp_php = isset($_POST['sp_php']) ? $_POST['sp_php'] : ''; $editor_content = isset($_POST['sp_content']) ? $_POST['sp_content'] : ''; $preview_content = SP_render_content($editor_content, $sp_php); $preview_title = isset($_POST['sp_title']) ? $_POST['sp_title'] : ''; $owner_id = $_POST['owner_id']; $group_id = $_POST['group_id']; $perm_owner = $_POST['perm_owner']; $perm_group = $_POST['perm_group']; $perm_members = $_POST['perm_members']; $perm_anon = $_POST['perm_anon']; list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon); $_POST['perm_owner'] = $perm_owner; $_POST['perm_group'] = $perm_group; $_POST['perm_members'] = $perm_members; $_POST['perm_anon'] = $perm_anon; case 'edit': SEC_setCookie($_CONF['cookie_name'] . 'adveditor', SEC_createTokenGeneral('advancededitor'), time() + 1200, $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure'], false); $display .= COM_siteHeader('menu', $LANG_STATIC['staticpageeditor']);