Example #1
0
 static function InlineEdit($section_data)
 {
     $section_data += array('type' => '', 'content' => '');
     $scripts = array();
     $scripts[] = '/include/js/inline_edit/inline_editing.js';
     $type = 'text';
     if (!empty($section_data['type'])) {
         $type = $section_data['type'];
     }
     switch ($type) {
         case 'gallery':
             $scripts = gpAjax::InlineEdit_Gallery($scripts);
             break;
         case 'include':
             $scripts = gpAjax::InlineEdit_Include($scripts);
             break;
         case 'text':
             $scripts = gpAjax::InlineEdit_Text($scripts);
             break;
         case 'image':
             echo 'var gp_blank_img = ' . gpAjax::quote(common::GetDir('/include/imgs/blank.gif')) . ';';
             $scripts[] = '/include/js/jquery.auto_upload.js';
             $scripts[] = '/include/js/inline_edit/image_common.js';
             $scripts[] = '/include/js/inline_edit/image_edit.js';
             break;
     }
     $scripts = gpPlugin::Filter('InlineEdit_Scripts', array($scripts, $type));
     self::SendScripts($scripts);
     //replace resized images with their originals
     if (isset($section_data['resized_imgs']) && is_array($section_data['resized_imgs']) && count($section_data['resized_imgs'])) {
         includeFile('tool/editing.php');
         $section_data['content'] = gp_edit::RestoreImages($section_data['content'], $section_data['resized_imgs']);
     }
     //create the section object that will be passed to gp_init_inline_edit
     $section_object = common::JsonEncode($section_data);
     //send call to gp_init_inline_edit()
     echo ';if( typeof(gp_init_inline_edit) == "function" ){';
     echo 'gp_init_inline_edit(';
     echo gpAjax::quote($_GET['area_id']);
     echo ',' . $section_object;
     echo ');';
     echo '}else{alert("gp_init_inline_edit() is not defined");}';
 }
Example #2
0
 function InlineEdit($section_data)
 {
     global $dataDir, $dirPrefix;
     $section_data += array('type' => '', 'content' => '');
     header('Content-type: application/x-javascript');
     $type = $section_data['type'];
     $scripts = array();
     $scripts[] = '/include/js/inline_edit/inline_editing.js';
     //$scripts[] = '/include/thirdparty/jquery_ui/jquery-ui.custom.min.js';
     $type = 'text';
     if (!empty($section_data['type'])) {
         $type = $section_data['type'];
     }
     switch ($section_data['type']) {
         case 'gallery':
             $scripts = gpAjax::InlineEdit_Gallery($scripts);
             break;
         case 'include':
             $scripts = gpAjax::InlineEdit_Include($scripts);
             break;
         case 'text':
             $scripts = gpAjax::InlineEdit_Text($scripts);
             break;
     }
     $scripts = gpPlugin::Filter('InlineEdit_Scripts', array($scripts, $type));
     $scripts = array_unique($scripts);
     //send all scripts
     foreach ($scripts as $script) {
         //absolute paths don't need $dataDir
         $full_path = $script;
         if (strpos($script, $dataDir) !== 0) {
             //fix addon paths that use $addonRelativeCode
             if (!empty($dirPrefix) && strpos($script, $dirPrefix) === 0) {
                 $script = substr($script, strlen($dirPrefix));
             }
             $full_path = $dataDir . $script;
         }
         if (!file_exists($full_path)) {
             echo 'if(isadmin){alert("Admin Notice: The following file could not be found: \\n\\n' . addslashes($full_path) . '");}';
             continue;
         }
         echo ';';
         //echo "\n/**\n* $script\n*\n*/\n";
         readfile($full_path);
     }
     //replace resized images with their originals
     if (is_array($section_data['resized_imgs']) && count($section_data['resized_imgs'])) {
         includeFile('tool/editing.php');
         $section_data['content'] = gp_edit::RestoreImages($section_data['content'], $section_data['resized_imgs']);
     }
     //create the section object that will be passed to gp_init_inline_edit
     $section_object = common::JsonEncode($section_data);
     //send call to gp_init_inline_edit()
     echo ';if( typeof(gp_init_inline_edit) == "function" ){';
     echo 'gp_init_inline_edit(';
     echo gpAjax::quote($_GET['area_id']);
     echo ',' . $section_object;
     echo ');';
     echo '}else{alert("gp_init_inline_edit() is not defined");}';
 }