本文整理汇总了PHP中AttributeType::getByHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP AttributeType::getByHandle方法的具体用法?PHP AttributeType::getByHandle怎么用?PHP AttributeType::getByHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeType
的用法示例。
在下文中一共展示了AttributeType::getByHandle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CoreAutoload
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);
}
}
}
}
示例2: getByHandle
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);
}
}
}
示例3: installOrUpgrade
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);
}
}
}
示例4: install
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'));
}
示例5: import
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);
}
示例6: __autoload
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);
}
}
示例7: getByHandle
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);
}
}
}
示例8: getSelectOptions
/**
* 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;
}
示例9: run
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();
}
示例10: installPageLinkAttribute
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);
}
}
}
示例11: install
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);
}
示例12: autoload
/**
* @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);
}
}
}
}
}
示例13: render
/**
* 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;
}
}
示例14: setupDashboardIcons
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);
}
}
}
示例15: upgradeUserAttributes
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;
}