Ejemplo n.º 1
0
 public function update($akID = null)
 {
     $this->edit($akID);
     $key = CollectionKey::getByID($akID);
     $category = Category::getByHandle('collection');
     $this->executeUpdate($key, \URL::to('/dashboard/pages/attributes', 'view'));
 }
 protected function installAttributeType($pkg)
 {
     $attributeHandle = 'related_pages';
     \Loader::model('attribute/categories/collection');
     AttributeType::add($attributeHandle, t('Related Pages'), \Package::getByHandle($this->pkgHandle));
     AttributeKeyCategory::getByHandle('collection')->associateAttributeKeyType(AttributeType::getByHandle($attributeHandle));
 }
 public function execute(Batch $batch)
 {
     $sets = $batch->getObjectCollection('attribute_set');
     if (!$sets) {
         return;
     }
     foreach ($sets->getSets() as $set) {
         $akc = Category::getByHandle($set->getCategory());
         if (!$set->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($set->getPackage()) {
                 $pkg = \Package::getByHandle($set->getPackage());
             }
             $setObject = $akc->addSet($set->getHandle(), $set->getName(), $pkg, intval($set->getIsLocked()));
         } else {
             $setObject = \Concrete\Core\Attribute\Set::getByHandle($set->getHandle());
         }
         if (is_object($setObject)) {
             $attributes = $set->getAttributes();
             foreach ($attributes as $handle) {
                 $ak = $akc->getAttributeKeyByHandle($handle);
                 if (is_object($ak)) {
                     $setObject->addKey($ak);
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 public function install()
 {
     $pkg = parent::install();
     \Loader::model('attribute/categories/collection');
     $col = AttributeKeyCategory::getByHandle('collection');
     $at = AttributeType::add('icon_selector', t('Icon Selector'), $pkg);
     $col->associateAttributeKeyType($at);
 }
Ejemplo n.º 5
0
 protected function setUp()
 {
     parent::setUp();
     Category::add('collection');
     Page::addHomePage();
     PageTemplate::add('full', 'Full');
     PageType::add(array('handle' => 'basic', 'name' => 'Basic'));
 }
Ejemplo n.º 6
0
 public function exportAll()
 {
     $this->x = $this->getXMLRoot();
     // First, attribute categories
     AttributeKeyCategory::exportList($this->x);
     // Features
     Feature::exportList($this->x);
     FeatureCategory::exportList($this->x);
     ConversationEditor::exportList($this->x);
     ConversationRatingType::exportList($this->x);
     // composer
     PageTypePublishTargetType::exportList($this->x);
     PageTypeComposerControlType::exportList($this->x);
     PageType::exportList($this->x);
     // attribute types
     AttributeType::exportList($this->x);
     // then block types
     BlockTypeList::exportList($this->x);
     // now block type sets (including user)
     BlockTypeSet::exportList($this->x);
     // gathering
     GatheringDataSource::exportList($this->x);
     GatheringItemTemplate::exportList($this->x);
     // now attribute keys (including user)
     AttributeKey::exportList($this->x);
     // now attribute keys (including user)
     AttributeSet::exportList($this->x);
     PageTemplate::exportList($this->x);
     // now theme
     PageTheme::exportList($this->x);
     // now packages
     PackageList::export($this->x);
     // permission access entity types
     PermissionAccessEntityType::exportList($this->x);
     // now task permissions
     PermissionKey::exportList($this->x);
     // workflow types
     WorkflowType::exportList($this->x);
     // now jobs
     Job::exportList($this->x);
     // now single pages
     $singlepages = $this->x->addChild("singlepages");
     $db = Loader::db();
     $r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc');
     while ($row = $r->FetchRow()) {
         $pc = Page::getByID($row['cID'], 'RECENT');
         $pc->export($singlepages);
     }
     // now stacks/global areas
     StackList::export($this->x);
     // now content pages
     $this->exportPages($this->x);
     SystemCaptchaLibrary::exportList($this->x);
     \Concrete\Core\Sharing\SocialNetwork\Link::exportList($this->x);
     \Concrete\Core\Page\Feed::exportList($this->x);
     \Concrete\Core\File\Image\Thumbnail\Type\Type::exportList($this->x);
     Tree::exportList($this->x);
 }
Ejemplo n.º 7
0
 public function view($ptID = false)
 {
     $this->setupPageType($ptID);
     $this->requireAsset('core/app/editable-fields');
     $this->set('pagetype', $this->pagetype);
     $this->set('defaultPage', $this->defaultPage);
     $category = AttributeKeyCategory::getByHandle('collection');
     $this->set('category', $category);
 }
Ejemplo n.º 8
0
 public function install()
 {
     $pkg = parent::install();
     \Loader::model('attribute/categories/collection');
     $col = AttributeKeyCategory::getByHandle('collection');
     //Install attribute and attach to the Colletion Category
     $gallery = AttributeType::add('mixed_gallery', t('Mixed Gallery'), $pkg);
     $col->associateAttributeKeyType($gallery);
 }
Ejemplo n.º 9
0
 public function getList($akCategoryHandle = false)
 {
     $r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Attribute\\Type');
     if ($akCategoryHandle == false) {
         return $r->findAll();
     } else {
         $category = Category::getByHandle($akCategoryHandle);
         return $category->getAttributeTypes();
     }
 }
Ejemplo n.º 10
0
 private function addAttributes($pkg)
 {
     \Loader::model('attribute/categories/collection');
     $col = AttributeKeyCategory::getByHandle('collection');
     $fileSelector = AttributeType::add('multifile_picker', t('Multiple File Picker'), $pkg);
     $col->associateAttributeKeyType($fileSelector);
     $userSelector = AttributeType::add('multiuser_picker', t('Multiple User Picker'), $pkg);
     $col->associateAttributeKeyType($userSelector);
     $pageSelector = AttributeType::add('multipage_picker', t('Multiple Page Picker'), $pkg);
     $col->associateAttributeKeyType($pageSelector);
 }
Ejemplo n.º 11
0
 protected function setUp()
 {
     $this->tables = array_merge($this->tables, array('Files', 'FileVersions', 'Users', 'PermissionAccessEntityTypes', 'FileAttributeValues', 'FileImageThumbnailTypes', 'FilePermissionAssignments', 'AttributeKeyCategories', 'AttributeTypes', 'ConfigStore', 'AttributeKeys', 'AttributeValues', 'atNumber', 'Logs', 'FileVersionLog'));
     parent::setUp();
     Config::set('concrete.upload.extensions', '*.txt;*.jpg;*.jpeg;*.png');
     $category = Category::add('file');
     $number = AttributeType::add('number', 'Number');
     FileKey::add($number, array('akHandle' => 'width', 'akName' => 'Width'));
     FileKey::add($number, array('akHandle' => 'height', 'akName' => 'Height'));
     CacheLocal::flush();
 }
Ejemplo n.º 12
0
 protected function setUp()
 {
     $this->tables = array_merge($this->tables, array('Files', 'FileVersions', 'Users', 'PermissionAccessEntityTypes', 'FileAttributeValues', 'FileImageThumbnailTypes', 'FilePermissionAssignments', 'AttributeKeyCategories', 'AttributeTypes', 'ConfigStore', 'AttributeKeys', 'SystemContentEditorSnippets', 'AttributeValues', 'atNumber', 'FileVersionLog'));
     parent::setUp();
     define('UPLOAD_FILE_EXTENSIONS_ALLOWED', '*.txt;*.jpg;*.jpeg;*.png');
     Category::add('file');
     $number = AttributeType::add('number', 'Number');
     FileKey::add($number, array('akHandle' => 'width', 'akName' => 'Width'));
     FileKey::add($number, array('akHandle' => 'height', 'akName' => 'Height'));
     CacheLocal::flush();
 }
Ejemplo n.º 13
0
 public function on_start()
 {
     parent::on_start();
     $this->set('category', AttributeKeyCategory::getByHandle('user'));
     $otypes = AttributeType::getList('user');
     $types = array();
     foreach ($otypes as $at) {
         $types[$at->getAttributeTypeID()] = $at->getAttributeTypeDisplayName();
     }
     $this->set('types', $types);
 }
 public function getResults(Request $request)
 {
     $list = Category::getList();
     $items = array();
     foreach ($list as $t) {
         $item = new \PortlandLabs\Concrete5\MigrationTool\Entity\Export\AttributeKeyCategory();
         $item->setItemId($t->getAttributeKeyCategoryID());
         $items[] = $item;
     }
     return $items;
 }
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->attributecategories)) {
         foreach ($sx->attributecategories->category as $akc) {
             $pkg = static::getPackageObject($akc['package']);
             $akx = \Concrete\Core\Attribute\Key\Category::getByHandle($akc['handle']);
             if (!is_object($akx)) {
                 $akx = \Concrete\Core\Attribute\Key\Category::add((string) $akc['handle'], (string) $akc['allow-sets'], $pkg);
             }
         }
     }
 }
Ejemplo n.º 16
0
 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 getResults(Request $request)
 {
     $category = Category::getByID($request->query->get('akCategoryID'));
     $items = array();
     if (is_object($category)) {
         $keys = Key::getAttributeKeyList($category->getAttributeKeyCategoryHandle());
         foreach ($keys as $key) {
             $item = new \PortlandLabs\Concrete5\MigrationTool\Entity\Export\AttributeKey();
             $item->setItemId($key->getAttributeKeyID());
             $items[] = $item;
         }
     }
     return $items;
 }
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->attributekeys)) {
         foreach ($sx->attributekeys->attributekey as $ak) {
             $akc = \Concrete\Core\Attribute\Key\Category::getByHandle($ak['category']);
             $controller = $akc->getController();
             $attribute = $controller->getAttributeKeyByHandle((string) $ak['handle']);
             if (!$attribute) {
                 $pkg = static::getPackageObject($ak['package']);
                 $type = Type::getByHandle((string) $ak['type']);
                 $key = $controller->import($type, $ak, $pkg);
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $categories = $batch->getObjectCollection('attribute_key_category');
     if (!$categories) {
         return;
     }
     foreach ($categories->getCategories() as $category) {
         if (!$category->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($category->getPackage()) {
                 $pkg = \Package::getByHandle($category->getPackage());
             }
             Category::add($category->getHandle(), $category->getAllowSets(), $pkg);
         }
     }
 }
 private function installAttributeKeys($pkg)
 {
     $dbTableDemoAT = AttributeType::getByHandle("db_table_demo");
     if (!$dbTableDemoAT) {
         $dbTableDemoAT = AttributeType::add("db_table_demo", "Database Table Demo", $pkg);
         $cakc = AttributeKeyCategory::getByHandle('collection');
         $cakc->associateAttributeKeyType($dbTableDemoAT);
         $uakc = AttributeKeyCategory::getByHandle('user');
         $uakc->associateAttributeKeyType($dbTableDemoAT);
         $fakc = AttributeKeyCategory::getByHandle('file');
         $fakc->associateAttributeKeyType($dbTableDemoAT);
     }
     $this->addPageAttributeKeys($pkg);
     $this->addUserAttributeKeys($pkg);
     $this->addFileAttributeKeys($pkg);
 }
Ejemplo n.º 21
0
 public function view()
 {
     $pk = PermissionKey::getByHandle('edit_page_properties');
     $pk->setPermissionObject($this->page);
     $assignment = $pk->getMyAssignment();
     $allowed = $assignment->getAttributesAllowedArray();
     $category = AttributeKeyCategory::getByHandle('collection');
     $controller = $category->getController();
     $sets = $controller->getSetManager()->getAttributeSets();
     $leftovers = $controller->getSetManager()->getUnassignedAttributeKeys();
     $selectedAttributes = $this->page->getSetCollectionAttributes();
     $selectedAttributeIDs = array();
     foreach ($selectedAttributes as $ak) {
         $selectedAttributeIDs[] = $ak->getAttributeKeyID();
     }
     $data = array();
     foreach ($sets as $set) {
         $obj = new stdClass();
         $obj->title = $set->getAttributeSetDisplayName();
         $obj->attributes = array();
         foreach ($set->getAttributeKeys() as $ak) {
             if (in_array($ak->getAttributeKeyID(), $allowed)) {
                 $obj->attributes[] = $ak;
             }
         }
         if (count($obj->attributes)) {
             $data[] = $obj;
         }
     }
     if (count($leftovers)) {
         $obj = new stdClass();
         $obj->title = t('Other');
         $obj->attributes = array();
         foreach ($leftovers as $ak) {
             if (in_array($ak->getAttributeKeyID(), $allowed)) {
                 $obj->attributes[] = $ak;
             }
         }
         if (count($obj->attributes)) {
             $data[] = $obj;
         }
     }
     $this->set('selectedAttributeIDs', $selectedAttributeIDs);
     $this->set('assignment', $assignment);
     $this->set('attributes', $data);
 }
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->attributesets)) {
         foreach ($sx->attributesets->attributeset as $as) {
             $set = \Concrete\Core\Attribute\Set::getByHandle((string) $as['handle']);
             $akc = \Concrete\Core\Attribute\Key\Category::getByHandle($as['category']);
             $controller = $akc->getController();
             $manager = $controller->getSetManager();
             if (!is_object($set)) {
                 $pkg = static::getPackageObject($as['package']);
                 $set = $manager->addSet((string) $as['handle'], (string) $as['name'], $pkg, $as['locked']);
             }
             foreach ($as->children() as $ask) {
                 $ak = $controller->getAttributeKeyByHandle((string) $ask['handle']);
                 if (is_object($ak)) {
                     $manager->addKey($set, $ak);
                 }
             }
         }
     }
 }
