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


PHP JText::sprinf方法代码示例

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


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

示例1: generatefile

 function generatefile()
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $lang = JRequest::getVar('tlang', '');
     $tr_from = JRequest::getVar('tr_from', 'en-GB');
     $user = JRequest::getVar('nickname', '');
     $component = JRequest::getVar('tcomponent', '');
     $type = JRequest::getVar('ttype', 'site');
     $path = JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'translations';
     $relpath = JURI::root() . 'components/com_onepage/translations';
     if ($type == 'site') {
         $path = JPATH_ROOT . DS . 'language';
     } else {
         $path = JPATH_ADMINISTRATOR . DS . 'language';
     }
     // basic security
     if (strpos($lang, '..') !== false) {
         die('edit.php: hacking attempt');
     }
     if (strpos($component, '..') !== false) {
         die('edit.php: hacking attempt');
     }
     if (strpos($user, '..') !== false) {
         die('edit.php: hacking attempt');
     }
     if (strpos($type, '..') !== false) {
         die('edit.php: hacking attempt');
     }
     $lang = JFile::makeSafe($lang);
     $user = JFile::makeSafe($user);
     $component = JFile::makeSafe($component);
     $type = JFile::makeSafe($type);
     $tr_from = JFile::makeSafe($tr_from);
     if (!file_exists($path)) {
         if (JFolder::create($path) === false) {
             echo JText::sprinf('COM_ONEPAGE_CANNOT_CREATE_DIRECTORY', $path);
         }
     }
     // sk-SK
     $path .= DS . $lang;
     $relpath .= '/' . $lang;
     if (!file_exists($path)) {
         if (JFolder::create($path) === false) {
             echo JText::sprinf('COM_ONEPAGE_CANNOT_CREATE_DIRECTORY', $path);
         }
     }
     /*
     // sk-SK/site
     $path .= DS.$type; 
     $relpath .= '/'.$type;
     if (!file_exists($path)) 
     	if (JFolder::create($path) === false)
     	echo 'Cannot create directory: '.$path; 
     
     	
     $path .= DS.$user; 
     $relpath .= '/'.$user;
     if (!file_exists($path)) 
     	if (JFolder::create($path) === false)
     	echo 'Cannot create directory: '.$path; 
     */
     $filename = $path . DS . $lang . '.' . $component . '.ini';
     if (file_exists($filename)) {
         $x = rand(100000, 999999);
         // will create a random filename
         $filename2 = $path . DS . $lang . '.' . $component . '_bck_opc' . $x . '.ini';
         if (JFile::copy($filename, $filename2) === false) {
             echo JText::sprintf('COM_ONEPAGE_CANNOT_CREATE_BACKUP', $filename) . '<br />';
         }
         //echo 'Cannot create a backup of '.$filename.'<br />';
     }
     $relpath .= '/' . $lang . '.' . $component . '.ini';
     $this->createtable();
     $arr1 = $this->getIni($tr_from, $type, $component);
     if (empty($arr1)) {
         echo '<b style="color: red;">' . JText::_('COM_ONEPAGE_CANNOT_SAVE_LANG') . '</b><br />';
         return;
     }
     $arr_orig = $arr1;
     $arr2 = $this->getIni($lang, $type, $component);
     foreach ($arr1 as $key => $v) {
         if (!empty($arr2[$key])) {
             $arr1[$key] = $arr2[$key];
         }
     }
     $db = JFactory::getDBO();
     echo JText::sprintf('COM_ONEPAGE_FETCHING_TRANSLATIONS_PERUSER', $user, $component, $type, $lang) . '<br />';
     foreach ($arr1 as $key => $val) {
         $translation = $val;
         $q = "select * from #__vmtranslator_translations where user = '" . $db->escape($user) . "' and var = '" . $db->escape(urlencode($key)) . "' and entity = '" . $db->escape($component) . "' and lang = '" . $db->escape($lang) . "' and type = '" . $db->escape($type) . "' order by id asc limit 0, 1";
         $db->setQuery($q);
         $res = $db->loadAssoc();
         $err = $db->getErrorMsg();
         if (!empty($err)) {
             var_dump($err);
             die;
         }
         if (!empty($res)) {
             $translation = urldecode($res['translation']);
//.........这里部分代码省略.........
开发者ID:aldegtyarev,项目名称:stelsvelo,代码行数:101,代码来源:edit.php

示例2: batchImportHandler

function batchImportHandler()
{
    jimport('joomla.filesystem.*');
    jimport('joomla.filesystem.archive');
    $app = JFactory::getApplication('administrator');
    $catid = JRequest::getVar('catid', 0, 'post', 'int');
    @ini_set('max_execution_time', '240');
    $time_start = getmicrotime();
    $max_wait = @ini_get('max_execution_time') - 2;
    $filelist = array();
    require JPATH_COMPONENT . DS . 'config.datsogallery.php';
    require_once JPATH_COMPONENT . DS . 'images.datsogallery.php';
    $dir = JPATH_SITE . DS . 'zipimport';
    dgChmod($dir, 0777);
    $directory_zip = opendir($dir);
    while ($file_name = readdir($directory_zip)) {
        $ext = strtolower(substr($file_name, -4));
        if ($ext == ".zip") {
            if (JArchive::extract($dir . DS . $file_name, $dir) == TRUE) {
                JFile::delete($dir . DS . $file_name);
            }
        }
    }
    closedir($directory_zip);
    $directory_zip = opendir($dir);
    while (false !== ($file = readdir($directory_zip))) {
        $files[] = $file;
    }
    sort($files);
    $i = 0;
    foreach ($files as $file) {
        if ($file != '.' && $file != '..' && strcasecmp($file, 'index.html') != 0 && strcasecmp($file, '__MACOSX') != 0) {
            $i++;
            $count = $i > 1 ? ' ' . $i : '';
            $origfilename = $file;
            $imagetype = array(1 => 'GIF', 2 => 'JPG', 3 => 'PNG');
            $imginfo = getimagesize($dir . DS . $origfilename);
            $ext = strtolower($imagetype[$imginfo[2]]);
            if (is_dir($dir . DS . $origfilename)) {
                JFolder::delete($dir . DS . $origfilename);
                $msg = JText::sprintf('COM_DATSOGALLERY_ZIP_PACKAGE_ERROR', '<a href="http://www.datso.fr/en/video-guidelines.html" target="_blank">', '</a>');
                $app->redirect('index.php?option=com_datsogallery&task=pictures', $msg);
            }
            if (!$ext) {
                JFile::delete($dir . DS . $origfilename);
            } else {
                $newfilename = $ad_fname ? $origfilename : dgImgId($catid, $ext);
                JFile::copy($dir . DS . $origfilename, JPath::clean(JPATH_SITE . $ad_pathoriginals . DS . $newfilename));
                JFile::delete($dir . DS . $origfilename);
                $db = JFactory::getDBO();
                $user = JFactory::getUser();
                $row = new DatsoImages($db);
                if (!$row->bind(JRequest::get('post'))) {
                    return JError::raiseWarning(500, $row->getError());
                }
                $row->ordering = $row->getNextOrder('catid = ' . (int) $catid);
                $row->imgtitle = JRequest::getVar('gentitle') . $count;
                $row->imgtext = JRequest::getVar('gendesc');
                $row->imgauthor = JRequest::getVar('genimgauthor');
                $row->imgauthorurl = JRequest::getVar('genimgauthorurl');
                $row->imgdate = mktime();
                $row->owner_id = $user->id;
                $row->published = 1;
                $row->approved = 1;
                $row->imgoriginalname = $newfilename;
                $row->useruploaded = 0;
                if (!$row->store()) {
                    JError::raiseError(500, $row->getError());
                }
                $time_end = getmicrotime();
                if ($max_wait < $time_end - $time_start) {
                    $time = $time_end - $time_start;
                    $timelimit = ini_get('max_execution_time');
                    closedir($directory_zip);
                    dgChmod($dir, 0755);
                    $msg = JText::sprinf('COM_DATSOGALLERY_TIME_LIMIT_MSG', $timelimit);
                    $app->redirect('index.php?option=com_datsogallery&task=pictures', $msg);
                }
            }
        }
    }
    closedir($directory_zip);
    dgChmod($dir);
    $msg = 'Зашибись!';
    $app->redirect('index.php?option=com_datsogallery&task=pictures', $msg);
}
开发者ID:j0rg3m414,项目名称:centerar,代码行数:86,代码来源:admin.datsogallery.php


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