Adds the survey compare form to the current table, showing the matches between different surveys

@param $tableBody \MUtil_Html Table object
@param $post array List of Post data
178193
public function addSurveyCompareForm($tableBody, $post) {
        if ($this->sourceSurveyId && $this->targetSurveyId) {
            $sourceSurveyData = $this->getSurveyData($this->sourceSurveyId);
            $targetSurveyData = $this->getSurveyData($this->targetSurveyId);
            $surveyCompare    = $this->getSurveyCompare($sourceSurveyData, $targetSurveyData, $post);

            $icon = \MUtil_Html::create()->i(['class' => 'fa fa-exclamation-triangle', 'style' => 'color: #d43f3a; margin: 1em;', 'renderClosingTag' => true]);

            foreach ($surveyCompare as $question) {
                if ($question['status'] == 'missing') {
                    continue;
                }
                $rowMessage  = false;
                $statusClass = '';

                if (isset($this->questionStatusClasses[$question['status']])) {
                    $statusClass = $this->questionStatusClasses[$question['status']];
                }

                if ($question['status'] == 'type-difference') {
                    $rowMessage = $this->_('Question type is not the same. Check compatibility!');
                } elseif ($question['status'] == 'new') {
                    $rowMessage = $this->_('Question could not be found in source. Is this a new question?');
                } /*elseif ($question['status'] == 'missing') {
                    $rowMessage = $this->_('Warning! Question not found in target survey. Data will be lost on transfer');
                }*/

                $row = $tableBody->tr(['class' => $statusClass]);
                $row->td($question['target']);

                // Source column
                $row->td($this->getSurveyQuestionSelect($sourceSurveyData, $question['source'], $question['target']));

                // Target column
                if (isset($targetSurveyData[$question['target']])) {
                    $row->td($targetSurveyData[$question['target']]['question']);
                } else {
                    $row->td();
                }

                if ($rowMessage) {
                    $tableBody->tr(['class' => $statusClass])->td(['colspan' => 3])->append($icon, $rowMessage);
                }
            }
        }
    }
1117624
protected function addColumns(\MUtil_Html_TableElement $table)
    {
        $table->addColumn(
                array(\MUtil_Html::raw($this->repeater->key), 'class' => $this->repeater->class),
                $this->_('Question code')
                );
        $table->addColumn(
                array(\MUtil_Html::raw($this->repeater->question), 'class' => $this->repeater->class),
                $this->_('Question')
                );
        $table->addColumn(
                $this->repeater->answers->call($this, 'showAnswers', $this->repeater->answers),
                $this->_('Answer options')
                );
        // $table->addColumn($this->repeater->type, 'Type');
    }
