예제 #1
0
 protected function _export($start)
 {
     // do we have a valid filename
     $this->_filename = Sh404sefHelperFiles::createFileName($this->_filename, 'sh404sef_export_' . $this->_context);
     // put some data in the file
     $end = $start + self::MAX_PAGEIDS_PER_STEP + 1;
     $end = $end > $this->_total ? $this->_total : $end;
     // fetch shURLs record from model
     $model =& JModel::getInstance('urls', 'Sh404sefModel');
     $model->setContext('urls.view404');
     $options = (object) array('layout' => 'view404');
     $records = $model->getList($options, $returnZeroElement = false, $start, $forcedLimit = self::MAX_PAGEIDS_PER_STEP);
     // do we need a header written to the file, for first record
     $header = $start == 0 ? Sh404sefHelperGeneral::getExportHeaders($this->_context) . "\n" : '';
     // format them for text file output
     $data = '';
     $counter = $start;
     $glue = Sh404sefHelperFiles::$stringDelimiter . Sh404sefHelperFiles::$fieldDelimiter . Sh404sefHelperFiles::$stringDelimiter;
     if (!empty($records)) {
         foreach ($records as $record) {
             $counter++;
             $textRecord = $record->oldurl . $glue . $record->newurl . $glue . $record->cpt . $glue . $record->rank . $glue . $record->dateadd . $glue . '' . $glue . '' . $glue . '' . $glue . '' . $glue . '' . Sh404sefHelperFiles::$stringDelimiter;
             $line = Sh404sefHelperFiles::$stringDelimiter . $counter . $glue . $textRecord;
             $data .= $line . "\n";
         }
     }
     // prepare data for storage
     if (!empty($header)) {
         // first record written to file, prepend header
         $data = $header . $data;
     }
     // store in file
     $status = Sh404sefHelperFiles::appendToFile($this->_filename, $data);
     // return any error
     return $status;
 }
예제 #2
0
 /**
  * Second step, read file content, validate and display for user go ahead
  *
  */
 public function doValidate()
 {
     // get file name
     $fileRecord = JRequest::getVar('wizardfile', null, 'files');
     // move uploaded file, to get access to it
     $this->_filename = Sh404sefHelperFiles::createFileName($this->_filename, 'sh404sef_import_' . $this->_context);
     try {
         if (!move_uploaded_file($fileRecord['tmp_name'], $this->_filename)) {
             // could not write to web space temp dir
             throw new Sh404sefExceptionDefault(JText::_('COM_SH404SEF_WRITE_FAILED'));
         }
         // which button should be displayed ?
         $this->_visibleButtonsList = array('previous', 'next', 'cancel');
         // next steps definition
         $this->_steps = array('next' => 3, 'previous' => 1, 'cancel' => -1, 'terminate' => -2);
         // analyse file content, returning itemsCount
         $importType = $this->_analyzeImportFileContent($this->_filename);
         // we may have to change the opSubject and related data. If user asked for instance to import
         // aliases, from the aliases page, but actually loaded an import file
         // containing urls or pageids
         if ($this->_context != $importType) {
             $this->_result['opSubject'] = $importType;
             // update filename
             $oldFileName = $this->_filename;
             $this->_filename = str_replace($this->_context, $importType, $this->_filename);
             // and rename the temp file
             JFile::move($oldFileName, $this->_filename);
             // tell parent controller that we should go to new target afer this import
             $this->_parentController->set('_returnController', $importType);
             $this->_parentController->set('_returnView', $importType);
         }
         // save current file for next steps
         $this->_result['mainText'] = JText::sprintf('COM_SH404SEF_IMPORT_VALIDATE_IMPORT', $importType, $this->_total);
         $this->_result['hiddenText'] = '<input type="hidden" name="filename" value="' . $this->_filename . '" />';
     } catch (Exception $e) {
         $this->_handleException($e);
     }
     return $this->_result;
 }
예제 #3
0
 protected function _export($start)
 {
     // do we have a valid filename
     $this->_filename = Sh404sefHelperFiles::createFileName($this->_filename, 'sh404sef_export_' . $this->_context);
     // put some data in the file
     $end = $start + self::MAX_PAGEIDS_PER_STEP + 1;
     $end = $end > $this->_total ? $this->_total : $end;
     // fetch pageIds record from model
     $model = ShlMvcModel_Base::getInstance('aliases', 'Sh404sefModel');
     $model->setContext('aliases.default');
     $options = (object) array('layout' => 'default', 'includeHomeData' => true);
     $records = $model->getList($options, $returnZeroElement = false, $start, $forcedLimit = self::MAX_PAGEIDS_PER_STEP);
     // do we need a header written to the file, for first record
     $header = $start == 0 ? Sh404sefHelperGeneral::getExportHeaders($this->_context) . "\n" : '';
     // format them for text file output
     $data = '';
     $counter = $start;
     $glue = Sh404sefHelperFiles::$stringDelimiter . Sh404sefHelperFiles::$fieldDelimiter . Sh404sefHelperFiles::$stringDelimiter;
     if (!empty($records)) {
         foreach ($records as $record) {
             $counter++;
             if ($record->newurl == sh404SEF_HOMEPAGE_CODE) {
                 $record->newurl = '__ Homepage __';
             }
             $textRecord = $record->alias . $glue . $record->oldurl . $glue . $record->newurl . $glue . $record->type . $glue . $record->hits . Sh404sefHelperFiles::$stringDelimiter;
             $line = Sh404sefHelperFiles::$stringDelimiter . $counter . $glue . $textRecord;
             $data .= $line . "\n";
         }
     }
     // prepare data for storage
     if (!empty($header)) {
         // first record written to file, prepend header
         $data = $header . $data;
     }
     // store in file
     $status = Sh404sefHelperFiles::appendToFile($this->_filename, $data);
     // return any error
     return $status;
 }
 protected function _export($start)
 {
     // do we have a valid filename
     $this->_filename = Sh404sefHelperFiles::createFileName($this->_filename, 'sh404sef_export_' . $this->_context);
     // put some data in the file
     $end = $start + self::MAX_PAGEIDS_PER_STEP + 1;
     $end = $end > $this->_total ? $this->_total : $end;
     // fetch pageIds record from model
     $model =& JModel::getInstance('urls', 'Sh404sefModel');
     $model->setContext('metas.default');
     $options = (object) array('layout' => 'export', 'getMetaData' => true, 'onlyWithMetaData' => true, 'simpleUrlList' => true);
     $records = $model->getList($options, $returnZeroElement = false, $start, $forcedLimit = self::MAX_PAGEIDS_PER_STEP);
     // do we need a header written to the file, for first record
     $header = $start == 0 ? Sh404sefHelperGeneral::getExportHeaders($this->_context) . "\n" : '';
     // format them for text file output
     $data = '';
     $counter = $start;
     $glue = Sh404sefHelperFiles::$stringDelimiter . Sh404sefHelperFiles::$fieldDelimiter . Sh404sefHelperFiles::$stringDelimiter;
     if (!empty($records)) {
         foreach ($records as $record) {
             $counter++;
             $data .= $this->_createLine($record, $counter, $glue);
         }
     }
     // prepare data for storage
     if (!empty($header)) {
         // first record written to file, prepend header
         $data = $header . $data;
     }
     // store in file
     $status = Sh404sefHelperFiles::appendToFile($this->_filename, $data);
     // return any error
     return $status;
 }