本文整理汇总了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));
}
}