Esempio n. 1
0
 /**
  * Save a theme image
  * Resize image if necessary
  *
  */
 public function SaveHeaderImage()
 {
     global $gpLayouts, $langmessage;
     $this->page->ajaxReplace = array();
     $section = array();
     if (!\gp\tool\Editing::SectionFromPost_Image($section, '/data/_uploaded/headers/')) {
         return false;
     }
     $save_info = array();
     $save_info['img_rel'] = $section['attributes']['src'];
     $save_info['width'] = $section['attributes']['width'];
     $save_info['height'] = $section['attributes']['height'];
     $container = $_REQUEST['container'];
     $gpLayouts[$this->curr_layout]['images'][$container] = array();
     //prevents shuffle
     $gpLayouts[$this->curr_layout]['images'][$container][] = $save_info;
     if (!$this->SaveLayouts()) {
         return false;
     }
     $this->page->ajaxReplace[] = array('ck_saved', '', '');
     return true;
 }
Esempio n. 2
0
 /**
  * Get the content of the file in the trash so we can restore file information
  *  - resized images
  *  - \gp\special\Galleries::UpdateGalleryInfo($title,$content)
  *
  */
 public static function RestoreFile($title, $file, $title_info)
 {
     $file_sections = \gp\tool\Files::Get($file, 'file_sections');
     // Restore resized images
     if (count($file_sections)) {
         includeFile('image.php');
         \gp_resized::SetIndex();
         foreach ($file_sections as $section => $section_data) {
             if (!isset($section_data['resized_imgs'])) {
                 continue;
             }
             foreach ($section_data['resized_imgs'] as $image_index => $sizes) {
                 if (!isset(\gp_resized::$index[$image_index])) {
                     continue;
                 }
                 $img = \gp_resized::$index[$image_index];
                 foreach ($sizes as $size) {
                     list($width, $height) = explode('x', $size);
                     \gp\tool\Editing::CreateImage($img, $width, $height);
                 }
             }
             \gp\tool\Editing::ResizedImageUse(array(), $section_data['resized_imgs']);
         }
         \gp_resized::SaveIndex();
     }
     // Restore Galleries
     if (strpos($title_info['type'], 'gallery') !== false) {
         \gp\special\Galleries::UpdateGalleryInfo($title, $file_sections);
     }
 }
Esempio n. 3
0
 /**
  * Used by slideshow addons
  * @deprecated 3.6rc4
  *
  */
 public function SaveSection_Text($section)
 {
     return \gp\tool\Editing::SectionFromPost_Text($this->file_sections[$section]);
 }
Esempio n. 4
0
 public function SaveAddonText()
 {
     global $langmessage, $config;
     $addon = \gp\tool\Editing::CleanArg($_REQUEST['addon']);
     $texts = $this->GetAddonTexts($addon);
     //not set up correctly
     if ($texts === false) {
         message($langmessage['OOPS'] . ' (0)');
         return;
     }
     foreach ($texts as $text) {
         if (!isset($_POST['values'][$text])) {
             continue;
         }
         $default = $text;
         if (isset($langmessage[$text])) {
             $default = $langmessage[$text];
         }
         $value = htmlspecialchars($_POST['values'][$text]);
         if ($value === $default || htmlspecialchars($default) == $value) {
             unset($config['customlang'][$text]);
         } else {
             $config['customlang'][$text] = $value;
         }
     }
     if ($this->SaveConfig()) {
         $this->UpdateAddon($addon);
     }
 }
Esempio n. 5
0
 /**
  * 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;
 }
Esempio n. 6
0
 /**
  * Display Current Configuration Settings
  *
  */
 function DisplayCurrent()
 {
     global $langmessage;
     echo '<h3>' . $langmessage['Current Configuration'] . '</h3>';
     $default_config = \gp\tool\Editing::CKConfig(array(), 'array');
     echo '<pre class="json">';
     echo self::ReadableJson($default_config);
     echo '</pre>';
 }
