Beispiel #1
0
	protected function prepareFields()
	{
		$this->set('contenttypeid', vb_Types::instance()->getContentTypeID("vBCms_Section"));

		if ($this->set_fields['nodeid'])
		{
			$this->item_id = $this->set_fields['nodeid'];
		}
		parent::prepareFields();
	}
Beispiel #2
0
	/**
	 * Prepare meta description to use first 20 keywords of the artile if it's not set. See bug #30456
	 */
	protected function prepareFields()
	{
		parent::prepareFields();

		if ((empty($this->set_fields['description']) OR $this->set_fields['description'] == (string) new vB_Phrase('vbcms', 'new_article'))
			AND !empty($this->type_set_fields['pagetext']))
		{
			require_once(DIR . '/includes/functions_databuild.php');

			$words = fetch_postindex_text($this->type_set_fields['pagetext']);

			$wordarray = split_string($words);
			$scores = array();
			foreach ($wordarray AS $word)
			{
				if (!is_index_word($word))
				{
					continue;
				}
				$scores[$word]++;
			}

			// Sort scores
			arsort($scores, SORT_NUMERIC);
			$scores = array_slice($scores, 0, 10, true);
			$this->set_fields['description'] = '';
			foreach ($scores as $k => $v)
			{
				$this->set_fields['description'] .= $k . ' ';
			}
			$this->set_fields['description'] = trim($this->set_fields['description']);
		}
	}