コード例 #1
0
ファイル: image.php プロジェクト: kishoreweblabs/SobiPro
 /**
  * @param $entry
  * @param $request
  * @param $files
  * @param $cloneFiles
  * @return SPdb
  */
 protected function cloneFiles(&$entry, $request, $files, $cloneFiles)
 {
     $orgName = basename($files['original']);
     $sPath = $this->parseName($entry, $orgName, $this->savePath);
     $cloneFiles['original'] = $sPath . $this->parseName($entry, $orgName, '{orgname}', true);
     SPFs::copy(SOBI_ROOT . '/' . $files['original'], SOBI_ROOT . '/' . $cloneFiles['original']);
     $cloneFiles['image'] = $sPath . $this->parseName($entry, $orgName, $this->imageName, true);
     SPFs::copy(SOBI_ROOT . '/' . $files['image'], SOBI_ROOT . '/' . $cloneFiles['image']);
     $cloneFiles['thumb'] = $sPath . $this->parseName($entry, $orgName, $this->thumbName, true);
     SPFs::copy(SOBI_ROOT . '/' . $files['thumb'], SOBI_ROOT . '/' . $cloneFiles['thumb']);
     $cloneFiles['ico'] = $sPath . $this->parseName($entry, strtolower($orgName), 'ico_{orgname}', true);
     SPFs::copy(SOBI_ROOT . '/' . $files['ico'], SOBI_ROOT . '/' . $cloneFiles['ico']);
     return $this->storeData($entry, $request, $cloneFiles);
 }
コード例 #2
0
ファイル: template.php プロジェクト: ranrolls/ras-full-portal
 private function cloneTpl()
 {
     $dir = $this->dir(SPRequest::cmd('templateName'));
     $newName = SPRequest::word('templateNewName', 'Duplicated Template', 'post');
     $dirName = SPLang::nid($newName);
     $dirNameOrg = $dirName;
     $c = 1;
     while (SPFs::exists(SPLoader::dirPath('usr.templates.' . $dirName, 'front', false))) {
         $dirName = $dirNameOrg . '-' . $c++;
     }
     $newPath = SPLoader::dirPath('usr.templates.' . $dirName, 'front', false);
     if (!SPFs::copy($dir, $newPath)) {
         throw new SPException(SPLang::e('COULD_NOT_COPY_DIRECTORY', $dir, $newPath));
     }
     $defFile = SPLoader::path($newPath . '.template', 'absolute', true, 'xml');
     if ($defFile) {
         $fc = SPLoader::loadClass('base.fs.file');
         $def = new DOMDocument();
         $def->load($defFile);
         $xdef = new DOMXPath($def);
         $oldName = $xdef->query('/template/name')->item(0)->nodeValue;
         $oldDesc = $xdef->query('/template/description')->item(0)->nodeValue;
         $date = SPFactory::config()->date(time());
         $xdef->query('/template/name')->item(0)->nodeValue = $newName;
         $xdef->query('/template/creationDate')->item(0)->nodeValue = $date;
         $xdef->query('/template/id')->item(0)->nodeValue = $dirName;
         $newDesc = Sobi::Txt('TP.CLONE_NOTE', array('name' => $oldName, 'date' => $date));
         $xdef->query('/template/description')->item(0)->nodeValue = "{$newDesc}\n{$oldDesc}";
         $file = new $fc($defFile);
         $file->content($def->saveXML());
         $file->save();
     }
     $this->response(Sobi::Url(array('task' => 'template.info', 'template' => str_replace(SOBI_PATH . DS . 'usr' . DS . 'templates' . DS, null, $dirName))), Sobi::Txt('TP.DUPLICATED'), false, 'success');
 }
