예제 #1
0
 /**
  * Override the parent function to get our special properties.
  * @param string $namespace
  * @return array
  */
 public function getProperties($namespace = 'core')
 {
     $properties = parent::getProperties($namespace);
     //$this->xpdo->log(1, print_r($properties,true));
     if (!empty($properties)) {
         return $properties;
     }
     // Properties defaults
     $properties = array('product_type' => 'regular', 'product_template' => $this->xpdo->getOption('moxycart.default_product_template', '', $this->xpdo->getOption('default_template')), 'sort_order' => 'name', 'qty_alert' => 0, 'track_inventory' => 0, 'specs' => array(), 'variations' => array(), 'taxonomies' => array());
     return $properties;
 }
    /**
     * @param modManagerController $controller
     * @param modResource $resource
     */
    public function loadManagerFiles(modManagerController $controller, modResource $resource)
    {
        $modx23 = (int) $this->systemVersion();
        $cssUrl = $this->config['cssUrl'] . 'mgr/';
        $jsUrl = $this->config['jsUrl'] . 'mgr/';
        $properties = $resource->getProperties('modupdater');
        $controller->addLexiconTopic('modupdater:default');
        $controller->addJavascript($jsUrl . 'modupdater.js');
        $controller->addLastJavascript($jsUrl . 'misc/utils.js');
        $controller->addCss($cssUrl . 'main.css');
        if (!$modx23) {
            $controller->addCss($cssUrl . 'font-awesome.min.css');
        }
        $controller->addHtml('
		<script type="text/javascript">
			MODx.modx23 = ' . $modx23 . ';
			modUpdater.config = ' . $this->modx->toJSON($this->config) . ';
			modUpdater.config.resID = ' . $resource->id . ';
            modUpdater.config.connector_url = "' . $this->config['connectorUrl'] . '";
		</script>', true);
        $controller->addLastJavascript($jsUrl . 'widgets/items.windows.js');
    }
예제 #3
0
    /**
     * @param modManagerController $controller
     * @param modResource $resource
     */
    public function loadManagerFiles(modManagerController $controller, modResource $resource)
    {
        $modx23 = (int) $this->systemVersion();
        $cssUrl = $this->config['cssUrl'] . 'mgr/';
        $jsUrl = $this->config['jsUrl'] . 'mgr/';
        $properties = $resource->getProperties('ms2gallery');
        if (empty($properties['media_source'])) {
            if (!($source_id = $resource->getTVValue('ms2Gallery'))) {
                /** @var modContextSetting $setting */
                $setting = $this->modx->getObject('modContextSetting', array('key' => 'ms2gallery_source_default', 'context_key' => $resource->get('context_key')));
                $source_id = !empty($setting) ? $setting->get('value') : $this->modx->getOption('ms2gallery_source_default');
            }
            $resource->setProperties(array('media_source' => $source_id), 'ms2gallery');
            $resource->save();
        } else {
            $source_id = $properties['media_source'];
        }
        if (empty($source_id)) {
            $source_id = $this->modx->getOption('ms2gallery_source_default');
        }
        $resource->set('media_source', $source_id);
        $controller->addLexiconTopic('ms2gallery:default');
        $controller->addJavascript($jsUrl . 'ms2gallery.js');
        $controller->addLastJavascript($jsUrl . 'misc/ms2.combo.js');
        $controller->addLastJavascript($jsUrl . 'misc/ms2.utils.js');
        $controller->addLastJavascript($jsUrl . 'misc/plupload/plupload.full.js');
        $controller->addLastJavascript($jsUrl . 'misc/ext.ddview.js');
        $controller->addLastJavascript($jsUrl . 'gallery.view.js');
        $controller->addLastJavascript($jsUrl . 'gallery.window.js');
        $controller->addLastJavascript($jsUrl . 'gallery.toolbar.js');
        $controller->addLastJavascript($jsUrl . 'gallery.panel.js');
        $controller->addCss($cssUrl . 'main.css');
        if (!$modx23) {
            $controller->addCss($cssUrl . 'font-awesome.min.css');
        }
        $source_config = array();
        /** @var modMediaSource $source */
        if ($source = $this->modx->getObject('modMediaSource', $source_id)) {
            $tmp = $source->getProperties();
            foreach ($tmp as $v) {
                $source_config[$v['name']] = $v['value'];
            }
        }
        $controller->addHtml('
		<script type="text/javascript">
			MODx.modx23 = ' . $modx23 . ';
			ms2Gallery.config = ' . $this->modx->toJSON($this->config) . ';
			ms2Gallery.config.media_source = ' . $this->modx->toJSON($source_config) . ';
		</script>');
        if ($this->modx->getOption('ms2gallery_new_tab_mode', null, true)) {
            $controller->addLastJavascript($jsUrl . 'tab.js');
        } else {
            $insert = '
				tabs.add({
					xtype: "ms2gallery-page",
					id: "ms2gallery-page",
					title: _("ms2gallery"),
					record: {
						id: ' . $resource->get('id') . ',
						source: ' . $source_id . ',
					}
				});
			';
            if ($this->modx->getCount('modPlugin', array('name' => 'AjaxManager', 'disabled' => false))) {
                $controller->addHtml('
				<script type="text/javascript">
					Ext.onReady(function() {
						window.setTimeout(function() {
							var tabs = Ext.getCmp("modx-resource-tabs");
							if (tabs) {
								' . $insert . '
							}
						}, 10);
					});
				</script>');
            } else {
                $controller->addHtml('
				<script type="text/javascript">
					Ext.ComponentMgr.onAvailable("modx-resource-tabs", function() {
						var tabs = this;
						tabs.on("beforerender", function() {
							' . $insert . '
						});
					});
				</script>');
            }
        }
    }
예제 #4
0
 /**
  * Get the properties for the specific namespace for the Resource
  *
  * @param string $namespace
  *
  * @return array
  */
 public function getProperties($namespace = 'tickets')
 {
     $properties = parent::getProperties($namespace);
     // Convert old settings
     if (empty($this->reloadOnly)) {
         $flag = false;
         $tmp = array('disable_jevix', 'process_tags', 'rating');
         if ($old = parent::get('properties')) {
             foreach ($tmp as $v) {
                 if (array_key_exists($v, $old)) {
                     $properties[$v] = $old[$v];
                     $flag = true;
                     unset($old[$v]);
                 }
             }
             if ($flag) {
                 $old['tickets'] = $properties;
                 $this->set('properties', $old);
                 $this->save();
             }
         }
     }
     // --
     if (empty($properties)) {
         /** @var TicketsSection $parent */
         if (!($parent = $this->getOne('Parent'))) {
             $parent = $this->xpdo->newObject('TicketsSection');
         }
         $default_properties = $parent->getProperties($namespace);
         if (!empty($default_properties)) {
             foreach ($default_properties as $key => $value) {
                 if (!isset($properties[$key])) {
                     $properties[$key] = $value;
                 } elseif ($properties[$key] === 'true') {
                     $properties[$key] = true;
                 } elseif ($properties[$key] === 'false') {
                     $properties[$key] = false;
                 } elseif (is_numeric($value) && $key == 'disable_jevix' || $key == 'process_tags') {
                     $properties[$key] = boolval(intval($value));
                 }
             }
         }
     }
     return $properties;
 }
예제 #5
0
 /**
  * Get the properties for the specific namespace for the Resource
  *
  * @param string $namespace
  *
  * @return array
  */
 public function getProperties($namespace = 'tickets')
 {
     $properties = parent::getProperties($namespace);
     if ($namespace == 'tickets') {
         $default_properties = array('template' => $this->xpdo->context->getOption('tickets.default_template', 0), 'uri' => '%id-%alias%ext', 'show_in_tree' => $this->xpdo->context->getOption('tickets.ticket_show_in_tree_default', false), 'hidemenu' => $this->xpdo->context->getOption('tickets.ticket_hidemenu_force', $this->xpdo->context->getOption('hidemenu_default')), 'disable_jevix' => $this->xpdo->context->getOption('tickets.disable_jevix_default', false), 'process_tags' => $this->xpdo->context->getOption('tickets.process_tags_default', false));
         // Old default values
         if (array_key_exists('tickets.ticket_id_as_alias', $this->xpdo->config)) {
             $default_properties['uri'] = $this->xpdo->context->getOption('tickets.ticket_id_as_alias') ? '%id' : '%alias';
             $default_properties['uri'] .= $this->xpdo->context->getOption('tickets.ticket_isfolder_force') ? '/' : '%ext';
         }
         foreach ($default_properties as $key => $value) {
             if (!isset($properties[$key])) {
                 $properties[$key] = $value;
             } elseif ($properties[$key] === 'true') {
                 $properties[$key] = true;
             } elseif ($properties[$key] === 'false') {
                 $properties[$key] = false;
             } elseif (is_numeric($value) && ($key == 'disable_jevix' || $key == 'process_tags')) {
                 $properties[$key] = (bool) intval($value);
             }
         }
     } elseif ($namespace == 'ratings') {
         $default_properties = array('ticket' => $this->xpdo->context->getOption('tickets.rating_ticket_default', 10), 'comment' => $this->xpdo->context->getOption('tickets.rating_comment_default', 1), 'view' => $this->xpdo->context->getOption('tickets.rating_view_default', 0.1), 'vote_ticket' => $this->xpdo->context->getOption('tickets.rating_vote_ticket_default', 1), 'vote_comment' => $this->xpdo->context->getOption('tickets.rating_vote_comment_default', 0.2), 'star_ticket' => $this->xpdo->context->getOption('tickets.rating_star_ticket_default', 3), 'star_comment' => $this->xpdo->context->getOption('tickets.rating_star_comment_default', 0.6));
         foreach ($default_properties as $key => $value) {
             if (!isset($properties[$key])) {
                 $properties[$key] = $value;
             }
         }
     }
     return $properties;
 }