function perform()
 {
     $this->_fileContent = $this->_request->getValue("fileContent");
     // get a list with all the specific template files
     $ts = new TemplateSetStorage();
     $blogId = $this->_blogInfo->getId();
     $templateFolder = $ts->getTemplateFolder($this->_templateId, $blogId);
     if (!empty($this->_subFolderId)) {
         $templateFolder = $templateFolder . $this->_subFolderId . "/";
     }
     $backupFolder = $templateFolder . "backups/";
     if (!File::exists($backupFolder)) {
         File::createDir($backupFolder);
     }
     $fileName = $templateFolder . $this->_fileId;
     $backupFileName = $backupFolder . $this->_fileId . "_" . time();
     if (!File::copy($fileName, $backupFileName)) {
         if (empty($this->_subFolderId)) {
             $this->_view = new PluginBlogEditTemplateFileView($this->_blogInfo, $this->_templateId, $this->_fileId, $this->_backupId);
         } else {
             $this->_view = new PluginBlogEditSubFolderTemplateFileView($this->_blogInfo, $this->_templateId, $this->_subFolderId, $this->_fileId, $this->_backupId);
         }
         $this->_view->setErrorMessage($this->_locale->tr("error_backup_template_file"));
         $this->setCommonData();
         return false;
     }
     $file = new MyFile($fileName);
     if (!$file->isWritable()) {
         if (empty($this->_subFolderId)) {
             $this->_view = new PluginBlogEditTemplateFileView($this->_blogInfo, $this->_templateId, $this->_fileId, $this->_backupId);
         } else {
             $this->_view = new PluginBlogEditSubFolderTemplateFileView($this->_blogInfo, $this->_templateId, $this->_subFolderId, $this->_fileId, $this->_backupId);
         }
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_template_file"));
         $this->setCommonData();
         return false;
     }
     $fileContent = $file->writeFileContent($this->_fileContent);
     // if everything went ok...
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     if (empty($this->_subFolderId)) {
         $this->_view = new PluginBlogTemplatesListView($this->_blogInfo, $this->_templateId);
     } else {
         $this->_view = new PluginBlogTemplateSubFolderListView($this->_blogInfo, $this->_templateId, $this->_subFolderId);
     }
     $this->_view->setSuccessMessage($this->_locale->tr("templateeditor_file_saved_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 function render()
 {
     $config =& Config::getConfig();
     $maxBackupFiles = $config->getValue("plugin_templateeditor_maxbackupfiles");
     if ($maxBackupFiles == "") {
         $maxBackupFiles = 5;
     }
     // get a list with all the specific template files
     $ts = new TemplateSetStorage();
     $blogId = $this->_blogInfo->getId();
     $templateFolder = $ts->getTemplateFolder($this->_templateId);
     $templateFolder = $templateFolder . $this->_subFolderId . "/";
     $backupFolder = $templateFolder . "backups/";
     if (!File::exists($backupFolder)) {
         File::createDir($backupFolder);
     }
     if (!$this->_backupId) {
         $filename = $templateFolder . $this->_fileId;
     } else {
         $filename = $backupFolder . $this->_fileId . "_" . $this->_backupId;
     }
     $backupFilePattern = $this->_fileId . "_*";
     $bakFiles = Glob::myGlob($backupFolder, $backupFilePattern);
     sort($bakFiles);
     $backupFiles = array();
     $backupFileCount = 0;
     for ($i = count($bakFiles) - 1; $i >= 0; $i--) {
         $bakFile = $bakFiles[$i];
         if ($backupFileCount < $maxBackupFiles) {
             $bakElements = explode("_", $bakFile);
             $bakId = $bakElements[count($bakElements) - 1];
             $bakTime = strftime("%Y/%m/%d - %H:%M:%S", $bakId);
             $file['time'] = $bakTime;
             $file['backupId'] = basename($bakId);
             array_push($backupFiles, $file);
             $backupFileCount++;
         } else {
             File::delete($bakFile);
         }
     }
     $file = new MyFile($filename);
     $fileContent = $file->readFileContent();
     $this->setValue("backupId", $this->_backupId);
     $this->setValue("backupFiles", $backupFiles);
     $this->setValue("currentTemplate", $this->_templateId);
     $this->setValue("currentSubFolder", $this->_subFolderId);
     $this->setValue("currentFile", $this->_fileId);
     $this->setValue("fileContent", $fileContent);
     parent::render();
 }
 /**
  * Recursively copy a folder and its contents
  * http://aidan.dotgeek.org/lib/?file=function.copyr.php
  *
  * @author      Aidan Lister <*****@*****.**>
  * @version     1.0.1
  * @param       string   $source    Source path
  * @param       string   $dest      Destination path
  * @return      bool     Returns TRUE on success, FALSE on failure
  */
 function copyDir($source, $dest)
 {
     clearstatcache();
     // Simple copy for a file
     if (is_file($source)) {
         return File::copy($source, $dest);
     }
     // Make destination directory
     if (!File::isDir($dest)) {
         File::createDir($dest);
     }
     // Loop through the folder
     $dir = dir($source);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         if ($dest !== "{$source}/{$entry}") {
             MyFile::copyDir("{$source}/{$entry}", "{$dest}/{$entry}");
         }
     }
     // Clean up
     $dir->close();
     return true;
 }
 function perform()
 {
     // get a list with all the global template sets
     $ts = new TemplateSets();
     $globalTemplates = $ts->getGlobalTemplateSets();
     foreach ($globalTemplates as $template) {
         if ($template->getName() == $this->_newTemplateId) {
             $this->_view = new PluginSiteTemplateSetsListView($this->_blogInfo);
             $this->_view->setErrorMessage($this->_locale->tr("error_duplicate_templateset_name"));
             $this->setCommonData();
             return false;
         }
     }
     $ts = new TemplateSetStorage();
     $blogId = $this->_blogInfo->getId();
     $sourceTemplateFolder = $ts->getTemplateFolder($this->_templateId);
     $newTemplateFolder = $ts->getBaseTemplateFolder() . "/" . $this->_newTemplateId;
     if (MyFile::copyDir($sourceTemplateFolder, $newTemplateFolder)) {
         $ts->addTemplate($this->_newTemplateId);
     } else {
         File::deleteDir($newTemplateFolder);
         $this->_view = new PluginSiteTemplateSetsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_copying_templateset"));
         $this->setCommonData();
         return false;
     }
     // if everything went ok...
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->_view = new PluginSiteTemplateSetsListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("templateeditor_templateset_copyed_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
Example #5
0
 public function register($submode = '')
 {
     /** 
      * proses register data people
      * - get latest id
      * - get posted data
      */
     //$this->load->library('image_lib');
     $MYFILE = new MyFile();
     $now = date('U');
     if ($submode == 'add') {
         $data['id'] = sprintf('%09d', $this->db_model->select_max('id', 'mybf_people') + 1);
         $data['date_added'] = $now;
     } else {
         if ($submode == 'update') {
             $updated_id = $this->input->post('people_id');
             $data['id'] = $updated_id;
         }
     }
     $data['date_updated'] = $now;
     $data['nama'] = $this->input->post('nama');
     //validasi
     $data['alias'] = $this->input->post('alias');
     //validasi
     $data['jenis_kelamin'] = $this->input->post('jenis_kelamin');
     //validasi
     $data['tempat_lahir'] = $this->input->post('tempat_lahir');
     $data['tanggal_lahir'] = $this->input->post('tanggal_lahir');
     //validasi
     $data['tempat_tinggal'] = $this->input->post('tempat_tinggal');
     $data['phone'] = $this->input->post('phone');
     //validasi
     $data['kontak_lain'] = $this->input->post('kontak_lain');
     $data['id_pernikahan'] = $this->input->post('id_pernikahan');
     $data['note'] = $this->input->post('note');
     $data['tanggal_lahir'] = $data['tanggal_lahir'] == '' ? '0000-00-00' : $data['tanggal_lahir'];
     $data['id_pernikahan'] = $data['tanggal_lahir'] == '' ? '0' : $data['id_pernikahan'];
     $id_pasangan = $this->input->post('id_pasangan');
     // jika ada file gambar dilampirkan, upload gambar
     if (is_array($_FILES)) {
         if (is_uploaded_file($_FILES['people_image']['tmp_name'])) {
             print_r($_FILES);
             $path_parts = pathinfo($_FILES['people_image']['name']);
             $newFileName = $data['id'] . "." . $path_parts['extension'];
             $newThumbsFileName = $data['id'] . "_thumbs." . $path_parts['extension'];
             $newThumbsFileName_mini = $data['id'] . "_thumbs_mini." . $path_parts['extension'];
             $sourcePath = $_FILES['people_image']['tmp_name'];
             $targetPath = "assets/images/foto/individual/";
             if (move_uploaded_file($sourcePath, $targetPath . $newFileName)) {
                 $data['photo'] = $_FILES['people_image']['name'];
                 //success
                 $MYFILE->makeImageThumbs($targetPath . $newFileName, $targetPath . $newThumbsFileName, 165, 200, "fill", "center", array(), 80);
                 $MYFILE->makeImageThumbs($targetPath . $newThumbsFileName, $targetPath . $newThumbsFileName_mini, 50, 50, "fit-h", "center", array(), 80);
             }
         }
     }
     if ($submode == 'add') {
         //validasi exitensi data person
         $query_people_add = $this->db->insert('mybf_people', $data);
         if ($query_people_add) {
             $content['message'] = "adding individual data success";
         } else {
             $content['message'] = "adding individual data failed" . ERROR_TAG;
         }
     } else {
         if ($submode == 'update') {
             //validasi exitensi data person
             //print_r($data);
             /**/
             $this->db->where('id', $updated_id);
             //$this->db->update('mybf_people', $data);
             $query_people_update = $this->db->update('mybf_people', $data);
             if ($query_people_update) {
                 $content['message'] = "updating individual data success";
             } else {
                 $content['message'] = "updating individual data failed" . ERROR_TAG;
             }
         }
     }
     /**/
     if (is_numeric($id_pasangan) && $id_pasangan > 0) {
         //registrasikan pasangan jika belum ada di db
         /*
         			$query = $this->db->query("SELECT * FROM mybf_people 
         				WHERE nama='{$data['nama']}'
         				OR tempat_lahir='{$data['tempat_lahir']}'
         				ORDER BY id DESC LIMIT 0,1");
         				
         			$data_people 	= $query->result_array();*/
         $people_id = $data['id'];
         //validasi urutan
         if ($data['jenis_kelamin'] == 'L') {
             $data_pasangan = array('id_suami' => $people_id, 'id_istri' => $id_pasangan);
         } else {
             $data_pasangan = array('id_istri' => $people_id, 'id_suami' => $id_pasangan);
         }
         $data_pasangan['date_added'] = $data_pasangan['date_updated'] = $now;
         $query_couple = $this->db->select('id')->get_where('mybf_marriage', $data_pasangan);
         $c_data = $query_couple->result_array();
         if (empty($c_data['id'])) {
             // jika tidak ada di tabel, tambahkan
             $this->db->insert('mybf_marriage', $data_pasangan);
         }
     }
     //output
     $data['peoples'] = $this->individual_model->get_people($data['id']);
     $data['mode'] = 'list_content';
     $content['row'] = $this->load->view('individual_view', $data, TRUE);
     //print rows function
     print DATA_SPLITER . print_json($content, false) . DATA_SPLITER;
 }
Example #6
0
function delfiles(&$url)
{
    checkPerm('view');
    $file_man = new MyFile(getLogUserId());
    $lang =& DoceboLanguage::createInstance('myfiles');
    $area = importVar('working_area', false, $file_man->getDefaultArea());
    $id_file = importVar('id_file', true, 0);
    if (isset($_GET['confirm'])) {
        $result = $file_man->deleteFile($id_file);
        Util::jump_to($url->getUrl('op=myfiles&working_area=' . $area . '&result=' . ($result ? 'delete_ok' : 'delete_fail')));
    } else {
        $f_info = $file_man->getFileInfo($id_file);
        $title_page = array($url->getUrl('op=myfiles') => $lang->def('_MYFILE'), $lang->def('_DEL') . ' : ' . $f_info[MYFILE_TITLE]);
        $GLOBALS['page']->add(getTitleArea($title_page, 'myfile') . '<div class="std_block">' . getDeleteUi($lang->def('_AREYOUSURE'), '<span>' . $lang->def('_TITLE') . ' : </span>' . $f_info[MYFILE_TITLE] . '<br />' . '<span>' . $lang->def('_DESCRIPTION') . ' : </span>' . $f_info[MYFILE_DESCRIPTION], true, $url->getUrl('op=delfiles&id_file=' . $id_file . '&confirm=1&working_area=' . $area), $url->getUrl('op=myfiles&working_area=' . $area)) . '</div>', 'content');
    }
}
Example #7
0
 function loadSelector()
 {
     require_once _base_ . '/lib/lib.tab.php';
     require_once _base_ . '/lib/lib.form.php';
     require_once _base_ . '/lib/lib.table.php';
     $file_man = new MyFile(getLogUserId());
     $tab_man = new TabView('myfiles', '');
     $lang =& DoceboLanguage::createInstance('myfiles');
     $areas = $file_man->getFilesAreas();
     while (list($id_page, $area_name) = each($areas)) {
         $new_tab = new TabElemDefault($id_page, $lang->def($area_name), getPathImage('fw') . 'myfiles/' . $id_page . '.gif');
         $tab_man->addTab($new_tab);
     }
     $this->parse();
     $tab_man->parseInput($_POST, $_SESSION);
     $active_tab = $tab_man->getActiveTab();
     if (!$active_tab) {
         $active_tab = importVar('working_area', true, $file_man->getDefaultArea());
         $tab_man->setActiveTab($active_tab);
     }
     $tb = new Table(0, $lang->def('_MYFILES_CAPTION'), $lang->def('_MYFILES_SUMMARY'));
     $cont_h = array('<span class="access-only">' . $lang->def('_FILE_SELECTION') . '</span>', $lang->def('_TITLE') . '</label>');
     $type_h = array('image', '');
     $tb->setColsStyle($type_h);
     $tb->addHead($cont_h);
     $id_list = array();
     $re_files = $file_man->getFileList($active_tab, false, MYFILE_TITLE);
     while ($file_info = $file_man->fetch_row($re_files)) {
         $id_file = $file_info[MYFILE_ID_FILE];
         $id_list[$id_file] = $id_file;
         $cont = array(Form::getInputCheckbox('new_file_selected_' . $id_file, 'new_file_selected[' . $id_file . ']', $id_file, isset($this->current_selection[$id_file]), ''), '<label for="new_file_selected_' . $id_file . '">' . $file_info[MYFILE_TITLE] . '</label>');
         $tb->addBody($cont);
     }
     // print selector
     $GLOBALS['page']->add(Form::getHidden('working_area', 'working_area', $active_tab) . Form::getHidden('old_selection', 'old_selection', urlencode(serialize($this->current_selection))) . Form::getHidden('displayed', 'displayed', urlencode(serialize($id_list))) . $tab_man->printTabView_Begin('', false) . $tb->getTable() . $tab_man->printTabView_End(), 'content');
 }
Example #8
0
 function getAttachedFile($ext = false, $code = false)
 {
     $html = '';
     require_once $GLOBALS['where_framework'] . '/lib/lib.myfiles.php';
     require_once _base_ . '/lib/lib.table.php';
     $lang =& DoceboLanguage::createInstance('eportfolio');
     $file_man = new MyFile($this->id_user);
     $files = $this->man_epf->getPresentationAttach($this->id_presentation, $this->id_user);
     if (!count($files)) {
         return $html;
     }
     $files_info = $file_man->getFilteredFileList($files);
     // print presentation -------------------------------------------------------------
     $tb = new Table(0, '', $lang->def('_SUMMARY_FILES'));
     $tb->setTableStyle('epf_files');
     $tb->setColsStyle(array(''));
     $tb->addHead(array($lang->def('_NAME')));
     while ($row = sql_fetch_row($files_info)) {
         if ($ext) {
             $link = 'index.php?modname=eportfolio&amp;type=ext&amp;op=downloadfile&amp;id_presentation=' . $this->id_presentation . '&amp;id_portfolio=' . $this->id_portfolio . '&amp;id_user='******'&amp;id_file=' . $row[MYFILE_ID_FILE] . '&amp;code=' . $code . '&amp;no_redirect=1';
         } else {
             $link = 'index.php?modname=eportfolio&amp;op=downloadfile&amp;id_portfolio=' . $this->id_portfolio . '&amp;id_user='******'&amp;id_file=' . $row[MYFILE_ID_FILE];
         }
         $cont = array('<a href="' . $link . '">' . $row[MYFILE_TITLE] . '</a>');
         $tb->addBody($cont);
     }
     $html .= $tb->getTable();
     return $html;
 }
                 if ($name === $myfiles[$i]->GetName()) {
                     $is_error = true;
                     $content = json_encode(['error' => 'File with name ' . $name . ' already exists']);
                     break;
                 }
             }
             if ($is_error) {
                 break;
             }
             $new_dir_it->next();
         }
         if ($is_error) {
             break;
         }
         for ($i = 0; $i < $size; ++$i) {
             if ($rc = Error::IsError(MyFile::InsertToDB($myfiles[$i]))) {
                 $content = json_encode(['error' => Error::ToString($rc)]);
                 $is_error = true;
                 break;
             }
         }
         if ($is_error) {
             break;
         }
         simple_copy($dir, $new_dir);
         clear_tmp_files_dir(MyFile::$type, 0);
         $content = json_encode(['ok' => true]);
         break;
     default:
         break;
 }