コード例 #1
0
 /** Set attribute with value.
  * @param string                $name  - attribute name
  * @param string|int|float|null $value - attribute value
  * @throws ArgumentTypeException
  * @throws SystemException
  */
 public function setAttribute($name, $value = null)
 {
     if (!is_string($name)) {
         throw new ArgumentTypeException('name', 'string');
     }
     if (!(is_scalar($value) || is_null($value))) {
         throw new ArgumentTypeException('name', 'scalar');
     }
     if ($this->id !== null) {
         throw new SystemException('Cannot set attribute for existent context!');
     }
     static $types;
     if (!$types) {
         $types = AttributeManager::getTypes();
     }
     if (!($type = $types[$name])) {
         throw new SystemException("Undefined attribute '{$name}' type!");
     }
     // set attribute
     $this->attributes[$name] = $value;
 }
コード例 #2
0
ファイル: detailed.php プロジェクト: vim84/b-markt
}
// SITES
$sites = array();
$result = SiteTable::getList(array('select' => array('LID', 'NAME'), 'order' => array('DEF' => 'DESC', 'SORT' => 'ASC')));
while ($row = $result->fetch()) {
    $sites[$row['LID']] = $row['NAME'];
}
if (!$sites) {
    die('No sites available!');
}
$site = $_GET['site'] ?: $userOptions['site'];
if (!($siteName = $sites[$site])) {
    list($site, $siteName) = each($sites);
}
// ATTRIBUTES
if (!($attributeTypes = AttributeManager::getTypes())) {
    die('No attributes!');
}
unset($attributeTypes['conversion_site']);
$attributeName = $_GET['split'];
// different split in $userOptions from summary page!
if (!($attributeType = $attributeTypes[$attributeName])) {
    list($attributeName, $attributeType) = each($attributeTypes);
}
$attributeGroupTypes = AttributeGroupManager::getTypes();
// FILTER
$filter = array('from' => $from->toString(), 'to' => $to->toString(), 'site' => $site);
CUserOptions::SetOption('conversion', 'filter', array_merge($userOptions, $filter));
$filter['rate'] = $rateName;
$filter['split'] = $attributeName;
$filter['lang'] = LANGUAGE_ID;