示例#1
0
	public function saveValue($value) {
		$db = Loader::db();
		$this->load();
		$options = array();		
		
		if (is_array($value) && $this->akSelectAllowMultipleValues) {
			foreach($value as $v) {
				$opt = SelectAttributeTypeOption::getByValue($v, $this->attributeKey);
				if (is_object($opt)) {
					$options[] = $opt;	
				}
			}
		} else {
			if (is_array($value)) {
				$value = $value[0];
			}
			
			$opt = SelectAttributeTypeOption::getByValue($value, $this->attributeKey);
			if (is_object($opt)) {
				$options[] = $opt;	
			}
		}
		
		$db->Execute('delete from atSelectOptionsSelected where avID = ?', array($this->getAttributeValueID()));
		if (count($options) > 0) {
			foreach($options as $opt) {
				$db->Execute('insert into atSelectOptionsSelected (avID, atSelectOptionID) values (?, ?)', array($this->getAttributeValueID(), $opt->getSelectAttributeOptionID()));
				if ($this->akSelectAllowMultipleValues == false) {
					break;
				}
			}
		}
	}
示例#2
0
 public function addFile($file)
 {
     Loader::library("file/importer");
     Loader::library("mootools/plugin_parser", FRONTEND_DEVELOPER_PACKAGE_HANDLE);
     $fi = new FileImporter();
     $fv = $fi->import($file, basename($file), $this->getExistFile(basename($file)));
     if (!$fv instanceof FileVersion) {
         $message = FileImporter::getErrorMessage($result);
         return $message;
     }
     $parser = new MootoolsPluginParser();
     $meta = $parser->parse($file);
     $requireValues = array();
     if (is_array($meta["requires"])) {
         $requires = $meta["requires"];
         foreach ($requires as $module) {
             $option = SelectAttributeTypeOption::getByValue($module);
             if (empty($option)) {
                 $ak = FileAttributeKey::getByHandle(MOOTOOLS_PLUGIN_DEPENDENCES);
                 $type = SelectAttributeTypeOption::add($ak, $module, true);
                 $value = $type->getSelectAttributeOptionValue();
             } else {
                 $value = $option->getSelectAttributeOptionValue();
             }
             $requireValues[$value] = $value;
         }
     }
     $namespaces = explode('.', $meta['name']);
     $packageName = array_shift($namespaces);
     $moduleName = str_replace('.js', '', basename($file));
     $componentName = $packageName . '/' . $moduleName;
     $authors = is_array($meta["authors"]) ? join(",", $meta["authors"]) : $meta["authors"];
     $license = is_array($meta["license"]) ? join(",", $meta["license"]) : $meta["license"];
     $fv->setAttribute(MOOTOOLS_PLUGIN, true);
     $fv->setAttribute(MOOTOOLS_COMPONENT_NAME, $componentName);
     $fv->setAttribute(MOOTOOLS_PLUGIN_LICENSE, $license);
     $fv->setAttribute(MOOTOOLS_PLUGIN_AUTHORS, $authors);
     $fv->setAttribute(MOOTOOLS_PLUGIN_DEPENDENCES, $requireValues);
     $fv->setAttribute(MOOTOOLS_PLUGIN_DISPLAY_ORDER, 0);
     $fv->updateDescription($meta["description"]);
     $fv->updateTags("mootools\nplugin");
     $this->_fileset->addFileToSet($fv);
     return $fv;
 }