Ejemplo n.º 1
0
    /**
     * Register custom CSS/JS for the page
     *
     * @return void
     */
    public function loadCustomCssJs()
    {
        $html = $this->head['html'];
        parent::loadCustomCssJs();
        $this->head['html'] = $html;
        if (is_null($this->resourceArray['properties'])) {
            $this->resourceArray['properties'] = array();
        }
        $this->resourceArray['properties']['tickets'] = $this->resource->getProperties('tickets');
        $this->resourceArray['properties']['ratings'] = $this->resource->getProperties('ratings');
        $this->resourceArray['syncsite'] = 0;
        /** @var Tickets $Tickets */
        $Tickets = $this->modx->getService('Tickets');
        $Tickets->loadManagerFiles($this, array('config' => true, 'utils' => true, 'css' => true, 'section' => true));
        $this->addLastJavascript($Tickets->config['jsUrl'] . 'mgr/section/create.js');
        $ready = array('xtype' => 'tickets-page-section-create', 'record' => $this->resourceArray, 'publish_document' => (int) $this->canPublish, 'canSave' => (int) $this->canSave, 'show_tvs' => (int) (!empty($this->tvCounts)), 'mode' => 'create');
        $this->addHtml('
		<script type="text/javascript">
		// <![CDATA[
		MODx.config.publish_document = ' . (int) $this->canPublish . ';
		MODx.onDocFormRender = "' . $this->onDocFormRender . '";
		MODx.ctx = "' . $this->ctx . '";
		Ext.onReady(function() {
			MODx.load(' . $this->modx->toJSON($ready) . ');
		});
		// ]]>
		</script>');
    }
Ejemplo n.º 2
0
 /**
  * @return mixed
  */
 public function setFieldDefaults()
 {
     $set = parent::setFieldDefaults();
     // Ticket properties
     $properties = $this->modx->context->key == 'mgr' ? $this->getProperty('properties') : $this->parentResource->getProperties();
     $this->unsetProperty('properties');
     // Define introtext
     $introtext = $this->getProperty('introtext');
     if (empty($introtext)) {
         $introtext = $this->object->getIntroText($this->getProperty('content'), false);
     }
     if (empty($properties['disable_jevix'])) {
         $introtext = $this->object->Jevix($introtext);
     }
     $createdon = time();
     // Redefine main parameters if we are not in the manager
     if ($this->modx->context->key == 'mgr') {
         $template = $this->getProperty('template');
         $hidemenu = $this->getProperty('hidemenu');
         $show_in_tree = $this->getProperty('show_in_tree');
         $createdby = $this->getProperty('createdby');
         $published = $this->getProperty('published');
         $publishedon = $this->getProperty('publishedon', $createdon);
         $publishedby = $this->getProperty('publishedby', $createdby);
     } else {
         $template = $properties['template'];
         $hidemenu = $properties['hidemenu'];
         $show_in_tree = $properties['show_in_tree'];
         $createdby = $this->modx->user->id;
         $published = $this->_published;
         $publishedon = $this->_published ? $createdon : 0;
         $publishedby = $this->modx->user->id;
     }
     if (empty($template)) {
         $template = $this->modx->context->getOption('tickets.default_template', $this->modx->context->getOption('default_template'));
     }
     $tmp = array('disable_jevix' => !empty($properties['disable_jevix']), 'process_tags' => !empty($properties['process_tags']));
     if (empty($published)) {
         $tmp['was_published'] = false;
     } else {
         $this->_sendEmails = true;
     }
     // Set properties
     $this->setProperties(array('class_key' => 'Ticket', 'published' => $published, 'createdby' => $createdby, 'createdon' => $createdon, 'publishedby' => $publishedby, 'publishedon' => $publishedon, 'syncsite' => 0, 'template' => $template, 'introtext' => $introtext, 'hidemenu' => $hidemenu, 'show_in_tree' => $show_in_tree, 'properties' => array('tickets' => $tmp)));
     return $set;
 }