Esempio n. 7
0
 /**
  * Create a new extra content section
  *
  */
 public function NewSection()
 {
     global $langmessage, $gpAdmin;
     $title = \gp\tool\Editing::CleanTitle($_REQUEST['new_title']);
     if (empty($title)) {
         message($langmessage['OOPS'] . ' (Invalid Title)');
         return false;
     }
     $file = $this->folder . '/' . $title . '/page.php';
     $section = \gp\tool\Editing::DefaultContent($_POST['type']);
     $section['created'] = time();
     $section['created_by'] = $gpAdmin['username'];
     $sections = array($section);
     if (!\gp\tool\Files::SaveData($file, 'file_sections', $sections)) {
         message($langmessage['OOPS'] . ' (Not Saved)');
         return false;
     }
     message($langmessage['SAVED']);
     $this->areas[$title] = $title;
 }
Esempio n. 8
0
 /**
  * Output a list a images in a director for use in inline editing
  * @static
  */
 public static function InlineList($dir_piece)
 {
     global $langmessage, $dataDir, $page;
     $page->ajaxReplace = array();
     $dir_piece = \gp\tool::WinPath($dir_piece);
     $dir = $dataDir . '/data/_uploaded' . $dir_piece;
     $prev_piece = false;
     while ($dir_piece != '/' && !file_exists($dir)) {
         $prev_piece = $dir_piece;
         $dir = \gp\tool::DirName($dir);
         $dir_piece = \gp\tool::DirName($dir_piece);
     }
     //new directory?
     if ($prev_piece) {
         $prev_piece = \gp\tool\Editing::CleanArg($prev_piece);
         $dir_piece = $prev_piece;
         $dir = $dataDir . '/data/_uploaded' . $prev_piece;
         if (!\gp\tool\Files::CheckDir($dir)) {
             message($langmessage['OOPS']);
             $dir = \gp\tool::DirName($dir);
             $dir_piece = \gp\tool::DirName($prev_piece);
         }
     }
     //folder information
     $folders = $files = array();
     $allFiles = \gp\tool\Files::ReadFolderAndFiles($dir);
     list($folders, $files) = $allFiles;
     //available images
     ob_start();
     $image_count = 0;
     foreach ($files as $file) {
         $img = self::ShowFile_Gallery($dir_piece, $file);
         if (is_string($img)) {
             echo $img;
             $image_count++;
         }
     }
     $gp_gallery_avail_imgs = ob_get_clean();
     $gp_option_area = self::InlineList_Options($dir_piece, $folders);
     $folder_options = self::InlineList_Folder($image_count, $dir_piece);
     //send content according to request
     $cmd = \gp\tool::GetCommand();
     switch ($cmd) {
         case 'gallery_folder':
             $page->ajaxReplace[] = array('inner', '#gp_option_area', $gp_option_area);
             $page->ajaxReplace[] = array('inner', '#gp_gallery_avail_imgs', $gp_gallery_avail_imgs);
             break;
         default:
             $content = '<div id="gp_option_area">' . $gp_option_area . '</div>' . '<div id="gp_gallery_avail_imgs">' . $gp_gallery_avail_imgs . '</div>';
             $page->ajaxReplace[] = array('inner', '#gp_image_area', $content);
             break;
     }
     $page->ajaxReplace[] = array('inner', '#gp_folder_options', $folder_options);
     $page->ajaxReplace[] = array('gp_gallery_images', '', '');
     //tell the script the images have been loaded
 }