Ejemplo n.º 23
0
 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');
 }
Ejemplo n.º 24
0
 protected function setUp()
 {
     $this->tables = array_merge($this->tables, array('Files', 'FileVersions', 'Users', 'PermissionAccessEntityTypes', 'FileAttributeValues', 'AttributeKeyCategories', 'AttributeSetKeys', 'Packages', 'AttributeSets', 'FileImageThumbnailTypes', 'AttributeTypes', 'ConfigStore', 'AttributeKeys', 'AttributeValues', 'FileSets', 'atNumber', 'FileVersionLog', 'FileSetFiles'));
     parent::setUp();
     \Config::set('concrete.upload.extensions', '*.txt;*.jpg;*.jpeg;*.png');
     Category::add('file');
     \Concrete\Core\Permission\Access\Entity\Type::add('file_uploader', 'File Uploader');
     $number = AttributeType::add('number', 'Number');
     FileKey::add($number, array('akHandle' => 'width', 'akName' => 'Width'));
     FileKey::add($number, array('akHandle' => 'height', 'akName' => 'Height'));
     mkdir($this->getStorageDirectory());
     $this->getStorageLocation();
     $sample = dirname(__FILE__) . '/StorageLocation/fixtures/sample.txt';
     $image = DIR_BASE . '/concrete/images/logo.png';
     $fi = new Importer();
     $files = array('sample1.txt' => $sample, 'sample2.txt' => $sample, 'sample4.txt' => $sample, 'sample5.txt' => $sample, 'awesome.txt' => $sample, 'testing.txt' => $sample, 'logo1.png' => $image, 'logo2.png' => $image, 'logo3.png' => $image, 'foobley.png' => $image, 'test.png' => $image);
     foreach ($files as $filename => $pointer) {
         $fi->import($pointer, $filename);
     }
     $this->list = new \Concrete\Core\File\FileList();
     $this->list->ignorePermissions();
 }
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->attributetypes)) {
         foreach ($sx->attributetypes->attributetype as $at) {
             $pkg = static::getPackageObject($at['package']);
             $name = (string) $at['name'];
             if (!$name) {
                 $name = \Core::make('helper/text')->unhandle($at['handle']);
             }
             $type = Type::getByHandle($at['handle']);
             if (!is_object($type)) {
                 $type = Type::add((string) $at['handle'], $name, $pkg);
             }
             if (isset($at->categories)) {
                 foreach ($at->categories->children() as $cat) {
                     $catobj = \Concrete\Core\Attribute\Key\Category::getByHandle((string) $cat['handle']);
                     $catobj->getController()->associateAttributeKeyType($type);
                 }
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $types = $batch->getObjectCollection('attribute_key_category');
     if (!$types) {
         return;
     }
     foreach ($types->getCategories() as $type) {
         if (!$type->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($type->getPackage()) {
                 $pkg = \Package::getByHandle($type->getPackage());
             }
             $type = Type::add($type->getHandle(), $type->getName(), $pkg);
             $categories = $type->getCategories();
             foreach ($categories as $category) {
                 $co = Category::getByHandle($category);
                 if (is_object($co)) {
                     $co->associateAttributeKeyType($type);
                 }
             }
         }
     }
 }
 public function getPackageItems(Package $package)
 {
     return Category::getListByPackage($package);
 }
 protected function installAttributeCategoryAndObject()
 {
     $this->category = Category::add('collection');
     $this->object = Page::addHomePage();
 }
Ejemplo n.º 29
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
use Concrete\Core\Attribute\Type as AttributeType;
use Concrete\Core\Attribute\Key\Category as AttributeKeyCategory;
use Concrete\Core\Attribute\PendingType as PendingAttributeType;
$types = AttributeType::getList();
$categories = AttributeKeyCategory::getList();
$txt = Loader::helper('text');
$form = Loader::helper('form');
$interface = Loader::helper('concrete/ui');
echo Loader::helper('concrete/dashboard')->getDashboardPaneHeaderWrapper(t('Attribute Type Associations'), false, 'span10 offset1');
?>
<form method="post" class="" id="attribute_type_associations_form" action="<?php 
echo $view->action('save_attribute_type_associations');
?>
">
	<table border="0" cellspacing="1" cellpadding="0" border="0" class="table">
		<tr>
			<th><?php 
echo t('Name');
?>
</th>
			<?php 
foreach ($categories as $cat) {
    ?>
				<th><?php 
    echo $txt->unhandle($cat->getAttributeKeyCategoryHandle());
    ?>
</th>
			<?php 
Ejemplo n.º 30
0
 /**
  * Automatically run when an attribute key is added or updated
  * @param bool|array $args
  * @return \Concrete\Core\Error\Error
  */
 public function validateKey($args = false)
 {
     if ($args == false) {
         $args = $this->post();
     }
     /** @var \Concrete\Core\Form\Service\Validation $val */
     $val = Core::make('helper/validation/form');
     /** @var \Concrete\Core\Validation\CSRF\Token $valt */
     $valt = Core::make('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());
     }
     /** @var \Concrete\Core\Utility\Service\Validation\Strings $stringValidator */
     $stringValidator = Core::make('helper/validation/strings');
     if (!$stringValidator->handle($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.", $args['akHandle']));
                 }
             } else {
                 $error->add(t("An attribute with the handle %s already exists.", $args['akHandle']));
             }
         }
     } else {
         $error->add('Invalid attribute category.');
     }
     return $error;
 }