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


PHP JFilterOutput::stringUrlUnicodeSlug方法代码示例

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


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

示例1: prepareTableData

 /**
  * Prepare project images before saving.
  *
  * @param   CrowdfundingTableProject $table
  * @param   array  $data
  *
  * @throws Exception
  *
  * @since    1.6
  */
 protected function prepareTableData($table, $data)
 {
     $params = JComponentHelper::getParams($this->option);
     /** @var  $params Joomla\Registry\Registry */
     // Set order value
     if (!$table->get('id') and !$table->get('ordering')) {
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         $query->select('MAX(ordering)')->from($db->quoteName('#__crowdf_projects'));
         $db->setQuery($query, 0, 1);
         $max = $db->loadResult();
         $table->set('ordering', $max + 1);
     }
     // Prepare image.
     if (!empty($data['image'])) {
         // Delete old image if I upload a new one
         if ($table->get('image')) {
             $imagesFolder = $params->get('images_directory', 'images/crowdfunding');
             // Remove an image from the filesystem
             $fileImage = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $imagesFolder . DIRECTORY_SEPARATOR . $table->get('image'));
             $fileSmall = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $imagesFolder . DIRECTORY_SEPARATOR . $table->get('image_small'));
             $fileSquare = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $imagesFolder . DIRECTORY_SEPARATOR . $table->get('image_square'));
             if (is_file($fileImage)) {
                 JFile::delete($fileImage);
             }
             if (is_file($fileSmall)) {
                 JFile::delete($fileSmall);
             }
             if (is_file($fileSquare)) {
                 JFile::delete($fileSquare);
             }
         }
         $table->set('image', $data['image']);
         $table->set('image_small', $data['image_small']);
         $table->set('image_square', $data['image_square']);
     }
     // Prepare pitch image.
     if (!empty($data['pitch_image'])) {
         // Delete old image if I upload a new one
         if ($table->get('pitch_image')) {
             $imagesFolder = $params->get('images_directory', 'images/crowdfunding');
             // Remove an image from the filesystem
             $pitchImage = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $imagesFolder . DIRECTORY_SEPARATOR . $table->get('pitch_image'));
             if (is_file($pitchImage)) {
                 JFile::delete($pitchImage);
             }
         }
         $table->set('pitch_image', $data['pitch_image']);
     }
     // If an alias does not exist, I will generate the new one using the title.
     if (!$table->get('alias')) {
         $table->set('alias', $table->get('title'));
     }
     if ((int) JFactory::getConfig()->get('unicodeslugs') === 1) {
         $table->set('alias', JFilterOutput::stringUrlUnicodeSlug($table->get('alias')));
     } else {
         $table->set('alias', JFilterOutput::stringURLSafe($table->get('alias')));
     }
     // Prepare funding duration
     $durationType = Joomla\Utilities\ArrayHelper::getValue($data, 'duration_type');
     $fundingStart = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_start');
     $fundingEnd = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_end');
     $fundingDays = Joomla\Utilities\ArrayHelper::getValue($data, 'funding_days');
     // Prepare funding start date.
     $fundingStartValidator = new Prism\Validator\Date($fundingStart);
     if (!$fundingStartValidator->isValid()) {
         $table->funding_start = Prism\Constants::DATE_DEFAULT_SQL_DATE;
     } else {
         $date = new JDate($fundingStart);
         $table->funding_start = $date->toSql();
     }
     switch ($durationType) {
         case 'days':
             // Set funding day.
             $table->funding_days = $fundingDays;
             // Calculate end date
             $fundingStartValidator = new Prism\Validator\Date($table->funding_start);
             if (!$fundingStartValidator->isValid()) {
                 $table->funding_end = Prism\Constants::DATE_DEFAULT_SQL_DATE;
             } else {
                 $fundingStartDate = new Crowdfunding\Date($table->funding_start);
                 $fundingEndDate = $fundingStartDate->calculateEndDate($table->funding_days);
                 $table->funding_end = $fundingEndDate->toSql();
             }
             break;
         case 'date':
             $fundingEndValidator = new Prism\Validator\Date($fundingEnd);
             if (!$fundingEndValidator->isValid()) {
                 throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_INVALID_DATE'));
             }
//.........这里部分代码省略.........
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:101,代码来源:project.php


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