當前位置: 首頁>>代碼示例>>PHP>>正文


PHP xPDOObject::getTVValue方法代碼示例

本文整理匯總了PHP中xPDOObject::getTVValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP xPDOObject::getTVValue方法的具體用法?PHP xPDOObject::getTVValue怎麽用?PHP xPDOObject::getTVValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xPDOObject的用法示例。


在下文中一共展示了xPDOObject::getTVValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Index

 /**
  * Create index of resource
  *
  * @param xPDOObject $resource
  */
 public function Index(xPDOObject $resource)
 {
     $words = array();
     $intro = '';
     // For proper transliterate umlauts
     setlocale(LC_ALL, 'en_US.UTF8', LC_CTYPE);
     foreach ($this->mSearch2->fields as $field => $weight) {
         $text = strpos($field, 'tv_') !== false && $resource instanceof modResource ? $resource->getTVValue(substr($field, 3)) : $resource->get($field);
         $forms = $this->_getBaseForms($text);
         $intro .= $this->modx->stripTags(is_array($text) ? $this->_implode_r(' ', $text) : $text) . ' ';
         foreach ($forms as $form => $count) {
             $words[$form][$field] = $count;
         }
     }
     $tword = $this->modx->getTableName('mseWord');
     $tintro = $this->modx->getTableName('mseIntro');
     $resource_id = $resource->get('id');
     $intro = str_replace(array("\n", "\r\n", "\r"), ' ', $intro);
     $intro = preg_replace('/\\s+/', ' ', str_replace(array('\'', '"', '«', '»', '`'), '', $intro));
     $sql = "INSERT INTO {$tintro} (`resource`, `intro`) VALUES ('{$resource_id}', '{$intro}') ON DUPLICATE KEY UPDATE `intro` = '{$intro}';";
     $sql .= "DELETE FROM {$tword} WHERE `resource` = '{$resource_id}';";
     if (!($class_key = $resource->get('class_key'))) {
         $class_key = get_class($resource);
     }
     if (!empty($words)) {
         $rows = array();
         foreach ($words as $word => $fields) {
             foreach ($fields as $field => $count) {
                 $rows[] = "({$resource_id}, '{$field}', '{$word}', '{$count}', '{$class_key}')";
             }
         }
         $sql .= "INSERT INTO {$tword} (`resource`, `field`, `word`, `count`, `class_key`) VALUES " . implode(',', $rows);
         //$sql .= " ON DUPLICATE KEY UPDATE `resource` = '$resource_id';";
     }
     $q = $this->modx->prepare($sql);
     if (!$q->execute()) {
         $this->modx->log(modX::LOG_LEVEL_ERROR, '[mSearch2] Could not save search index of resource ' . $resource_id . ': ' . print_r($q->errorInfo(), 1));
     }
 }
開發者ID:svyatoslavteterin,項目名稱:belton.by,代碼行數:44,代碼來源:create.class.php


注:本文中的xPDOObject::getTVValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。