本文整理汇总了PHP中Core::IsComponentAvailable方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::IsComponentAvailable方法的具体用法?PHP Core::IsComponentAvailable怎么用?PHP Core::IsComponentAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core::IsComponentAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct() {
$this->_linked = array(
'Page' => array(
'link' => Model::LINK_BELONGSTOONE,
'on' => 'baseurl',
),
);
// This system now has a combined primary key.
// HOWEVER, construction of the model should still be allowed to be performed with simply the baseurl.
// The first part of the key can be assumed.
if(func_num_args() == 3){
if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled()){
$site = MultiSiteHelper::GetCurrentSiteID();
}
else{
$site = null;
}
$key1 = func_get_arg(0);
$key2 = func_get_arg(1);
$key3 = func_get_arg(2);
parent::__construct($site, $key1, $key2, $key3);
$this->load();
}
elseif(func_num_args() == 4){
$site = func_get_arg(0);
$key1 = func_get_arg(1);
$key2 = func_get_arg(2);
$key3 = func_get_arg(3);
parent::__construct($site, $key1, $key2, $key3);
}
else{
parent::__construct();
}
}
示例2: __construct
public function __construct(){
// This system now has a combined primary key.
// HOWEVER, construction of the model should still be allowed to be performed with simply the baseurl.
// The first part of the key can be assumed.
if(func_num_args() == 2){
if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled()){
$site = MultiSiteHelper::GetCurrentSiteID();
}
else{
$site = 0;
}
$baseurl = func_get_arg(0);
$name = func_get_arg(1);
parent::__construct($site, $baseurl, $name);
}
elseif(func_num_args() == 3){
$site = func_get_arg(0);
$baseurl = func_get_arg(1);
$name = func_get_arg(2);
parent::__construct($site, $baseurl, $name);
}
else{
parent::__construct();
}
}
示例3: getInsertValue
/**
* Get the value appropriate for INSERT statements.
*
* @return string
*/
public function getInsertValue(){
if($this->value === null || $this->value === false){
if(\Core::IsComponentAvailable('multisite') && \MultiSiteHelper::IsEnabled()){
$this->setValueFromApp(\MultiSiteHelper::GetCurrentSiteID());
}
else{
$this->setValueFromApp(0);
}
}
return $this->value;
}
示例4: GetArticleForm
/**
* Get the form for article creation and updating.
*
* @param BlogArticleModel $article
*
* @return Form
*/
public static function GetArticleForm(BlogArticleModel $article)
{
$page = $article->getLink('Page');
$blog = $article->getLink('Blog');
$page->set('parenturl', $blog->get('baseurl'));
$form = new Form();
$form->set('callsmethod', 'BlogHelper::BlogArticleFormHandler');
$form->addModel($page, 'page');
$form->addModel($article, 'model');
if (Core::IsComponentAvailable('facebook') && Core::IsLibraryAvailable('jquery')) {
// Is this article already posted?
if ($article->get('fb_post_id')) {
$form->addElement('select', ['disabled' => true, 'title' => 'Post to Facebook', 'options' => ['' => 'Posted!'], 'group' => 'Publish Settings']);
} else {
$form->addElement('select', ['class' => 'facebook-post-to-select', 'title' => 'Post to Facebook', 'name' => 'facebook_post', 'options' => ['' => '-- Please enable javascript --'], 'group' => 'Publish Settings']);
}
}
// Lock in some elements for this blog article page.
$form->getElement('page[parenturl]')->setFromArray(array('value' => $blog->get('baseurl'), 'readonly' => 'readonly'));
// And remove a few other elements.
$form->removeElement('model[title]');
return $form;
}
示例5: view
public function view()
{
$view = $this->getView();
$factory = new ModelFactory('GalleryImageModel');
if ($this->getSetting('order') == 'random') {
$factory->order('RAND()');
} else {
$factory->order($this->getSetting('order'));
}
if ($this->getSetting('album')) {
$factory->where('albumid = ' . $this->getSetting('album'));
$album = GalleryAlbumModel::Construct($this->getSetting('album'));
$link = $album->get('baseurl');
} else {
$link = null;
}
$factory->limit($this->getSetting('count'));
$images = $factory->get();
$view->assign('images', $images);
$view->assign('dimensions', $this->getSetting('dimensions'));
$view->assign('link', $link);
$view->assign('uselightbox', $this->getSetting('uselightbox') && Core::IsComponentAvailable('jquery-lightbox'));
}
示例6: save
public function save($defer = false){
if(Core::IsComponentAvailable('core')){
$isnew = !$this->exists();
$ret = parent::save($defer);
// No change happened, nothing extra to do.
if(!$ret){
return $ret;
}
// Wasn't a previously new model? Also nothing to do beyond.
if(!$isnew){
return $ret;
}
}
// @todo email message function
// log message (to file).
if(
($this->get('type') == 'error' || $this->get('type') == 'security') &&
$this->get('details')
){
Core\Utilities\Logger\append_to($this->get('type'), $this->get('message') . "\n" . $this->get('details'), $this->get('code'));
}
else{
Core\Utilities\Logger\append_to($this->get('type'), $this->get('message'), $this->get('code'));
}
}
示例7: render
/**
* @return string
* @throws Exception
*/
public function render() {
if (!$this->get('id')) {
// This system requires a valid id.
++self::$_AutoID;
$this->set('id', 'formfileinput-' . self::$_AutoID);
}
if (!$this->get('basedir')) {
throw new Exception('FormFileInput cannot be rendered without a basedir attribute!');
}
// If multiple is set, but the name does not have a [] at the end.... add it.
if ($this->get('multiple') && !preg_match('/.*\[.*\]/', $this->get('name'))) $this->_attributes['name'] .= '[]';
$file = $this->getTemplateName();
$tpl = \Core\Templates\Template::Factory($file);
$mediaavailable = Core::IsComponentAvailable('media-manager');
$browsable = ( $mediaavailable && \Core\user()->checkAccess('p:/mediamanager/browse') && ($this->get('browsable') || $this->get('browseable')) );
//var_dump($file, $this); die();
$tpl->assign('element', $this);
$tpl->assign('browsable', $browsable);
return $tpl->fetch();
}
示例8: GetForm
/**
* @param \UserModel|null $user
*
* @return \Form
*/
public static function GetForm($user = null){
$form = new \Form();
if($user === null) $user = new \UserModel();
$type = ($user->exists()) ? 'edit' : 'registration';
$usermanager = \Core\user()->checkAccess('p:/user/users/manage');
$groupmanager = \Core\user()->checkAccess('p:/user/groups/manage');
$allowemailchanging = \ConfigHandler::Get('/user/email/allowchanging');
if($type == 'registration'){
$form->set('callsmethod', 'Core\\User\\Helper::RegisterHandler');
}
else{
$form->set('callsmethod', 'Core\\User\\Helper::UpdateHandler');
}
$form->addElement('system', ['name' => 'user', 'value' => $user]);
// Because the user system may not use a traditional Model for the backend, (think LDAP),
// I cannot simply do a setModel() call here.
// Only enable email changes if the current user is an admin or it's new.
// (Unless the admin allows it via the site config)
if($type != 'registration' && ( $usermanager || $allowemailchanging)){
$form->addElement('text', array('name' => 'email', 'title' => 'Email', 'required' => true, 'value' => $user->get('email')));
}
// Tack on the active option if the current user is an admin.
if($usermanager){
$form->addElement(
'checkbox',
array(
'name' => 'active',
'title' => 'Active',
'checked' => ($user->get('active') == 1),
)
);
$form->addElement(
'checkbox',
array(
'name' => 'admin',
'title' => 'System Admin',
'checked' => $user->get('admin'),
'description' => 'The system admin, (or root user), has complete control over the site and all systems.',
)
);
}
if($usermanager){
$elements = array_keys($user->getKeySchemas());
}
elseif($type == 'registration'){
$elements = explode('|', \ConfigHandler::Get('/user/register/form_elements'));
}
else{
$elements = explode('|', \ConfigHandler::Get('/user/edit/form_elements'));
}
// If avatars are disabled globally, remove that from the list if it's set.
if(!\ConfigHandler::Get('/user/enableavatar') && in_array('avatar', $elements)){
array_splice($elements, array_search('avatar', $elements), 1);
}
foreach($elements as $k){
if($k){
// Skip blank elements that can be caused by string|param|foo| or empty strings.
$el = $user->getColumn($k)->getAsFormElement();
if($el){
$form->addElement($el);
}
}
}
// Tack on the group registration if the current user is an admin.
if($groupmanager){
// Find all the groups currently on the site.
$where = new DatasetWhereClause();
$where->addWhere('context = ');
if(\Core::IsComponentAvailable('multisite') && \MultiSiteHelper::IsEnabled()){
$where->addWhereSub('OR', ['site = ' . \MultiSiteHelper::GetCurrentSiteID(), 'site = -1']);
}
$groups = \UserGroupModel::Find($where, null, 'name');
if(sizeof($groups)){
$groupopts = array();
foreach($groups as $g){
$groupopts[$g->get('id')] = $g->get('name');
}
$form->addElement(
'checkboxes',
array(
//.........这里部分代码省略.........
示例9: _setGroups
/**
* Set all groups for a given user on the current site from a set of IDs.
*
* @param array $groups
* @param bool|Model|string $context True to set all context groups, false to ignore, a string or model for the
* specific context.
*
* @throws Exception
*/
protected function _setGroups($groups, $context) {
// Map the groups to a complex array if necessary.
foreach($groups as $key => $data) {
if(!is_array($data)) {
$groups[ $key ] = [
'group_id' => $data,
'context' => '',
'context_pk' => '',
];
}
}
if($context === false) {
// Skip all context groups.
$contextname = null;
$contextpk = null;
}
elseif($context === true) {
// Skip regular groups, but include all context groups.
$contextname = null;
$contextpk = null;
}
elseif($context instanceof Model) {
$contextname = substr(get_class($context), 0, -5);
$contextpk = $context->getPrimaryKeyString();
$context = true;
}
elseif(is_scalar($context)) {
$contextname = $context;
$contextpk = null;
$context = true;
}
else {
throw new Exception('If a context is provided, please ensure it is either a model or model name');
}
$uugs = $this->getLink('UserUserGroup');
foreach($uugs as $uug) {
/** @var UserUserGroupModel $uug */
// Only process the requested group types.
if($context && !$uug->get('context')) {
// A context option was selected, but this is a regular group, skip it.
continue;
}
elseif(!$context && $uug->get('context')) {
// Similarly, no context was requested, but this group has one.
continue;
}
elseif($context && $contextname && $uug->get('context') != $contextname) {
// A context was requested, and a specific context name was set also!
// But it doesn't match.... SKIP!
continue;
}
elseif($context && $contextpk && $uug->get('context_pk') != $contextpk) {
// A context was requested, and a specific context name was set also!
// But it doesn't match.... SKIP!
continue;
}
if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled()) {
// Only return this site's groups if in multisite mode
$ugsite = $uug->getLink('UserGroup')->get('site');
if(!($ugsite == -1 || $ugsite == MultiSiteHelper::GetCurrentSiteID())) {
/// Skip any group not on this site... they'll simply be ignored.
continue;
}
}
$gid = $uug->get('group_id');
$gcontext = $uug->get('context');
$gcontextpk = $uug->get('context_pk');
foreach($groups as $key => $data) {
if($data['group_id'] == $gid && $data['context'] == $gcontext && $data['context_pk'] == $gcontextpk
) {
// Yay, group matches up with both!
// Unlink it from the groups array so it doesn't try to get recreated.
unset($groups[ $key ]);
continue 2;
}
}
// This group isn't in the new list, unset it!
$this->deleteLink($uug);
}
// Any new groups remaining?
foreach($groups as $data) {
$this->setLink(
'UserUserGroup', new UserUserGroupModel(
//.........这里部分代码省略.........
示例10: delete
public function delete(){
$view = $this->getView();
$req = $this->getPageRequest();
$id = $req->getParameter(0);
$model = new UserGroupModel($id);
if(!$req->isPost()){
return View::ERROR_BADREQUEST;
}
if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled()){
$where['site'] = MultiSiteHelper::GetCurrentSiteID();
}
$model->delete();
\Core\set_message('Removed group successfully', 'success');
\core\redirect('/usergroupadmin');
}
示例11: require_once
// Load all the themes on the system.
//require_once(ROOT_PDIR . 'core/libs/core/ThemeHandler.class.php');
//ThemeHandler::Load();
HookHandler::DispatchHook('/core/components/loaded');
$profiler->record('Components Load Complete');
/**
* All the post includes, these are here for performance reasons, (they can get compiled into the compiled bootstrap)
*/
require_once(__DIR__ . '/bootstrap_postincludes.php');
// If the geo-location libraries are available, load the user's location!
if(Core::IsComponentAvailable('geographic-codes') && class_exists('GeoIp2\\Database\\Reader')){
try{
if(REMOTE_IP == '127.0.0.1'){
// Load local connections up with Columbus, OH.
// Why? ;)
$geocity = 'Columbus';
$geoprovince = 'OH';
$geocountry = 'US';
$geotimezone = 'America/New_York';
$geopostal = '43215';
}
else{
$reader = new GeoIp2\Database\Reader(ROOT_PDIR . 'components/geographic-codes/libs/maxmind-geolite-db/GeoLite2-City.mmdb');
$profiler->record('Initialized GeoLite Database');
$geo = $reader->cityIspOrg(REMOTE_IP);
示例12: _ConfigSubmit
public static function _ConfigSubmit(Form $form) {
$elements = $form->getElements();
$updatedcount = 0;
foreach ($elements as $e) {
/** @var FormElement $e */
// I'm only interested in config options.
if (strpos($e->get('name'), 'config[') === false) continue;
// Make the name usable a little.
$n = $e->get('name');
if (($pos = strpos($n, '[]')) !== false) $n = substr($n, 0, $pos);
$n = substr($n, 7, -1);
// And get the config object
$c = new ConfigModel($n);
$val = null;
switch ($c->get('type')) {
case 'string':
case 'text':
case 'enum':
case 'boolean':
case 'int':
$val = $e->get('value');
break;
case 'set':
$val = implode('|', $e->get('value'));
break;
default:
throw new Exception('Unsupported configuration type for ' . $c->get('key') . ', [' . $c->get('type') . ']');
break;
}
// This is required because enterprise multisite mode has a different location for site configs.
if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::GetCurrentSiteID()){
$siteconfig = MultiSiteConfigModel::Construct($c->get('key'), MultiSiteHelper::GetCurrentSiteID());
$siteconfig->setValue($val);
if($siteconfig->save()) ++$updatedcount;
}
else{
$c->setValue($val);
if ($c->save()) ++$updatedcount;
}
}
\Core\set_message('t:MESSAGE_SUCCESS_UPDATED_N_CONFIGURATION', $updatedcount);
return true;
}
示例13: _AttachCoreJavascript
/**
* Function that attaches the core javascript to the page.
*
* This should be called automatically from the hook /core/page/preexecute.
*/
public static function _AttachCoreJavascript() {
if(Core::IsComponentAvailable('User')){
$userid = (\Core\user()->get('id') ? \Core\user()->get('id') : 0);
$userauth = \Core\user()->exists() ? 'true' : 'false';
}
else{
$userid = 0;
$userauth = 'false';
}
$ua = \Core\UserAgent::Construct();
$uastring = '';
foreach($ua->asArray() as $k => $v){
if($v === true){
$uastring .= "\t\t\t$k: true,\n";
}
elseif($v === false){
$uastring .= "\t\t\t$k: false,\n";
}
else{
$uastring .= "\t\t\t$k: \"$v\",\n";
}
}
$uastring .= "\t\t\tis_mobile: " . ($ua->isMobile() ? 'true' : 'false') . "\n";
$url = htmlentities(\Core\page_request()->uriresolved);
if(ConfigHandler::Get('/core/page/url_remove_stop_words')){
$stopwords = json_encode(\Core\get_stop_words());
$removeStopWords = 'true';
}
else{
$stopwords = '""';
$removeStopWords = 'false';
}
$version = DEVELOPMENT_MODE ? self::GetComponent()->getVersion() : '';
$rootWDIR = ROOT_WDIR;
$rootURL = ROOT_URL;
$rootURLSSL = ROOT_URL_SSL;
$rootURLnoSSL = ROOT_URL_NOSSL;
$ssl = SSL ? 'true' : 'false';
$sslMode = SSL_MODE;
$script = <<<EOD
<script type="text/javascript">
var Core = {
Version: "$version",
ROOT_WDIR: "$rootWDIR",
ROOT_URL: "$rootURL",
ROOT_URL_SSL: "$rootURLSSL",
ROOT_URL_NOSSL: "$rootURLnoSSL",
SSL: $ssl,
SSL_MODE: "$sslMode",
User: {
id: "$userid",
authenticated: $userauth
},
Url: "$url",
Browser: { $uastring },
URLRemoveStopWords: $removeStopWords,
StopWords: $stopwords
};
</script>
EOD;
$minified = \ConfigHandler::Get('/core/javascript/minified');
if($minified){
$script = str_replace(["\t", "\n"], ['', ''], $script);
}
\Core\view()->addScript($script, 'head');
// And the static functions.
\Core\view()->addScript('js/core.js', 'foot');
//\Core\view()->addScript('js/core-foot.js', 'foot');
}
示例14: CheckRequirement
/**
* Simple function to scan through the components provided for one that
* satisfies the requirement.
*
* Returns true if requirement is met with current packages,
* Returns false if requirement cannot be met at all.
* Returns the component array of an available repository package if that will solve this requirement.
*
* @param array $requirement Associative array [type, name, version, operation], of requirement to look for
* @param array $newcomponents Associatve array [core, components, themes], of currently installed components
* @param array $allavailable Indexed array of all available components from the repositories
*
* @return array | false | true
*/
public static function CheckRequirement($requirement, $newcomponents = array(), $allavailable = array()){
$rtype = $requirement['type'];
$rname = $requirement['name'];
$rvers = $requirement['version'];
$rvrop = $requirement['operation'];
// operation by default is ge.
if(!$rvrop) $rvrop = 'ge';
// This will check if the requirement is already met.
switch($rtype){
case 'library':
if(Core::IsLibraryAvailable($rname, $rvers, $rvrop)){
return true;
}
break;
case 'jslibrary':
if(Core::IsJSLibraryAvailable($rname, $rvers, $rvrop)){
return true;
}
break;
case 'component':
if(Core::IsComponentAvailable($rname, $rvers, $rvrop)){
return true;
}
break;
}
// Check the new components too. Those are already queued up to be installed.
// New components are squashed a little; all themes/components/core updates are lumped together.
foreach($newcomponents as $data){
// And provides is [type => "", name => "", version => ""].
foreach($data['provides'] as $prov){
if($prov['type'] == $rtype && $prov['name'] == $rname){
if(Core::VersionCompare($prov['version'], $rvers, $rvrop)){
// Yay, it's able to be provided by a package already set to be installed!
return true;
}
}
}
}
// Maybe it's in the set of available updates...
// First array is [core => ..., components => ..., themes => ...].
foreach($allavailable as $type => $availableset){
// Core doesn't count here!
if($type == 'core') continue;
if(!is_array($availableset)) continue;
// Next inner array will be [componentname => {its data}, ... ].
foreach($availableset as $data){
// And provides is [type => "", name => "", version => ""].
if(!isset($data['provides']) || !is_array($data['provides'])){
continue;
}
foreach($data['provides'] as $prov){
if($prov['type'] == $rtype && $prov['name'] == $rname){
if(Core::VersionCompare($prov['version'], $rvers, $rvrop)){
// Yay, add this to the queue!
return $data;
}
}
}
}
}
// Requirement not met... ok. This needs to be conveyed to the calling script.
return false;
}
示例15: getAsFormElement
/**
* Transpose a populated form element from the underlying ConfigModel object.
* Will populate the name, options, validation, etc.
*
* @return \FormElement
*
* @throws \Exception
*/
public function getAsFormElement(){
// key is in the format of:
// /user/displayname/displayoptions
$key = $this->get('key');
$attributes = $this->getFormAttributes();
$val = \ConfigHandler::Get($key);
$type = $attributes['type'];
$el = \FormElement::Factory($type, $attributes);
if($type == 'radio'){
// Ensure that this matches what the radios will have.
if ($val == '1' || $val == 'true' || $val == 'yes') $val = 'true';
else $val = 'false';
}
if($this->get('type') == 'int' && $type == 'text'){
$el->validation = '/^[0-9]*$/';
$el->validationmessage = $attributes['group'] . ' - ' . $attributes['title'] . ' expects only whole numbers with no punctuation.';
}
if($type == 'checkboxes' && !is_array($val)){
// Convert the found value to an array so it matches what checkboxes are expecting.
$val = array_map('trim', explode('|', $val));
}
$el->set('value', $val);
// If multisite is enabled and this config is NOT set to overrideable, then set the field as read only!
if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled() && MultiSiteHelper::GetCurrentSiteID()){
if(!$this->get('overrideable')){
$el->set('readonly', true);
$el->set('disabled', true);
}
}
return $el;
}