Skip to content

Commit

Permalink
Removed obsolete edit_area script
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10857 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Aug 26, 2011
1 parent 471b9a7 commit 572c599
Show file tree
Hide file tree
Showing 63 changed files with 40 additions and 8,128 deletions.
82 changes: 40 additions & 42 deletions application/controllers/admin/templates.php
Expand Up @@ -33,7 +33,7 @@ function __construct()
{
parent::__construct();
}

/**
* templates::upload()
* function responsible to import a template archive.
Expand All @@ -42,22 +42,22 @@ function __construct()
function upload()
{
$clang = $this->limesurvey_lang;

self::_js_admin_includes(base_url().'scripts/admin/templates.js');

self::_getAdminHeader();
self::_initialise('default','welcome', 'startpage.pstpl',FALSE);
$lid = $this->input->post('lid');
$action = $this->input->post('action');



if ($action == 'templateupload')
{
$basedestdir = $this->config->item('publicdir')."/upload/surveys";
$importtemplateoutput = "<div class='header ui-widget-header'>".$clang->gT("Import template")."</div>\n";
$importtemplateoutput .= "<div class='messagebox ui-corner-all'>";

if ($this->config->item('demoModeOnly') === true)
{
$importtemplateoutput .= "<div class=\"warningheader\">".$clang->gT("Error")."</div><br />\n";
Expand All @@ -67,7 +67,7 @@ function upload()
show_error($importtemplateoutput);
return;
}

//require("classes/phpzip/phpzip.inc.php");
$this->load->library('admin/Phpzip');
//$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
Expand All @@ -80,7 +80,7 @@ function upload()
$basedestdir = $this->config->item('usertemplaterootdir');
$newdir=str_replace('.','',self::_strip_ext(sanitize_paranoid_string($_FILES['the_file']['name'])));
$destdir=$basedestdir.'/'.$newdir.'/';

if (!is_writeable($basedestdir))
{
$importtemplateoutput .= "<div class=\"warningheader\">".$clang->gT("Error")."</div><br />\n";
Expand All @@ -90,7 +90,7 @@ function upload()
show_error($importtemplateoutput);
return;
}

if (!is_dir($destdir))
{
mkdir($destdir);
Expand All @@ -104,17 +104,17 @@ function upload()
show_error($importtemplateoutput);
return;
}

$aImportedFilesInfo=array();
$aErrorFilesInfo=array();


if (is_file($zipfile))
{
$importtemplateoutput .= "<div class=\"successheader\">".$clang->gT("Success")."</div><br />\n";
$importtemplateoutput .= $clang->gT("File upload succeeded.")."<br /><br />\n";
$importtemplateoutput .= $clang->gT("Reading file..")."<br /><br />\n";

if ($z->extract($extractdir,$zipfile) != 'OK')
{
$importtemplateoutput .= "<div class=\"warningheader\">".$clang->gT("Error")."</div><br />\n";
Expand All @@ -124,10 +124,10 @@ function upload()
show_error($importtemplateoutput);
return;
}

$ErrorListHeader = "";
$ImportListHeader = "";

// now read tempdir and copy authorized files only
$dh = opendir($extractdir);
while($direntry = readdir($dh))
Expand All @@ -146,7 +146,7 @@ function upload()
"status" => $clang->gT("Copy failed")
);
unlink($extractdir."/".$direntry);

}
else
{
Expand All @@ -157,7 +157,7 @@ function upload()
unlink($extractdir."/".$direntry);
}
}

else
{ // Extension forbidden
$aErrorFilesInfo[]=Array(
Expand All @@ -169,14 +169,14 @@ function upload()
} // end if is_file
} // end if ! . or ..
} // end while read dir


//Delete the temporary file
unlink($zipfile);
closedir($dh);
//Delete temporary folder
rmdir($extractdir);

// display summary
$okfiles = 0;
$errfiles= 0;
Expand All @@ -196,7 +196,7 @@ function upload()
$importtemplateoutput .= "</div>\n";
show_error($importtemplateoutput);
return;

}
elseif (count($aErrorFilesInfo)>0 && count($aImportedFilesInfo)>0)
{
Expand All @@ -214,7 +214,7 @@ function upload()
$errfiles = count($aErrorFilesInfo);
$ErrorListHeader .= "<br /><strong><u>".$clang->gT("Error Files List").":</u></strong><br />\n";
}

$importtemplateoutput .= "<strong>".$clang->gT("Imported template files for")."</strong> $lid<br /><br />\n";
$importtemplateoutput .= "<div class=\"".$statusClass."\">".$status."</div><br />\n";
$importtemplateoutput .= "<strong><u>".$clang->gT("Resources Import Summary")."</u></strong><br />\n";
Expand Down Expand Up @@ -250,21 +250,21 @@ function upload()
}
$importtemplateoutput .= "<input type='submit' value='".$clang->gT("Open imported template")."' onclick=\"window.open('".site_url('admin/templates/view/startpage.pstpl/welcome/'.$newdir)."', '_top')\"/>\n";
$importtemplateoutput .= "</div>\n";

$idata['display'] = $importtemplateoutput;
$this->load->view('survey_view',$idata);

}
else
{

$ZIPimportAction = " onclick='if (validatefilename(this.form,\"".$clang->gT('Please select a file to import!','js')."\")) {this.form.submit();}'";
if (!function_exists("zip_open"))
{
$ZIPimportAction = " onclick='alert(\"".$clang->gT("zip library not supported by PHP, Import ZIP Disabled","js")."\");'";
}
$templatesoutput= "<div class='header ui-widget-header'>".$clang->gT("Uploaded template file") ."</div>\n";


$templatesoutput.= "\t<form enctype='multipart/form-data' id='importtemplate' name='importtemplate' action='".site_url('admin/templates/upload')."' method='post' onsubmit='return validatefilename(this,\"".$clang->gT('Please select a file to import!','js')."\");'>\n"
. "\t<input type='hidden' name='lid' value='$lid' />\n"
Expand All @@ -277,31 +277,31 @@ function upload()
$data['display'] = $templatesoutput;
$this->load->view('survey_view',$data);
}



self::_loadEndScripts();


self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual"));


}

//---------------------
// Comes from http://fr2.php.net/tempnam
function _tempdir($dir, $prefix='', $mode=0700)
{
if (substr($dir, -1) != '/') $dir .= '/';

do
{
$path = $dir.$prefix.mt_rand(0, 9999999);
} while (!mkdir($path, $mode));

return $path;
}

/**
* Strips file extension
*
Expand All @@ -317,8 +317,8 @@ function _strip_ext($name)
}
return $name;
}


/**
* templates::view()
* Load default view screen of template controller.
Expand All @@ -330,8 +330,6 @@ function _strip_ext($name)
function view($editfile='startpage.pstpl', $screenname='welcome', $templatename='default')
{

//self::_js_admin_includes(base_url().'scripts/admin/edit_area/edit_area_loader.js');
//self::_js_admin_includes(base_url().'scripts/jquery/jquery.js');
self::_js_admin_includes(base_url().'scripts/admin/templates.js');

self::_getAdminHeader();
Expand Down

0 comments on commit 572c599

Please sign in to comment.