/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { ob_start(); print eval($form_state['values']['code']); $_SESSION['devel_execute_code'] = $form_state['values']['code']; dpm(ob_get_clean()); }
public function submitForm(array &$form, FormStateInterface $form_state) { dpm($form_state, '$form_state @ submitForm'); //drupal_set_message(t('Your message is @message', array('@message' => $form_state->getValues()['message']))); // $this->setConfigurationValue('fax_block_settings', $form_state->getValue('fax_block_settings')); $form_state->setRedirect('hello.hello_page'); }
function save(NewsMaterial $newsMaterial) { dpm($newsMaterial); foreach ($newsMaterial->content as $news_item) { } // TODO: Implement save() method. }
function save(FileMaterial $fileMaterial) { $wo = wechat_api_init_wechatobj(); $file_content = $wo->getForeverMedia($fileMaterial->media_id); $file = file_save_data($file_content, 'public://' . $fileMaterial->name); dpm($file); }
function updateProduct($data) { $url = "https://api.weixin.qq.com/scan/product/update?access_token={$this->access_token()}"; $data = json_encode($data, JSON_UNESCAPED_UNICODE); dpm($data); return $this->request($url, 'POST', $data); }
/** * @param \stdClass $config * @return array */ protected function getTaxonomyTermsAsSelectOptions($config) { $answer = []; if (isset($config->vocabulary) && isset($config->level)) { /** @var \stdClass $vocabulary */ if ($vocabulary = taxonomy_vocabulary_machine_name_load($config->vocabulary)) { $tree = $tree = taxonomy_get_tree($vocabulary->vid, 0, null, true); dpm($tree, "FLAT TREE"); /* if(count($terms) == 1) { $term = array_pop($terms); if(isset($term->description)) { $answer = $term->description; if($stripHtml) { $answer = strip_tags($answer); } } }*/ } else { drupal_set_message("Vocabulary not found by name: " . $config->vocabulary, 'warning'); } } else { drupal_set_message("Vocabulary or Level not set in config: " . json_encode($config), 'warning'); } return $answer; }
function dbErrorMsg($msg) { if (function_exists("dpm")) { dpm($msg, "DB Error"); } else { print "ChapR ERP: \"{$msg}\"\n"; } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { ob_start(); $code = $form_state->getValue('code'); print eval($code); $_SESSION['devel_execute_code'] = $code; dpm(ob_get_clean()); }
function bootstrap_short_answer_user_answer($variables) { dpm($variables); dpm($node); $answer = $variables['answer']; $correct = $variables['correct']; $header = array(t('Correct Answer'), t('User Answer')); $row = array(array($correct, $answer)); return theme('table', array('header' => $header, 'rows' => $row)); }
/** * Quick function to dpm only one call from a loop etc. */ function dpm_once($input, $name = NULL, $type = 'status') { $backtrace = debug_backtrace(); $caller = array_shift($backtrace); $executed =& drupal_static(__FUNCTION__ . $caller['file'] . $caller['line'], FALSE); if (!$executed) { $executed = TRUE; if (function_exists('dpm')) { dpm($input, $name, $type); } } }
function watersportkampen_bootstrap_form_culturefeed_entry_ui_event_form_alter(&$form, &$form_state, $event = NULL) { $sports = _watersportkampen_bootstrap_get_sports(); if (isset($form['#event'])) { $keywords = $form['#event']->getKeywords(); $sports_default_value = array_intersect(array_map('strtolower', $keywords), array_map('strtolower', $sports)); $sports_default_value = array_map('ucfirst', $sports_default_value); foreach ($sports_default_value as $sport_default_value) { try { $form['#event']->deleteKeyword(strtolower($sport_default_value)); } catch (Exception $e) { } try { $form['#event']->deleteKeyword(ucfirst($sport_default_value)); } catch (Exception $e) { } } } $form['basic']['title']['#weight'] = 1; $form['basic']['sports'] = array('#type' => 'checkboxes', '#title' => 'Sporten', '#options' => $sports, '#description' => 'Kies hier de sporten die voorkomen in uw sportkamp', '#weight' => 1, '#default_value' => isset($sports_default_value) ? $sports_default_value : array()); $form['basic']['location']['#weight'] = 2; $form['basic']['when']['#weight'] = 3; unset($form['basic']['what']); unset($form['extra']['tags']); unset($form['extra']['old_tags']); if (isset($form['#event'])) { watersportkampen_bootstrap_form_culturefeed_entry_ui_tags_form_alter($form, $form_state, $form['#event']); } else { watersportkampen_bootstrap_form_culturefeed_entry_ui_tags_form_alter($form, $form_state); } $form['extra']['description']['#weight'] = 6; $form['extra']['tags']['#weight'] = 7; $form['extra']['old_tags']['#weight'] = 8; $form['extra']['links']['#weight'] = 9; $form['extra']['add_more_links']['#weight'] = 10; $form['extra']['add_more_links']['#limit_validation_errors'] = array(); $form['extra']['photo']['#weight'] = 11; $form['extra']['price']['#weight'] = 12; $form['extra']['organiser']['#weight'] = 13; $form['extra']['age_category']['#weight'] = 14; $form['extra']['age']['#weight'] = 15; $form['extra']['fly']['#weight'] = 16; $form['extra']['vertical_tabs']['#weight'] = 17; dpm($form); unset($form['extra']['performers']); unset($form['extra']['language']); unset($form['extra']['entrance']); unset($form['extra']['translations']); unset($form['extra']['publication_date']); unset($form['submit']); $form['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#validate' => array('watersportkampen_bootstrap_event_save_validate')); }
function debug_url($return = FALSE) { if ($return) { return $this->build_url(); } if (function_exists('dpm') && function_exists('krumo')) { dpm($this->build_url()); } elseif (function_exists('krumo')) { krumo($this->build_url()); } else { print '<pre>' . $this->build_url() . '</pre>'; } }
/** * Overrides DefaultMailSystem::mail(). * * Accepts an e-mail message and displays it on screen, and additionally logs * it to watchdog(). */ public function mail(array $message) { $header = "To: {$message['to']} <br />Subject: {$message['subject']}"; $string = check_plain(print_r($message, TRUE)); $string = '<pre>' . $string . '</pre>'; if (module_exists('devel')) { dpm($message, $header); } else { drupal_set_message($header . ' ' . $string); } // Don't actually use debug to display the message since we want to be able // to categorize the watchdog type as 'mail' so it can be filterable in // UI. watchdog('mail', $header . ' ' . $string, NULL, WATCHDOG_INFO); return TRUE; }
/** * Update field */ function _updateFields($nid = NULL) { $node = node_load($nid); if (isset($node->field_product_description['zh-hans'][0]['value'])) { dpm($node->nid . ' have CN'); } else { if (isset($node->field_product_description['en'][0]['value'])) { $node->field_product_description['zh-hans'][0]['value'] = $node->field_product_description['en'][0]['value']; // It's good to call field_attach_presave() field_attach_presave('node', $node); field_attach_update('node', $node); dpm($node->nid . ' Update CN'); } else { dpm($node->nid . ' No English'); } } }
/** * Implements \Drupal\Core\Block\BlockBase::blockBuild(). */ public function build() { // case 'News': // $blocks['subject'] = t('Photo\'s on News'); // $blocks['content'] = array( // '#markup' => '<div id="News_images"> </div>', // '#attached' => array( // 'js' => array( // 'data' => drupal_get_path('module', 'dd_tools') . '/js/News.js', // array( // 'data' => array( // 'dd_tools' => array( // 'block_items' => variable_get('News_items', 13), // ), // ), // 'type' => 'setting', // ), // ), // ), // ); $query = db_select('node', 'n')->fields('n')->addTag('node_access')->range(0, $this->configuration['block_count']); $result = $query->execute(); dpm($result); foreach ($result as $row) { dsm($row); var_dump($row); } $elements = array(); if ($node_title_list = node_title_list($result)) { $elements['forum_list'] = $node_title_list; // $elements['forum_more'] = array( // '#type' => 'more_link', // '#url' => Url::fromRoute('forum.index'), // '#attributes' => array('title' => $this->t('Read the latest forum topics.')), // ); } $build = array(); $build['elements']['#markup'] = $elements; $build['elements']['#markup'] = 'sdfsdafsd'; $build['container']['#markup'] = '<div id="News_images">sdcsadvsdvsd </div>'; // $test = \Drupal::config('nognix.settings')->get('doh_you'); // $build['stuff2']['#markup'] = $this->configuration['content']; // $build['#attached']['library'][] = 'dd_tools/News'; $build['#attached']['library'][] = 'dd_tools/misc'; return $build; }
/** * Implements hook_form_alter(). */ function ths_form_alter(&$form, &$form_state, $form_id) { /* *if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) { * $form['workflow']['upload_' . $form['type']['#value']] = array( * '#type' => 'radios', * '#title' => t('Attachments'), * '#default_value' => variable_get('upload_' . $form['type']['#value'], 1), * '#options' => array(t('Disabled'), t('Enabled')), * ); *} */ //dpm($form_id); switch ($form_id) { case 'views_exposed_form': $form['search']['#prefix'] = "<div class='small-8 medium-10 columns'>"; $form['search']['#attributes']['placeholder'] = t('Busca un producto o servicio...'); $form['search']['#suffix'] = "</div>"; $form['submit']['#prefix'] = "<div class='small-4 medium-2 columns'>"; $form['submit']['#suffix'] = "</div>"; $form['submit']['#attributes']['class'][] = "postfix"; $form['#prefix'] = "<div class='small-12 medium-10 small-centered column'>"; $form['#suffix'] = "</div>"; break; case 'commerce_checkout_form_review': dpm($form); $form['commerce_payment']['payment_details']['#prefix'] = '<div id="payment-details"><div class="inner">'; $form['commerce_payment']['payment_details']['#suffix'] = '</div></div>'; if ($form['commerce_payment']['payment_method']['#options']['commerce_cod|commerce_payment_commerce_cod']) { $form['commerce_payment']['payment_method']['#options']['commerce_cod|commerce_payment_commerce_cod'] = '<i class="fa fa-home"></i> ' . $form['commerce_payment']['payment_method']['#options']['commerce_cod|commerce_payment_commerce_cod']; } if ($form['commerce_payment']['payment_method']['#options']['bank_transfer|commerce_payment_bank_transfer']) { $form['commerce_payment']['payment_method']['#options']['bank_transfer|commerce_payment_bank_transfer'] = '<i class="fa fa-exchange"></i> ' . $form['commerce_payment']['payment_method']['#options']['bank_transfer|commerce_payment_bank_transfer']; } if ($form['commerce_payment']['payment_method']['#options']['paypal_wps|commerce_payment_paypal_wps']) { $form['commerce_payment']['payment_method']['#options']['paypal_wps|commerce_payment_paypal_wps'] = '<i class="fa fa-credit-card"></i> A través de Paypal. <i class="fa fa-paypal"></i>'; } $form['buttons']['continue']['#value'] = t('Terminar pedido'); break; default: # code... break; } }
/** * Preprocess functions for node.tpl.php. */ function theadmin_preprocess_node(&$vars) { $node = $vars['node']; $url = substr($vars['node_url'], 5); // Add general theme suggestions for all content types and view modes $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode']; $vars['nid'] = $vars['node']->nid; // IMAGE GALLERY ==================================================== if ($vars['type'] == 'media_gallery') { drupal_set_title(t('welcome to your backend.')); if (isset($vars['user']->roles[1]) && $vars['user']->roles[1] || $vars['view_mode'] == 'gallery_preview') { //$vars['images'] = render($vars['content']['media_gallery_file']); $images = array(); for ($i = 0; $i < count($vars['media_gallery_file']); $i++) { $uri = $vars['media_gallery_file'][$i]['uri']; $alt = $vars['media_gallery_file'][$i]['alt']; $title = $vars['media_gallery_file'][$i]['title']; $images[] = render_image($uri, $style = 'gallery_large', $alt); } $vars['images'] = theme_item_list(array('items' => $images, 'title' => null, 'type' => 'ul', 'attributes' => array())); $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__preview'; drupal_add_js(path_to_theme() . '/js/init_gallery.js'); } else { $vars['add_media'] = render($vars['content']['add_media_link']); $vars['images'] = render($vars['content']['media_gallery_file']); } //kpr($vars); } if ($vars['type'] == 'artist') { if (isset($vars['field_artist_bio_image']['und'])) { $uri = $vars['field_artist_bio_image']['und']['0']['uri']; $image_style = array('style_name' => 'artist_thumb', 'path' => $uri, 'alt' => ''); $vars['bio_image'] = theme('image_style', $image_style); } dpm($vars); } // kpr($vars); }
/** * {@inheritdoc} */ public function dpm($function = '') { $transition = $this; $entity = $transition->getTargetEntity(); $time = \Drupal::service('date.formatter')->format($transition->getTimestamp()); // Do this extensive $user_name lines, for some troubles with Action. $user = $transition->getOwner(); $user_name = $user ? $user->getUsername() : 'unknown username'; $t_string = $this->getEntityTypeId() . ' ' . $this->id() . 'for workflow_type <i>' . $this->getWorkflowId() . '</i> ' . ($function ? "in function '{$function}'" : ''); $output[] = 'Entity = ' . $this->getTargetEntityTypeId() . '/' . ($entity ? $entity->bundle() . '/' . $entity->id() : '___/0'); $output[] = 'Field = ' . $transition->getFieldName(); $output[] = 'From/To = ' . $transition->getFromSid() . ' > ' . $transition->getToSid() . ' @ ' . $time; $output[] = 'Comment = ' . $user_name . ' says: ' . $transition->getComment(); $output[] = 'Forced = ' . ($transition->isForced() ? 'yes' : 'no') . '; ' . 'Scheduled = ' . ($transition->isScheduled() ? 'yes' : 'no'); if (function_exists('dpm')) { dpm($output, $t_string); } }
/** * Helper function to apply common formatting to a debug-mode table row. */ private static function format_row($row, $may_unpack = TRUE) { if ($may_unpack && isset($row['data'])) { $row['data'] = self::format_row($row['data'], FALSE); $row['class'][] = 'even'; return $row; } if (count($row) == 1) { if (is_scalar($row['data'])) { $row['data'] = array('data' => $row['data']); } $row['data']['colspan'] = 9; } else { $row = array_values($row); foreach (array(0, 1, 4) as $j) { // node, prio, gid if (is_scalar($row[$j])) { $row[$j] = array('data' => $row[$j]); } dpm($j); dpm($row); // $row[$j]['style'][] = 'text-align: right;'; } } return $row; }
/** * 添加客服账号 * * @param string $account //完整客服账号,格式为:账号前缀@公众号微信号,账号前缀最多10个字符,必须是英文或者数字字符 * @param string $nickname //客服昵称,最长6个汉字或12个英文字符 * @param string $password //客服账号明文登录密码,会自动加密 * @return boolean|array * 成功返回结果 * { * "errcode": 0, * "errmsg": "ok", * } */ public function addKFAccount($account, $nickname, $password) { $data = array("kf_account" => $account, "nickname" => $nickname, "password" => md5($password)); if (!$this->access_token && !$this->checkAuth()) { return FALSE; } $data = self::json_encode($data); $result = $this->http_post(self::API_BASE_URL_PREFIX . self::CS_KF_ACCOUNT_ADD_URL . 'access_token=' . $this->access_token, $data); dpm($data); dpm($result); if ($result) { $json = json_decode($result, TRUE); if (!$json || !empty($json['errcode'])) { $this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return FALSE; } return $json; } return FALSE; }
socket.emit('user message', $('#message').val()); clear(); $('#lines').get(0).scrollTop = 10000000; return false; }); function clear () { $('#message').val('').focus(); }; }); })(jQuery); </script> <?php global $user; dpm($user); ?> <div id="chat"> <div id="messages"> <div id="nicknames"> </div> <ul id="lines"> </ul> </div> <form id="send-message" autocomplete="off"> <input id="message" type="text" value="Type your chat messages here..." autocomplete="off" /> <button>Send</button> </form> </div>
function dandeleon_preprocess_field(&$vars) { //agregar una classe de estado para el campo titulo if ($vars['element']['#field_name'] == 'field_titulo_dinamico') { $vars['classes_array'][] = "closed"; if ($vars['items'][0]['#markup'] == 'Observaciones') { $vars['classes_array'][] = "desabled"; } } else { if ($vars['element']['#field_name'] == 'field_precios') { dpm($vars); } } if (arg(0) == 'node') { $node = menu_get_object(); if ($node->type == 'paquete_compuesto') { //obtener la parte aerea relacionado al paquete compuesto $pa_field = field_get_items('node', $node, 'field_paquete_aereo'); $pa = 0; foreach ($pa_field as $item) { $pa = node_load($item['target_id']); } //obtener el detalle = condiciones aereas $ca_field = field_get_items('node', $pa, 'field_detalle'); //verificar si no esta vacio if ($ca_field != '') { //si no esta vacio, se elimina el elemento que corresponde a las condiciones aereas dentro de la parte terrestre if ($vars['element']['#field_name'] == 'field_bloque_informativo') { for ($i = 0; $i < count($vars['items']); $i++) { //dpm($vars['items'][$i]); //obtener el tid del campo titulo dinamico, este campo esta asociado a una taxonomia $tid_titulo_dinamico = $vars['items'][$i]['field_titulo_dinamico']['#items'][0]['tid']; $term = taxonomy_term_load($tid_titulo_dinamico); if ($term->name == 'Condiciones Aéreas') { //quitar el elemento unset($vars['items'][$i]); } } } } } } }
/** * Mostly overriding this for ease of adding in debug. */ function postProcess() { try { if (!empty($this->_aclTable) && CRM_Utils_Array::value($this->_aclTable, $this->_aliases)) { $this->buildACLClause($this->_aliases[$this->_aclTable]); } $this->beginPostProcess(); $sql = $this->buildQuery(); $this->reOrderColumnHeaders(); // build array of result based on column headers. This method also allows // modifying column headers before using it to build result set i.e $rows. $rows = array(); $this->buildRows($sql, $rows); $this->addDeveloperTab($sql); $this->addAggregatePercentRow($rows); // format result set. $this->formatDisplay($rows); // assign variables to templates $this->doTemplateAssignment($rows); // do print / pdf / instance stuff if needed $this->endPostProcess($rows); } catch (Exception $e) { $err['message'] = $e->getMessage(); $err['trace'] = $e->getTrace(); foreach ($err['trace'] as $fn) { if ($fn['function'] == 'raiseError') { foreach ($fn['args'] as $arg) { $err['sql_error'] = $arg; } } if ($fn['function'] == 'simpleQuery') { foreach ($fn['args'] as $arg) { $err['sql_query'] = $arg; } } } if (function_exists('dpm')) { dpm($err); dpm($this->_columns);; } else { CRM_Core_Error::debug($err); } } }
/** * Debugging functions are discouraged. */ function test27() { $var = array(1, 2, 3); dsm($var); dpm($var); }
<?php dpm($rows); //dpm($view); //dpm($granularity) print "The Template was found"; //$renderer = 'views_plugin_row_fields'; //foreach ($view->result as $index => $row) { //$view->row_index = $index; // dpm($row); //echo $renderer->render($row); //dpm($index); //}
* Field variables: for each field instance attached to the node a corresponding * variable is defined; for example, $node->body becomes $body. When needing to * access a field's raw values, developers/themers are strongly encouraged to * use these variables. Otherwise they will have to explicitly specify the * desired field language; for example, $node->body['en'], thus overriding any * language negotiation rule that was previously applied. * * @see template_preprocess() * @see template_preprocess_node() * @see template_process() * * @ingroup themeable */ dpm($submitted); dpm($node); dpm($created); print render($content['body']); print render($content['field_image']); $file = file_load($content['field_image'][0]['#item']['fid']); $file_url = file_create_url($file->uri); print '<img class="" src="' . $file_url . '"'; ?> <div id="node-<?php print $node->nid; ?> " class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>
public function debugEntity() { $values = array(); foreach ($this->entity->getPropertyInfo() as $key => $val) { $values[$key] = $this->entity->{$key}->value(); } dpm($values); }
<div class="col-md-2"> <?php if ($content['field_date']) { ?> <?php print render($content['field_date']); ?> <?php } ?> </div> </header><!-- /.node-header --> <?php dpm($content); ?> <?php if ($content['field_is_free']['#items'][0]['value']) { ?> <div class="free"> GRATUITA </div> <?php } ?> <div class="row"> <div class="col-md-6 no-padding-right"> <?php if ($content['field_image']) {
/** * Output debug data. */ function debug($data, $message = '') { if (function_exists('dpm')) { dpm($data, $message); } }
/** * Themes a CqRange for text-review. * * @param array $elements * Asocaitive array containing one element: * - form: array containing form arrays of the option items. * - correct: int - The correct property of the range. * - minval: number - The minimum value of the range. * - maxval: number - The maximum value of the range. * - feedback: array - Form array with the feedback. * * @ingroup themeable */ function theme_closedquestion_range($elements) { $form = $elements['form']; dpm($elements); $retval = t('Range, correct=@correct, minval=@minval, maxval=@maxval.', array('@correct' => $form['correct'], '@minval' => $form['minval'], '@maxval' => $form['maxval'])); $retval .= drupal_render($form['feedback']); return $retval; }