コード例 #3
0
ファイル: installer.php プロジェクト: kishoreweblabs/SobiPro
 private function langFiles($tag, $def, $dir, &$FilesLog)
 {
     $target = $tag == 'administration' ? implode(DS, array(SOBI_ROOT, 'administrator', 'language', $this->id)) : implode(DS, array(SOBI_ROOT, 'language', $this->id));
     if (!file_exists($target)) {
         $this->error = Sobi::Txt('LANG_INSTALL_NO_CORE', $this->id);
         $this->errorType = SPC::WARN_MSG;
         SPFs::mkdir($target);
     }
     $files = $def->getElementsByTagName($tag)->item(0)->getElementsByTagName('files')->item(0);
     $folder = $files->getAttribute('folder');
     $folder = $dir . $folder . DS;
     foreach ($files->getElementsByTagName('filename') as $file) {
         if (file_exists($folder . $file->nodeValue)) {
             if (!SPFs::copy($folder . $file->nodeValue, $target . DS . $file->nodeValue)) {
                 SPFactory::message()->error(Sobi::Txt('Cannot copy %s to %s', $folder . $file->nodeValue, $target . DS . $file->nodeValue), false);
             } else {
                 $FilesLog[] = str_replace(array(DS . DS, SOBI_ROOT), array(DS, null), $target . DS . $file->nodeValue);
             }
         } else {
             SPFactory::message()->error(Sobi::Txt('File %s does not exist!', $folder . $file->nodeValue), false);
         }
     }
 }
コード例 #4
0
ファイル: file.php プロジェクト: kishoreweblabs/SobiPro
 /**
  * Copy file
  * @param string $target - path
  * @return bool
  */
 public function copy($target)
 {
     return SPFs::copy($this->_filename, $target);
 }
コード例 #5
0
ファイル: sobiproapp.php プロジェクト: pelloq1/SobiPro
 /**
  * @param DOMNodeList $changes
  * @return void
  */
 private function revert($changes)
 {
     $files = array();
     foreach ($changes as $file) {
         if ($file->hasChildNodes()) {
             $f = array();
             foreach ($file->childNodes as $node) {
                 if ($node->nodeName != '#text') {
                     $f[$node->nodeName] = $node->nodeValue;
                 }
             }
             $files[] = $f;
         }
     }
     if (count($files)) {
         foreach ($files as $file) {
             if (strstr($file['path'], '/opt/') || strstr($file['path'], '/field/')) {
                 SPFs::delete(SOBI_ROOT . $file['path']);
                 continue;
             }
             if (SPFs::exists(SOBI_ROOT . $file['path'])) {
                 if (md5_file(SOBI_ROOT . $file['path'])) {
                     if (SPFs::exists(SOBI_ROOT . $file['backup'])) {
                         if (!SPFs::copy(SOBI_ROOT . $file['backup'], SOBI_ROOT . $file['path'])) {
                             Sobi::Error('installer', SPLang::e('Cannot restore file. Cannot copy from "%s" to "%s"', $file['path'], $file['backup']), SPC::WARNING, 0);
                         }
                     } else {
                         Sobi::Error('installer', SPLang::e('Cannot restore file "%s". Backup file does not exist', $file['path']), SPC::WARNING, 0);
                     }
                 } else {
                     Sobi::Error('installer', SPLang::e('Cannot restore file "%s". File has been modified since the installation', $file['path']), SPC::WARNING, 0);
                 }
             } else {
                 Sobi::Error('installer', SPLang::e('Cannot restore file "%s". File does not exist', $file['path']), SPC::WARNING, 0);
             }
         }
     }
 }
コード例 #6
0
ファイル: helper.php プロジェクト: kishoreweblabs/SobiPro
 /**
  * Install language file
  * @param string $lang
  * @param bool $force
  * @param bool $move
  * @return array
  */
 public static function installLang($lang, $force = true, $move = false)
 {
     $log = array();
     if (count($lang)) {
         foreach ($lang as $language => $files) {
             $language = str_replace('_', '-', $language);
             if (count($files)) {
                 foreach ($files as $file) {
                     $target = $file['adm'] ? implode('/', array(JPATH_ADMINISTRATOR, 'language', $language)) : implode('/', array(SOBI_ROOT, 'language', $language));
                     if ($force || SPFs::exists($target)) {
                         $iFile = $target . '/' . trim($file['name']);
                         $log[] = $iFile;
                         $move ? SPFs::move(Sobi::FixPath($file['path']), $iFile) : SPFs::copy(Sobi::FixPath($file['path']), $iFile);
                     }
                 }
             }
         }
     }
     return $log;
 }