public function getAttributeKeys() { $db = Loader::db(); $r = $db->Execute('select akID from AttributeSetKeys where asID = ? order by displayOrder asc', $this->getAttributeSetID()); $keys = array(); $cat = AttributeKeyCategory::getByID($this->akCategoryID); while ($row = $r->FetchRow()) { $ak = $cat->getAttributeKeyByID($row['akID']); if (is_object($ak)) { $keys[] = $ak; } } return $keys; }
public static function getItemName($item) { $txt = Loader::helper('text'); Loader::model('single_page'); if ($item instanceof BlockType) { return t($item->getBlockTypeName()); } else { if ($item instanceof PageTheme) { return $item->getThemeDisplayName(); } else { if ($item instanceof CollectionType) { return $item->getCollectionTypeName(); } else { if ($item instanceof MailImporter) { return $item->getMailImporterName(); } else { if ($item instanceof SinglePage) { return $item->getCollectionPath(); } else { if ($item instanceof AttributeType) { return $item->getAttributeTypeDisplayName(); } else { if ($item instanceof PermissionAccessEntityType) { return $item->getAccessEntityTypeDisplayName(); } else { if ($item instanceof PermissionKeyCategory) { return $txt->unhandle($item->getPermissionKeyCategoryHandle()); } else { if ($item instanceof AttributeKeyCategory) { return $txt->unhandle($item->getAttributeKeyCategoryHandle()); } else { if ($item instanceof AttributeSet) { $at = AttributeKeyCategory::getByID($item->getAttributeSetKeyCategoryID()); return t('%s (%s)', $item->getAttributeSetDisplayName(), $txt->unhandle($at->getAttributeKeyCategoryHandle())); } else { if ($item instanceof GroupSet) { return $item->getGroupSetDisplayName(); } else { if (is_a($item, 'AttributeKey')) { $akc = AttributeKeyCategory::getByID($item->getAttributeKeyCategoryID()); return t(' %s (%s)', $txt->unhandle($item->getAttributeKeyHandle()), $txt->unhandle($akc->getAttributeKeyCategoryHandle())); } else { if ($item instanceof ConfigValue) { return ucwords(strtolower($txt->unhandle($item->key))); } else { if ($item instanceof SystemAntispamLibrary) { return $item->getSystemAntispamLibraryName(); } else { if (is_a($item, 'PermissionKey')) { return $item->getPermissionKeyDisplayName(); } else { if (is_a($item, 'Job')) { return $item->getJobName(); } else { if (is_a($item, 'WorkflowType')) { return $item->getWorkflowTypeName(); } } } } } } } } } } } } } } } } } }
</h3> <form class="" method="post" action="<?php echo $this->action('update_set_attributes'); ?> "> <input type="hidden" name="asID" value="<?php echo $set->getAttributeSetID(); ?> " /> <?php echo Loader::helper('validation/token')->output('update_set_attributes'); ?> <?php $cat = AttributeKeyCategory::getByID($set->getAttributeSetKeyCategoryID()); $list = AttributeKey::getList($cat->getAttributeKeyCategoryHandle()); $unassigned = $cat->getUnassignedAttributeKeys(); if (count($list) > 0) { ?> <div class="clearfix"> <ul class="inputs-list"> <?php foreach ($list as $ak) { $disabled = ''; if (!in_array($ak, $unassigned) && !$ak->inAttributeSet($set)) { $disabled = array('disabled' => 'disabled'); } ?>
/** * Updates an attribute key. */ public function update($args) { $prevHandle = $this->getAttributeKeyHandle(); extract($args); if (!$akIsSearchable) { $akIsSearchable = 0; } if (!$akIsSearchableIndexed) { $akIsSearchableIndexed = 0; } $db = Loader::db(); $akCategoryHandle = $db->GetOne("select akCategoryHandle from AttributeKeyCategories inner join AttributeKeys on AttributeKeys.akCategoryID = AttributeKeyCategories.akCategoryID where akID = ?", $this->getAttributeKeyID()); $a = array($akHandle, $akName, $akIsSearchable, $akIsSearchableIndexed, $this->getAttributeKeyID()); $r = $db->query("update AttributeKeys set akHandle = ?, akName = ?, akIsSearchable = ?, akIsSearchableIndexed = ? where akID = ?", $a); $category = AttributeKeyCategory::getByID($this->akCategoryID); switch ($category->allowAttributeSets()) { case AttributeKeyCategory::ASET_ALLOW_SINGLE: if ($asID > 0) { $as = AttributeSet::getByID($asID); if (!$this->inAttributeSet($as) && is_object($as)) { $this->clearAttributeSets(); $this->setAttributeSet($as); } } else { // clear set $this->clearAttributeSets(); } break; } if ($r) { $txt = Loader::helper('text'); $className = $txt->camelcase($akCategoryHandle) . 'AttributeKey'; $ak = new $className(); $ak->load($this->getAttributeKeyID()); $at = $ak->getAttributeType(); $cnt = $at->getController(); $cnt->setAttributeKey($ak); $cnt->saveKey($args); $ak->updateSearchIndex($prevHandle); return $ak; } }
public function validateKey($args = false) { if ($args == false) { $args = $this->post(); } $val = Loader::helper('validation/form'); $valt = Loader::helper('validation/token'); $val->setData($args); $val->addRequired("akHandle", t("Handle required.")); $val->addRequired("akName", t('Name required.')); $val->addRequired("atID", t('Type required.')); $val->test(); $error = $val->getError(); if (!$valt->validate('add_or_update_attribute')) { $error->add($valt->getErrorMessage()); } if(preg_match("/[^A-Za-z0-9\_]/", $args['akHandle'])) { $error->add(t('Attribute handles may only contain letters, numbers and underscore "_" characters')); } $akc = AttributeKeyCategory::getByID($args['akCategoryID']); if (is_object($akc)) { if ($akc->handleExists($args['akHandle'])) { if (is_object($this->attributeKey)) { $ak2 = $akc->getAttributeKeyByHandle($args['akHandle']); if ($ak2->getAttributeKeyID() != $this->attributeKey->getAttributeKeyID()) { $error->add(t("An attribute with the handle %s already exists.", $akHandle)); } } else { $error->add(t("An attribute with the handle %s already exists.", $akHandle)); } } } else { $error->add('Invalid attribute category.'); } return $error; }
public static function add($akCategoryHandle, $akCategoryAllowSets = AttributeKeyCategory::ASET_ALLOW_NONE, $pkg = false) { $db = Loader::db(); if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } $db->Execute('insert into AttributeKeyCategories (akCategoryHandle, akCategoryAllowSets, pkgID) values (?, ?, ?)', array($akCategoryHandle, $akCategoryAllowSets, $pkgID)); $id = $db->Insert_ID(); if ($pkgID > 0) { Loader::model('attribute/categories/' . $akCategoryHandle, $pkg->getPackageHandle()); } else { Loader::model('attribute/categories/' . $akCategoryHandle); } $txt = Loader::helper("text"); $class = $txt->camelcase($akCategoryHandle) . 'AttributeKey'; $obj = new $class; $obj->createIndexedSearchTable(); return AttributeKeyCategory::getByID($id); }
public function update_set_attributes() { if ($this->token->validate('update_set_attributes')) { $as = AttributeSet::getByID($this->post('asID')); if (!is_object($as)) { $this->error->add(t('Invalid attribute set.')); } if (!$this->error->has()) { // go through and add all the attributes that aren't in another set $as->clearAttributeKeys(); $cat = AttributeKeyCategory::getByID($as->getAttributeSetKeyCategoryID()); $unassigned = $cat->getUnassignedAttributeKeys(); if (is_array($this->post('akID'))) { foreach ($unassigned as $ak) { if (in_array($ak->getAttributeKeyID(), $this->post('akID'))) { $as->addKey($ak); } } } $this->redirect('dashboard/system/attributes/sets', 'category', $cat->getAttributeKeyCategoryID(), 'set_updated'); } } else { $this->error->add($this->token->getErrorMessage()); } $this->edit($this->post('asID')); }
<?php defined('C5_EXECUTE') or die("Access Denied."); $canRead = false; $ch = Page::getByPath('/dashboard/settings/attributes/sets'); $cp = new Permissions($ch); if ($cp->canViewPage()) { $canRead = true; } if (!$canRead) { die(t("Access Denied.")); } $db = Loader::db(); $akc = AttributeKeyCategory::getByID($_POST['categoryID']); $uats = $_REQUEST['asID']; if (is_array($uats)) { $akc->updateAttributeSetDisplayOrder($uats); }
public static function getItemName($item) { $txt = Loader::helper('text'); Loader::model('single_page'); Loader::model('dashboard/homepage'); if ($item instanceof BlockType) { return $item->getBlockTypeName(); } else if ($item instanceof PageTheme) { return $item->getThemeName(); } else if ($item instanceof CollectionType) { return $item->getCollectionTypeName(); } else if ($item instanceof MailImporter) { return $item->getMailImporterName(); } else if ($item instanceof SinglePage) { return $item->getCollectionPath(); } else if ($item instanceof AttributeType) { return $item->getAttributeTypeName(); } else if ($item instanceof AttributeKeyCategory) { return $txt->unhandle($item->getAttributeKeyCategoryHandle()); } else if ($item instanceof AttributeSet) { $at = AttributeKeyCategory::getByID($item->getAttributeSetKeyCategoryID()); return t('%s (%s)', $item->getAttributeSetName(), $txt->unhandle($at->getAttributeKeyCategoryHandle())); } else if (is_a($item, 'AttributeKey')) { $akc = AttributeKeyCategory::getByID($item->getAttributeKeyCategoryID()); return t(' %s (%s)', $txt->unhandle($item->getAttributeKeyHandle()), $txt->unhandle($akc->getAttributeKeyCategoryHandle())); } else if ($item instanceof ConfigValue) { return ucwords(strtolower($txt->unhandle($item->key))); } else if ($item instanceof DashboardHomepage) { return t('%s (%s)', $item->dbhDisplayName, $txt->unhandle($item->dbhModule)); } else if (is_a($item, 'TaskPermission')) { return $item->getTaskPermissionName(); } else if (is_a($item, 'Job')) { return $item->getJobName(); } }