<commit_before><?
defined('C5_EXECUTE') or die("Access Denied.");
class Concrete5_Model_Composer extends Object {

	public function getComposerID() {return $this->cmpID;}
	public function getComposerName() {return $this->cmpName;}
	public function getComposerTargetTypeID() {return $this->cmpTargetTypeID;}
	public function getComposerTargetObject() {return $this->cmpTargetObject;}

	public function getComposerPageTypeObjects() {
		$db = Loader::db();
		$types = array();
		$r = $db->Execute('select ctID from ComposerPageTypes where cmpID = ? order by ctID asc', array($this->cmpID));
		while ($row = $r->FetchRow()) {
			$ct = CollectionType::getByID($row['ctID']);
			if (is_object($ct)) {
				$types[] = $ct;
			}
		}
		return $types;
	}

	public static function add($cmpName, $types) {
		$db = Loader::db();
		$db->Execute('insert into Composers (cmpName) values (?)', array(
			$cmpName
		));
		$cmpID = $db->Insert_ID();
		foreach($types as $ct) {
			$db->Execute('insert into ComposerPageTypes (cmpID, ctID) values (?, ?)', array(
				$cmpID, $ct->getCollectionTypeID()
			));
		}
		return Composer::getByID($db->Insert_ID());
	}

	/** 
	 * Returns an array of all areas on the page type defaults for the page types selected
	 */
	public function getPageTypeAreaList() {
		$db = Loader::db();
		$ctIDs = array(-1);
		foreach($this->getComposerPageTypeObjects() as $ct) {
			$ctIDs[] = $ct->getCollectionTypeID();
		}
		$r = $db->Execute('select distinct arHandle from Areas where cID in (select p.cID from Pages p inner join CollectionVersions cv on (p.cID = cv.cID and cv.cvIsApproved = 1) where cIsTemplate = 1 and ctID in (' . implode(',', $ctIDs) . ')) order by arHandle');
		$areas = array();
		while ($row = $r->FetchRow()) {
			$areas[] = $row['arHandle'];
		}
		return $areas;
	}

	public function update($cmpName, $types) {<commit_msg>tweak<commit_after><?
defined('C5_EXECUTE') or die("Access Denied.");
class Concrete5_Model_Composer extends Object {

	public function getComposerID() {return $this->cmpID;}
	public function getComposerName() {return $this->cmpName;}
	public function getComposerTargetTypeID() {return $this->cmpTargetTypeID;}
	public function getComposerTargetObject() {return $this->cmpTargetObject;}

	public function getComposerPageTypeObjects() {
		$db = Loader::db();
		$types = array();
		$r = $db->Execute('select ctID from ComposerPageTypes where cmpID = ? order by ctID asc', array($this->cmpID));
		while ($row = $r->FetchRow()) {
			$ct = CollectionType::getByID($row['ctID']);
			if (is_object($ct)) {
				$types[] = $ct;
			}
		}
		return $types;
	}

	public static function add($cmpName, $types) {
		$db = Loader::db();
		$db->Execute('insert into Composers (cmpName) values (?)', array(
			$cmpName
		));
		$cmpID = $db->Insert_ID();
		foreach($types as $ct) {
			$db->Execute('insert into ComposerPageTypes (cmpID, ctID) values (?, ?)', array(
				$cmpID, $ct->getCollectionTypeID()
			));
		}
		return Composer::getByID($db->Insert_ID());
	}

	/** 
	 * Returns an array of all areas on the page type defaults for the page types selected
	 */
	public function getPageTypeAreaList() {
		$db = Loader::db();
		$ctIDs = array(-1);
		foreach($this->getComposerPageTypeObjects() as $ct) {
			$ctIDs[] = $ct->getCollectionTypeID();
		}
		$r = $db->Execute('select distinct arHandle from Areas where cID in (select p.cID from Pages p inner join CollectionVersions cv on (p.cID = cv.cID and cv.cvIsApproved = 1) where cIsTemplate = 1 and arIsGlobal = 0 and ctID in (' . implode(',', $ctIDs) . ')) order by arHandle');
		$areas = array();
		while ($row = $r->FetchRow()) {
			$areas[] = $row['arHandle'];
		}
		return $areas;
	}

	public function update($cmpName, $types) {
{'fraction_non_alphanumeric': 0.1680559290131756, 'fraction_numerical': 0.0029577843506318905, 'mean_word_length': 4.462555066079295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3390241', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1249, 'n_words': 333}