Esempio n. 9
0
 function Edit404($text = false)
 {
     global $langmessage;
     if ($text === false) {
         if (isset($this->error_data['404_TEXT'])) {
             $text = $this->error_data['404_TEXT'];
         } else {
             $text = self::DefaultContent();
         }
     }
     echo '<h2>' . $langmessage['Link Errors'] . ' &#187; ' . $langmessage['404_Page'] . '</h2>';
     echo '<form action="' . \gp\tool::GetUrl('Admin/Missing') . '" method="post">';
     echo '<input type="hidden" name="cmd" value="save404" />';
     \gp\tool\Editing::UseCK($text);
     echo '<input type="submit" name="" value="' . $langmessage['save'] . '" class="gpsubmit"/>';
     echo ' <input type="submit" name="cmd" value="' . $langmessage['cancel'] . '" class="gpcancel"/>';
     echo '</form>';
     echo '<table class="bordered">';
     echo '<tr><th>';
     echo $langmessage['Useful Variables'];
     echo '</th>';
     echo '<th>';
     echo '&nbsp;';
     echo '</th>';
     echo '</tr>';
     echo '<tr><td>';
     echo '{{Similar_Titles}}';
     echo '</td>';
     echo '<td>';
     echo $langmessage['Similar_Titles'];
     echo '</td>';
     echo '</tr></table>';
 }
Esempio n. 10
0
 /**
  * Create a new page from a user post
  *
  */
 public static function CreateNew()
 {
     global $gp_index, $gp_titles, $langmessage, $gpAdmin;
     //check title
     $title = $_POST['title'];
     $title = \gp\admin\Tools::CheckPostedNewPage($title, $message);
     if ($title === false) {
         msg($message);
         return false;
     }
     //multiple section types
     $type = $_POST['content_type'];
     if (strpos($type, '{') === 0) {
         $types = json_decode($type, true);
         if ($types) {
             $types += array('wrapper_class' => 'gpRow');
             $content = array();
             //wrapper section
             $section = \gp\tool\Editing::DefaultContent('wrapper_section');
             $section['contains_sections'] = count($types['types']);
             $section['attributes']['class'] = $types['wrapper_class'];
             $content[] = $section;
             //nested sections
             foreach ($types['types'] as $type) {
                 if (strpos($type, '.')) {
                     list($type, $class) = explode('.', $type, 2);
                 } else {
                     $class = '';
                 }
                 $section = \gp\tool\Editing::DefaultContent($type);
                 $section['attributes']['class'] .= ' ' . $class;
                 $content[] = $section;
             }
         }
         //single section type
     } else {
         $content = \gp\tool\Editing::DefaultContent($type, $_POST['title']);
         if ($content['content'] === false) {
             return false;
         }
     }
     //add to $gp_index first!
     $index = \gp\tool::NewFileIndex();
     $gp_index[$title] = $index;
     if (!\gp\tool\Files::NewTitle($title, $content, $type)) {
         msg($langmessage['OOPS'] . ' (cn1)');
         unset($gp_index[$title]);
         return false;
     }
     //add to gp_titles
     $new_titles = array();
     $new_titles[$index]['label'] = \gp\admin\Tools::PostedLabel($_POST['title']);
     $new_titles[$index]['type'] = $type;
     $gp_titles += $new_titles;
     //add to users editing
     if ($gpAdmin['editing'] != 'all') {
         $gpAdmin['editing'] = rtrim($gpAdmin['editing'], ',') . ',' . $index . ',';
         $users = \gp\tool\Files::Get('_site/users');
         $users[$gpAdmin['username']]['editing'] = $gpAdmin['editing'];
         \gp\tool\Files::SaveData('_site/users', 'users', $users);
     }
     return $index;
 }
Esempio n. 11
0
 /**
  * Check the posted name of a menu
  *
  */
 public function AltMenu_NewName()
 {
     global $langmessage;
     $menu_name = \gp\tool\Editing::CleanTitle($_POST['menu_name'], ' ');
     if (empty($menu_name)) {
         msg($langmessage['OOPS'] . ' (Empty Name)');
         return false;
     }
     if (array_search($menu_name, $this->avail_menus) !== false) {
         msg($langmessage['OOPS'] . ' (Name Exists)');
         return false;
     }
     return $menu_name;
 }
