Example #1
0
 public function saveValue($value)
 {
     $db = Database::get();
     $this->load();
     $options = array();
     if ($value != null) {
         if (is_array($value) && $this->akSelectAllowMultipleValues) {
             foreach ($value as $v) {
                 if ($v instanceof Option) {
                     $opt = $v;
                 } else {
                     $opt = Option::getByValue($v, $this->attributeKey);
                 }
                 if (is_object($opt)) {
                     $options[] = $opt;
                 } elseif ($this->akSelectAllowOtherValues) {
                     $options[] = Option::add($this->attributeKey, $v, true);
                 }
             }
         } else {
             if (is_array($value)) {
                 $value = $value[0];
             }
             if ($value instanceof Option) {
                 $opt = $value;
             } else {
                 $opt = Option::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;
             }
         }
     }
 }
Example #2
0
 public function saveOrCreate($ak)
 {
     if ($this->tempID != false || $this->ID == 0) {
         return Option::add($ak, $this->value);
     } else {
         $db = Loader::db();
         $th = Loader::helper('text');
         $db->Execute('update atSelectOptions set value = ? where ID = ?', array($th->sanitize($this->value), $this->ID));
         return Option::getByID($this->ID);
     }
 }
Example #3
0
 public function upgrade()
 {
     parent::upgrade();
     // Install Single Pages
     $sP = Page::getByPath('/dashboard/fundamental');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental', $this);
         $sP->update(array('cName' => t("Fundamental Theme Settings")));
         // Set up Default Config Settings
         // Navigation
         Config::save('c5hub.fundamental.navigation.position', 'right');
         Config::save('c5hub.fundamental.navigation.branding', true);
         Config::save('c5hub.fundamental.navigation.branding_position', 'branding-left');
         Config::save('c5hub.fundamental.navigation.contain_to_grid', true);
         Config::save('c5hub.fundamental.navigation.sticky', false);
         Config::save('c5hub.fundamental.navigation.custom_back_text', true);
         Config::save('c5hub.fundamental.navigation.back_text', 'Back');
         Config::save('c5hub.fundamental.navigation.is_hover', true);
         Config::save('c5hub.fundamental.navigation.mobile_show_parent_link', true);
         Config::save('c5hub.fundamental.navigation.scroll_top', false);
         Config::save('c5hub.fundamental.navigation.divider', false);
         // Page Meta
         Config::save('c5hub.fundamental.page_meta_alignment', 'text-left');
         Config::save('c5hub.fundamental.page_meta_title', true);
         Config::save('c5hub.fundamental.page_meta_description', true);
         // Background Images
         Config::save('c5hub.fundamental.body_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.body_background_image_size', 'auto');
         Config::save('c5hub.fundamental.body_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.top_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.top_background_image_size', 'auto');
         Config::save('c5hub.fundamental.top_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.branding_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.branding_background_image_size', 'auto');
         Config::save('c5hub.fundamental.branding_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.navigation_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.navigation_background_image_size', 'auto');
         Config::save('c5hub.fundamental.navigation_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.header_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.header_background_image_size', 'auto');
         Config::save('c5hub.fundamental.header_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.banner_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.banner_background_image_size', 'auto');
         Config::save('c5hub.fundamental.banner_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.page_info_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.page_info_background_image_size', 'auto');
         Config::save('c5hub.fundamental.page_info_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.main_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.main_background_image_size', 'auto');
         Config::save('c5hub.fundamental.main_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.footer_top_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.footer_top_background_image_size', 'auto');
         Config::save('c5hub.fundamental.footer_top_background_image_attachment', 'scroll');
         Config::save('c5hub.fundamental.footer_bottom_background_image_repeat', 'repeat');
         Config::save('c5hub.fundamental.footer_bottom_background_image_size', 'auto');
         Config::save('c5hub.fundamental.footer_bottom_background_image_attachment', 'scroll');
         // Attribution
         Config::save('c5hub.fundamental.footer_attribution', '/ <a href="http://c5hub.com" target="_blank" title="concrete5 themes & add-ons">Responsive concrete5 Theme by <b>c5Hub</b></a>');
         // White Label
         Config::save('concrete.marketplace.enabled', true);
         Config::save('concrete.marketplace.intelligent_search', true);
         Config::save('concrete.external.news_overlay', true);
         Config::save('concrete.external.news', true);
     }
     $sP = Page::getByPath('/dashboard/fundamental/navigation');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/navigation', $this);
         $sP->update(array('cName' => t("Navigation")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/off_canvas_navigation');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/off_canvas_navigation', $this);
         $sP->update(array('cName' => t("Off Canvas Navigation")));
         // Off Canvas Navigation
         Config::save('c5hub.fundamental.off_canvas.position', 'right');
         Config::save('c5hub.fundamental.off_canvas.open_method', 'move');
         Config::save('c5hub.fundamental.off_canvas.close_on_click', false);
     }
     $sP = Page::getByPath('/dashboard/fundamental/page_meta');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/page_meta', $this);
         $sP->update(array('cName' => t("Page Meta")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/background_images');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/background_images', $this);
         $sP->update(array('cName' => t("Background Images")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/attribution');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/attribution', $this);
         $sP->update(array('cName' => t("Attribution")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/white_label');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/white_label', $this);
         $sP->update(array('cName' => t("White Label")));
     }
     $sP = Page::getByPath('/dashboard/fundamental/general');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/general', $this);
         $sP->update(array('cName' => t("General")));
         // General
         Config::save('c5hub.fundamental.general.boxed', false);
         Config::save('c5hub.fundamental.general.sticky_footer', false);
     }
     $sP = Page::getByPath('/dashboard/fundamental/masonry_grid');
     if (!is_object($sP) || $sP->isError()) {
         $sP = SinglePage::add('/dashboard/fundamental/masonry_grid', $this);
         $sP->update(array('cName' => t("Masonry Grid")));
         // Masonry Grid
         Config::save('c5hub.fundamental.masonry_grid_columns_desktop', 4);
         Config::save('c5hub.fundamental.masonry_grid_columns_tablet', 4);
         Config::save('c5hub.fundamental.masonry_grid_columns_mobile', 12);
     }
     // Install Page Types
     if (!PageTemplate::getByHandle('blog_entry')) {
         PageTemplate::add('blog_entry', 'Blog Entry', 'left_sidebar.png', $pkg);
     }
     if (!PageTemplate::getByHandle('custom')) {
         PageTemplate::add('custom', 'Custom', 'full.png', $pkg);
     }
     if (!PageTemplate::getByHandle('blank')) {
         PageTemplate::add('blank', t('Blank'), 'full.png', $pkg);
     }
     // Install Blocks
     if (!BlockType::getByHandle('fundamental_simple_document')) {
         BlockType::installBlockTypeFromPackage('fundamental_simple_document', $this);
     }
     if (!BlockType::getByHandle('fundamental_section')) {
         BlockType::installBlockTypeFromPackage('fundamental_section', $this);
     }
     if (!BlockType::getByHandle('fundamental_slick_slider')) {
         BlockType::installBlockTypeFromPackage('fundamental_slick_slider', $this);
     }
     // Install Thumbnail Types
     $small = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('small');
     if (!is_object($small)) {
         $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
         $type->setName('Small');
         $type->setHandle('small');
         $type->setWidth(740);
         $type->save();
     }
     $medium = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('medium');
     if (!is_object($medium)) {
         $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
         $type->setName('Medium');
         $type->setHandle('medium');
         $type->setWidth(940);
         $type->save();
     }
     $large = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('large');
     if (!is_object($large)) {
         $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
         $type->setName('Large');
         $type->setHandle('large');
         $type->setWidth(1140);
         $type->save();
     }
     $xlarge = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('xlarge');
     if (!is_object($xlarge)) {
         $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type();
         $type->setName('XLarge');
         $type->setHandle('xlarge');
         $type->setWidth(9999);
         $type->save();
     }
     // Attributes
     $navIconKey = CollectionAttributeKey::getByHandle('nav_icon');
     if (!$navIconKey || !intval($navIconKey->getAttributeKeyID())) {
         $navIconType = AttributeType::getByHandle('select');
         $navIconKey = CollectionAttributeKey::add($navIconType, array('akHandle' => 'nav_icon', 'akName' => t('Nav Icon'), 'akIsSearchable' => false), $pkg);
         ## Add Options
         $options = $this->getIconClasses();
         foreach ($options as $opt) {
             $navIconKeyOption = SelectAttributeTypeOption::add($navIconKey, $opt, 0);
         }
     }
     $thumbnailKey = CollectionAttributeKey::getByHandle('thumbnail');
     if (!$thumbnailKey || !intval($thumbnailKey->getAttributeKeyID())) {
         $thumbnailType = AttributeType::getByHandle('image_file');
         $thumbnailKey = CollectionAttributeKey::add($thumbnailType, array('akHandle' => 'thumbnail', 'akName' => t('Thumbnail'), 'akIsSearchable' => false), $pkg);
     }
     $disableTitleKey = CollectionAttributeKey::getByHandle('disable_page_info_title');
     if (!$disableTitleKey || !intval($disableTitleKey->getAttributeKeyID())) {
         $disableTitleType = AttributeType::getByHandle('boolean');
         $disableTitleKey = CollectionAttributeKey::add($disableTitleType, array('akHandle' => 'disable_page_info_title', 'akName' => t('Disable Page Info Title'), 'akIsSearchable' => false), $pkg);
     }
     $disableDescriptionKey = CollectionAttributeKey::getByHandle('disable_page_info_description');
     if (!$disableDescriptionKey || !intval($disableDescriptionKey->getAttributeKeyID())) {
         $disableDescriptionType = AttributeType::getByHandle('boolean');
         $disableDescriptionKey = CollectionAttributeKey::add($disableDescriptionType, array('akHandle' => 'disable_page_info_description', 'akName' => t('Disable Page Info Description'), 'akIsSearchable' => false), $pkg);
     }
     $areaCountKey = CollectionAttributeKey::getByHandle('area_count');
     if (!$areaCountKey || !intval($areaCountKey->getAttributeKeyID())) {
         $areaCountType = AttributeType::getByHandle('number');
         $areaCountKey = CollectionAttributeKey::add($areaCountType, array('akHandle' => 'area_count', 'akName' => t('Area Count'), 'akIsSearchable' => false), $pkg);
     }
 }