public final function __construct(&$modx, &$helpers, $fields, $mode = MODE_BOOTSTRAP)
 {
     parent::__construct($modx, $helpers);
     if (is_array($fields)) {
         $this->myFields = $fields;
     }
 }
 public static function createTransportFiles(&$helpers, $mode = MODE_BOOTSTRAP)
 {
     /* @var $helpers Helpers */
     $helpers->sendLog(modX::LOG_LEVEL_INFO, "\n" . '    ' . $helpers->modx->lexicon('mc_processing_system_settings'));
     $settings = $helpers->modx->getOption('newSystemSettings', ObjectAdapter::$myObjects, array());
     parent::createTransportFile($helpers, $settings, '', 'modSystemSetting', $mode);
 }
 public final function __construct(&$modx, &$helpers, $fields, $mode = MODE_BOOTSTRAP)
 {
     parent::__construct($modx, $helpers);
     if (is_array($fields)) {
         if (isset($fields['lang_topics']) && empty($fields['lang_topics'])) {
             $fields['lang_topics'] = $this->helpers->props['packageNameLower'] . ':default';
         }
     }
     $this->myFields = $fields;
 }
 function __construct(&$modx, &$helpers, $fields, $createChildren = false)
 {
     /* @var $helpers Helpers */
     $this->myComponent =& $component;
     $this->modx =& $modx;
     $this->helpers =& $helpers;
     $this->myFields = $fields;
     $this->name = $fields['name'];
     ObjectAdapter::$myObjects['nameSpaces'][] = $fields;
     parent::__construct($modx, $helpers);
 }
 public function addToMODx($overwrite = false)
 {
     /* create category if necessary */
     $fields = $this->myFields;
     if (isset($fields['parent']) && !empty($fields['parent'])) {
         $pn = $fields['parent'];
         if (!is_numeric($fields['parent'])) {
             $p = $this->modx->getObject('modCategory', array('category' => $pn));
             if ($p) {
                 $fields['parent'] = $p->get('id');
             }
         }
     } else {
         $fields['parent'] = '0';
     }
     $this->myFields = $fields;
     parent::addToModx($overwrite);
 }
 public final function __construct(&$modx, $helpers, $fields, $mode = MODE_BOOTSTRAP)
 {
     /* @var $modx modX */
     /* @var $helpers Helpers */
     parent::__construct($modx, $helpers);
     if (is_array($fields)) {
         if (!isset($fields['namespace'])) {
             $fields['namespace'] = $this->helpers->getProp('packageNameLower');
         }
         $this->myFields = $fields;
         $actionFields = $modx->getOption('action', $fields, array());
         if (empty($actionFields)) {
             $helpers->sendLog(modX::LOG_LEVEL_ERROR, '    ' . $this->modx->lexicon('mc_menu_has_no_action'));
             return;
         }
         if (empty($actionFields['namespace'])) {
             $helpers->sendLog(modX::LOG_LEVEL_ERROR, '    ' . $this->modx->lexicon('mc_menu_action_no_namespace'));
             return;
         }
         ObjectAdapter::$myObjects['menus'][] = $fields;
         $this->myFields = $fields;
     }
 }
 /**
  * Handle static elements before ObjectAdapter
  * adds to MODX
  *
  * @param bool $overwrite
  * @return bool|int
  */
 public function addToMODx($overwrite = false)
 {
     unset($this->myFields['propertySets']);
     $fields = $this->myFields;
     $class = $this->getClass();
     $allStatic = $this->modx->getOption('allStatic', $this->helpers->props, false);
     if ($class != 'modPropertySet' && $class != 'modPlugin' && $allStatic) {
         $fields['static'] = true;
     }
     /* Handle static elements */
     if (isset($fields['static']) && !empty($fields['static'])) {
         $projectDir = str_replace(MODX_ASSETS_PATH . 'mycomponents/', '', $this->helpers->props['targetRoot']);
         $dir = 'assets/mycomponents/';
         $dir .= $projectDir . 'core/components/' . $this->helpers->props['packageNameLower'] . '/';
         $path = $this->helpers->getCodeDir($dir, $this->dbClass);
         if (isset($this->myFields['filename'])) {
             $fileName = $this->myFields['filename'];
         } else {
             $fileName = $this->helpers->getFileName($this->getName(), $this->dbClass);
         }
         $path .= '/' . $fileName;
         $this->myFields['source'] = $this->modx->getOption('default_media_source');
         $this->myFields['static_file'] = $path;
         $this->helpers->sendLog(modX::LOG_LEVEL_INFO, '        ' . $this->modx->lexicon('mc_set_static_path_to') . ' ' . $path);
     }
     return parent::addToMODx($overwrite);
 }
 /**
  * Export all MODX objects in the package to the appropriate
  * code files. Most objects are selected by namespace or category,
  * with the exception of resources, which are specified in the project
  * config file.
  *
  * Only object types in the 'process' member of the config file are
  * processed.
  */
 public function exportComponent()
 {
     //Only run if MC is installed
     if (!$this->isMCInstalled()) {
         $this->helpers->sendLog(modX::LOG_LEVEL_ERROR, '[MyComponentProject] ' . $this->modx->lexicon('mc_mycomponent_not_installed_export'));
         return;
     }
     ObjectAdapter::$myObjects = array();
     $this->helpers->sendLog(modX::LOG_LEVEL_INFO, $this->modx->lexicon('mc_action') . ': ' . $this->modx->lexicon('mc_export_objects'));
     $mode = MODE_EXPORT;
     $toProcess = $this->modx->getOption('process', $this->props, array());
     $this->createNamespaces($mode);
     if (in_array('contexts', $toProcess)) {
         $this->createContexts($mode);
     }
     if (in_array('contextSettings', $toProcess)) {
         $this->createContextSettings($mode);
     }
     if (in_array('systemSettings', $toProcess)) {
         $this->createNewSystemSettings($mode);
     }
     if (in_array('systemEvents', $toProcess)) {
         $this->createNewSystemEvents($mode);
     }
     $this->createCategories($mode);
     if (in_array('resources', $toProcess)) {
         $this->createResources($mode);
     }
     $this->createResolvers($mode);
     $this->createTransportFiles($mode);
     if ($this->modx->getOption('minifyJS', $this->props, false)) {
         $this->helpers->minifyJs();
     }
     $this->helpers->sendLog(modX::LOG_LEVEL_INFO, "\n" . $this->modx->lexicon('mc_updating_project_config'));
     $this->updateProjectConfig(MODE_EXPORT);
 }