Example #1
0
 public function dbSave()
 {
     if (!$this->hook->hasErrors()) {
         // exclude fields from database save
         $this->excludeFields();
         $formDataResponse = $this->modx->runProcessor('mgr/formz/form/data/create', array('form_id' => $this->config->formid), array('processors_path' => $this->config->processorPath));
         if ($formDataResponse->isError()) {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'An error occurred while trying to save the Form: ' . $formDataResponse->getMessage());
         }
         $formData = $formDataResponse->getObject();
         // Save Fields
         foreach ($this->config->data as $field => $value) {
             if (is_array($value)) {
                 switch ($this->formArray[$field]['type']) {
                     case 'select':
                     case 'radio':
                         $value = implode('', $value);
                         break;
                 }
             }
             $formDataFieldResponse = $this->modx->runProcessor('mgr/formz/field/data/create', array('data_id' => $formData['id'], 'label' => $this->formArray[$field]['label'], 'value' => serialize($value)), array('processors_path' => $this->config->processorPath));
             if ($formDataFieldResponse->isError()) {
                 $this->modx->log(modX::LOG_LEVEL_ERROR, 'An error occurred while trying to save the Form: ' . $formDataFieldResponse->getMessage());
             }
         }
     }
     return true;
 }
 /**
  * Shorthand for the call of processor
  *
  * @access public
  *
  * @param string $action Path to processor
  * @param array $data Data to be transmitted to the processor
  *
  * @return mixed The result of the processor
  */
 public function runProcessor($action = '', $data = array())
 {
     if (empty($action)) {
         return false;
     }
     return $this->modx->runProcessor($action, $data, array('processors_path' => $this->config['processorsPath']));
 }
Example #3
0
 /**
  * @param string $action
  * @param array $scriptProperties
  * @param array $options
  *
  * @return array
  */
 public function runProcessor($action = '', $scriptProperties = array(), $options = array())
 {
     $this->pdoTools->debugParserMethod('runProcessor', $action, $scriptProperties);
     /** @var modProcessorResponse $response */
     $response = $this->modx->runProcessor($action, $scriptProperties, $options);
     $this->pdoTools->debugParserMethod('runProcessor', $action, $scriptProperties);
     return array('success' => !$response->isError(), 'message' => $response->getMessage(), 'response' => $response->getResponse(), 'errors' => $response->getFieldErrors());
 }
 /**
  * Delete or restore uploaded file
  *
  * @param $id
  *
  * @return array|string
  */
 public function fileRemove($id)
 {
     if (!$this->authenticated) {
         return $this->error('ms2galleryform_err_access_denied');
     }
     /** @var modProcessorResponse $response */
     $response = $this->modx->runProcessor('web/gallery/remove', array('id' => $id), array('processors_path' => $this->config['corePath'] . 'processors/'));
     if ($response->isError()) {
         return $this->error($response->getMessage());
     }
     return $this->success();
 }
$signature = $builder->getSignature();
if (defined('PKG_AUTO_INSTALL') && PKG_AUTO_INSTALL) {
    $sig = explode('-', $signature);
    $versionSignature = explode('.', $sig[1]);
    /* @var modTransportPackage $package */
    if (!($package = $modx->getObject('transport.modTransportPackage', array('signature' => $signature)))) {
        $package = $modx->newObject('transport.modTransportPackage');
        $package->set('signature', $signature);
        $package->fromArray(array('created' => date('Y-m-d h:i:s'), 'updated' => null, 'state' => 1, 'workspace' => 1, 'provider' => 0, 'source' => $signature . '.transport.zip', 'package_name' => $sig[0], 'version_major' => $versionSignature[0], 'version_minor' => !empty($versionSignature[1]) ? $versionSignature[1] : 0, 'version_patch' => !empty($versionSignature[2]) ? $versionSignature[2] : 0));
        if (!empty($sig[2])) {
            $r = preg_split('/([0-9]+)/', $sig[2], -1, PREG_SPLIT_DELIM_CAPTURE);
            if (is_array($r) && !empty($r)) {
                $package->set('release', $r[0]);
                $package->set('release_index', isset($r[1]) ? $r[1] : '0');
            } else {
                $package->set('release', $sig[2]);
            }
        }
        $package->save();
    }
    if ($package->install()) {
        $modx->runProcessor('system/clearcache');
    }
}
if (!empty($_GET['download'])) {
    echo '<script>document.location.href = "/core/packages/' . $signature . '.transport.zip' . '";</script>';
}
$modx->log(modX::LOG_LEVEL_INFO, "\n<br />Execution time: {$totalTime}\n");
if (!XPDO_CLI_MODE) {
    echo '</pre>';
}
Example #6
0
 /**
  * @param string $action
  * @param array $scriptProperties
  * @param array $options
  */
 public function runProcessor($action = '', $scriptProperties = array(), $options = array())
 {
     $this->debugParser('runProcessor', $action, $scriptProperties);
     $this->modx->runProcessor($action, $scriptProperties, $options);
     $this->debugParser('runProcessor', $action, $scriptProperties);
 }
 public function runProcessor($action = '', $scriptProperties = array(), $location = '')
 {
     $path = $this->getOption('processorsPath');
     return $this->modx->runProcessor($action, $scriptProperties, array('processors_path' => $path, 'location' => $location));
 }
Example #8
0
    exit;
}
$modx = new modX();
$modx->initialize('web');
$modx->getRequest();
$modx->request->loadErrorHandler();
function get_filter_categories()
{
    global $modx;
    $modelpath = $modx->config['core_path'] . 'components/tag_manager2/model/';
    $modx->addPackage('tag_manager2', $modelpath);
    $f_categories = array();
    $c = $modx->newQuery("tagManager");
    $c->select(array('id', 'category'));
    $c->groupby('category');
    if ($c->prepare() && $c->stmt->execute()) {
        while ($row = $c->stmt->fetch(PDO::FETCH_ASSOC)) {
            array_push($f_categories, $row['category']);
        }
    }
    return $f_categories;
}
$f_categories = get_filter_categories();
foreach ($f_categories as $f_category) {
    $response = $modx->runProcessor('updatefilters', array('parent_id' => $f_category, 'clear_cache' => false), array('processors_path' => $modx->config['core_path'] . 'components/tag_manager2/processors/mgr/'));
    if ($response->isError()) {
        echo $response->getMessage();
        exit;
    }
}
echo 'OK';
Example #9
0
 /**
  * @param $action
  * @param array $data
  *
  * @return mixed
  */
 public function runProcessor($action, array $data)
 {
     $this->modx->error->reset();
     return $this->modx->runProcessor($action, $data, array('processors_path' => $this->config['processorsPath']));
 }