Exemplo n.º 1
0
 public static function getByHandle($akHandle)
 {
     $ak = CacheLocal::getEntry('file_attribute_key_by_handle', $akHandle);
     if (is_object($ak)) {
         return $ak;
     } else {
         if ($ak == -1) {
             return false;
         }
     }
     $ak = -1;
     $db = Loader::db();
     $q = "SELECT ak.akID FROM AttributeKeys ak INNER JOIN AttributeKeyCategories akc ON ak.akCategoryID = akc.akCategoryID  WHERE ak.akHandle = ? AND akc.akCategoryHandle = 'file'";
     $akID = $db->GetOne($q, array($akHandle));
     if ($akID > 0) {
         $ak = self::getByID($akID);
     } else {
         // else we check to see if it's listed in the initial registry
         $ia = FileTypeList::getImporterAttribute($akHandle);
         if (is_object($ia)) {
             // we create this attribute and return it.
             $at = AttributeType::getByHandle($ia->akType);
             $args = array('akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable);
             $ak = FileAttributeKey::add($at, $args);
         }
     }
     CacheLocal::set('file_attribute_key_by_handle', $akHandle, $ak);
     if ($ak === -1) {
         return false;
     }
     return $ak;
 }
Exemplo n.º 2
0
 public function add()
 {
     $this->select_type();
     $type = $this->get('type');
     $cnt = $type->getController();
     $e = $cnt->validateKey($this->post());
     if ($e->has()) {
         $this->set('error', $e);
     } else {
         $type = AttributeType::getByID($this->post('atID'));
         $ak = FileAttributeKey::add($type, $this->post());
         $this->redirect('/dashboard/files/attributes/', 'attribute_created');
     }
 }
Exemplo n.º 3
0
 public function add()
 {
     $this->select_type();
     $type = $this->get('type');
     $cnt = $type->getController();
     $e = $cnt->validateKey($this->post());
     if ($e->has()) {
         $this->set('error', $e);
     } else {
         $type = AttributeType::getByID($this->post('atID'));
         $args = array('akHandle' => $this->post('akHandle'), 'akName' => $this->post('akName'), 'akIsSearchable' => $this->post('akIsSearchable'), 'akIsSearchableIndexed' => $this->post('akIsSearchableIndexed'), 'akIsAutoCreated' => 0, 'akIsEditable' => 1);
         $ak = FileAttributeKey::add($type, $this->post());
         $this->redirect('/dashboard/files/attributes/', 'attribute_created');
     }
 }
Exemplo n.º 4
0
 public static function getByHandle($akHandle)
 {
     $db = Loader::db();
     $akID = $db->GetOne('select akID from AttributeKeys where akHandle = ?', array($akHandle));
     if ($akID > 0) {
         $ak = FileAttributeKey::getByID($akID);
         return $ak;
     } else {
         // else we check to see if it's listed in the initial registry
         $ia = FileTypeList::getImporterAttribute($akHandle);
         if (is_object($ia)) {
             // we create this attribute and return it.
             $at = AttributeType::getByHandle($ia->akType);
             $args = array('akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable);
             return FileAttributeKey::add($at, $args);
         }
     }
 }
Exemplo n.º 5
0
 public static function getByHandle($akHandle)
 {
     $db = Loader::db();
     $q = "SELECT ak.akID \r\n\t\t\tFROM AttributeKeys ak\r\n\t\t\tINNER JOIN AttributeKeyCategories akc ON ak.akCategoryID = akc.akCategoryID \r\n\t\t\tWHERE ak.akHandle = ?\r\n\t\t\tAND akc.akCategoryHandle = 'file'";
     $akID = $db->GetOne($q, array($akHandle));
     if ($akID > 0) {
         $ak = FileAttributeKey::getByID($akID);
         return $ak;
     } else {
         // else we check to see if it's listed in the initial registry
         $ia = FileTypeList::getImporterAttribute($akHandle);
         if (is_object($ia)) {
             // we create this attribute and return it.
             $at = AttributeType::getByHandle($ia->akType);
             $args = array('akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable);
             return FileAttributeKey::add($at, $args);
         }
     }
 }
Exemplo n.º 6
0
 private function installPageLinkAttribute(&$pkg)
 {
     $at = AttributeType::getByHandle('page_selector');
     if ($at && intval($at->getAttributeTypeID())) {
         //Associate with "file" category (if not done alrady)
         Loader::model('attribute/categories/collection');
         $akc = AttributeKeyCategory::getByHandle('file');
         $sql = 'SELECT COUNT(*) FROM AttributeTypeCategories WHERE atID = ? AND akCategoryID = ?';
         $vals = array($at->getAttributeTypeID(), $akc->akCategoryID);
         $existsInCategory = Loader::db()->GetOne($sql, $vals);
         if (!$existsInCategory) {
             $akc->associateAttributeKeyType($at);
         }
         //Install the link-to-page attribute (if not done already)
         Loader::model('file_attributes');
         $akHandle = 'gallery_link_to_cid';
         $akGalleryLinkToCID = FileAttributeKey::getByHandle($akHandle);
         if (!is_object($akGalleryLinkToCID) || !intval($akGalleryLinkToCID->getAttributeKeyID())) {
             $akGalleryLinkToCID = FileAttributeKey::add($at, array('akHandle' => $akHandle, 'akName' => t('Gallery Link To Page')), $pkg);
         }
     }
 }
Exemplo n.º 7
0
 public function install()
 {
     Loader::library('mootools/attribute', FRONTEND_DEVELOPER_PACKAGE_HANDLE);
     $pkg = parent::install();
     Loader::model('single_page');
     Loader::model('attribute/categories/user');
     Loader::model('attribute/categories/file');
     $singlePages = array("/dashboard/mootools" => array('cName' => t('Mootools Plugin Developer'), 'cDescription' => t('Management of mootools plugin')), "/dashboard/mootools/plugin" => array('cName' => t('plugin'), 'cDescription' => t('Management of Mootools Plugin that does import')), "/dashboard/mootools/importer" => array('cName' => t('import'), 'cDescription' => t('Import from repository')));
     foreach ($singlePages as $key => $page) {
         $collection = SinglePage::add($key, $pkg);
         if (!empty($collection)) {
             $collection->update($page);
         }
     }
     //The name of the user of github is added to the attribute.
     $values = array("akHandle" => MOOTOOLS_GITHUB_USER, "akName" => t("Name of user of github"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true);
     $key = UserAttributeKey::add("text", $values, $pkg);
     $fileAttributes = array(array("type" => "boolean", "values" => array("akHandle" => MOOTOOLS_PLUGIN, "akName" => t("This file is a plugin of Mootools"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_COMPONENT_NAME, "akName" => t("Component name of Mootools"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_PLUGIN_LICENSE, "akName" => t("License of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "text", "values" => array("akHandle" => MOOTOOLS_PLUGIN_AUTHORS, "akName" => t("Authors of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "select", "values" => array("akHandle" => MOOTOOLS_PLUGIN_DEPENDENCES, "akName" => t("Dependence of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)), array("type" => "number", "values" => array("akHandle" => MOOTOOLS_PLUGIN_DISPLAY_ORDER, "akName" => t("The order of display of Mootools plugin"), "akIsSearchable" => true, "akIsSearchableIndexed" => true, "akIsAutoCreated" => true, "akIsEditable" => true)));
     $attributesKeys = array();
     foreach ($fileAttributes as $key => $attr) {
         $type = $attr["type"];
         $values = $attr["values"];
         $handle = $values["akHandle"];
         $attributesKeys[$handle] = FileAttributeKey::add($type, $values, $pkg);
     }
     if (!empty($attributesKeys[MOOTOOLS_PLUGIN_DEPENDENCES])) {
         $key = $attributesKeys[MOOTOOLS_PLUGIN_DEPENDENCES];
         $db = Loader::db();
         $db->Replace('atSelectSettings', array('akID' => $key->getAttributeKeyID(), 'akSelectAllowMultipleValues' => true), array('akID'), true);
     }
     BlockType::installBlockTypeFromPackage("mootools_plugin_build_form", $pkg);
     BlockType::installBlockTypeFromPackage("github_tags", $pkg);
     BlockType::installBlockTypeFromPackage("github_issues", $pkg);
     BlockType::installBlockTypeFromPackage("github_repository", $pkg);
     PageTheme::add('small_project', $pkg);
 }
Exemplo n.º 8
0
 private function installFileAttributes($pkg)
 {
     $fakc = AttributeKeyCategory::getByHandle('file');
     // Multiple means an attribute can be in more than one set, but you
     // can't choose what set they show up in for the gui
     // $fakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_MULTIPLE);
     // $fakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_NONE);
     $fakc->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
     $bfa = $fakc->addSet('c5_boilerplate_file_attributes', t('Boilerplate File Attributes'), $pkg);
     //add boolean attributes
     $bp_boolean = FileAttributeKey::getByHandle('bp_boolean');
     if (!$bp_boolean instanceof FileAttributeKey) {
         $bp_boolean = FileAttributeKey::add('boolean', array('akHandle' => 'bp_boolean', 'akName' => t('Boolean Name'), 'akIsSearchable' => true, 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($bfa);
     }
     //add text attributes
     $bp_text = FileAttributeKey::getByHandle('bp_text');
     if (!$bp_text instanceof FileAttributeKey) {
         $bp_text = FileAttributeKey::add('text', array('akHandle' => 'bp_text', 'akName' => t('Text Name'), 'akIsSearchable' => true, 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($bfa);
     }
 }
Exemplo n.º 9
0
	protected function upgradeFileAttributes() {
		$messages = array();
		$db = Loader::db();
		$r = $db->Execute('select _FileAttributeKeys.* from _FileAttributeKeys order by fakID asc');
		while ($row = $r->FetchRow()) {
			$cleanHandle = preg_replace("/[^A-Za-z0-9\_]/",'',$row['akHandle']); // remove spaces, chars that'll mess up our index tables
			$existingAKID = $db->GetOne('select akID from AttributeKeys where akHandle = ?',  array($cleanHandle) );
			if ($existingAKID < 1) {
				$args = array(
					'akHandle' => $cleanHandle,
					'akIsSearchable' => $row['akSearchable'],
					'akIsAutoCreated' => $row['akIsImporterAttribute'],
					'akIsEditable' => $row['akIsEditable'],
					'akName' => $row['akName']			
				);
				$sttype = $row['akType'];
				switch($row['akType']) {
					case 'SELECT':
					case 'SELECT_ADD':
						if ($row['akAllowOtherValues']) {
							$args['akSelectAllowMultipleValues'] = 1;
						}
						$sttype = 'SELECT';
						break;
					case 'SELECT_MULTIPLE':
						$sttype = 'SELECT';
						$args['akSelectAllowMultipleValues'] = 1;
						if ($row['akAllowOtherValues']) {
							$args['akSelectAllowMultipleValues'] = 1;
						}
						break;
				}
				
				$type = AttributeType::getByHandle(strtolower($sttype));
				$ak = FileAttributeKey::add($type, $args);
				if ($sttype == 'SELECT') {
					$selectOptions = explode("\n", $row['akValues']);
					foreach($selectOptions as $so) {
						if ($so != '') {
							SelectAttributeTypeOption::add($ak, $so);
						}
					}
				}
			} else {
				$ak = FileAttributeKey::getByID($existingAKID);
			}
			
			$r2 = $db->Execute('select * from _FileAttributeValues where fakID = ? and isImported = 0', $row['fakID']);
			while ($row2 = $r2->FetchRow()) {
				$f = File::getByID($row2['fID']);
				$fv = $f->getVersion($row2['fvID']);
				$value = $row2['value'];
				if ($row['akType'] == 'SELECT' || $row['akType'] == 'SELECT_MULTIPLE' || $row['akType'] == 'SELECT_ADD') {
					$value = explode("\n", $value);					
				}
				$fv->setAttribute($ak, $value);
				unset($f);
				unset($fv);

				$db->Execute('update _FileAttributeValues set isImported = 1 where fakID = ? and fvID = ? and fID = ?', array($row['fakID'], $row2['fvID'], $row2['fID']));
				$this->incrementImported();
			}
			
			unset($ak);
			unset($row2);
			$r2->Close();
			unset($r2);
		}
		
		unset($row);
		$r->Close();
		unset($r);
		return $messages;
	}