Esempio n. 12
0
 /**
  * @deprecated 3.0
  * Use \gp\tool\Editing::CleanTitle() instead
  * Used by Simple_Blog1
  */
 public static function CleanTitle($title, $spaces = '_')
 {
     trigger_error('Deprecated Function');
     return \gp\tool\Editing::CleanTitle($title, $spaces);
 }
Esempio n. 13
0
 public function ExtraJS()
 {
     header('Content-type: application/javascript');
     trigger_error('Deprecated: special_extrajs');
     $_GET += array('which' => array());
     foreach ((array) $_GET['which'] as $which_code) {
         switch ($which_code) {
             case 'autocomplete2':
                 $options['admin_vals'] = false;
                 $options['var_name'] = 'gp_include_titles';
                 echo \gp\tool\Editing::AutoCompleteValues(false, $options);
                 break;
             case 'autocomplete':
                 echo \gp\tool\Editing::AutoCompleteValues(true);
                 break;
             case 'gp_ckconfig':
                 $options = array();
                 echo \gp\tool\Editing::CKConfig($options, 'gp_ckconfig');
                 break;
         }
     }
     die;
 }
Esempio n. 14
0
 /**
  * Show the default admin page
  *
  */
 private function AdminPanel()
 {
     global $langmessage;
     $cmd = \gp\tool::GetCommand();
     switch ($cmd) {
         case 'embededcheck':
             new \gp\admin\Update('embededcheck');
             return;
         case 'autocomplete-titles':
             $opts = array('var_name' => false);
             echo \gp\tool\Editing::AutoCompleteValues(false, $opts);
             die;
     }
     $this->head_js[] = '/include/js/auto_width.js';
     echo '<h2>' . $langmessage['administration'] . '</h2>';
     echo '<div id="adminlinks2">';
     \gp\admin\Tools::AdminPanelLinks(false);
     echo '</div>';
 }
