/** * InitContent. * Checks the cache status and create the content. */ function pmxc_InitContent() { global $scripturl, $boardurl, $pmxCacheFunc; // if visible init the content if ($this->visible) { if ($this->cfg['cache'] > 0) { // check the block cache if (($cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) !== null) { list($dummy, $dummy, $this->posts, $this->attaches, $this->imgName) = $cachedata; } else { $this->fetch_data(); $cachedata = array(array(), array(), $this->posts, $this->attaches, $this->imgName); $pmxCacheFunc['put']($this->cache_key, $cachedata, $this->cache_time, $this->cache_mode); } unset($cachedata); } else { $this->fetch_data(); } // no posts .. disable the block if (empty($this->posts)) { $this->visible = false; } else { // create page index if set .. if (!empty($this->cfg['config']['settings']['onpage']) && count($this->posts) > $this->cfg['config']['settings']['onpage']) { // paging key $this->postKey = 'pmxpost_' . $this->cfg['blocktype'] . $this->cfg['id'] . (!empty($this->inBlockCall) ? '_0' : ''); $this->postarray = array('pg' => 0); if (isset($_POST[$this->postKey])) { pmx_GetPostKey($this->postKey, $this->postarray); $_SESSION['PortaMx'][$this->postKey] = $this->postarray; $this->startpage = $this->postarray['pg']; } elseif (isset($_SESSION['PortaMx'][$this->postKey])) { if (intval($_SESSION['PortaMx'][$this->postKey]['pg'] * $this->cfg['config']['settings']['onpage']) > count($this->posts)) { $this->startpage = 0; } else { $this->startpage = $_SESSION['PortaMx'][$this->postKey]['pg']; } } else { $this->startpage = 0; } $baseurl = function_exists('pmxsef_query') ? $boardurl . '/' : $scripturl . '?'; $this->pmxc_constructPageIndex(count($this->posts), $this->cfg['config']['settings']['onpage'], false, $this->startpage); $this->pageindex = str_replace('<a', '<a onclick="pmx_StaticBlockSub(\'' . $this->postKey . '\', this, \'/' . rtrim($baseurl, '?/') . '/\', \'' . $this->cfg['uniID'] . '\')"', $this->pageindex); } } // image rescale if (!empty($this->imgName)) { if (empty($this->cfg['config']['settings']['rescale']) && !is_numeric($this->cfg['config']['settings']['rescale'])) { addInlineCss(' .' . $this->imgName . '{}'); } else { $vals = explode(',', $this->cfg['config']['settings']['rescale']); addInlineCss(' .' . $this->imgName . '{' . (empty($vals[0]) ? 'width:auto' : 'max-width:' . (strpos($vals[0], '%') === false ? $vals[0] . 'px' : $vals[0])) . ';' . (empty($vals[1]) ? 'height:auto' : 'max-height:' . (strpos($vals[1], '%') === false ? $vals[1] . 'px' : $vals[1])) . ';}'); } } } // return the visibility return $this->visible; }
function CharacterList() { global $context, $smcFunc, $txt, $scripturl, $modSettings; global $image_proxy_enabled, $image_proxy_secret; isAllowedTo('view_mlist'); loadTemplate('Profile-Chars'); $context['page_title'] = $txt['chars_menu_title']; $context['sub_template'] = 'character_list'; $context['linktree'][] = array('name' => $txt['chars_menu_title'], 'url' => $scripturl . '?action=characters'); if (isset($_GET['sa']) && $_GET['sa'] == 'sheets') { return CharacterSheetList(); } $context['filterable_groups'] = []; foreach (get_char_membergroup_data() as $id_group => $group) { if ($group['is_character']) { $context['filterable_groups'][$id_group] = $group; } } $context['filter_groups'] = []; $filter = []; if (isset($_POST['filter']) && is_array($_POST['filter'])) { $filter = $_POST['filter']; } elseif (isset($_GET['filter'])) { $filter = explode(',', base64_decode($_GET['filter'])); } if (!empty($filter)) { if (allowedTo('admin_forum') && in_array(-1, $filter)) { $context['filter_groups'] = true; } else { foreach ($filter as $filter_val) { if (isset($context['filterable_groups'][$filter_val])) { $context['filter_groups'][] = (int) $filter_val; } } } } $clauses = array('chars.is_main = {int:not_main}'); $vars = array('not_main' => 0); $filter_url = ''; if (!empty($context['filter_groups'])) { if (is_array($context['filter_groups'])) { $vars['filter_groups'] = $context['filter_groups']; $this_clause = []; foreach ($context['filter_groups'] as $group) { $this_clause[] = 'FIND_IN_SET(' . $group . ', chars.char_groups)'; } $clauses[] = '(chars.main_char_group IN ({array_int:filter_groups}) OR (' . implode(' OR ', $this_clause) . '))'; $filter_url = ';filter=' . base64_encode(implode(',', $context['filter_groups'])); } else { $clauses[] = '(chars.main_char_group = 0 AND chars.char_groups = {empty})'; $filter_url = ';filter=' . base64_encode('-1'); } } $request = $smcFunc['db_query']('', ' SELECT COUNT(id_character) FROM {db_prefix}characters AS chars WHERE ' . implode(' AND ', $clauses), $vars); list($context['char_count']) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); $context['items_per_page'] = 12; $context['page_index'] = constructPageIndex($scripturl . '?action=characters' . $filter_url . ';start=%1$d', $_REQUEST['start'], $context['char_count'], $context['items_per_page'], true); $vars['start'] = $_REQUEST['start']; $vars['limit'] = $context['items_per_page']; $context['char_list'] = []; if (!empty($context['char_count'])) { if (!empty($modSettings['avatar_max_width_external'])) { addInlineCss(' .char_list_avatar { width: ' . $modSettings['avatar_max_width_external'] . 'px; height: ' . $modSettings['avatar_max_height_external'] . 'px; } .char_list_name { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; }'); } $request = $smcFunc['db_query']('', ' SELECT chars.id_character, chars.id_member, chars.character_name, chars.avatar, chars.posts, chars.date_created, chars.main_char_group, chars.char_groups, chars.char_sheet, chars.retired FROM {db_prefix}characters AS chars WHERE ' . implode(' AND ', $clauses) . ' ORDER BY chars.character_name LIMIT {int:start}, {int:limit}', $vars); while ($row = $smcFunc['db_fetch_assoc']($request)) { if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); } elseif (empty($row['avatar'])) { $row['avatar'] = $modSettings['avatar_url'] . '/default.png'; } $groups = !empty($row['main_char_group']) ? array($row['main_char_group']) : []; $groups = array_merge($groups, explode(',', $row['char_groups'])); $details = get_labels_and_badges($groups); $row['group_title'] = $details['title']; $row['group_color'] = $details['color']; $row['group_badges'] = $details['badges']; $context['char_list'][] = $row; } $smcFunc['db_free_result']($request); } }
/** * load the article editor by article type. * field: name of a input element. * content: the content in the editor or empty. */ function PortaMx_EditArticle($type, $field, $content) { global $context, $sourcedir, $boardurl, $modSettings, $user_info, $options, $smcFunc, $txt; // for html blocks if ($type == 'html') { loadJavascriptFile($boardurl . '/ckeditor/ckeditor.js', array('external' => true)); $context['pmx']['htmledit'] = array('id' => 'content', 'content' => $content); } else { if ($type == 'script') { addInlineCss(' textarea{min-height:100px;resize:vertical;}'); $context['pmx']['script'] = array('id' => 'content', 'value' => !empty($content) ? $content : '', 'width' => '100%', 'height' => '150px'); } elseif ($type == 'php') { addInlineCss(' textarea{min-height:100px;}'); if (preg_match('~\\[\\?pmx_initphp(.*)pmx_initphp\\?\\]~is', $content, $match)) { $cont = trim($match[1]); } else { $cont = ''; } $context['pmx']['phpInit'] = array('id' => 'content_init', 'value' => $smcFunc['htmlspecialchars']($cont, ENT_NOQUOTES), 'width' => '100%', 'height' => '150px', 'havecont' => !empty($cont)); if (preg_match('~\\[\\?pmx_showphp(.*)pmx_showphp\\?\\]~is', $content, $match)) { $cont = trim($match[1]); } else { $cont = $content; } $context['pmx']['phpShow'] = array('id' => 'content', 'value' => $smcFunc['htmlspecialchars']($cont, ENT_NOQUOTES), 'width' => '100%', 'height' => '150px', 'havecont' => !empty($cont)); } else { // Let's load the SMF editor. require_once $sourcedir . '/Subs-Editor.php'; $user_info['smiley_set'] = 'PortaMx'; $modSettings['smiley_enable'] = true; $options['wysiwyg_default'] = true; $editorOptions = array('id' => 'content', 'value' => !empty($content) ? $content : '', 'width' => '100%', 'height' => '200px', 'labels' => array(), 'preview_type' => 0, 'bbc_level' => 'full', 'disable_smiley_box' => 0, 'locale' => !empty($txt['lang_locale']) && substr($txt['lang_locale'], 0, 5) != 'en_US' ? $txt['lang_locale'] : '', 'form' => 'pxmedit'); create_control_richedit($editorOptions); $context['pmx']['editorID'] = $editorOptions['id']; } } }
/** * InitContent. * Checks the cache status and create the content. */ function pmxc_InitContent() { global $context, $scripturl, $boardurl, $pmxCacheFunc; if (empty($context['pmx']['settings']['manager']['promote']) || empty($context['pmx']['promotes'])) { $this->visible = false; } // if visible init the content if ($this->visible) { // paging key $this->postKey = 'pmxpost_' . $this->cfg['blocktype'] . $this->cfg['id'] . (!empty($this->inBlockCall) ? '_0' : ''); // posts can select by posts or boards .. defaut posts if (empty($this->cfg['config']['settings']['selectby'])) { $this->cfg['config']['settings']['selectby'] = 'posts'; } // force reload for this block? if (!empty($_SESSION['pmx_refresh_promote']) && in_array($this->cfg['id'], $_SESSION['pmx_refresh_promote'])) { if (isset($_SESSION['PortaMx'][$this->postKey])) { unset($_SESSION['PortaMx'][$this->postKey]); $this->startpage = 0; } // clear reload and fetch the data $_SESSION['pmx_refresh_promote'] = array_diff($_SESSION['pmx_refresh_promote'], array($this->cfg['id'])); $posts = $this->fetch_data(); // store in cache if enabled if ($this->cfg['cache'] > 0) { $pmxCacheFunc['put']($this->cache_key, array($posts, $this->posts, $this->attaches, $this->imgName), $this->cache_time, $this->cache_mode); } } else { // cache enabled ? if ($this->cfg['cache'] > 0) { // cache valid? if (($cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) !== null) { // yes.. list($posts, $this->posts, $this->attaches, $this->imgName) = $cachedata; unset($cachedata); } else { $posts = $this->fetch_data(); $pmxCacheFunc['put']($this->cache_key, array($posts, $this->posts, $this->attaches, $this->imgName), $this->cache_time, $this->cache_mode); } } else { $posts = $this->fetch_data(); } } // no posts .. disable the block if (empty($posts) || empty($this->posts)) { $this->visible = false; } elseif (!empty($this->cfg['config']['settings']['onpage'])) { if (!empty($this->cfg['config']['settings']['onpage']) && count($this->posts) > $this->cfg['config']['settings']['onpage']) { $this->postarray = array('pg' => 0); if (isset($_POST[$this->postKey])) { pmx_GetPostKey($this->postKey, $this->postarray); $_SESSION['PortaMx'][$this->postKey] = $this->postarray; $this->startpage = $this->postarray['pg']; } elseif (isset($_SESSION['PortaMx'][$this->postKey])) { if (intval($_SESSION['PortaMx'][$this->postKey]['pg'] * $this->cfg['config']['settings']['onpage']) > count($this->posts)) { $this->startpage = 0; } else { $this->startpage = $_SESSION['PortaMx'][$this->postKey]['pg']; } } else { $this->startpage = 0; } $baseurl = function_exists('pmxsef_query') ? $boardurl . '/' : $scripturl . '?'; $this->pmxc_constructPageIndex(count($this->posts), $this->cfg['config']['settings']['onpage'], false, $this->startpage); $this->pageindex = str_replace('<a', '<a onclick="pmx_StaticBlockSub(\'' . $this->postKey . '\', this, \'/' . rtrim($baseurl, '?/') . '/\', \'' . $this->cfg['uniID'] . '\')"', $this->pageindex); } } // image rescale.. if (!empty($this->imgName)) { if (empty($this->cfg['config']['settings']['rescale']) && !is_numeric($this->cfg['config']['settings']['rescale'])) { addInlineCss(' .' . $this->imgName . '{}'); } else { $vals = explode(',', $this->cfg['config']['settings']['rescale']); addInlineCss(' .' . $this->imgName . '{' . (empty($vals[0]) ? 'width:auto' : 'max-width:' . (strpos($vals[0], '%') === false ? $vals[0] . 'px' : $vals[0])) . ';' . (empty($vals[1]) ? 'height:auto' : 'max-height:' . (strpos($vals[1], '%') === false ? $vals[1] . 'px' : $vals[1])) . ';}'); } } } // return the visibility return $this->visible; }