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


PHP c2cTools::Letter2Model方法代码示例

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


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

示例1: doMerge

 protected function doMerge($from_id, $document_from, $to_id, $document_to)
 {
     // fetch associated documents before doing the merging as associations will be transferred
     $associations = Association::findAllAssociations($from_id);
     parent::doMerge($from_id, $document_from, $to_id, $document_to);
     // search documents in which from is inserted, and replace the insertion with to
     foreach ($associations as $a) {
         $check_id = $a['main_id'] == $from_id ? $a['linked_id'] : ($check_id = $a['main_id']);
         $check_model = c2cTools::Letter2Model(substr($a['type'], 0, 1));
         $check_module = c2cTools::Model2Module($check_model);
         $check_doc = Document::find($check_model, $check_id);
         $fields = sfConfig::get('mod_images_bbcode_fields_' . $check_module);
         // clear linked doc cache
         $this->clearCache($check_module, $check_id);
         $languages = $check_doc->getLanguages();
         foreach ($languages as $language) {
             $modified = false;
             $conn = sfDoctrine::Connection();
             $conn->beginTransaction();
             $check_doc->setCulture($language);
             foreach ($fields as $field) {
                 $text = $check_doc[$field];
                 $edited = preg_replace('#(\\[img=\\s*)' . $from_id . '([\\w\\s]*\\].*?\\[/img\\])\\n?#is', '${1}' . $to_id . '${2}', $text);
                 $edited = preg_replace('#(\\[img=\\s*)' . $from_id . '([\\w\\s]*\\/\\])\\n?#is', '${1}' . $to_id . '${2}', $edited);
                 if ($edited != $text) {
                     $modified = true;
                     $check_doc->set($field, $edited);
                 }
             }
             if ($modified) {
                 $history_metadata = new HistoryMetadata();
                 $history_metadata->setComment('Updated image tags');
                 $history_metadata->set('is_minor', true);
                 $history_metadata->set('user_id', sfConfig::get('app_moderator_user_id'));
                 $history_metadata->save();
                 c2cTools::log('After merge of image ' . $from_id . ' into ' . $to_id . ': update image tag for ' . strtolower($check_model) . ' ' . $check_id . ' (' . $language . ')');
                 $check_doc->save();
                 $conn->commit();
             } else {
                 $conn->rollback();
             }
         }
     }
     // clear images lists and whatsnew cache
     $this->clearCache('images', 0, true);
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:46,代码来源:actions.class.php


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