Esempio n. 15
0
 /**
  * Primary Display
  *
  *
  */
 public function ShowForm()
 {
     global $langmessage, $config;
     $menu_output = false;
     ob_start();
     if (isset($this->list_displays[$this->curr_menu_id])) {
         $this->SearchDisplay();
         $replace_id = '#gp_menu_available';
     } else {
         $menu_output = true;
         $this->OutputMenu();
         $replace_id = '#admin_menu';
     }
     $content = ob_get_clean();
     // json response
     if (isset($_REQUEST['gpreq']) && $_REQUEST['gpreq'] == 'json') {
         $this->MenuJsonResponse($replace_id, $content);
         return;
     }
     // search form
     echo '<form action="' . \gp\tool::GetUrl('Admin/Menu') . '" method="post" id="page_search">';
     $_REQUEST += array('q' => '');
     echo '<input type="text" name="q" size="15" value="' . htmlspecialchars($_REQUEST['q']) . '" class="gptext gpinput title-autocomplete" /> ';
     echo '<input type="submit" name="cmd" value="' . $langmessage['search pages'] . '" class="gpbutton" />';
     echo '<input type="hidden" name="menu" value="search" />';
     echo '</form>';
     $menus = $this->GetAvailMenus('menu');
     $lists = $this->GetAvailMenus('display');
     //heading
     echo '<form action="' . \gp\tool::GetUrl('Admin/Menu') . '" method="post" id="gp_menu_select_form">';
     echo '<input type="hidden" name="curr_menu" id="gp_curr_menu" value="' . $this->curr_menu_id . '" />';
     echo '<h2 class="first-child">';
     echo $langmessage['file_manager'] . ' &#187;  ';
     echo '<select id="gp_menu_select" name="gp_menu_select" class="gpselect">';
     echo '<optgroup label="' . $langmessage['Menus'] . '">';
     foreach ($menus as $menu_id => $menu_label) {
         if ($menu_id == $this->curr_menu_id) {
             echo '<option value="' . $menu_id . '" selected="selected">';
         } else {
             echo '<option value="' . $menu_id . '">';
         }
         echo $menu_label . '</option>';
     }
     echo '</optgroup>';
     echo '<optgroup label="' . $langmessage['Lists'] . '">';
     foreach ($lists as $menu_id => $menu_label) {
         if ($menu_id == $this->curr_menu_id) {
             echo '<option value="' . $menu_id . '" selected="selected">';
         } elseif ($menu_id == 'search') {
             continue;
         } else {
             echo '<option value="' . $menu_id . '">';
         }
         echo $menu_label . '</option>';
     }
     echo '</optgroup>';
     echo '</select>';
     echo '</h2>';
     echo '</form>';
     //homepage
     echo '<div class="homepage_setting">';
     $this->HomepageDisplay();
     echo '</div>';
     \gp\tool\Editing::PrepAutoComplete();
     echo '<div id="admin_menu_div">';
     if ($menu_output) {
         echo '<ul id="admin_menu" class="sortable_menu">';
         echo $content;
         echo '</ul><div id="admin_menu_tools" ></div>';
         echo '<div id="menu_info" style="display:none">';
         $this->MenuSkeleton();
         echo '</div>';
         echo '<div id="menu_info_extern" style="display:none">';
         $this->MenuSkeletonExtern();
         echo '</div>';
     } else {
         echo '<div id="gp_menu_available">';
         echo $content;
         echo '</div>';
     }
     echo '</div>';
     echo '<div class="admin_footnote">';
     echo '<div>';
     echo '<b>' . $langmessage['Menus'] . '</b>';
     $this->MenuList($menus);
     echo '<span>' . \gp\tool::Link('Admin/Menu/Menus', '+ ' . $langmessage['Add New Menu'], 'cmd=NewMenuPrompt', 'data-cmd="gpabox"') . '</span>';
     echo '</div>';
     echo '<div>';
     echo '<b>' . $langmessage['Lists'] . '</b>';
     $this->MenuList($lists);
     echo '</div>';
     //options for alternate menu
     if ($this->is_alt_menu) {
         echo '<div>';
         $label = $menus[$this->curr_menu_id];
         echo '<b>' . $label . '</b>';
         echo '<span>' . \gp\tool::Link('Admin/Menu/Menus', $langmessage['rename'], 'cmd=RenameMenuPrompt&id=' . $this->curr_menu_id, 'data-cmd="gpabox"') . '</span>';
         $title_attr = sprintf($langmessage['generic_delete_confirm'], '&quot;' . $label . '&quot;');
         echo '<span>' . \gp\tool::Link('Admin/Menu/Menus', $langmessage['delete'], 'cmd=MenuRemove&id=' . $this->curr_menu_id, array('data-cmd' => 'cnreq', 'class' => 'gpconfirm', 'title' => $title_attr)) . '</span>';
         echo '</div>';
     }
     echo '</div>';
     echo '<div class="gpclear"></div>';
 }
Esempio n. 16
0
 /**
  * @deprecated 3.0
  * Use \gp\tool\Editing::UseCK();
  */
 public static function UseCK($contents, $name = 'gpcontent', $options = array())
 {
     trigger_error('Deprecated Function');
     \gp\tool\Editing::UseCK($contents, $name, $options);
 }
Esempio n. 17
0
 /**
  * Return the name of the cleansed extra area name, create file if it doesn't already exist
  *
  */
 public function NewExtraArea()
 {
     global $langmessage, $dataDir;
     $title = \gp\tool\Editing::CleanTitle($_REQUEST['extra_area']);
     if (empty($title)) {
         message($langmessage['OOPS']);
         return false;
     }
     $data = \gp\tool\Editing::DefaultContent($_POST['type']);
     $file = $dataDir . '/data/_extra/' . $title . '.php';
     if (\gp\tool\Files::Exists($file)) {
         return $title;
     }
     if (!\gp\tool\Files::SaveData($file, 'extra_content', $data)) {
         message($langmessage['OOPS']);
         return false;
     }
     return $title;
 }