function CoreAutoload($class) { $txt = Loader::helper('text'); if ($class == 'DashboardBaseController') { Loader::controller('/dashboard/base'); } if (strpos($class, 'BlockController') > 0) { $class = substr($class, 0, strpos($class, 'BlockController')); $handle = $txt->uncamelcase($class); Loader::block($handle); } else { if (strpos($class, 'Helper') > 0) { $class = substr($class, 0, strpos($class, 'Helper')); $handle = $txt->uncamelcase($class); $handle = preg_replace('/^site_/', '', $handle); Loader::helper($handle); } else { if (strpos($class, 'AttributeType') > 0) { $class = substr($class, 0, strpos($class, 'AttributeType')); $handle = $txt->uncamelcase($class); $at = AttributeType::getByHandle($handle); } } } }
public static function getByHandle($akHandle) { $db = Loader::db(); $q = "SELECT ak.akID FROM AttributeKeys ak INNER JOIN AttributeKeyCategories akc ON ak.akCategoryID = akc.akCategoryID WHERE ak.akHandle = ? AND akc.akCategoryHandle = 'file'"; $akID = $db->GetOne($q, array($akHandle)); if ($akID > 0) { $ak = FileAttributeKey::getByID($akID); return $ak; } else { // else we check to see if it's listed in the initial registry $ia = FileTypeList::getImporterAttribute($akHandle); if (is_object($ia)) { // we create this attribute and return it. $at = AttributeType::getByHandle($ia->akType); $args = array( 'akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable ); return FileAttributeKey::add($at, $args); } } }
private function installOrUpgrade($pkg, $fromVersion) { $at = AttributeType::getByHandle('handle_https'); if (!is_object($at)) { $at = AttributeType::add('handle_https', tc('AttributeTypeName', 'HTTPS handling'), $pkg); } $akc = AttributeKeyCategory::getByHandle('collection'); if (is_object($akc)) { if (!$akc->hasAttributeKeyTypeAssociated($at)) { $akc->associateAttributeKeyType($at); } } if (empty($fromVersion)) { $ak = CollectionAttributeKey::getByHandle('handle_https'); if (!is_object($ak)) { $hhh = Loader::helper('https_handling', 'handle_https'); /* @var $hhh HttpsHandlingHelper */ $httpDomain = defined('BASE_URL') ? BASE_URL : Config::get('BASE_URL'); if (!$httpDomain) { $httpDomain = 'http://' . $hhh->getRequestDomain(); } $httpsDomain = defined('BASE_URL_SSL') ? BASE_URL_SSL : Config::get('BASE_URL_SSL'); if (!$httpsDomain) { $httpsDomain = 'https://' . $hhh->getRequestDomain(); } $ak = CollectionAttributeKey::add($at, array('akHandle' => 'handle_https', 'akName' => tc('AttributeKeyName', 'Page HTTP/HTTPS'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => 1, 'akIsInternal' => 0, 'akEnabled' => 0, 'akDefaultRequirement' => HttpsHandlingHelper::SSLHANDLING_DOESNOT_MATTER, 'akCustomDomains' => 0, 'akHTTPDomain' => $httpDomain, 'akHTTPSDomain' => $httpsDomain), $pkg); } } }
public function install() { $pkg = parent::install(); $pkgh = Package::getByHandle('page_selector_attribute'); Loader::model('attribute/categories/collection'); $col = AttributeKeyCategory::getByHandle('collection'); $pageselector = AttributeType::add('page_selector', t('Page Selector'), $pkgh); $col->associateAttributeKeyType(AttributeType::getByHandle('page_selector')); }
public static function import(SimpleXMLElement $ak) { $type = AttributeType::getByHandle($ak['type']); $pkg = false; if ($ak['package']) { $pkg = Package::getByHandle($ak['package']); } $akn = UserAttributeKey::add($type, array('akHandle' => $ak['handle'], 'akName' => $ak['name'], 'akIsSearchableIndexed' => $ak['indexed'], 'akIsSearchable' => $ak['searchable'], 'uakProfileDisplay' => $ak['profile-displayed'], 'uakProfileEdit' => $ak['profile-editable'], 'uakProfileEditRequired' => $ak['profile-required'], 'uakRegisterEdit' => $ak['register-editable'], 'uakRegisterEditRequired' => $ak['register-required'], 'uakMemberListDisplay' => $ak['member-list-displayed']), $pkg); $akn->getController()->importKey($ak); }
function __autoload($class) { $txt = Loader::helper('text'); if (strpos($class, 'BlockController') > 0) { $class = substr($class, 0, strpos($class, 'BlockController')); $handle = $txt->uncamelcase($class); Loader::block($handle); } else if (strpos($class, 'Helper') > 0) { $class = substr($class, 0, strpos($class, 'Helper')); $handle = $txt->uncamelcase($class); $handle = preg_replace('/^site_/', '', $handle); Loader::helper($handle); } else if (strpos($class, 'AttributeType') > 0) { $class = substr($class, 0, strpos($class, 'AttributeType')); $handle = $txt->uncamelcase($class); $at = AttributeType::getByHandle($handle); } }
public static function getByHandle($akHandle) { $db = Loader::db(); $akID = $db->GetOne('select akID from AttributeKeys where akHandle = ?', array($akHandle)); if ($akID > 0) { $ak = FileAttributeKey::getByID($akID); return $ak; } else { // else we check to see if it's listed in the initial registry $ia = FileTypeList::getImporterAttribute($akHandle); if (is_object($ia)) { // we create this attribute and return it. $at = AttributeType::getByHandle($ia->akType); $args = array('akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable); return FileAttributeKey::add($at, $args); } } }
/** * Looks up the list of options from the DB * This is the only place where themes are 'categorized', which is purely for presentation in the walk create form * * @param string $type Which type of tag to return (e.g. theme, accessible) * @return array */ public static function getSelectOptions($type = 'all') { $options = array(); $satc = new SelectAttributeTypeController(AttributeType::getByHandle('select')); if ($type === 'all' || $type === 'theme') { $satc->setAttributeKey(CollectionAttributeKey::getByHandle('theme')); $themeAK = CollectionAttributeKey::getByHandle('theme'); foreach ($satc->getOptions() as $v) { $category = $this->getCategory($v->value); $options['theme'][$category][] = ['handle' => $v->value, 'name' => self::getName($v->value)]; } } if ($type === 'all' || $type === 'accessibile') { $satc->setAttributeKey(CollectionAttributeKey::getByHandle('accessible')); foreach ($satc->getOptions() as $v) { $options['accessible'][] = ['handle' => $v->value, 'name' => self::getName($v->value)]; } } return $options; }
public function run() { $db = Loader::db(); Cache::disableLocalCache(); Loader::model('attribute/categories/collection'); $cak = CollectionAttributeKey::getByHandle('exclude_page_list'); if (!is_object($cak)) { $boolt = AttributeType::getByHandle('boolean'); $cab4b = CollectionAttributeKey::add($boolt, array('akHandle' => 'exclude_page_list', 'akName' => t('Exclude From Page List'), 'akIsSearchable' => true)); Loader::model('page_list'); $pl = new PageList(); $pl->filterByExcludeNav(1); $list = $pl->get(); foreach ($list as $c) { $c->setAttribute('exclude_page_list', 1); $c->reindex(); } } Cache::enableLocalCache(); }
private function installPageLinkAttribute(&$pkg) { $at = AttributeType::getByHandle('page_selector'); if ($at && intval($at->getAttributeTypeID())) { //Associate with "file" category (if not done alrady) Loader::model('attribute/categories/collection'); $akc = AttributeKeyCategory::getByHandle('file'); $sql = 'SELECT COUNT(*) FROM AttributeTypeCategories WHERE atID = ? AND akCategoryID = ?'; $vals = array($at->getAttributeTypeID(), $akc->akCategoryID); $existsInCategory = Loader::db()->GetOne($sql, $vals); if (!$existsInCategory) { $akc->associateAttributeKeyType($at); } //Install the link-to-page attribute (if not done already) Loader::model('file_attributes'); $akHandle = 'gallery_link_to_cid'; $akGalleryLinkToCID = FileAttributeKey::getByHandle($akHandle); if (!is_object($akGalleryLinkToCID) || !intval($akGalleryLinkToCID->getAttributeKeyID())) { $akGalleryLinkToCID = FileAttributeKey::add($at, array('akHandle' => $akHandle, 'akName' => t('Gallery Link To Page')), $pkg); } } }
public function install() { $pkg = parent::install(); Loader::model('single_page'); $single_page = SinglePage::add('/dashboard/wordpress_import', $pkg); $single_page->update(array('cName' => t('WordPress Import'), 'cDescription' => t('Import WordPress Sites'))); $import_stuff = SinglePage::add('/dashboard/wordpress_import/import', $pkg); $import_stuff->update(array('cName' => t('Import'))); $import_stuff = SinglePage::add('/dashboard/wordpress_import/file', $pkg); $import_stuff->update(array('cName' => t('File'))); $select = AttributeType::getByHandle('select'); $wpCategory = CollectionAttributeKey::getByHandle('wordpress_category'); if (!$wpCategory instanceof CollectionAttributeKey) { $wpCategory = CollectionAttributeKey::add($select, array('akSelectAllowMultipleValues' => 1, 'akSelectOptionDisplayOrder' => 'popularity_desc', 'akSelectAllowOtherValues' => 1, 'akHandle' => 'wordpress_category', 'akName' => t('Wordpress Category')), $pkg); } $tags = CollectionAttributeKey::getByHandle('tags'); if (!$tags instanceof CollectionAttributeKey) { $tags = CollectionAttributeKey::add($select, array('akSelectAllowMultipleValues' => 1, 'akSelectOptionDisplayOrder' => 'popularity_desc', 'akSelectAllowOtherValues' => 1, 'akHandle' => 'tagsy', 'akName' => t('Tags')), $pkg); } $co = new Config(); $co->setPackageObject($pkg); $co->save("WORDPRESS_IMPORT_FID", 0); }
/** * @private */ public static function autoload($class) { $classes = self::$autoloadClasses; $cl = $classes[$class]; if ($cl) { call_user_func_array(array(__CLASS__, $cl[0]), array($cl[1], $cl[2])); } else { /* lets handle some things slightly more dynamically */ $txt = self::helper('text'); if (strpos($class, 'BlockController') > 0) { $class = substr($class, 0, strpos($class, 'BlockController')); $handle = $txt->uncamelcase($class); self::block($handle); } else { if (strpos($class, 'AttributeType') > 0) { $class = substr($class, 0, strpos($class, 'AttributeType')); $handle = $txt->uncamelcase($class); $at = AttributeType::getByHandle($handle); } else { if (strpos($class, 'Helper') > 0) { $class = substr($class, 0, strpos($class, 'Helper')); $handle = $txt->uncamelcase($class); $handle = preg_replace('/^site_/', '', $handle); self::helper($handle); } } } } }
/** * Renders a view for this attribute key. If no view is default we display it's "view" * Valid views are "view", "form" or a custom view (if the attribute has one in its directory) * Additionally, an attribute does not have to have its own interface. If it doesn't, then whatever * is printed in the corresponding $view function in the attribute's controller is printed out. */ public function render($view = 'view', $value = false, $return = false) { $at = AttributeType::getByHandle($this->atHandle); $resp = $at->render($view, $this, $value, $return); if ($return) { return $resp; } }
protected function setupDashboardIcons() { $cak = CollectionAttributeKey::getByHandle('icon_dashboard'); if (!is_object($cak)) { $textt = AttributeType::getByHandle('text'); $cab4b = CollectionAttributeKey::add($textt, array('akHandle' => 'icon_dashboard', 'akName' => t('Dashboard Icon'), 'akIsInternal' => true)); } $iconArray = array('/dashboard/composer/write' => 'icon-pencil', '/dashboard/composer/drafts' => 'icon-book', '/dashboard/sitemap/full' => 'icon-home', '/dashboard/sitemap/explore' => 'icon-road', '/dashboard/sitemap/search' => 'icon-search', '/dashboard/files/search' => 'icon-picture', '/dashboard/files/attributes' => 'icon-cog', '/dashboard/files/sets' => 'icon-list-alt', '/dashboard/files/add_set' => 'icon-plus-sign', '/dashboard/users/search' => 'icon-user', '/dashboard/users/groups' => 'icon-globe', '/dashboard/users/attributes' => 'icon-cog', '/dashboard/users/add' => 'icon-plus-sign', '/dashboard/users/add_group' => 'icon-plus', '/dashboard/users/group_sets' => 'icon-list', '/dashboard/reports/statistics' => 'icon-signal', '/dashboard/reports/forms' => 'icon-briefcase', '/dashboard/reports/surveys' => 'icon-tasks', '/dashboard/reports/logs' => 'icon-time', '/dashboard/pages/themes' => 'icon-font', '/dashboard/pages/types' => 'icon-file', '/dashboard/pages/attributes' => 'icon-cog', '/dashboard/pages/single' => 'icon-wrench', '/dashboard/workflow/list' => 'icon-list', '/dashboard/workflow/me' => 'icon-user', '/dashboard/blocks/stacks' => 'icon-th', '/dashboard/blocks/permissions' => 'icon-lock', '/dashboard/blocks/types' => 'icon-wrench'); foreach ($iconArray as $path => $icon) { $sp = Page::getByPath($path); if (is_object($sp) && !$sp->isError()) { $sp->setAttribute('icon_dashboard', $icon); } } }
protected function upgradeUserAttributes() { $messages = array(); $db = Loader::db(); $r = $db->Execute('select _UserAttributeKeys.* from _UserAttributeKeys order by displayOrder asc'); while ($row = $r->FetchRow()) { $cleanHandle = preg_replace("/[^A-Za-z0-9\_]/",'',$row['ukHandle']); // remove spaces, chars that'll mess up our index tables $existingAKID = $db->GetOne('select akID from AttributeKeys where akHandle = ?', array($cleanHandle) ); if ($existingAKID < 1) { if(!$row['ukHandle']) continue; $args = array( 'akHandle' => $cleanHandle, 'akIsSearchable' => 1, 'akIsEditable' => 1, 'akName' => $row['ukName'], 'uakIsActive' => ($row['ukHidden']?0:1), 'uakProfileEditRequired' => $row['ukRequired'], 'uakProfileDisplay' => ($row['ukPrivate'] == 0), 'uakRegisterEdit' => $row['ukDisplayedOnRegister'] ); $sttype = $row['ukType']; if ($sttype == 'TEXTAREA') { $sttype = 'TEXT'; } if ($sttype == 'RADIO') { $sttype = 'SELECT'; } $type = AttributeType::getByHandle(strtolower($sttype)); $ak = UserAttributeKey::add($type, $args); if ($sttype == 'SELECT') { $selectOptions = explode("\n", $row['ukValues']); foreach($selectOptions as $so) { if ($so != '') { SelectAttributeTypeOption::add($ak, $so); } } } } else { $ak = UserAttributeKey::getByID($existingAKID); } $r2 = $db->Execute('select * from _UserAttributeValues where ukID = ? and isImported = 0', $row['ukID']); while ($row2 = $r2->FetchRow()) { $ui = UserInfo::getByID($row2['uID']); if(is_object($ui)) { $value = $row2['value']; $ui->setAttribute($ak, $value); } unset($ui); $db->Execute('update _UserAttributeValues set isImported = 1 where ukID = ? and uID = ?', array($row['ukID'], $row2['uID'])); $this->incrementImported(); } unset($ak); unset($row2); $r2->Close(); unset($r2); } unset($row); $r->Close(); unset($r); return $messages; }
$num = (int) $row['num']; $pl->setItemsPerPage($num); if ($paginate_list == 1) { $current_page_get_var = 'ccm_paging_p_b' . $bID; $current_page = intval($_GET[$current_page_get_var]); // Page of results requested in query string $current_page = empty($current_page) ? 1 : $current_page; // PageList object returns this page of results $pages = $pl->getPage($current_page); } else { $pages = $pl->getPage(1); } // Display attribute filter links if (count($row['displayAttributes']) > 0) { Loader::model('attribute/categories/collection'); $satc = new SelectAttributeTypeController(AttributeType::getByHandle('select')); // Get existing query string to pass through filtering parameters $request = $_SERVER['REQUEST_URI']; $url_parts = parse_url($request); $url_params = array(); parse_str($url_parts['query'], $url_params); $query_string = http_build_query($url_params); // Display select attributes (and their options) specified in ajax_page_list.php as lists of links echo '<div class="page-list-filters">'; echo '<p><strong>' . t('Filter by:') . '</strong></p>'; foreach ($row['displayAttributes'] as $attribute_handle) { $ak = CollectionAttributeKey::getByHandle($attribute_handle); $satc->setAttributeKey($ak); $options = $satc->getOptions(); if (count($options) > 0) { echo '<div class="page-list-filter">';
protected function importAttributes(SimpleXMLElement $sx) { if (isset($sx->attributekeys)) { foreach($sx->attributekeys->attributekey as $ak) { $akc = AttributeKeyCategory::getByHandle($ak['category']); $pkg = ContentImporter::getPackageObject($ak['package']); $type = AttributeType::getByHandle($ak['type']); if (is_object($pkg)) { Loader::model('attribute/categories/' . $akc->getAttributeKeyCategoryHandle(), $pkg->getPackageHandle()); } else { Loader::model('attribute/categories/' . $akc->getAttributeKeyCategoryHandle()); } $txt = Loader::helper('text'); $className = $txt->camelcase($akc->getAttributeKeyCategoryHandle()); $c1 = $className . 'AttributeKey'; $ak = call_user_func(array($c1, 'import'), $ak); } } }
protected function importAttributes(SimpleXMLElement $sx) { if (isset($sx->attributekeys)) { $db = Loader::db(); foreach ($sx->attributekeys->attributekey as $ak) { $akc = AttributeKeyCategory::getByHandle($ak['category']); $akID = $db->GetOne('select akID from AttributeKeys where akHandle = ? and akCategoryID = ?', array($ak['handle'], $akc->getAttributeKeyCategoryID())); if (!$akID) { $pkg = ContentImporter::getPackageObject($ak['package']); $type = AttributeType::getByHandle($ak['type']); $txt = Loader::helper('text'); $className = $txt->camelcase($akc->getAttributeKeyCategoryHandle()); $c1 = $className . 'AttributeKey'; $ak = call_user_func(array($c1, 'import'), $ak); } } } }