Пример #1
0
 /**
  * CustomRequest constructor
  *
  * @param modX &$modx A reference to the modX instance.
  * @param array $config An array of configuration options. Optional.
  */
 function __construct(modX &$modx, array $config = array())
 {
     $this->modx =& $modx;
     $corePath = $this->modx->getOption('customrequest.core_path', NULL, MODX_CORE_PATH . 'components/customrequest/');
     /* loads some default paths for easier management */
     $this->config = array_merge(array('corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'pluginsPath' => $corePath . 'elements/plugins/', 'configsPath' => $this->modx->getOption('customrequest.configsPath', NULL, $corePath . 'configs/'), 'debug' => $this->modx->getOption('customrequest.debug', NULL, FALSE)), $config);
     $this->requests = $this->modx->fromJson($this->config['aliases']);
 }
Пример #2
0
 /**
  * RememberThis constructor
  *
  * @param modX $modx A reference to the modX instance.
  * @param array $options An array of options. Optional.
  */
 public function __construct(modX &$modx, array $options = array())
 {
     $this->modx =& $modx;
     $this->modx->lexicon->load('rememberthis:default');
     $corePath = $this->getOption('core_path', $options, $this->modx->getOption('core_path') . 'components/rememberthis/');
     $assetsPath = $this->getOption('assets_path', $options, $this->modx->getOption('assets_path') . 'components/rememberthis/');
     $assetsUrl = $this->getOption('assets_url', $options, $this->modx->getOption('assets_url') . 'components/rememberthis/');
     // Load some default paths for easier management
     $this->options = array_merge(array('namespace' => $this->namespace, 'version' => '1.1.6', 'assetsPath' => $assetsPath, 'assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'pagesPath' => $corePath . 'elements/pages/', 'snippetsPath' => $corePath . 'elements/snippets/', 'pluginsPath' => $corePath . 'elements/plugins/', 'processorsPath' => $corePath . 'processors/', 'templatesPath' => $corePath . 'templates/', 'cachePath' => $this->modx->getOption('core_path') . 'cache/', 'connectorUrl' => $assetsUrl . 'connector.php'), $options);
     // Load parameters
     $this->options = array_merge($this->options, array('wrapperTpl' => $this->getOption('wrapperTpl', $options, 'tplRememberThisWrapper'), 'noResultsTpl' => $this->getOption('noResultsTpl', $options, 'tplRememberThisNoResults'), 'scriptTpl' => $this->getOption('scriptTpl', $options, 'tplRememberThisScript'), 'showZeroCount' => intval($this->getOption('showZeroCount', $options, 1)), 'rowTpl' => $this->getOption('rowTpl', $options, 'tplRememberThisRow'), 'outerTpl' => $this->getOption('outerTpl', $options, 'tplRememberThisOuter'), 'addTpl' => $this->getOption('addTpl', $options, 'tplRememberThisAdd'), 'itemTitleTpl' => $this->getOption('itemTitleTpl', $options, 'tplRememberThisItemTitle'), 'packagename' => $this->getOption('packagename', null, ''), 'classname' => $this->getOption('classname', null, ''), 'keyname' => $this->getOption('keyname', null, 'id'), 'joins' => $this->modx->fromJson($this->getOption('joins', null, '')), 'jQueryPath' => $this->getOption('jQueryPath', null, ''), 'includeScripts' => intval($this->getOption('includeScripts', null, 1)), 'includeCss' => intval($this->getOption('includeCss', null, 1)), 'debug' => intval($this->getOption('debug', null, 0)), 'tvPrefix' => $this->getOption('tvPrefix', $options, 'tv.'), 'ajaxLoaderImg' => $this->getOption('ajaxLoaderImg', null, ''), 'language' => $modx->getOption('language', $options, $this->modx->getOption('cultureKey')), 'languages' => array('de', 'en'), 'notRememberRedirect' => intval($modx->getOption('notRememberRedirect', $options, false)), 'argSeparator' => $this->modx->getOption('xhtml_urls') ? '&' : '&', 'queryAdd' => $this->getOption('queryAdd', $options, 'add'), 'queryDelete' => $this->getOption('queryDelete', $options, 'delete'), 'useCookie' => intval($this->getOption('useCookie', null, 0)), 'cookieName' => $this->getOption('cookieName', $options, 'rememberlist'), 'cookieExpireDays' => intval($this->getOption('cookieExpireDays', $options, 90))));
     // Custom options
     $this->setOption('language', in_array($this->getOption('language'), $this->getOption('languages')) ? $this->getOption('language') : 'en');
     // Set script options
     $this->setOption('scriptOptions', array('connectorUrl' => $this->getOption('connectorUrl'), 'language' => $this->getOption('language')));
     if ($this->getOption('ajaxLoaderImg')) {
         $this->setOption('scriptOptions', array_merge($this->getOption('scriptOptions'), array('ajaxLoaderImg' => $this->getOption('ajaxLoaderImg'))));
     }
     if (!isset($_SESSION['rememberThis'])) {
         $_SESSION['rememberThis'] = array();
     }
 }
 /**
  * CustomRequest constructor
  *
  * @param modX $modx A reference to the modX instance.
  * @param array $options An array of options. Optional.
  */
 function __construct(modX &$modx, array $options = array())
 {
     $this->modx =& $modx;
     $this->modx->lexicon->load('customrequest:default');
     $corePath = $this->getOption('core_path', $options, $this->modx->getOption('core_path') . 'components/customrequest/');
     $assetsPath = $this->getOption('assets_path', $options, $this->modx->getOption('assets_path') . 'components/customrequest/');
     $assetsUrl = $this->getOption('assets_url', $options, $this->modx->getOption('assets_url') . 'components/customrequest/');
     // Load some default paths for easier management
     $this->options = array_merge(array('namespace' => $this->namespace, 'assetsPath' => $assetsPath, 'assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'pagesPath' => $corePath . 'elements/pages/', 'snippetsPath' => $corePath . 'elements/snippets/', 'pluginsPath' => $corePath . 'elements/plugins/', 'processorsPath' => $corePath . 'processors/', 'templatesPath' => $corePath . 'templates/', 'configsPath' => $this->getOption('configsPath', null, $corePath . 'configs/', true), 'cachePath' => $this->modx->getOption('core_path') . 'cache/', 'connectorUrl' => $assetsUrl . 'connector.php'), $options);
     // Load (system) properties
     $this->options = array_merge($this->options, array('debug' => $this->getOption('debug', null, false)));
     $this->modx->addPackage('customrequest', $this->getOption('modelPath'));
     if (isset($this->options['aliases'])) {
         $this->requests = $this->modx->fromJson($this->options['aliases'], true);
     }
     if (!$this->requests) {
         $this->requests = array();
     }
     // Import old config files if no configuration is set
     if (!$this->modx->getCount('CustomrequestConfigs')) {
         $i = 0;
         $configFiles = glob($this->getOption('configsPath') . '*.config.inc.php');
         // Import old config files
         foreach ($configFiles as $configFile) {
             // $settings will be defined in each config file
             $settings = array();
             include $configFile;
             foreach ($settings as $key => $setting) {
                 // fill urlParams if defined
                 $urlParams = isset($setting['urlParams']) && is_array($setting['urlParams']) ? $setting['urlParams'] : array();
                 $regEx = isset($setting['regEx']) ? $setting['regEx'] : '';
                 if (isset($setting['alias'])) {
                     // if alias is defined, calculate the other values
                     if (isset($setting['resourceId'])) {
                         $resourceId = $setting['resourceId'];
                     } elseif ($res = $this->modx->getObject('modResource', array('uri' => $setting['alias']))) {
                         $resourceId = $res->get('id');
                     } else {
                         // if resourceId could not be calculated, don't use that setting
                         if ($this->getOption('debug')) {
                             $this->modx->log(modX::LOG_LEVEL_INFO, 'CustomRequest Plugin: Could not calculate the resourceId for the given alias');
                         }
                         break;
                     }
                     $alias = $setting['alias'];
                 } elseif (isset($setting['resourceId'])) {
                     $resourceId = $setting['resourceId'];
                     if (isset($setting['alias'])) {
                         $alias = $setting['alias'];
                     } else {
                         $alias = '';
                     }
                 }
                 $config = $this->modx->newObject('CustomrequestConfigs');
                 $config->fromArray(array('name' => ucfirst($key), 'menuindex' => $i, 'alias' => $alias, 'resourceid' => $resourceId, 'urlparams' => json_encode($urlParams), 'regex' => $regEx));
                 $config->save();
                 $i++;
             }
         }
         return;
     }
 }
$props = $modx->fromJson(file_get_contents(dirname(__FILE__) . '/config/config.json'));
$props['install.options'] = '1';
$props['packageName'] = $modx->getOption('package', $props);
$props['packageNameLower'] = strtolower($modx->getOption('package', $props));
//$props['targetRoot'] = $modx->getOption('assets_path') . 'mypackages/' . $props['packageNameLower'] . '/';
//$props = isset($configArray) ? $configArray : false;
if (!is_array($props)) {
    session_write_close();
    die($modx->lexicon('mc_no_config_file'));
}
$criticalSettings = array('packageNameLower', 'packageName', 'version', 'release');
foreach ($criticalSettings as $setting) {
    if (!isset($setting)) {
        session_write_close();
        die($modx->lexicon('mc_critical_setting_not_set') . ': ' . $setting);
    }
}
if (strpos($props['packageNameLower'], '-') || strpos($props['packageNameLower'], ' ')) {
    session_write_close();
    die($modx->lexicon("mc_space_hyphen_warning"));
}
/* Set package info. These are initially set from the the the project config
* but feel free to hard-code them for future versions */
define('PKG_NAME', $props['packageName']);
define('PKG_NAME_LOWER', $props['packageNameLower']);
define('PKG_VERSION', $props['version']);
define('PKG_RELEASE', $props['release']);
/* define sources */
$root = dirname(dirname(__FILE__)) . '/';
$sources = array('root' => $root, 'build' => $root . '_build/', 'config' => $root . '_build/config/', 'utilities' => $root . '_build/utilities/', 'source_core' => $root . 'core/components/' . PKG_NAME_LOWER, 'source_core_model' => $root . 'core/model/', 'source_assets' => $root . 'assets/components/' . PKG_NAME_LOWER, 'resolvers' => $root . '_build/resolvers/', 'validators' => $root . '_build/validators/', 'data' => $root . '_build/data/', 'docs' => $root . 'core/components/' . PKG_NAME_LOWER . '/docs/', 'install_options' => $root . '_build/install.options/', 'subpackages' => $root . '_build/subpackages/');
unset($root);
$packagepath = $sources['source_core'] . '/';
$categories = (include $sources['build'] . 'config/categories.php');
if (empty($categories) || !is_array($categories)) {
    //if no category was found, we create a category with the package-name
    $categories = array();
    $category = array('category' => PKG_NAME);
    $categories[] = $category;
    //session_write_close();
    //die($modx->lexicon('no_categories'));
}
$menuprops = isset($props['menus']) ? $modx->fromJson($props['menus']) : '';