/** * Display form for selecting classes * */ function ClassesForm() { global $dataDir, $langmessage; echo '<h2 class="hmargin">Manage Classes</h2>'; $cmd = \gp\tool::GetCommand(); switch ($cmd) { case 'LoadDefault': $classes = self::Defaults(); break; case 'LoadBootstrap': $classes = self::Bootstrap(); break; default: $classes = self::GetClasses(); break; } $classes[] = array('names' => '', 'desc' => ''); $this->page->jQueryCode .= '$(".sortable_table").sortable({items : "tr",handle: "td"});'; // FORM echo '<form action="' . $this->admin_link . '" method="post">'; echo '<table class="bordered full_width sortable_table">'; echo '<thead><tr><th>className(s)</th><th>Description (optional)</th></tr></thead>'; echo '<tbody>'; foreach ($classes as $key => $classArray) { echo '<tr><td>'; echo '<img alt="" src="' . \gp\tool::GetDir('/include/imgs/drag_handle.gif') . '" /> '; echo '<input size="16" class="gpinput" type="text" name="class_names[]" value="' . $classArray['names'] . '"/>'; echo '</td><td>'; echo '<input size="64" class="gpinput" type="text" name="class_desc[]" value="' . $classArray['desc'] . '"/> '; echo '<a class="gpbutton rm_table_row" title="Remove Item" data-cmd="rm_table_row">×</a>'; echo '</td></tr>'; } echo '<tr><td colspan="3">'; echo '<a data-cmd="add_table_row">Add Row</a>'; echo '</td></tr>'; echo '</tbody>'; echo '</table>'; echo '<br/>'; // SAVE / CANCEL BUTTONS echo '<button type="submit" name="cmd" value="SaveClasses" class="gpsubmit">' . $langmessage['save'] . '</button>'; echo '<button type="submit" name="cmd" value="" class="gpcancel">' . $langmessage['cancel'] . '</button>'; echo '<div style="margin-top:2em; border:1px solid #ccc; background:#fafafa; border-radius:3px; padding:12px;">'; echo 'CSS classNames you set here will be easily selectable in the Section Attributes dialog.'; echo '<ul>'; echo '<li>Single classNames (like <em>gpRow</em>) will show as checkboxes</li>'; echo '<li>Multiple, space separated classNames (like <em>gpCol-1 gpCol-2 gpCol-3 […]</em> will show as checkable dropdown list.</li>'; echo '<li>The list is drag’n’drop sortable.</li>'; echo '</ul><hr/>'; echo '</form>'; //$tooltip = $isBootswatchTheme ? ":-) Your current default theme is Bootstrap based - cleared for Take Off!" : ":-/ You will have to use a Bootstrap based theme for this preset!"; echo '<p>'; echo '<form action="' . $this->admin_link . '" method="get">'; echo '<button class="gpbutton" name="cmd" value="LoadBootstrap">Load the Bootstrap Preset</button> '; echo '<button class="gpbutton" name="cmd" value="LoadDefault">Load the Default Preset</button>'; echo '</p>'; echo '</div>'; }
/** * Show images available in themes * */ public function ShowThemeImages() { global $langmessage; $this->page->ajaxReplace = array(); $current_theme = false; //which theme folder if (isset($_REQUEST['theme']) && isset($this->avail_addons[$_REQUEST['theme']])) { $current_theme = $_REQUEST['theme']; $current_info = $this->avail_addons[$current_theme]; $current_label = $current_info['name']; $current_dir = $current_info['full_dir']; $current_url = \gp\tool::GetDir($current_info['rel']); //current layout } else { $layout_info = \gp\tool::LayoutInfo($this->curr_layout, false); $current_label = $layout_info['theme_name']; $current_dir = $layout_info['dir']; $current_url = \gp\tool::GetDir(dirname($layout_info['path'])); } //list of themes ob_start(); echo '<div class="gp_edit_select ckeditor_control">'; echo '<a class="gp_selected_folder"><span class="folder"></span>'; echo $current_label; echo '</a>'; echo '<div class="gp_edit_select_options">'; foreach ($this->avail_addons as $theme_id => $info) { $slug = 'Admin_Theme_Content/Image/' . rawurlencode($this->curr_layout); echo \gp\tool::Link($slug, '<span class="folder"></span>' . $info['name'], 'cmd=ShowThemeImages&theme=' . rawurlencode($theme_id), ' data-cmd="gpajax" class="gp_gallery_folder" '); } echo '</div>'; echo '</div>'; $gp_option_area = ob_get_clean(); //images in theme $images = array(); self::GetAvailThemeImages($current_dir, $current_url, $images); ob_start(); foreach ($images as $image) { echo '<span class="expand_child">' . '<a href="' . $image['url'] . '" data-cmd="gp_gallery_add" data-width="' . $image['width'] . '" data-height="' . $image['height'] . '">' . '<img src="' . $image['url'] . '" alt=""/>' . '</a></span>'; } $gp_gallery_avail_imgs = ob_get_clean(); if ($current_theme) { $this->page->ajaxReplace[] = array('inner', '#gp_option_area', $gp_option_area); $this->page->ajaxReplace[] = array('inner', '#gp_gallery_avail_imgs', $gp_gallery_avail_imgs); } else { $content = '<div id="gp_option_area">' . $gp_option_area . '</div>' . '<div id="gp_gallery_avail_imgs">' . $gp_gallery_avail_imgs . '</div>'; $this->page->ajaxReplace[] = array('inner', '#gp_image_area', $content); } $this->page->ajaxReplace[] = array('inner', '#gp_folder_options', ''); //remove upload button }
public function GalleryEditBox($title, $info) { if (is_array($info)) { $icon = $info['icon']; } else { $icon = $info; } if (empty($icon)) { $thumbPath = \gp\tool::GetDir('/include/imgs/blank.gif'); } elseif (strpos($icon, '/thumbnails/') === false) { $thumbPath = \gp\tool::GetDir('/data/_uploaded/image/thumbnails' . $icon . '.jpg'); } else { $thumbPath = \gp\tool::GetDir('/data/_uploaded' . $icon); } echo '<div class="draggable">'; echo \gp\tool::Link('Special_Galleries', htmlspecialchars($title), 'cmd=drag&to=%s&title=' . urlencode($title), 'data-cmd="gpajax" class="dragdroplink nodisplay" '); echo '<input type="hidden" name="title" value="' . htmlspecialchars($title) . '" class="title" />'; echo ' <img src="' . $thumbPath . '" alt="" class="icon"/>'; echo '<div class="caption">'; echo str_replace('_', ' ', $title); echo '</div>'; echo '</div>'; }
return $args; } function rename_check($event, $args, $finder) { $name = $args['name']; if (gp_restrict_uploads && !\gp\admin\Content\Uploaded::AllowedExtension($name)) { return false; } $args['name'] = $name; return $args; } function SaveFinderData($data) { global $config; $config['finder_data'] = $data; \gp\admin\Tools::SaveConfig(); } function ReturnFinderData() { global $config; if (isset($config['finder_data'])) { return $config['finder_data']; } return false; } $opts = array('debug' => gpdebug, 'saveData' => 'SaveFinderData', 'returnData' => 'ReturnFinderData', 'roots' => array(array('driver' => 'LocalFileSystem', 'path' => $dataDir . '/data/_uploaded/', 'URL' => \gp\tool::GetDir('data/_uploaded'), 'accessControl' => 'access', 'tmbPath' => $dataDir . '/data/_elthumbs', 'tmbURL' => \gp\tool::GetDir('data/_elthumbs'), 'separator' => '/', 'tmbBgColor' => 'transparent', 'copyOverwrite' => false, 'uploadOverwrite' => false, 'tmbPathMode' => gp_chmod_dir, 'dirMode' => gp_chmod_dir, 'fileMode' => gp_chmod_file)), 'bind' => array('duplicate upload rename rm paste resize' => array('\\gp\\admin\\Content\\Uploaded', 'FinderChange'), 'upload-before' => 'upload_check', 'rename-before' => 'rename_check')); $opts = \gp\tool\Plugins::Filter('FinderOptionsServer', array($opts)); gpSettingsOverride('finder_options_server', $opts); // run Finder $connector = new Finder($opts); $connector->run();
/** * Return a list of section types * */ public static function NewSections($checkboxes = false) { $types_with_imgs = array('text', 'image', 'gallery'); $section_types = \gp\tool\Output\Sections::GetTypes(); $links = array(); foreach ($section_types as $type => $type_info) { $img = ''; if (in_array($type, $types_with_imgs)) { $img = \gp\tool::GetDir('/include/imgs/section-' . $type . '.png'); } $links[] = array($type, $img); } $links[] = array(array('text.gpCol-6', 'image.gpCol-6'), \gp\tool::GetDir('/include/imgs/section-combo-text-image.png')); $links[] = array(array('text.gpCol-6', 'gallery.gpCol-6'), \gp\tool::GetDir('/include/imgs/section-combo-text-gallery.png')); //section combo: text & gallery $links = \gp\tool\Plugins::Filter('NewSections', array($links)); foreach ($links as $link) { $link += array('', '', 'gpRow'); echo self::NewSectionLink($link[0], $link[1], $link[2], $checkboxes); } }
/** * Check the path of the img, return full path of image if the requested image is found * */ function __construct() { global $dataDir; if (!isset($_GET['w']) || !isset($_GET['h']) || !isset($_GET['img'])) { self::Send404(); //dies } $img = $_GET['img']; $height = $_GET['h']; $width = $_GET['w']; $index = $_GET['i']; if (!is_numeric($height) || !is_numeric($width)) { self::Send404(); //dies } $img = \gp\tool\Files::NoNull($img); //check file path if (strpos($img, './') !== false || strpos($img, '%2f') !== false || strpos($img, '%2F') !== false) { return false; } //make sure the index is set gp_resized::SetIndex(); if (!isset(self::$index[$index])) { self::Send404(); //dies } //if the image has been renamed, redirect to the new name $index_img = self::$index[$index]; if ($index_img != $img) { $path = \gp\tool::GetDir('/include/image.php', false) . '?i=' . $index . '&w=' . $width . '&h=' . $height . '&img=' . rawurlencode($index_img); \gp\tool::Redirect($path); } $info = self::ImageInfo($img, $width, $height); $folder = $dataDir . '/data/_resized/' . $info['index']; $full_path = $folder . '/' . $info['name']; //if it exists return true if (file_exists($full_path)) { header('Cache-Control: public, max-age=5184000'); //60 days //attempt to send 304 $stats = lstat($full_path); if ($stats) { \gp\tool::Send304(\gp\tool::GenEtag($stats['mtime'], $stats['size'])); } header('Content-Transfer-Encoding: binary'); header('Content-Type: ' . $info['ctype']); readfile($full_path); die; } //redirect to next largest image if available $usage = self::GetUsage($info['index']); foreach ($usage as $size => $data) { if (!$data['uses']) { continue; } list($use_width, $use_height) = explode('x', $size); if ($use_width >= $width && $use_height > $height || $use_width > $width && $use_height >= $height) { $path = \gp\tool::GetDir('/include/image.php', false) . '?i=' . $index . '&w=' . $use_width . '&h=' . $use_height . '&img=' . rawurlencode($img); \gp\tool::Redirect($path); //dies } } //redirect to full size image $original = \gp\tool::GetDir('/data/_uploaded' . $img, false); \gp\tool::Redirect($original); //dies }
/** * Parse the ini a second time with variables * */ public function IniContents() { global $dataDir, $dirPrefix; $folder = basename($this->dest); $variables = array('{$addon}' => $folder, '{$plugin}' => $folder, '{$dataDir}' => $dataDir, '{$dirPrefix}' => $dirPrefix, '{$addonRelativeData}' => \gp\tool::GetDir('/data/_addondata/' . $this->data_folder), '{$addonRelativeCode}' => \gp\tool::GetDir($this->addon_folder_rel . '/' . $folder)); $this->ini_contents = \gp\tool\Ini::ParseString($this->ini_text, $variables); }
/** * Return settings of addon defined by $addon_key * */ public static function GetAddonConfig($addon_key) { global $config, $dataDir; if (!array_key_exists($addon_key, $config['addons'])) { return false; } $addon_config = $config['addons'][$addon_key]; if (!is_array($addon_config)) { trigger_error('Corrupted configuration for addon: ' . $addon_key); //.pre($config['addons'])); return false; } $addon_config += array('version' => false, 'id' => false, 'data_folder' => $addon_key, 'order' => false, 'code_folder_part' => '/data/_addoncode/' . $addon_key, 'name' => $addon_key); //data folder $addon_config['data_folder_part'] = '/data/_addondata/' . $addon_config['data_folder']; $addon_config['data_folder_full'] = $dataDir . $addon_config['data_folder_part']; $addon_config['data_folder_rel'] = \gp\tool::GetDir($addon_config['data_folder_part']); // Code folder //$addon_config['code_folder_part'] = $addon_config['code_folder'].'/'.$addon_key; $addon_config['code_folder_full'] = $dataDir . $addon_config['code_folder_part']; $addon_config['code_folder_rel'] = \gp\tool::GetDir($addon_config['code_folder_part']); return $addon_config; }
public function GenerateOutput() { global $langmessage; \gp\tool::ShowingGallery(); echo '<h2>'; echo \gp\tool\Output::ReturnText('galleries'); echo '</h2>'; $wrap = \gp\admin\Tools::CanEdit($this->page->gp_index); if ($wrap) { echo \gp\tool\Output::EditAreaLink($edit_index, 'Admin/Galleries', $langmessage['edit']); echo '<div class="editable_area cf" id="ExtraEditArea' . $edit_index . '">'; // class="edit_area" added by javascript } $image_text = \gp\tool\Output::ReturnText('image'); $images_text = \gp\tool\Output::ReturnText('images'); $list = ''; $shown = 0; foreach ($this->galleries as $title => $info) { //page is hidden if (!$this->GalleryVisible($title, $info)) { continue; } $count = ''; if (is_array($info)) { $icon = $info['icon']; if ($info['count'] == 1) { $count = $info['count'] . ' ' . \gp\tool\Output::ReturnText('image'); } elseif ($info['count'] > 1) { $count = $info['count'] . ' ' . \gp\tool\Output::ReturnText('images'); } } else { $icon = $info; } if (empty($icon)) { continue; } $icon = rawurldecode($icon); //prevent double encoding if (strpos($icon, '/thumbnails/') === false) { $thumbPath = \gp\tool::GetDir('/data/_uploaded/image/thumbnails' . $icon . '.jpg'); } else { $thumbPath = \gp\tool::GetDir('/data/_uploaded' . $icon); } $label = \gp\tool::GetLabel($title); $title_attr = ' title="' . \gp\tool::GetBrowserTitle($title) . '"'; $label_img = ' <img src="' . $thumbPath . '" alt=""/>'; $list .= '<li>' . \gp\tool::Link($title, $label_img, '', $title_attr) . '<div>' . \gp\tool::Link($title, $label, '', $title_attr) . '<p>' . $count . '</p>' . '</div>' . '</li>'; } if (!empty($list)) { echo '<ul class="gp_gallery gp_galleries">'; echo $list; echo '</ul>'; } if ($wrap) { echo '</div>'; } $this->PostSave(); }
/** * Complete the response by adding final content to the <head> of the document * @static * @since 2.4.1 * @param string $buffer html content * @return string finalized response */ public static function BufferOut($buffer) { global $config; //add error notice if there was a fatal error if (!ini_get('display_errors')) { $last_error = self::LastFatal(); if ($last_error) { self::RecordFatal($last_error); $buffer .= self::FatalMessage($last_error); } } //remove lock if (defined('gp_has_lock') && gp_has_lock) { \gp\tool\Files::Unlock('write', gp_random); } //make sure whe have a complete html request $placeholder = '<!-- get_head_placeholder ' . gp_random . ' -->'; if (strpos($buffer, $placeholder) === false) { return $buffer; } //add js to bottom of <body> $buffer = self::AddToBody($buffer, self::$head_js); $replacements = array(); //performace stats if (class_exists('admin_tools')) { $replacements = self::PerformanceStats(); } //head content $replacements[$placeholder] = self::$head_content; //add jquery if needed $placeholder = '<!-- jquery_placeholder ' . gp_random . ' -->'; $replacement = ''; if (!empty(self::$head_js) || stripos($buffer, '<script') !== false) { $replacement = "\n<script type=\"text/javascript\" src=\"" . \gp\tool::GetDir('/include/thirdparty/js/jquery.js') . "\"></script>"; } $replacements[$placeholder] = $replacement; //messages $pos = strpos($buffer, '<!-- message_start ' . gp_random . ' -->'); $len = strpos($buffer, '<!-- message_end -->') - $pos; if ($pos && $len) { $replacement = GetMessages(false); $buffer = substr_replace($buffer, $replacement, $pos, $len + 20); } return str_replace(array_keys($replacements), array_values($replacements), $buffer); }
public function Exported() { global $langmessage; if (count($this->exported) == 0) { return; } echo '<table class="bordered full_width">'; echo '<tr><th>'; echo $langmessage['Previous Exports']; echo '</th><th> </th><th>'; echo $langmessage['File Size']; echo '</th><th>'; echo $langmessage['options']; echo '</th></tr>'; $total_size = 0; $total_count = 0; foreach ($this->exported as $file) { $info = $this->FileInfo($file); if (!$info) { continue; } $full_path = $this->export_dir . '/' . $file; echo '<tr><td>'; echo str_replace(' ', ' ', $info['time']); echo '</td><td>'; echo implode(', ', $info['exported']); echo '</td><td>'; $size = filesize($full_path); echo \gp\admin\Tools::FormatBytes($size); echo ' '; echo $info['ext']; echo '</td><td>'; echo '<a href="' . \gp\tool::GetDir('/data/_exports/' . $file) . '">' . $langmessage['Download'] . '</a>'; echo ' '; if ($this->CanRevert($info['bits'])) { echo \gp\tool::Link('Admin/Port', $langmessage['Revert'], 'cmd=revert&archive=' . rawurlencode($file), '', $file); } else { echo $langmessage['Revert']; } echo ' '; echo \gp\tool::Link('Admin/Port', $langmessage['delete'], 'cmd=delete&file=' . rawurlencode($file), array('data-cmd' => 'postlink', 'title' => $langmessage['delete_confirm'], 'class' => 'gpconfirm'), $file); echo '</td></tr>'; $total_count++; $total_size += $size; } //totals echo '<tr><th>'; echo $langmessage['Total']; echo ': '; echo $total_count; echo '</th><th> </th><th>'; echo \gp\admin\Tools::FormatBytes($total_size); echo '</th><th> </th></tr>'; echo '</table>'; }
function ShowRedirection() { global $langmessage, $gp_index, $config; $this->page->head_js[] = '/include/thirdparty/tablesorter/tablesorter.js'; $this->page->jQueryCode .= '$("table.tablesorter").tablesorter({cssHeader:"gp_header",cssAsc:"gp_header_asc",cssDesc:"gp_header_desc"});'; echo '<p>' . $langmessage['About_Redirection'] . '</p>'; echo \gp\tool::Link('Admin/Missing', $langmessage['New Redirection'], 'cmd=newform', array('data-cmd' => 'gpabox')); if (empty($this->error_data['redirects'])) { return; } echo '<table class="bordered tablesorter full_width">'; echo '<thead>'; echo '<tr><th>'; echo $langmessage['Source URL']; echo '</th><th>'; echo $langmessage['Target URL']; echo '</th><th>'; echo $langmessage['Similarity']; echo '</th><th>'; echo $langmessage['Method']; echo '</th><th>'; echo $langmessage['options']; echo '</th></tr>'; echo '</thead>'; echo '<tbody>'; $has_invalid_target = false; $admin_urls = \gp\admin\Tools::AdminScripts(); foreach ($this->error_data['redirects'] as $source => $data) { echo '<tr><td>'; $raw_source = $source; if (!empty($data['raw_source'])) { $raw_source = $data['raw_source']; } echo htmlspecialchars($raw_source); echo '</td><td>'; $target_show = $data['target']; if (strlen($target_show) > 40) { $target_show = substr($target_show, 0, 15) . ' ... ' . substr($target_show, -15); } $full_target = $this->GetTarget($data['target'], false); echo '<a href="' . htmlspecialchars($full_target) . '">' . str_replace(' ', ' ', htmlspecialchars($target_show)) . '</a>'; $is_gplink = $this->isGPLink($data['target']); if (!empty($data['target']) && $is_gplink) { if (!isset($gp_index[$data['target']]) && !isset($admin_urls[$data['target']])) { $has_invalid_target = true; echo ' <img src="' . \gp\tool::GetDir('/include/imgs/error.png') . '" alt="" height="16" width="16" style="vertical-align:middle" title="' . $langmessage['Target URL Invalid'] . '"/> '; } } echo '</td><td>'; if ($is_gplink) { $lower_source = strtolower($raw_source); $lower_target = strtolower($target_show); similar_text($lower_source, $lower_target, $percent); if ($config['auto_redir'] > 0 && $percent >= $config['auto_redir']) { //echo '<span style="color:orange">'.number_format($percent,1).'%</span>'; echo number_format($percent, 1) . '%'; } else { echo number_format($percent, 1) . '%'; } } else { echo ' '; } echo '</td><td>'; echo $this->GetCodeLanguage($data['code']); echo '</td><td>'; echo \gp\tool::Link('Admin/Missing', $langmessage['edit'], 'cmd=editredir&source=' . urlencode($source), array('data-cmd' => 'gpabox')); echo ' '; echo \gp\tool::Link($source, $langmessage['Test']); echo ' '; $title = sprintf($langmessage['generic_delete_confirm'], $source); echo \gp\tool::Link('Admin/Missing', $langmessage['delete'], 'cmd=rmredir&link=' . urlencode($source), array('data-cmd' => 'postlink', 'title' => $title, 'class' => 'gpconfirm')); echo '</td></tr>'; } echo '</tbody>'; echo '</table>'; echo '<p>'; echo \gp\tool::Link('Admin/Missing', $langmessage['New Redirection'], 'cmd=newform', array('data-cmd' => 'gpabox')); echo '</p>'; if ($has_invalid_target) { echo '<p>'; echo ' <img src="' . \gp\tool::GetDir('/include/imgs/error.png') . '" alt="" height="16" width="16" style="vertical-align:middle" title="' . $langmessage['Target URL Invalid'] . '"/> '; echo $langmessage['Target URL Invalid']; echo '</p>'; } }
public function PreviewThemeIframe($theme, $theme_info) { global $langmessage, $config; \gp\admin\Tools::$show_toolbar = false; $this->page->gpLayout = false; $this->page->theme_name = $theme_info['folder']; $this->page->theme_color = $theme_info['color']; $this->page->theme_dir = $theme_info['full_dir']; $this->page->theme_rel = $theme_info['rel'] . '/' . $theme_info['color']; $this->LoremIpsum(); if (isset($theme_info['id'])) { $this->page->theme_addon_id = $theme_info['id']; } $this->page->theme_path = \gp\tool::GetDir($this->page->theme_rel); $this->page->show_admin_content = false; }
/** * Output the link areas that are displayed in the main admin toolbar and admin_main * @param bool $in_panel Whether or not the links will be displayed in the toolbar * @static */ public static function AdminPanelLinks($in_panel = true) { global $langmessage, $page, $gpAdmin; //content $links = self::GetAdminGroup('content'); self::_AdminPanelLinks($in_panel, $links, 'Content', 'fa fa-file-text-o', 'con'); //appearance $links = self::GetAppearanceGroup($in_panel); self::_AdminPanelLinks($in_panel, $links, 'Appearance', 'fa fa-th', 'app'); //add-ons $links = self::GetAddonLinks($in_panel); self::_AdminPanelLinks($in_panel, $links, 'plugins', 'fa fa-plug', 'add'); //settings $links = self::GetAdminGroup('settings'); self::_AdminPanelLinks($in_panel, $links, 'Settings', 'fa fa-sliders', 'set'); //tools $links = self::GetAdminGroup('tools'); self::_AdminPanelLinks($in_panel, $links, 'Tools', 'fa fa-wrench', 'tool'); //updates if (count(self::$new_versions) > 0) { ob_start(); if (gp_remote_update && isset(self::$new_versions['core'])) { echo '<li>'; echo '<a href="' . \gp\tool::GetDir('/include/install/update.php') . '">' . CMS_NAME . ' ' . self::$new_versions['core'] . '</a>'; echo '</li>'; } foreach (self::$new_versions as $addon_id => $new_addon_info) { if (!is_numeric($addon_id)) { continue; } $label = $new_addon_info['name'] . ': ' . $new_addon_info['version']; $url = self::RemoteUrl($new_addon_info['type']); if ($url === false) { continue; } echo '<li><a href="' . addon_browse_path . '/' . $url . '/' . $addon_id . '" data-cmd="remote">' . $label . '</a></li>'; } $links = ob_get_clean(); self::_AdminPanelLinks($in_panel, $links, 'updates', 'fa fa-refresh', 'upd'); } //username ob_start(); self::GetFrequentlyUsed($in_panel); echo '<li>'; echo \gp\tool::Link('Admin/Preferences', $langmessage['Preferences']); echo '</li>'; echo '<li>'; echo \gp\tool::Link($page->title, $langmessage['logout'], 'cmd=logout', array('data-cmd' => 'creq')); echo '</li>'; echo '<li>'; echo \gp\tool::Link('Admin/About', 'About ' . CMS_NAME); echo '</li>'; $links = ob_get_clean(); self::_AdminPanelLinks($in_panel, $links, $gpAdmin['useralias'], 'fa fa-user', 'use'); // stats ob_start(); echo '<li><span><span cms-memory-usage>?</span> Memory</span></li>'; echo '<li><span><span cms-memory-max>?</span> Max Memory</span></li>'; echo '<li><span><span cms-seconds>?</span> Seconds</span></li>'; echo '<li><span><span cms-ms>?</span> Milliseconds</span></li>'; echo '<li><span>0 DB Queries</span></li>'; $links = ob_get_clean(); self::_AdminPanelLinks($in_panel, $links, 'Performance', 'fa fa-bar-chart', 'cms'); //resources if ($page->pagetype === 'admin_display') { ob_start(); if (gp_remote_plugins && self::HasPermission('Admin_Addons')) { echo '<li>' . \gp\tool::Link('Admin/Addons/Remote', $langmessage['Download Plugins']) . '</li>'; } if (gp_remote_themes && self::HasPermission('Admin_Theme_Content')) { echo '<li>' . \gp\tool::Link('Admin_Theme_Content/Remote', $langmessage['Download Themes']) . '</li>'; } echo '<li><a href="' . CMS_DOMAIN . '/Forum">Support Forum</a></li>'; echo '<li><a href="' . CMS_DOMAIN . '/Services">Service Providers</a></li>'; echo '<li><a href="' . CMS_DOMAIN . '">Official ' . CMS_NAME . ' Site</a></li>'; echo '<li><a href="https://github.com/Typesetter/Typesetter/issues">Report A Bug</a></li>'; $links = ob_get_clean(); self::_AdminPanelLinks($in_panel, $links, 'resources', 'fa fa-globe', 'res'); if ($in_panel) { echo '<div class="gpversion">'; echo CMS_NAME . ' ' . gpversion; echo '</div>'; } } }
/** * Get the default content for the specified content type * @static * @since 3.6 * */ public static function DefaultContent($type = 'text', $heading = 'Lorem Ipsum') { global $langmessage; $section = array(); $section['type'] = $type; $section['content'] = ''; switch ($type) { case 'include': break; case 'gallery': $section['content'] = '<ul class="gp_gallery"><li class="gp_to_remove">' . '<a class="gallery_gallery" data-cmd="gallery" href="' . \gp\tool::GetDir('/include/imgs/default_image.jpg') . '" data-arg="gallery_gallery">' . '<img alt="" src="' . \gp\tool::GetDir('/include/imgs/default_thumb.jpg') . '" />' . '</a>' . '<div class="caption">Image caption</div>' . '</li></ul>'; break; case 'wrapper_section': $section['content'] = ''; $section['contains_sections'] = 0; break; case 'image': $section['nodeName'] = 'img'; $section['attributes']['src'] = '/include/imgs/default_image.jpg'; $section['attributes']['width'] = '400px'; $section['attributes']['height'] = '300px'; break; case 'text': default: $section['content'] = '<div><h2>' . strip_tags($heading) . '</h2><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p><p> Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div>'; break; } $content = \gp\tool\Plugins::Filter('GetDefaultContent', array($section['content'], $type)); if (is_array($content)) { $section = $content + $section; } else { $section['content'] = $content; } $section += array('attributes' => array()); $section['attributes'] += array('class' => ''); return $section; }
/** * Convert array of html attributes into a string for output * */ static function SectionAttributes($attrs, $type) { switch ($type) { case 'image': $attrs['src'] = \gp\tool::GetDir($attrs['src']); break; } $attrs += array('class' => ''); $attrs['class'] = trim('GPAREA filetype-' . $type . ' ' . $attrs['class']); $attr_string = ''; foreach ($attrs as $attr => $value) { $attr_string .= ' ' . htmlspecialchars($attr) . '="' . htmlspecialchars($value) . '"'; } return $attr_string; }
public function CSS_FixUrl($url, $pos, $pos2) { global $dataDir; $url = trim($url); $url = trim($url, '"\''); if (empty($url)) { return; } //relative url if ($url[0] == '/') { return; } elseif (strpos($url, '://') > 0) { return; } elseif (preg_match('/^data:/i', $url)) { return; } //use a relative path so sub.domain.com and domain.com/sub both work $replacement = \gp\tool::GetDir(dirname($this->file) . '/' . $url); $replacement = $this->ReduceUrl($replacement); $replacement = '"' . $replacement . '"'; $this->content = substr_replace($this->content, $replacement, $pos, $pos2 - $pos); }
/** * Set the page's theme name and path information according to the specified $layout * If $layout is not found, use the installation's default theme * */ function SetTheme($layout = false) { global $dataDir; if ($layout === false) { $layout = self::OrConfig($this->gp_index, 'gpLayout'); } $layout_info = \gp\tool::LayoutInfo($layout); if (!$layout_info) { $default_theme = explode('/', gp_default_theme); $this->gpLayout = false; $this->theme_name = $default_theme[0]; $this->theme_color = $default_theme[1]; $this->theme_rel = '/themes/' . $this->theme_name . '/' . $this->theme_color; $this->theme_dir = $dataDir . '/themes/' . $this->theme_name; } else { $this->gpLayout = $layout; $this->theme_name = $layout_info['theme_name']; $this->theme_color = $layout_info['theme_color']; $this->theme_rel = $layout_info['path']; $this->theme_dir = $layout_info['dir']; if (isset($layout_info['addon_id'])) { $this->theme_addon_id = $layout_info['addon_id']; } $this->theme_is_addon = $layout_info['is_addon']; //if installed in /themes or /data/_themes //css preferences if (isset($layout_info['menu_css_ordered']) && !$layout_info['menu_css_ordered']) { $this->menu_css_ordered = false; } if (isset($layout_info['menu_css_indexed']) && !$layout_info['menu_css_indexed']) { $this->menu_css_indexed = false; } } $this->theme_path = \gp\tool::GetDir($this->theme_rel); }
/** * Get scripts for editing inline text using ckeditor * */ static function InlineEdit_Text($scripts) { // autocomplete $scripts[] = array('code' => \gp\tool\Editing::AutoCompleteValues(true), 'object' => 'gptitles'); // ckeditor basepath and configuration $options = array('extraPlugins' => 'sharedspace', 'sharedSpaces' => array('top' => 'ckeditor_top', 'bottom' => ' ckeditor_bottom')); $ckeditor_basepath = \gp\tool::GetDir('/include/thirdparty/ckeditor_34/'); echo 'CKEDITOR_BASEPATH = ' . self::quote($ckeditor_basepath) . ';'; // config $scripts[] = array('code' => 'var gp_ckconfig = ' . \gp\tool\Editing::CKConfig($options, 'json', $plugins) . ';', 'object' => 'gp_ckconfig'); // extra plugins $scripts[] = array('code' => 'var gp_add_plugins = ' . json_encode($plugins) . ';', 'object' => 'gp_add_plugins'); // CKEDITOR $scripts[] = array('file' => '/include/thirdparty/ckeditor_34/ckeditor.js', 'object' => 'CKEDITOR'); $scripts[] = array('file' => '/include/js/ckeditor_config.js', 'object' => 'CKEDITOR'); $scripts[] = '/include/js/inline_edit/inlineck.js'; return $scripts; }
/** * Handle the processing of multiple less files into css * * @return mixed Compiled css string or false * */ static function ParseLess(&$less_files) { global $dataDir; $compiled = false; // don't use less if the memory limit is less than 64M $limit = @ini_get('memory_limit'); if ($limit) { $limit = \gp\tool::getByteValue($limit); //if less than 64M, disable less compiler if we can't increase if ($limit < 67108864 && @ini_set('memory_limit', '96M') === false) { if (\gp\tool::LoggedIn()) { msg('LESS compilation disabled. Please increase php\'s memory_limit'); } return false; //if less than 96M, try to increase } elseif ($limit < 100663296) { @ini_set('memory_limit', '96M'); } } //compiler options $options = array(); //prepare the compiler includeFile('thirdparty/less.php/Less.php'); $parser = new \Less_Parser($options); $import_dirs[$dataDir] = \gp\tool::GetDir('/'); $parser->SetImportDirs($import_dirs); $parser->cache_method = 'php'; $parser->SetCacheDir($dataDir . '/data/_cache'); // combine files try { foreach ($less_files as $less) { //treat as less markup if there are newline characters if (strpos($less, "\n") !== false) { $parser->Parse($less); continue; } // handle relative and absolute paths if (!empty($dataDir) && strpos($less, $dataDir) === false) { $relative = $less; $less = $dataDir . '/' . ltrim($less, '/'); } else { $relative = substr($less, strlen($dataDir)); } $parser->ParseFile($less, \gp\tool::GetDir(dirname($relative))); } $compiled = $parser->getCss(); } catch (Exception $e) { if (\gp\tool::LoggedIn()) { msg('LESS Compile Failed: ' . $e->getMessage()); } return false; } // significant difference in used memory 15,000,000 -> 6,000,000. Max still @ 15,000,000 if (function_exists('gc_collect_cycles')) { gc_collect_cycles(); } $less_files = $parser->allParsedFiles(); return $compiled; }
/** * @static */ public static function ShowFile_Gallery($dir_piece, $file) { global $langmessage, $dataDir; if (!self::IsImg($file)) { return; } //for gallery editing $rel_path = '/data/_uploaded' . $dir_piece . '/' . $file; $id = self::ImageId($rel_path); $file_url = \gp\tool::GetDir($rel_path); $full_path = $dataDir . $rel_path; //thumbnail $thumb_url = \gp\tool::ThumbnailPath($file_url); $thumb = ' <img src="' . $thumb_url . '" alt="" />'; //get size $size = ''; $size_a = getimagesize($full_path); if (is_array($size_a)) { $size = ' data-width="' . $size_a[0] . '" data-height="' . $size_a[1] . '"'; } $query_string = 'file_cmd=delete&show=inline&file=' . urlencode($file); return '<span class="expand_child" id="' . $id . '">' . '<a href="' . $file_url . '" data-cmd="gp_gallery_add" ' . $size . '>' . $thumb . '</a>' . \gp\tool::Link('Admin/Uploaded' . $dir_piece, '', $query_string, array('class' => 'delete fa fa-minus-circle gpconfirm', 'data-cmd' => 'gpajax', 'title' => $langmessage['delete_confirm']), 'delete') . '</span>'; }