当前位置: 首页>>代码示例>>PHP>>正文


PHP JText16::sprintf方法代码示例

本文整理汇总了PHP中JText16::sprintf方法的典型用法代码示例。如果您正苦于以下问题:PHP JText16::sprintf方法的具体用法?PHP JText16::sprintf怎么用?PHP JText16::sprintf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JText16的用法示例。


在下文中一共展示了JText16::sprintf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: confirmdelete

 /**
  * Redirect to a confirmation page showing in
  * a popup window
  */
 public function confirmdelete($deleteDuplicates = false)
 {
     // find and store edited item id
     $cid = JRequest::getVar('cid', array(0), 'default', 'array');
     // Set the view name and create the view object
     $viewName = 'confirm';
     $document =& JFactory::getDocument();
     $viewType = $document->getType();
     $viewLayout = JRequest::getCmd('layout', $this->_defaultLayout);
     $view =& $this->getView($viewName, $viewType, '', array('base_path' => $this->_basePath));
     // push url id(s) into the view
     $view->assign('cid', $cid);
     // tell it what to display
     $view->assign('mainText', JText16::sprintf('COM_SH404SEF_CONFIRM_URL_DELETION', count($cid)));
     // and who's gonna handle the request
     $view->assign('actionController', $this->_editController);
     // Get/Create the model
     if ($model =& $this->getModel($this->_defaultModel, 'Sh404sefModel')) {
         // store initial context in model
         $model->setContext($this->_context);
         // Push the model into the view (as default)
         $view->setModel($model, true);
         // check if delete duplicates requested
         $view->task = $deleteDuplicates ? 'confirmeddeldup' : 'delete';
     }
     // Set the layout
     $view->setLayout($viewLayout);
     // Display the view
     $view->display();
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:34,代码来源:editurl.php

示例2: saveFromInput

 /**
  * Save a list of aliases as entered by user in backend to the database
  *
  * @param string $aliasList data from an html textarea field
  * @param string $nonSefUrl the non sef url to which aliases are attached
  *
  * @return boolean true on success
  */
 public function saveFromInput($aliasList, $nonSefUrl)
 {
     // split aliases from raw input data into an array
     $aliasList = explode("\n", $aliasList);
     // delete them all. We should do a transaction, but not worth it
     $query = 'DELETE from #__sh404sef_aliases where newurl = ' . $this->_db->Quote($nonSefUrl);
     $this->_db->setQuery($query);
     $this->_db->query();
     // Write new aliases.
     if (!empty($aliasList[0])) {
         $baseQuery = 'INSERT INTO #__sh404sef_aliases (newurl, alias, type) VALUES __shValue__;';
         $endOfLine = array("\r\n", "\n", "\r");
         foreach ($aliasList as $alias) {
             // remove end of line chars
             $alias = str_replace($endOfLine, '', $alias);
             // if something left, try insert it into DB
             if (!empty($alias)) {
                 // first check value is not invalid
                 // either the alias already exists
                 // or same SEF url already exists
                 try {
                     $count = Sh404sefHelperDb::count('#__sh404sef_aliases', 'id', 'oldurl = ? and newurl <> ?', array($alias, ''));
                     if (empty($count)) {
                         $count = Sh404sefHelperDb::count('#__sh404sef_aliases', '*', array('alias' => $alias));
                     }
                 } catch (Sh404sefExceptionDefault $e) {
                     $count = 0;
                 }
                 // if ok, insert into db
                 if (empty($count)) {
                     $value = '(' . $this->_db->Quote($nonSefUrl) . ', ' . $this->_db->Quote($alias) . ', ' . $this->_db->Quote(Sh404sefHelperGeneral::COM_SH404SEF_URLTYPE_ALIAS) . ')';
                     $query = str_replace('__shValue__', $value, $baseQuery);
                     $this->_db->setQuery($query);
                     $this->_db->query();
                     // check errors
                     $error = $this->_db->getErrorNum();
                     if (!empty($error)) {
                         $this->setError('Internal database error # ' . $query);
                     }
                 } else {
                     // alias already exists either as an alias or a SEF url
                     $this->setError(JText16::sprintf('COM_SH404SEF_ALIAS_ALREADY_EXISTS', $alias));
                 }
             }
         }
     }
     // return true if no error
     $error = $this->getError();
     return empty($error);
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:58,代码来源:aliases.php

示例3: _createRecord

 /**
  * Creates a record in the database, based
  * on data read from import file
  *
  * @param array $header an array of fields, as built from the header line
  * @param string $line raw record obtained from import file
  */
 protected function _createRecord($header, $line)
 {
     // extract the record
     $line = $this->_lineToArray($line);
     // get table object to store record
     jimport('joomla.database.table');
     $table =& JTable::getInstance('pageids', 'Sh404sefTable');
     // bind table to current record
     $record = array();
     $record['newurl'] = $line[3];
     if ($record['newurl'] == '__ Homepage __') {
         $record['newurl'] = sh404SEF_HOMEPAGE_CODE;
     }
     $record['pageid'] = $line[1];
     $record['type'] = $line[4];
     // save record
     if (!$table->save($record)) {
         throw new Sh404sefExceptionDefault(JText16::sprintf('COM_SH404SEF_IMPORT_ERROR_INSERTING_INTO_DB', $line[0]));
     }
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:27,代码来源:importpageids.php

示例4: _fetchAccountsList

 protected function _fetchAccountsList()
 {
     $hClient =& Sh404sefHelperAnalytics::getHttpClient();
     $hClient->resetParameters($clearAll = true);
     // set target API url
     $hClient->setUri($this->_endPoint . 'accounts/default');
     // make sure we use GET
     $hClient->setMethod(Sh_Zend_Http_Client::GET);
     // set headers required by Google Analytics
     $headers = array('GData-Version' => 2, 'Authorization' => 'GoogleLogin auth="' . $this->_Auth . '"');
     $hClient->setHeaders($headers);
     //perform request
     // establish connection with available methods
     $adapters = array('Sh_Zend_Http_Client_Adapter_Curl', 'Sh_Zend_Http_Client_Adapter_Socket');
     $rawResponse = null;
     // perform connect request
     foreach ($adapters as $adapter) {
         try {
             $hClient->setAdapter($adapter);
             $response = $hClient->request();
             break;
         } catch (Exception $e) {
             // need that to be Exception, so as to catch Sh_Zend_Exceptions.. as well
             // we failed, let's try another method
         }
     }
     // return if error
     if (empty($response)) {
         $msg = 'unknown code';
         throw new Sh404sefExceptionDefault(JText16::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
     }
     if (empty($response) || !is_object($response) || $response->isError()) {
         $msg = method_exists($response, 'getStatus') ? $response->getStatus() : 'unknown code';
         throw new Sh404sefExceptionDefault(JText16::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
     }
     // analyze response
     // check if authentified
     Sh404sefHelperAnalytics::verifyAuthResponse($response);
     $xml = simplexml_load_string($response->getBody());
     if (!empty($xml->entry)) {
         foreach ($xml->entry as $entry) {
             $account = new StdClass();
             $accId = explode(':', (string) $entry->id);
             $account->id = array_pop($accId);
             $account->title = (string) $entry->title;
             $this->_accounts[] = clone $account;
         }
     }
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:49,代码来源:analyticsga.php

示例5: doExport

 /**
  * Second step, export data
  *
  */
 public function doExport()
 {
     // which button should be displayed ?
     $this->_visibleButtonsList = array();
     // next steps definition
     $this->_steps = array('next' => 1, 'previous' => 0, 'cancel' => -1, 'terminate' => -2);
     // return results
     $result = array();
     // exporting a limited set of pageids at a time
     $nextStart = JRequest::getInt('nextstart', 0);
     // are we adding to an existing data file ?
     $this->_filename = Sh404sefHelperFiles::createFileName($this->_filename, 'sh404sef_export_' . $this->_context);
     // calculate number of items to export
     $model =& JModel::getInstance('urls', 'Sh404sefModel');
     $model->setContext('urls.view404');
     $options = (object) array('layout' => 'view404');
     $this->_total = $model->getTotal($options);
     // do we have anything to export ?
     if (empty($this->_total)) {
         $result['mainText'] = JText16::_('COM_SH404SEF_NOTHING_TO_EXPORT');
         // which button should be displayed ?
         $this->_visibleButtonsList = array('terminate');
         // next step so to trigger download, as file is ready now
         $this->_steps = array('next' => -2, 'previous' => 0, 'cancel' => -1, 'terminate' => -2);
         return $result;
     }
     // get new start item
     if (empty($nextStart)) {
         // this is first pass, starting from 0
         $start = 0;
         $nextStart = $start + self::MAX_PAGEIDS_PER_STEP;
         if ($nextStart >= $this->_total) {
             // reached the end
             $nextStart = $this->_total;
         }
     } else {
         $start = $nextStart;
         $nextStart = $start + self::MAX_PAGEIDS_PER_STEP;
     }
     // are we done ? if so, move to next step
     $result['hiddenText'] = '';
     if ($start >= $this->_total) {
         $result['mainText'] = JText16::sprintf('COM_SH404SEF_EXPORT_DONE', $this->_total);
         $result['mainText'] .= $this->_getTerminateOptions();
         // which button should be displayed ?
         $this->_visibleButtonsList = array('terminate');
         // next step so to trigger download, as file is ready now
         $this->_steps = array('next' => 2, 'previous' => 0, 'cancel' => -1, 'terminate' => -2);
     } else {
         // actually export items
         $this->_export($start);
         // continuing for another round
         $result['mainText'] = JText16::sprintf('COM_SH404SEF_EXPORT_EXPORTING', $start + 1, $this->_total);
         $result['hiddenText'] = '<input type="hidden" name="nextstart" value="' . $nextStart . '" />';
         $result['nextStart'] = $nextStart;
     }
     $result['continue'] = array('task' => 'next', 'nextstart' => $nextStart, 'filename' => base64_encode($this->_filename));
     $result['continue'] = array_merge($result['continue'], $this->_steps);
     $result['hiddenText'] .= '<input type="hidden" name="filename" value="' . $this->_filename . '" />';
     return $result;
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:65,代码来源:exportview404.php

示例6: gridMainUrl

 public function gridMainUrl(&$url, $i)
 {
     $isMain = $url->rank == 0;
     $imgPrefix = $isMain ? '' : '-non';
     $img = 'components/com_sh404sef/assets/images/icon-16' . $imgPrefix . '-default.png';
     if ($isMain) {
         $alt = JText16::_('COM_SH404SEF_DUPLICATE_IS_MAIN');
         $href = '<img src="' . $img . '" border="0" alt="' . $alt . '" title="' . $alt . '" />';
     } else {
         $alt = JText16::sprintf('COM_SH404SEF_DUPLICATE_MAKE_MAIN', $url->oldurl);
         $href = '
 <a href="javascript:void(0);" onclick="return listItemTask(\'cb' . $i . '\',\'makemainurl\')" title="' . $alt . '">
 <img src="' . $img . '" border="0" alt="' . $alt . '" /></a>';
     }
     return $href;
 }
开发者ID:justinlyon,项目名称:scc,代码行数:16,代码来源:html.php

示例7: die

 * SEF module for Joomla!
 *
 * @author      $Author: shumisha $
 * @copyright   Yannick Gaultier - 2007-2010
 * @package     sh404SEF-15
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @version     $Id: default_top5urls.php 1717 2011-01-13 13:30:08Z silianacom-svn $
 */
// Security check to ensure this file is being included by a parent file.
if (!defined('_JEXEC')) {
    die('Direct Access to this location is not allowed.');
}
?>
<fieldset>
   <legend><?php 
echo JText16::sprintf('COM_SH404SEF_ANALYTICS_TOP5_PAGES', $this->options['max-top-urls']);
?>
</legend>
        
 	<table class="adminlist" >
    <thead>
      <tr>
        <th class="title" >
          <?php 
echo JText::_('NUM');
?>
        </th>
        
        <?php 
$t = JText16::_('COM_SH404SEF_ANALYTICS_TOP5_URL') . '::' . JText16::_('COM_SH404SEF_ANALYTICS_TT_URL_DESC');
?>
开发者ID:sangkasi,项目名称:joomla,代码行数:31,代码来源:default_top5urls.php

示例8: array

   </td>
   <td align="center" width="5%">
     <?php 
 if ($this->slowServer) {
     $linkData = array('c' => 'duplicates', 'cid[]' => $url->id, 'tmpl' => 'component');
     $anchor = $url->rank == 0 ? '[<strong>+++</strong>]' : '++';
     $title = $url->rank == 0 ? JText16::_('COM_SH404SEF_IS_A_MAIN_URL') : JText16::_('COM_SH404SEF_IS_DUPLICATE');
     $urlData = array('title' => $title, 'class' => 'modalediturl', 'anchor' => $anchor);
     $modalOptions = array('size' => array('x' => '\\window.getSize().scrollSize.x*.9', 'y' => '\\window.getSize().size.y*.9'));
     echo Sh404sefHelperHtml::makeLink($this, $linkData, $urlData, $modal = true, $modalOptions, $hasTip = false, $extra = '');
 }
 if (empty($url->duplicates)) {
     echo '&nbsp;';
 } else {
     $linkData = array('c' => 'duplicates', 'cid[]' => $url->id, 'tmpl' => 'component');
     $urlData = array('title' => JText16::sprintf('COM_SH404SEF_HAS_DUPLICATES_LINK_TITLE', $url->duplicates), 'class' => 'modalediturl', 'anchor' => $url->duplicates);
     $modalOptions = array('size' => array('x' => '\\window.getSize().scrollSize.x*.9', 'y' => '\\window.getSize().size.y*.9'));
     echo Sh404sefHelperHtml::makeLink($this, $linkData, $urlData, $modal = true, $modalOptions, $hasTip = false, $extra = '');
 }
 ?>
   </td>
   <td align="center" width="5%">
     <?php 
 if (empty($url->aliases)) {
     echo '&nbsp;';
 } else {
     $linkData = array('c' => 'editurl', 'task' => 'edit', 'cid[]' => $url->id, 'tmpl' => 'component', 'startOffset' => 2);
     $urlData = array('title' => 'Has ' . $url->aliases . ' alias(es)', 'class' => 'modalediturl', 'anchor' => $url->aliases);
     $modalOptions = array('size' => array('x' => 700, 'y' => 500));
     echo Sh404sefHelperHtml::makeLink($this, $linkData, $urlData, $modal = true, $modalOptions, $hasTip = false, $extra = '');
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:31,代码来源:default.php

示例9: _createRecord

 /**
  * Creates a record in the database, based
  * on data read from import file
  *
  * @param array $header an array of fields, as built from the header line
  * @param string $line raw record obtained from import file
  */
 protected function _createRecord($header, $line)
 {
     // extract the record
     $line = $this->_lineToArray(trim($line));
     // get table object to store record
     $model =& JModel::getInstance('metas', 'Sh404sefModel');
     // bind table to current record
     $record = array();
     $record['newurl'] = $line[1];
     $record['metatitle'] = $line[4];
     $record['metadesc'] = $line[2];
     $record['metakey'] = $line[3];
     $record['metalang'] = $line[5];
     $record['metarobots'] = $line[6];
     // clean up records
     foreach ($record as $key => $value) {
         if ($value == '&nbsp') {
             $record[$key] = '';
         }
     }
     // find if there is already an url record for this non-sef url. If so
     // we want the imported record to overwrite the existing one.
     // while makinf sure we're doing that with the main url, not one of the duplicates
     $existingRecords = $model->getByAttr(array('newurl' => $record['newurl']));
     if (!empty($existingRecords)) {
         $existingRecord = $existingRecords[0];
         // getByAttr always returns an array
         // use the existing id, this will be enought to override existing record when saving
         $record['id'] = $existingRecord->id;
         // ensure consistency : delete the remaining records, though there is no reason
         // there can be more than one record with same SEF AND same SEF
         array_shift($existingRecords);
         if (!empty($existingRecords)) {
             $db =& JFactory::getDBO();
             $ids = array();
             foreach ($existingRecords as $existingRecord) {
                 $ids[] = $db->Quote($existingRecord->id);
             }
             $query = 'delete from ' . $db->nameQuote('#__sh404SEF_meta') . ' where ' . $db->nameQuote('id') . ' in (' . implode(',', $ids) . ')';
             $db->setQuery($query);
             $db->query();
         }
     } else {
         $record['id'] = 0;
     }
     // save record : returns the record id, so failure is when 0 is returned
     $status = $model->save($record);
     if (!$status) {
         // rethrow a more appropriate error message
         throw new Sh404sefExceptionDefault(JText16::sprintf('COM_SH404SEF_IMPORT_ERROR_INSERTING_INTO_DB', $line[0]));
     }
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:59,代码来源:importsh404sefmetas.php

示例10: _updateRequired

 /**
  * Use response object from request to update info server
  * to find if an update is required
  *
  * @param object $response
  */
 private function _updateRequired($response)
 {
     // get configuration
     $sefConfig =& shRouter::shGetConfig();
     // compare versions
     $thisVersion = $sefConfig->version == '@ant_version_number@' ? '1.5.10' : $sefConfig->version;
     $response->shouldUpdate = version_compare($thisVersion, $response->current) == -1;
     $response->shouldUpdate = $response->shouldUpdate && version_compare($thisVersion, $response->minVersionToUpgrade) == 1;
     $response->shouldUpdate = $response->shouldUpdate && (empty($response->maxVersionToUpgrade) || version_compare($thisVersion, $response->maxVersionToUpgrade) == -1);
     if ($response->shouldUpdate) {
         // check specific versions exclusion list
         $response->shouldUpdate = $response->shouldUpdate && !in_array($thisVersion, $response->excludes);
     }
     // build status message based on result of should update calculation
     $response->statusMessage = $response->shouldUpdate ? JText16::sprintf('COM_SH404SEF_NEW_VERSION_AVAILABLE') : JText16::sprintf('COM_SH404SEF_YOU_ARE_UP_TO_DATE');
     // return whatever we found
     return $response;
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:24,代码来源:updates.php

示例11: doImport

 /**
  * Last step, actually perform importation
  *
  */
 public function doImport()
 {
     // collect file and import type information
     $this->_filename = JRequest::getString('filename');
     try {
         // read file content in an array
         $lines = file($this->_filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
         // start analysing
         if (empty($lines)) {
             throw new Sh404sefExceptionDefault('COM_SH404SEF_ERROR_IMPORT');
         }
         // extract header line
         $header = array_shift($lines);
         if (empty($header)) {
             throw new Sh404sefExceptionDefault('COM_SH404SEF_ERROR_IMPORT');
         }
         // turn header into an array
         $header = $this->_lineToArray($header);
         // count items
         $this->_total = count($lines);
         // iterate through file content and create each record
         foreach ($lines as $line) {
             $this->_createRecord($header, $line);
         }
         // get back memory
         unset($lines);
         // delete temporary uploaded file
         JFile::delete($this->_filename);
         // which button should be displayed ?
         $this->_visibleButtonsList = array('terminate');
         // next steps definition
         $this->_steps = array('next' => 3, 'previous' => 0, 'cancel' => -1, 'terminate' => -2);
         // setup display of wizard last page
         $this->_result['hiddenText'] = '';
         $this->_result['mainText'] = JText16::sprintf('COM_SH404SEF_IMPORT_DONE', $this->_total, $this->_context);
         $this->_result['mainText'] .= $this->_getTerminateOptions();
     } catch (Sh404sefExceptionDefault $e) {
         $this->_handleException($e);
     }
     return $this->_result;
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:45,代码来源:importgeneric.php

示例12: die

 *
 * @author      $Author: shumisha $
 * @copyright   Yannick Gaultier - 2007-2010
 * @package     sh404SEF-15
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @version     $Id: default_top5referrers.php 1717 2011-01-13 13:30:08Z silianacom-svn $
 */
// Security check to ensure this file is being included by a parent file.
if (!defined('_JEXEC')) {
    die('Direct Access to this location is not allowed.');
}
?>

<fieldset>
   <legend><?php 
echo JText16::sprintf('COM_SH404SEF_ANALYTICS_TOP5_REFERRERS', $this->options['max-top-referrers']);
?>
</legend>
        
  <table class="adminlist">
    <thead>
      <tr>
        <th class="title" width="3%">
          <?php 
echo JText::_('NUM');
?>
        </th>
        
        <?php 
$t = JText16::_('COM_SH404SEF_ANALYTICS_TOP5_REF_SOURCE') . '::' . JText16::_('COM_SH404SEF_ANALYTICS_TT_SOURCE_SITE_DESC');
?>
开发者ID:sangkasi,项目名称:joomla,代码行数:31,代码来源:default_top5referrers.php

示例13: listItemAjaxTask

          <td colspan="6">
            <?php 
echo $this->pagination->getListFooter();
?>
          </td>
        </tr>
      </tfoot>
      <tbody>
        <?php 
$k = 0;
if ($this->itemCount > 0) {
    for ($i = 0; $i < $this->itemCount; $i++) {
        $url =& $this->items[$i];
        $checked = JHtml::_('grid.id', $i, $url->id);
        $custom = !empty($url->newurl) && $url->dateadd != '0000-00-00' ? '<img src="components/com_sh404sef/assets/images/icon-16-user.png" border="0" alt="Custom" />' : '&nbsp;';
        $alt = JText16::sprintf('COM_SH404SEF_NOT_FOUND_REDIRECT_TO', $this->escape($this->url->get('oldurl')), $this->escape($url->oldurl));
        $oldUrl = '
              <a href="javascript:void(0);" onclick="return listItemAjaxTask(\'cb' . $i . '\',\'selectnfredirect\', {}, 1)" title="' . $alt . '">' . $this->escape($url->oldurl) . '</a>';
        ?>
        <tr class="<?php 
        echo "row{$k}";
        ?>
">
          <td align="center" >
            <?php 
        echo $this->pagination->getRowOffset($i);
        ?>
          </td>
          <td align="center">
            <?php 
        echo $checked;
开发者ID:sangkasi,项目名称:joomla,代码行数:31,代码来源:default.php

示例14: _createRecord

 /**
  * Creates a record in the database, based
  * on data read from import file
  *
  * @param array $header an array of fields, as built from the header line
  * @param string $line raw record obtained from import file
  */
 protected function _createRecord($header, $line)
 {
     // extract the record
     $line = $this->_lineToArray($line);
     // get table object to store record
     $model =& JModel::getInstance('editurl', 'Sh404sefModel');
     // bind table to current record
     $record = array();
     $record['oldurl'] = $line[1];
     $record['newurl'] = $line[2];
     if ($record['newurl'] == '__ Homepage __') {
         $record['newurl'] = sh404SEF_HOMEPAGE_CODE;
     }
     $record['cpt'] = $line[3];
     $record['rank'] = $line[4];
     $record['dateadd'] = $line[5];
     $record['metatitle'] = $line[6];
     $record['metadesc'] = $line[7];
     $record['metakey'] = $line[8];
     $record['metalang'] = $line[9];
     $record['metarobots'] = $line[10];
     // find if there is already an url record for this non-sef url. If so
     // we want the imported record to overwrite the existing one.
     // while makinf sure we're doing that with the main url, not one of the duplicates
     $existingRecords = $model->getByAttr(array('newurl' => $record['newurl'], 'oldurl' => $record['oldurl']));
     if (!empty($existingRecords)) {
         $existingRecord = $existingRecords[0];
         // getByAttr always returns an array
         // use the existing id, this will be enought to override existing record when saving
         $record['id'] = $existingRecord->id;
         // ensure consistency : delete the remaining records, though there is no reason
         // there can be more than one record with same SEF AND same SEF
         array_shift($existingRecords);
         if (!empty($existingRecords)) {
             $db =& JFactory::getDBO();
             $ids = array();
             foreach ($existingRecords as $existingRecord) {
                 $ids[] = $db->Quote($existingRecord->id);
             }
             $query = 'delete from ' . $db->nameQuote('#__redirection') . ' where ' . $db->nameQuote('id') . ' in (' . implode(',', $ids) . ')';
             $db->setQuery($query);
             $db->query();
         }
     } else {
         $record['id'] = 0;
     }
     // find if we already have a meta data record for this non-sef url
     // as we want to update it if so, instead of creating a new record
     $metasModel =& JModel::getInstance('metas', 'Sh404sefModel');
     $existingMetas = $metasModel->getByAttr(array('newurl' => $record['newurl']));
     if (!empty($existingMetas)) {
         $existingMeta = $existingMetas[0];
         // getByAttr always returns an array
         // use the existing id, this will be enought to override existing record when saving
         $record['meta_id'] = $existingMeta->id;
     } else {
         $record['meta_id'] = 0;
     }
     // for aliases, we don't import them here, but we need to create a dummy
     // record so as to preserve possible pre-existing aliases for the same non-sef url
     $aliasesModel =& JModel::getInstance('editalias', 'Sh404sefModel');
     $existingAliases = $aliasesModel->getByAttr(array('newurl' => $record['newurl']));
     $record['shAliasList'] = '';
     if (!empty($existingAliases)) {
         foreach ($existingAliases as $existingAlias) {
             // build up a text list, just as if we were to edit aliases
             // as this is what the model expect to receive
             $record['shAliasList'] .= $existingAlias->alias . "\n";
         }
     }
     // save record : returns the record id, so failure is when 0 is returned
     $savedId = $model->save($record, sh404SEF_URLTYPE_AUTO);
     if (empty($savedId)) {
         // rethrow a more appropriate error message
         throw new Sh404sefExceptionDefault(JText16::sprintf('COM_SH404SEF_IMPORT_ERROR_INSERTING_INTO_DB', $line[0]));
     }
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:84,代码来源:importurls.php

示例15: _connect

 /**
  * Connects to analytics supplier
  *
  * Meant to be overloaded by adapter
  *
  * @param $config , sef config object, holding connecton parameters
  */
 protected function _connect()
 {
     // get the http client
     $hClient =& Sh404sefHelperAnalytics::getHttpClient();
     // establish connection with available methods
     $adapters = array('Sh_Zend_Http_Client_Adapter_Curl', 'Sh_Zend_Http_Client_Adapter_Socket');
     $rawResponse = null;
     // perform connect request
     foreach ($adapters as $adapter) {
         try {
             $hClient->setAdapter($adapter);
             $rawResponse = $hClient->request();
             break;
         } catch (Exception $e) {
             // need that to be Exception, so as to catch Sh_Zend_Exceptions.. as well
             // we failed, let's try another method
             //echo '<br />exception in _connect' . $e->getMessage();
         }
     }
     // return if error
     if (empty($rawResponse)) {
         $msg = 'unknown code';
         throw new Sh404sefExceptionDefault(JText16::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
     }
     if (!is_object($rawResponse) || $rawResponse->isError()) {
         $msg = method_exists($rawResponse, 'getStatus') ? $rawResponse->getStatus() : 'unknown code';
         throw new Sh404sefExceptionDefault(JText16::sprintf('COM_SH404SEF_ERROR_CHECKING_ANALYTICS', $msg));
     }
     // success, return response
     return $rawResponse;
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:38,代码来源:baseanalytics.php


注:本文中的JText16::sprintf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。