751388
public function change()
    {
        $table = $this->table('polls');
        $table->addColumn('author', 'string', array('limit' => 16))
              ->addColumn('question', 'string')
              ->addColumn('ended', 'boolean', array('null' => false, 'default' => 0))
              ->addColumn('bottom', 'boolean', array('null' => false, 'default' => 0))
              ->addColumn('hide_results', 'boolean', array('null' => false, 'default' => 0))
              ->create();

        $table->addForeignKey('author', 'user', 'user', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->save();

        $table = $this->table('polls_option');
        $table->addColumn('poll', 'integer')
              ->addColumn('text', 'string')
              ->create();

        $table->addForeignKey('poll', 'polls', 'id', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->save();

        $table = $this->table('polls_response');
        $table->addColumn('poll', 'integer')
              ->addColumn('option', 'integer')
              ->addColumn('ip', 'string')
              ->addColumn('useragent', 'string')
              ->create();

        $table->addForeignKey('poll', 'polls', 'id', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->addForeignKey('option', 'polls_option', 'id', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->save();

        $table = $this->table('article_polls');
        $table->addColumn('poll', 'integer')
              ->addColumn('article', 'integer')
              ->create();

        $table->addForeignKey('poll', 'polls', 'id', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->addForeignKey('article', 'article', 'id', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->save();

    }
791813
public function compare($fromTables, $toTables, array $protectedTableNames, $force = false)
    {
        if ($this->response !== null && $force === false) {
            return $this->getResponse();
        }
        if ($force === false) {
            $this->setIgnoredChanges();
        }

        $this->checkTables($fromTables, $toTables);

        // If we have diffs, check if they need to be modified
        if ($this->diffs !== null) {
            $this->adjustDiffs($protectedTableNames);
            $this->addAlterResponses();
        }

        return $this->getResponse();
    }
1019261
protected function loadSurvey()
    {
        if (! $this->surveyList) {
            $this->addMessageInvalid($this->_('Survey insertion impossible: no insertable survey exists!'));
        }
        if (count($this->surveyList) === 1) {
            $model = $this->getModel();
            $model->set('gto_id_survey', 'elementClass', 'Exhibitor');

            reset($this->surveyList);
            $this->formData['gto_id_survey'] = key($this->surveyList);
        }

        if (isset($this->formData['gto_id_survey'])) {
            $this->survey = $this->tracker->getSurvey($this->formData['gto_id_survey']);

            $groupId = $this->survey->getGroupId();
            $groups  = $this->util->getDbLookup()->getGroups();
            if (isset($groups[$groupId])) {
                $this->formData['ggp_name'] = $groups[$groupId];
            }

            $this->formData['gto_valid_until'] = $this->survey->getInsertDateUntil($this->formData['gto_valid_from']);
        }
    }
185142
public function insert(Google_Service_Surveys_Survey $postBody, $optParams = array())
  {
    $params = array('postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('insert', array($params), "Google_Service_Surveys_Survey");
  }
1333662
public function save_meta( $post_id, $post ) {

		$this->post = $post;
		$data       = $this->get_data();

		if ( ! $this->is_active() || empty( $data ) ) {
			return;
		}

		// save compiled data
		update_post_meta( $post_id, $this->slug, $data );
		$data = call_user_func_array( 'array_merge', $data );

		foreach ( $data as $meta_key => $meta_value ) {

			$this->save_meta_data( $meta_key, $meta_value );
		}

	}
249603
protected function getCategorizedResults($post, $sourceSurveyData, $targetSurveyData) {
        $surveyCompare = $this->getSurveyCompare($sourceSurveyData, $targetSurveyData, $post);

        $categorizedResults = [];
        foreach (array_keys($this->questionStatusClasses) as $status) {
            $categorizedResults[$status] = [];
        }

        foreach ($surveyCompare as $result) {
            if (isset($result['status'])) {
                if ($result['status'] == 'missing') {
                    $categorizedResults[$result['status']][$result['source']] = $result;
                } else {
                    $categorizedResults[$result['status']][$result['target']] = $result;
                }
            } else {
                $categorizedResults['other'][] = $result;
            }
        }
        return $categorizedResults;
    }
884971
public function add_issue_to_table(&$table, $issueresult, $detailed = false) {
        global $OUTPUT;
        $statusarr = array(self::REPORT_PERFORMANCE_OK => 'statusok',
                        self::REPORT_PERFORMANCE_WARNING => 'statuswarning',
                        self::REPORT_PERFORMANCE_SERIOUS => 'statusserious',
                        self::REPORT_PERFORMANCE_CRITICAL => 'statuscritical');

        $row = array();
        if ($detailed) {
            $row[0] = $this->doc_link($issueresult->issue, $issueresult->name);
        } else {
            $url = new moodle_url('/report/performance/index.php', array('issue' => $issueresult->issue));
            $row[0] = html_writer::link($url, $issueresult->name);
        }
        $row[1] = html_writer::tag('span', $issueresult->statusstr, array('class' => $statusarr[$issueresult->status]));
        $row[2] = $issueresult->comment;
        if (!empty($issueresult->configlink)) {
            $editicon = $OUTPUT->pix_icon('i/settings', $issueresult->issue);
            $row[3] = $OUTPUT->action_link($issueresult->configlink, $editicon);
        } else {
            $row[3] = '';
        }

        $table->data[] = $row;
    }
227192
public function register(array $post = [])
    {
        $tables = $this->getTables();
        $registerParams = $tables['register'];

        if (count($registerParams) === count($post)) {
            $inputValues = array_values($post);
            if (count(array_diff($inputValues, $registerParams)) > 0) {
                throw new RegisterArgumentsException(sprintf('Register parametreleriniz %s dosyasındakilerle aynı olmalıdır.', self::USER_FILE));
            } else {
                $db = $this->getDb();

                $insert = $db->insert($post);

                return ($insert->isSuccess()) ? true : false;
            }
        } else {
            throw new RegisterArgumentsException('Register parametreleriniz %s dosyasındakilerle aynı olmalıdır.', self::USER_FILE);
        }

    }
1083607
public function updatePostViewCount($post)
    {
        $post->increaseViewCounter();
        $this->om->persist($post);
        $this->om->flush();
    }
156094
public function check(Table $table)
    {
        $columns = $table->getColumns();
        $filters = $table->getFilters();
        $successfulFilters = [];
        foreach ($filters as $id => $filterData) {
            $successfulNames = [];
            foreach ($filterData as $name => $value) {
                $test = $this->checkFilter($name, $columns[$id]['type'], $value, null);
                if ($test !== null)
                    $successfulNames[$name] = $value;
            }
            if (count($successfulNames) > 0)
                $successfulFilters[$id] = $successfulNames;
        }
        $table->setFilters($successfulFilters);
    }
1126961
public function insert(Fusiontables_Table $postBody, $optParams = array())
  {
    $params = array('postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('insert', array($params), "Fusiontables_Table");
  }
321807
protected function addPostData(RequestInterface $request, array $body)
    {
        static $fields = ['string' => true, 'array' => true, 'NULL' => true,
            'boolean' => true, 'double' => true, 'integer' => true];

        $post = new PostBody();
        foreach ($body as $key => $value) {
            if (isset($fields[gettype($value)])) {
                $post->setField($key, $value);
            } elseif ($value instanceof PostFileInterface) {
                $post->addFile($value);
            } else {
                $post->addFile(new PostFile($key, $value));
            }
        }

        if ($request->getHeader('Content-Type') == 'multipart/form-data') {
            $post->forceMultipartUpload(true);
        }

        $request->setBody($post);
    }
74351
protected function addPostReferences(&$post, $data)
    {
        $typeMap = array(
            'user' => ReferenceType::USER,
            'page' => ReferenceType::PAGE,
            'group' => ReferenceType::GROUP,
            'application' => ReferenceType::APPLICATION,
        );

        if (!isset($data['message_tags'])) {
            return;
        }

        foreach ($data['message_tags'] as $messageTagGroup) {
            if (isset($messageTagGroup['offset'])) {
                $messageTag = $messageTagGroup;
                $reference = new Reference();
                $reference
                    ->setIndices(array($messageTag['offset'], $messageTag['offset'] + $messageTag['length']))
                    //->setType($typeMap[$messageTag['type']])
                    ->setData($messageTag);

                $post->addReference($reference);
            } else {
                foreach ($messageTagGroup as $messageTag) {
                    $reference = new Reference();
                    $reference
                        ->setIndices(array($messageTag['offset'], $messageTag['offset'] + $messageTag['length']))
                        ->setType($typeMap[$messageTag['type']])
                        ->setData($messageTag);

                    $post->addReference($reference);
                }
            }
        }
    }
1223379
public function render( \WP_Post $post ){
        $this->nonce_field();
        $this->desc();
        echo '<table class="table form-table wpametu-meta-table">';
        foreach( $this->loop_fields() as $field ){
            if( !is_wp_error($field) ){
                /** @var \WPametu\UI\Field\Base $field */
                $field->render($post);
            }else{
                /** @var \WP_Error $field */
                printf('<div class="error"><p>%s</p></div>', $field->get_error_message());
            }
        }
        echo '</table>';
    }
649931
public function output_edit_form( $post ) {
		$params = $this->get_edit_form_params( $post );
		$this->before_output_edit_form( $post, $params );
		$this->add_style_view( 'admin/style/custom_post', $params );
		$this->add_style_view( 'admin/style/custom_post/' . $this->get_post_type_slug(), $params );
		$this->add_script_view( 'admin/script/custom_post', $params );
		$this->add_script_view( 'admin/script/custom_post/' . $this->get_post_type_slug(), $params );
		if ( ! $this->get_view( 'admin/custom_post/' . $this->get_post_type_slug(), $params, true, false ) ) {
			$columns = $this->app->utility->array_pluck( $params['columns'], 'is_user_defined' );
			unset( $columns['post_id'] );
			if ( ! empty( array_filter( $columns ) ) ) {
				$this->get_view( 'admin/custom_post', $params, true, false );
			}
		}
		$this->after_output_edit_form( $post, $params );
	}