public function add($id = null, $type = null) { $this->select_type($id, $type); $type = Type::getByID($type); $entity = $this->getEntity($id); $this->set('entity', $entity); $this->executeAdd($type, \URL::to('/dashboard/system/express/entities/attributes', 'view', $id)); }
public function getItemsFromRequest($array) { $items = array(); foreach ($array as $id) { $item = Type::getByID($id); if (is_object($item)) { $attributeType = new \PortlandLabs\Concrete5\MigrationTool\Entity\Export\AttributeType(); $attributeType->setItemId($item->getAttributeTypeID()); $items[] = $attributeType; } } return $items; }
public function save_attribute_type_associations() { $list = Category::getList(); foreach ($list as $cat) { $cat->clearAttributeKeyCategoryTypes(); if (is_array($this->post($cat->getAttributeKeyCategoryHandle()))) { foreach ($this->post($cat->getAttributeKeyCategoryHandle()) as $id) { $type = Type::getByID($id); $cat->associateAttributeKeyType($type); } } } $this->redirect('dashboard/system/attributes/types', 'saved', 'associations_updated'); }
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')); StoreProductKey::add($type, $this->post()); $this->redirect('/dashboard/store/products/attributes/', 'success'); } }
public function dispatch($action) { $arguments = explode('/', trim($action, '/')); if (count($arguments) > 2) { // there must at last be three arguments here if (isset($arguments[0])) { switch ($arguments[0]) { case 'key': if (isset($arguments[1])) { $key = Key::getByID($arguments[1]); if (is_object($key)) { $controller = $key->getController(); } } break; case 'type': if (isset($arguments[1])) { $type = Type::getByID($arguments[1]); if (is_object($type)) { $controller = $type->getController(); } } break; } } if (isset($controller)) { $action = $arguments[2]; $arguments = array_slice($arguments, 3); if (method_exists($controller, 'action_' . $action)) { //make sure the controller has the right method $response = call_user_func_array(array($controller, 'action_' . $action), $arguments); if ($response instanceof Response) { return $response; } else { print $response; $this->app->shutdown(); } } } } $response = new Response(t('Access Denied')); return $response; }
public function update() { $akID = $this->post('akID'); $key = AttributeFormKey::getByID($akID); if (!is_object($key) || $key->isAttributeKeyInternal()) { $this->redirect('/dashboard/forms/attributes/'); } $type = $key->getAttributeType(); $cnt = $type->getController(); $cnt->setAttributeKey($key); $e = $cnt->validateKey($this->post()); if ($e->has()) { $this->set('error', $e); } else { AttributeType::getByID($this->post('atID')); $key->update($this->post()); $this->redirect('/dashboard/forms/attributes/', 'attribute_updated'); } }
public function save_attribute_type_associations() { if (!$this->token->validate('save_attribute_type_associations')) { $this->error->add(t('Invalid CSRF token. Please refresh and try again.')); return; } $manager = \ORM::entityManager(); $list = Category::getList(); foreach ($list as $cat) { $cat->clearAttributeKeyCategoryTypes(); if (is_array($this->post($cat->getAttributeKeyCategoryHandle()))) { foreach ($this->post($cat->getAttributeKeyCategoryHandle()) as $id) { $type = Type::getByID($id); $cat->getAttributeTypes()->add($type); } } $this->entityManager->persist($cat); } $this->entityManager->flush(); $this->redirect('dashboard/system/attributes/types', 'saved', 'associations_updated'); }
<?php defined('C5_EXECUTE') or die("Access Denied."); use Concrete\Core\Attribute\Key\Key as AttributeKey; use Concrete\Core\Attribute\Type as AttributeType; if (isset($_REQUEST['akID'])) { $at = AttributeKey::getInstanceByID($_REQUEST['akID']); } else { $at = AttributeType::getByID($_REQUEST['atID']); } if (is_object($at)) { $cnt = $at->getController(); if (isset($_REQUEST['args']) && is_array($_REQUEST['args'])) { $args = $_REQUEST['args']; } else { $args = array(); } if (method_exists($cnt, 'action_' . $_REQUEST['action'])) { //make sure the controller has the right method call_user_func_array(array($cnt, 'action_' . $_REQUEST['action']), $args); } }
public function action_get_type_form() { $field = explode('|', $this->request->request->get('id')); if ($field[0] == 'attribute_key') { $type = Type::getByID($field[1]); if (is_object($type)) { ob_start(); echo $type->render(new AttributeTypeSettingsContext()); $html = ob_get_contents(); ob_end_clean(); $obj = new \stdClass(); $obj->content = $html; $obj->showControlRequired = true; $obj->showControlName = true; $obj->assets = $this->getAssetsDefinedDuringOutput(); } } else { if ($field[0] == 'entity_property') { $obj = new \stdClass(); switch ($field[1]) { case 'text': $controller = new TextOptions(); ob_start(); echo $controller->render(); $html = ob_get_contents(); ob_end_clean(); $obj = new \stdClass(); $obj->content = $html; $obj->showControlRequired = false; $obj->showControlName = false; $obj->assets = $this->getAssetsDefinedDuringOutput(); break; } } } if (isset($obj)) { return new JsonResponse($obj); } \Core::make('app')->shutdown(); }
/** * Returns an attribute type object */ public function getAttributeType() { return AttributeType::getByID($this->atID); }
public function add($type = null) { $this->select_type($type); $type = Type::getByID($type); $this->executeAdd($type, \URL::to('/dashboard/users/attributes', 'view')); }
public function add() { $this->select_type(); $type = $this->get('type'); $cnt = $type->getController(); $e = $cnt->validateKey($this->post()); if ($e->has()) { $this->error = $e; } else { $type = AttributeType::getByID($this->post('atID')); $ak = UserAttributeKey::add($type, $this->post()); $this->redirect('/dashboard/users/attributes/', 'attribute_created'); } }
public function edit($akID = 0) { if ($this->post('akID')) { $akID = $this->post('akID'); } $key = StoreProductKey::getByID($akID); $type = $key->getAttributeType(); $this->set('key', $key); $this->set('type', $type); $this->set('category', AttributeKeyCategory::getByHandle('store_product')); if ($this->isPost()) { $cnt = $type->getController(); $cnt->setAttributeKey($key); $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); $key->update($this->post()); $this->redirect('/dashboard/store/products/attributes', 'updated'); } } }
public function getAttributeTypeObject() { $ato = \Concrete\Core\Attribute\Type::getByID($this->atID); return $ato; }
public function edit($akID = 0) { if ($this->post('akID')) { $akID = $this->post('akID'); } $key = CollectionAttributeKey::getByID($akID); if (!is_object($key) || $key->isAttributeKeyInternal()) { $this->redirect('/dashboard/pages/attributes'); } $type = $key->getAttributeType(); $this->set('key', $key); $this->set('type', $type); if ($this->isPost()) { $cnt = $type->getController(); $cnt->setAttributeKey($key); $e = $cnt->validateKey($this->post()); if ($e->has()) { $this->error = $e; } else { $type = AttributeType::getByID($this->post('atID')); $key->update($this->post()); $this->redirect('/dashboard/pages/attributes/', 'attribute_updated'); } } }