function fever_links__system_main_menu($vars) { $class = implode($vars['attributes']['class'], ' '); $html = '<ul class="' . $class . '">'; foreach ($vars['links'] as $key => $link) { if (is_numeric($key)) { $sub_menu = ''; $link_class = ''; $link_title = '<span>'; $link_title .= $link['#title']; // Check for sub menu - note I've only checked this for 2 levels // it might not work for 3 level menus. if (!empty($link['#below'])) { $link_class = ' class="dropdown"'; $link['#attributes']['class'][] = 'dropdown-toggle'; $link['#attributes']['data-toggle'][] = 'dropdown'; // And recurse. $sub_menu = theme('links__system_main_menu', array('links' => $link['#below'], 'attributes' => array('class' => array('dropdown-menu')))); } $html .= '<li' . $link_class . '>' . l($link_title, $link['#href'], array('html' => 'true', 'attributes' => $link['#attributes'])) . '</span>' . $sub_menu . '</li>'; } } $html .= '</ul>'; return $html; }
/** * Overrides theme_menu_link(). */ function bootstrap_menu_link(array $variables) { $element = $variables['element']; $sub_menu = ''; if ($element['#below']) { // Prevent dropdown functions from being added to management menu so it // does not affect the navbar module. if ($element['#original_link']['menu_name'] == 'management' && module_exists('navbar')) { $sub_menu = drupal_render($element['#below']); } elseif (!empty($element['#original_link']['depth']) && $element['#original_link']['depth'] >= 1) { // Add our own wrapper. unset($element['#below']['#theme_wrappers']); $sub_menu = '<ul class="dropdown-menu">' . drupal_render($element['#below']) . '</ul>'; // Generate as standard dropdown. //$element['#title'] .= ' <span class="caret"></span>'; $element['#attributes']['class'][] = 'dropdown'; $element['#localized_options']['html'] = TRUE; // Set dropdown trigger element to # to prevent inadvertant page loading // when a submenu link is clicked. //$element['#localized_options']['attributes']['data-target'] = '#'; $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle'; //$element['#localized_options']['attributes']['data-toggle'] = 'dropdown'; } } // On primary navigation menu, class 'active' is not set on active menu item. // @see https://drupal.org/node/1896674 if (($element['#href'] == $_GET['q'] || $element['#href'] == '<front>' && drupal_is_front_page()) && empty($element['#localized_options']['language'])) { $element['#attributes']['class'][] = 'active'; } $output = l($element['#title'], $element['#href'], $element['#localized_options']); return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n"; }
/** * Implemensts hook_breadcrumb(). * * tth@bellcom.dk check if there is a better way to do this... */ function cmstheme_breadcrumb($variables) { $breadcrumb = $variables['breadcrumb']; $nid = arg(1); if (is_numeric($nid)) { $node = node_load($nid); } if (!empty($breadcrumb)) { $output = '<div class="breadcrumb you-are-here">' . t('Du er her: ') . '</div>'; $title = drupal_get_title(); $breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside'))); $breadcrumb[] = '<a href="#" title="' . $title . '">' . $title . '</a>'; if ($title == 'Søg') { unset($breadcrumb); $breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside'))); $breadcrumb[] = '<a href="#" title="Søgning">Søgning</a>'; } if (isset($node) && is_object($node) && $node->type == 'meeting') { unset($breadcrumb); $breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside'))); $breadcrumb[] = l(t('Politik & planer'), 'politik-og-planer', array('attributes' => array('title' => 'Politik og planer'))); $breadcrumb[] = l(t('Søg i dagsordener og referater'), 'dagsorden-og-referat', array('attributes' => array('title' => 'Søg i dagsordner og referater'))); $breadcrumb[] = l(t($title), '#'); } $output .= '<div class="breadcrumb">' . implode('<div class="bread-crumb"> > </div> ', $breadcrumb) . '</div>'; return $output; } }
function gavias_laikafood_format_comma_field($field_category, $node, $limit = NULL) { if (module_exists('i18n_taxonomy')) { $language = i18n_language(); } $category_arr = array(); $category = ''; $field = field_get_items('node', $node, $field_category); if (!empty($field)) { foreach ($field as $item) { $term = taxonomy_term_load($item['tid']); if ($term) { if (module_exists('i18n_taxonomy')) { $term_name = i18n_taxonomy_term_name($term, $language->language); // $term_desc = tagclouds_i18n_taxonomy_term_description($term, $language->language); } else { $term_name = $term->name; //$term_desc = $term->description; } $category_arr[] = l($term_name, 'taxonomy/term/' . $item['tid']); } if ($limit) { if (count($category_arr) == $limit) { $category = implode(', ', $category_arr); return $category; } } } } $category = implode(', ', $category_arr); return $category; }
public function foreverdelete() { //彻底删除指定记录 $ajax = intval($_REQUEST['ajax']); $id = $_REQUEST['id']; if (isset($id)) { $condition = array('id' => array('in', explode(',', $id))); if (M("Deal")->where(array('deal_goods_type' => array('in', explode(',', $id))))->count() > 0) { $this->error(l("GOODS_TYPE_EXIST_DEAL")); } $rel_data = M(MODULE_NAME)->where($condition)->findAll(); foreach ($rel_data as $data) { $info[] = $data['name']; } if ($info) { $info = implode(",", $info); } $list = M(MODULE_NAME)->where($condition)->delete(); if ($list !== false) { M("GoodsTypeAttr")->where(array('goods_type_id' => array('in', explode(',', $id))))->delete(); save_log($info . l("FOREVER_DELETE_SUCCESS"), 1); $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax); } else { save_log($info . l("FOREVER_DELETE_FAILED"), 0); $this->error(l("FOREVER_DELETE_FAILED"), $ajax); } } else { $this->error(l("INVALID_OPERATION"), $ajax); } }
function navigation($section = '') { global $lang; global $translation; //$tr = $translation->navigation; // Removed 22 Sep 2011 --CR $abo = array('About', 'Overview', 'People', 'Foundation'); $ref = array('Reference', 'Language', 'A-Z', 'Libraries', 'Tools', 'Environment'); $learn = array('Learning', 'Tutorials', 'Basics', 'Topics', '3D', 'Library', 'Books'); $html = "\t\t\t" . '<div id="navigation">' . "\n"; $id = in_array($section, $ref) || in_array($section, $learn) || in_array($section, $abo) ? 'mainnav' : 'mainnav_noSub'; $html .= "\t\t\t\t" . '<div class="navBar" id="' . $id . '">' . "\n"; $html .= "\t\t\t\t\t" . l('Cover', $section == 'Cover') . "<br><br>\n"; $html .= "\t\t\t\t\t" . l('Download', $section == 'Download') . "<br><br>\n"; $html .= "\t\t\t\t\t" . l('Exhibition', $section == 'Exhibition') . "<br><br>\n"; $html .= "\t\t\t\t\t" . l('Reference', $section == 'Reference') . "<br>\n"; $html .= "\t\t\t\t\t" . l('Libraries', $section == 'Libraries') . "<br>\n"; $html .= "\t\t\t\t\t" . l('Tools', $section == 'Tools') . "<br>\n"; $html .= "\t\t\t\t\t" . l('Environment', $section == 'Environment') . "<br><br>\n"; $html .= "\t\t\t\t\t" . l('Tutorials', $section == 'Tutorials') . "<br>\n"; $html .= "\t\t\t\t\t" . l('Examples', $section == 'Examples') . "<br>\n"; $html .= "\t\t\t\t\t" . l('Books', $section == 'Books') . "<br><br>\n"; $html .= "\t\t\t\t\t" . l('Overview', $section == 'Overview') . "<br> \n"; $html .= "\t\t\t\t\t" . l('People', $section == 'People') . "<br>\n"; $html .= "\t\t\t\t\t" . l('Foundation', $section == 'Foundation') . "<br><br>\n"; $html .= "\t\t\t\t\t" . l('Shop', $section == 'Shop') . "<br><br>\n"; $html .= "\t\t\t\t\t" . "<a href=\"http://forum.processing.org\"" . 'class="outward"' . "><span>»</span>Forum</a><br> \n"; $html .= "\t\t\t\t\t" . "<a href=\"https://github.com/processing\"" . 'class="outward"' . "><span>»</span>GitHub</a><br> \n"; $html .= "\t\t\t\t\t" . "<a href=\"https://github.com/processing/processing/issues?state=open\"" . 'class="outward"' . "><span>»</span>Issues</a><br> \n"; $html .= "\t\t\t\t\t" . "<a href=\"http://wiki.processing.org\"" . 'class="outward"' . "><span>»</span>Wiki</a><br> \n"; $html .= "\t\t\t\t\t" . "<a href=\"http://wiki.processing.org/w/FAQ\"" . 'class="outward"' . "><span>»</span>FAQ</a><br> \n"; $html .= "\t\t\t\t\t" . "<a href=\"https://twitter.com/processingOrg\"" . 'class="outward"' . "><span>»</span>Twitter</a><br> \n"; $html .= "\t\t\t\t\t" . "<a href=\"https://www.facebook.com/page.processing\"" . 'class="outward"' . "><span>»</span>Facebook</a><br> \n"; $html .= "\t\t\t\t</div>\n"; return $html . "\t\t\t</div>\n"; }
/** * Tests the integration. */ public function testIntegration() { // Remove the watchdog entries added by the potential batch process. $this->container->get('database')->truncate('watchdog')->execute(); $entries = array(); // Setup a watchdog entry without tokens. $entries[] = array('message' => $this->randomMachineName(), 'variables' => array(), 'link' => l('Link', 'node/1')); // Setup a watchdog entry with one token. $entries[] = array('message' => '@token1', 'variables' => array('@token1' => $this->randomMachineName()), 'link' => l('Link', 'node/2')); // Setup a watchdog entry with two tokens. $entries[] = array('message' => '@token1 !token2', 'variables' => array('@token1' => $this->randomMachineName(), '!token2' => $this->randomMachineName()), 'link' => l('<object>Link</object>', 'node/2', array('html' => TRUE))); foreach ($entries as $entry) { $entry += array('type' => 'test-views', 'severity' => WATCHDOG_NOTICE); watchdog($entry['type'], $entry['message'], $entry['variables'], $entry['severity'], $entry['link']); } $view = Views::getView('test_dblog'); $this->executeView($view); $view->initStyle(); foreach ($entries as $index => $entry) { $this->assertEqual($view->style_plugin->getField($index, 'message'), String::format($entry['message'], $entry['variables'])); $this->assertEqual($view->style_plugin->getField($index, 'link'), Xss::filterAdmin($entry['link'])); } // Disable replacing variables and check that the tokens aren't replaced. $view->destroy(); $view->initHandlers(); $this->executeView($view); $view->initStyle(); $view->field['message']->options['replace_variables'] = FALSE; foreach ($entries as $index => $entry) { $this->assertEqual($view->style_plugin->getField($index, 'message'), $entry['message']); } }
/** * @param array $data * @return bool|int|\Nette\Database\Table\IRow * @throws EntityExistsException Pokud existuje článek se stejným nadpisem. */ public function insert(array $data) { $image = $data['image']; if ($image->name == null) { throw new ArgumentException('Nebyl vložen obrázek'); } unset($data['image']); unset($data['idArticle']); $data['lang'] = $data['language']; unset($data['language']); $name = $this->imageName($image); $data['image'] = $name; try { if ($data['translate'] != null) { $data['idArticle'] = $data['translate']; } unset($data['translate']); $result = parent::insert($data); } catch (UniqueConstraintViolationException $ex) { if ($ex->getCode() == 23000) { throw new EntityExistsException('Článek s tímto nadpisem už existuje'); } l($ex->getMessage()); } $this->insertImage($image, $name); return $result; }
function dms_breadcrumb($breadcrumb) { if (!empty($breadcrumb)) { $breadcrumb[] = l(drupal_get_title(), $_GET['q']); return '<div class="breadcrumb">' . implode(' » ', $breadcrumb) . '</div>'; } }
public function headline() { if (!$this->readonly) { $fieldName = $this->name; $blueprint = blueprint::find($this->page()); $fieldsets = $blueprint->fields()->{$fieldName}->fieldsets; $addDropdownHtml = '<div class="drop-down">'; $addDropdownHtml .= '<a class="drop-down-toggle label-option"><i class="icon icon-left fa fa-chevron-circle-down"></i>' . l('fields.structure.add') . '</a>'; $addDropdownHtml .= '<ul>'; foreach ($fieldsets as $fieldsetName => $fieldsetFields) { $addDropdownHtml .= '<li>'; $addDropdownHtml .= '<a href="#0" class="builder-add-button" data-fieldset="' . $fieldsetName . '"><i class="icon icon-left fa fa-plus-circle"></i>' . $fieldsetFields['label'] . '</a>'; $addDropdownHtml .= '</li>'; } $addDropdownHtml .= '</ul>'; $addDropdownHtml .= '</div>'; } else { $addButtons[] = null; } $label = parent::label(); $label->addClass('builder-label'); // foreach ($addButtons as $key => $value) { // $label->append($add[$key]); // } $label->append($addDropdownHtml); return $label; }
/** * Example function: creates a graph of user logins by day. */ function user_last_login_by_day($n = 40) { $query = db_select('users'); $query->addField('users', 'name'); $query->addField('users', 'uid'); $query->addField('users', 'created'); $query->condition('uid', 0, '>'); $query->orderBy('created', 'DESC'); $query->range(0, $n); $result = $query->execute(); $g = graphapi_new_graph(); $now = time(); $days = array(); foreach ($result as $user) { $uid = $user->uid; $user_id = 'user_' . $uid; $day = intval(($now - $user->created) / (24 * 60 * 60)); $day_id = 'data_' . $day; graphapi_set_node_title($g, $user_id, l($user->name, "user/" . $uid)); graphapi_set_node_title($g, $day_id, "Day " . $day); graphapi_set_link_data($g, $user_id, $day_id, array('color' => '#F0F')); } $options = array('width' => 400, 'height' => 400, 'item-width' => 50, 'engine' => 'graph_phyz'); return theme('graphapi_dispatch', array('graph' => $g, 'config' => $options)); }
public function foreverdelete() { //彻底删除指定记录 $ajax = intval($_REQUEST['ajax']); $id = $_REQUEST['id']; if (isset($id)) { $condition = array('id' => array('in', explode(',', $id))); $rel_data = M(MODULE_NAME)->where($condition)->findAll(); foreach ($rel_data as $data) { $info[] = $data['id']; } if ($info) { $info = implode(",", $info); } $list = M(MODULE_NAME)->where($condition)->delete(); if ($list !== false) { //将已返利的数字减一 foreach ($rel_data as $data) { M("User")->setDec('referral_count', "id=" . $data['rel_user_id']); // 用户返利次数减一 } save_log($info . l("FOREVER_DELETE_SUCCESS"), 1); $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax); } else { save_log($info . l("FOREVER_DELETE_FAILED"), 0); $this->error(l("FOREVER_DELETE_FAILED"), $ajax); } } else { $this->error(l("INVALID_OPERATION"), $ajax); } }
/** * Implements theme_bootstrap_btn_dropdown(). */ function theme_bootstrap_btn_dropdown($variables) { $type_class = ''; $sub_links = ''; $variables['attributes']['class'][] = 'btn-group'; // Type class. if (isset($variables['type'])) { $type_class .= ' btn-' . $variables['type']; } else { $type_class .= ' btn-default'; } // Start markup. $output = '<div' . drupal_attributes($variables['attributes']) . '>'; // Add as string if its not a link. if (is_array($variables['label'])) { $output .= l($variables['label']['title'], ${$variables}['label']['href'], $variables['label']); } $output .= '<a class="btn' . $type_class . ' dropdown-toggle" data-toggle="dropdown" href="#">'; // It is a link, create one. if (is_string($variables['label'])) { $output .= check_plain($variables['label']); } if (is_array($variables['links'])) { $sub_links = theme('links', array('links' => $variables['links'], 'attributes' => array('class' => array('dropdown-menu')))); } // Finish markup. $output .= '<span class="caret"></span></a>' . $sub_links . '</div>'; return $output; }
public function update_debit() { $borrow_amount_cfg = array(); foreach ($_REQUEST["borrow_amount_cfg"] as $k => $v) { if ($v != "") { $borrow_amount_cfg[] = htmlspecialchars(addslashes(trim($v))); } } $data = array(); $data["borrow_amount_cfg"] = serialize($borrow_amount_cfg); $data["loantype"] = intval($_REQUEST["loantype"]); $data["services_fee"] = floatval($_REQUEST["services_fee"]); $data["manage_fee"] = floatval($_REQUEST["manage_fee"]); $data["manage_impose_fee_day1"] = strim($_REQUEST["manage_impose_fee_day1"]); $data["manage_impose_fee_day2"] = strim($_REQUEST["manage_impose_fee_day2"]); $data["impose_fee_day1"] = strim($_REQUEST["impose_fee_day1"]); $data["impose_fee_day2"] = strim($_REQUEST["impose_fee_day2"]); $data["rate_cfg"] = intval($_REQUEST["rate_cfg"]); $data["enddate"] = intval($_REQUEST["enddate"]); $data["first_relief"] = floatval($_REQUEST["first_relief"]); $count = $GLOBALS["db"]->getOne("select count(*) from " . DB_PREFIX . "debit_conf"); if ($count == 0) { $GLOBALS['db']->autoExecute(DB_PREFIX . "debit_conf", $data); } else { $GLOBALS['db']->autoExecute(DB_PREFIX . "debit_conf", $data, "UPDATE", " 1=1 "); } save_log(l("DEBIT_UPDATED"), 1); $this->success(L("UPDATE_SUCCESS")); }
public function add($id = '/') { $page = $this->page($id); $blueprint = blueprint::find($page); $templates = $blueprint->pages()->template(); $options = array(); $back = array('subpages' => purl('subpages/index/' . $page->id()), 'page' => purl($page, 'show')); $form = app::form('pages.add'); $form->save = l('add'); $form->back = a::get($back, get('to')); foreach ($templates as $template) { $options[$template->name()] = $template->title(); } $select = form::field('select', array('name' => 'template', 'label' => l('pages.add.template.label'), 'options' => $options, 'required' => true)); if ($templates->count() == 1) { $select->readonly = true; $select->value = $templates->first()->name(); } $form->fields()->append('template', $select); if (api::maxPages($page, $blueprint->pages()->max())) { $form->fields = array('info' => form::field('info', array('label' => 'pages.add.error.max.headline', 'text' => 'pages.add.error.max.text'))); $form->save = false; $form->centered = true; } return view('pages/add', array('page' => $page, 'form' => $form)); }
protected function setUp() { parent::setUp(); // Create Basic page node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); $this->vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => drupal_strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('page' => 'page'), 'weight' => mt_rand(0, 10))); $this->vocabulary->save(); // Setup a field and instance. $this->field_name = drupal_strtolower($this->randomMachineName()); entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array(array('vocabulary' => $this->vocabulary->id(), 'parent' => '0')))))->save(); entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => 'node', 'bundle' => 'page'))->save(); // Create a time in the past for the archive. $time = REQUEST_TIME - 3600; $this->container->get('comment.manager')->addDefaultField('node', 'page'); $this->container->get('views.views_data')->clear(); for ($i = 0; $i <= 10; $i++) { $user = $this->drupalCreateUser(); $term = $this->createTerm($this->vocabulary); $values = array('created' => $time, 'type' => 'page'); $values[$this->field_name][]['target_id'] = $term->id(); // Make every other node promoted. if ($i % 2) { $values['promote'] = TRUE; } $values['body'][]['value'] = l('Node ' . 1, 'node/' . 1); $node = $this->drupalCreateNode($values); $comment = array('uid' => $user->id(), 'status' => CommentInterface::PUBLISHED, 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment'); entity_create('comment', $comment)->save(); } // Some views, such as the "Who's Online" view, only return results if at // least one user is logged in. $account = $this->drupalCreateUser(array()); $this->drupalLogin($account); }
public function delete() { //彻底删除指定记录 $ajax = intval($_REQUEST['ajax']); $id = $_REQUEST['id']; if (isset($id)) { $condition = array('id' => array('in', explode(',', $id))); $rel_data = M(MODULE_NAME)->where($condition)->count(); $list = M(MODULE_NAME)->where($condition)->delete(); if ($list !== false) { foreach ($rel_data as $k => $v) { if ($v['log_id'] == 0) { $GLOBALS['db']->query("update " . DB_PREFIX . "deal set comment_count = comment_count - 1 where id = " . $v['deal_id']); } } save_log($info . "成功删除", 1); $this->success("成功删除", $ajax); } else { save_log($info . "删除出错", 0); $this->error("删除出错", $ajax); } } else { $this->error(l("INVALID_OPERATION"), $ajax); } }
/** * Overrides theme_menu_link() for book module. */ function bootstrap_menu_link__book_toc(array $variables) { $element = $variables['element']; $sub_menu = drupal_render($element['#below']); $title = $element['#title']; $href = $element['#href']; $options = !empty($element['#localized_options']) ? $element['#localized_options'] : array(); $attributes = !empty($element['#attributes']) ? $element['#attributes'] : array(); $attributes['role'] = 'presentation'; // Header. $link = TRUE; if ($title && $href === FALSE) { $attributes['class'][] = 'dropdown-header'; $link = FALSE; } elseif ($title === FALSE && $href === FALSE) { $attributes['class'][] = 'divider'; $link = FALSE; } elseif (($href == $_GET['q'] || $href == '<front>' && drupal_is_front_page()) && empty($options['language'])) { $attributes['class'][] = 'active'; } // Filter the title if the "html" is set, otherwise l() will automatically // sanitize using check_plain(), so no need to call that here. if (!empty($options['html'])) { $title = _bootstrap_filter_xss($title); } // Convert to a link. if ($link) { $title = l($title, $href, $options); } return '<li' . drupal_attributes($attributes) . '>' . $title . $sub_menu . "</li>\n"; }
public function get_settings_map() { foreach ($this->settings as $param_id => $param_data) { $this->settings[$param_id]["name"] = l('system_field_' . $param_id, 'payments'); } return $this->settings; }
public function update() { //$data = M(MODULE_NAME)->create (); $data = array(); $data['id'] = intval($_REQUEST['id']); $data['name'] = strim($_REQUEST['name']); //$data['content'] = $_REQUEST['content']; $data['content'] = stripslashes($_REQUEST['content']); $data['is_html'] = intval($_REQUEST['is_html']); $return = array('info' => '', 'status' => '0'); if ($data['name'] == '' || $data['id'] == 0) { $info = l("SELECT_MSG_TPL"); header("Content-Type:text/html; charset=utf-8"); echo $info; } $log_info = $data['name']; // 更新数据 $list = M(MODULE_NAME)->save($data); if (false !== $list) { //成功提示 save_log($log_info . L("UPDATE_SUCCESS"), 1); $info = '"' . L("LANG_" . $data['name']) . '"模板' . L("UPDATE_SUCCESS"); $return['status'] = 1; header("Content-Type:text/html; charset=utf-8"); echo $info; } else { //错误提示 save_log($log_info . L("UPDATE_FAILED"), 0); $info = L("LANG_" . $data['name']) . "模板" . L("UPDATE_FAILED"); $return['status'] = 0; header("Content-Type:text/html; charset=utf-8"); echo $info; } }
/** * @fn filename * @short Returns the filename of the artifact. */ public function filename() { if (!$this->file_exists()) { return span($this->file, array('class' => 'missing-file', 'title' => l('Missing file'))); } return $this->file; }
public function load($name) { // make sure there's no path included in the name $name = basename(strtolower($name)); if (isset(static::$cache[$name])) { $this->file = static::$cache[$name]['file']; $this->name = static::$cache[$name]['name']; $this->yaml = static::$cache[$name]['yaml']; return true; } // find the matching blueprint file $file = kirby()->get('blueprint', $name); if ($file) { $this->file = $file; $this->name = $name; $this->yaml = data::read($this->file, 'yaml'); // remove the broken first line unset($this->yaml[0]); static::$cache[$name] = array('file' => $this->file, 'name' => $this->name, 'yaml' => $this->yaml); return true; } else { if ($name == 'default') { throw new Exception(l('blueprints.error.default.missing')); } else { return $this->load('default'); } } }
function libya_cron_subscription_mail($data) { // subscription node $mail = $data[0]; $nids = $data[1]; // watchdog('actions', 'Cron subscription vars', func_get_args()); global $siteName, $isMail, $base_url; $isMail = TRUE; $body = '<h1 style="font-size:1.25em;">Your alert subscription results from ' . $siteName . '</h1> <p class="no-margin">The following results match your subscription alert.</p>'; foreach ($nids as $nid) { $N = node_load($nid); $content = strip_tags($N->body['und'][0]['value']); if (strlen($content) > 200) { $content = substr($content, 0, 200); } $CL = strrpos($content, ' '); $content = substr($content, 0, $CL) . '...'; $body .= '<h2 style="font-size:1.25em;">' . l($N->title, 'node/' . $N->nid, array('attributes' => array('style' => array('text-decoration' => 'none')))) . '</h2><p>' . $content . '</p> <p>' . t('read more: ') . l($base_url . '/' . drupal_lookup_path('alias', 'node/' . $N->nid), 'node/' . $N->nid, array('absolute' => TRUE)) . '</p> <hr/>'; } $data['message'] = 'Mail sent'; $to = $mail['mail']; $from = variable_get('site_mail', '*****@*****.**'); $params = array('body' => $body, 'rand' => $mail['rand'], 'to' => $to); $sent = drupal_mail('libya', 'subscription_alert_mail', $to, language_default(), $params, $from, TRUE); }
public function update() { $conf_res = M("Conf")->where("is_effect = 1 and is_conf = 1")->findAll(); foreach ($conf_res as $k => $v) { conf($v['name'], $_REQUEST[$v['name']]); if ($v['name'] == 'URL_MODEL' && $v['value'] != $_REQUEST[$v['name']]) { clear_dir_file(get_real_path() . "public/runtime/app/data_caches/"); clear_dir_file(get_real_path() . "public/runtime/app/tpl_caches/"); clear_dir_file(get_real_path() . "public/runtime/app/tpl_compiled/"); clear_dir_file(get_real_path() . "public/runtime/app/data_caches/"); clear_dir_file(get_real_path() . "public/runtime/data/page_static_cache/"); clear_dir_file(get_real_path() . "public/runtime/data/dynamic_avatar_cache/"); } } //开始写入配置文件 $sys_configs = M("Conf")->findAll(); $config_str = "<?php\n"; $config_str .= "return array(\n"; foreach ($sys_configs as $k => $v) { $config_str .= "'" . $v['name'] . "'=>'" . addslashes($v['value']) . "',\n"; } $config_str .= ");\n ?>"; $filename = get_real_path() . "public/sys_config.php"; if (!($handle = fopen($filename, 'w'))) { $this->error(l("OPEN_FILE_ERROR") . $filename); } if (fwrite($handle, $config_str) === FALSE) { $this->error(l("WRITE_FILE_ERROR") . $filename); } fclose($handle); save_log(l("CONF_UPDATED"), 1); //clear_cache(); write_timezone(); $this->success(L("UPDATE_SUCCESS")); }
public function foreverdelete() { //彻底删除指定记录 $ajax = intval($_REQUEST['ajax']); $id = $_REQUEST['id']; $ecv_type_id = 0; if (isset($id)) { $condition = array('id' => array('in', explode(',', $id))); $rel_data = M(MODULE_NAME)->where($condition)->findAll(); foreach ($rel_data as $data) { $info[] = $data['sn']; $ecv_type_id = $data['ecv_type_id']; } if ($info) { $info = implode(",", $info); } $list = M(MODULE_NAME)->where($condition)->delete(); if ($list !== false) { M("EcvType")->where("id=" . $ecv_type_id)->setField("gen_count", M("Ecv")->where("ecv_type_id=" . $ecv_type_id)->count()); save_log($info . l("FOREVER_DELETE_SUCCESS"), 1); $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax); } else { save_log($info . l("FOREVER_DELETE_FAILED"), 0); $this->error(l("FOREVER_DELETE_FAILED"), $ajax); } } else { $this->error(l("INVALID_OPERATION"), $ajax); } }
public function delete() { //彻底删除指定记录 $ajax = intval($_REQUEST['ajax']); $id = $_REQUEST['id']; if (isset($id)) { $condition = array('id' => array('in', explode(',', $id))); $rel_data = M(MODULE_NAME)->where($condition)->findAll(); $list = M(MODULE_NAME)->where($condition)->delete(); foreach ($rel_data as $data) { $info[] = "[单号:" . $data['notice_sn'] . "]"; } if ($info) { $info = implode(",", $info); } if ($list !== false) { save_log($info . "成功删除", 1); $this->success("成功删除", $ajax); } else { save_log($info . "删除出错", 0); $this->error("删除出错", $ajax); } } else { $this->error(l("INVALID_OPERATION"), $ajax); } }
public function index() { $chats = $this->Chats_model->get_list(true); $this->system_messages->set_data('header', l('admin_header_chats', 'chats')); $this->template_lite->assign('chats', $chats); $this->template_lite->view('list'); }
public function getHtmlContent() { $result = $this->getHtmlList(); $result .= '<hr/><p>' . l('[XML]', 'tour/' . $this->getId() . '/xml') . '</p>'; return $result; return theme('chgk_db_champ_full', $this); }
function tpl_modifier_time_ago($string) { $uts = tpl_make_timestamp($string); $mins = round((time() - $uts) / 60); if ($mins < 60) { return $mins . " " . l('mins_ago'); } else { $hours = round($mins / 60); if ($hours < 24) { return $hours . " " . l('hours_ago'); } else { $days = round($hours / 24); if ($days < 7) { return $days . " " . l('days_ago'); } else { $weeks = round($days / 7); if ($weeks < 3) { return $weeks . " " . l('weeks_ago'); } else { $months = round($days / 30); if ($months < 12) { return $months . " " . l('months_ago'); } else { $years = round($months / 12); return $years . " " . l('years_ago'); } } } } } return; }
public function structure($id, $fieldName, $context) { $page = empty($id) ? site() : page($id); if (!$page) { throw new Exception('The page could not be found'); } $blueprint = blueprint::find($page); $field = null; $fields = $context == 'file' ? $blueprint->files()->fields() : $blueprint->fields(); // make sure to get fields by case insensitive field names foreach ($fields as $f) { if (strtolower($f->name) == strtolower($fieldName)) { $field = $f; } } if (!$field) { throw new Exception('The field could not be found'); } $fields = new Blueprint\Fields($field->fields(), $page); $fields = $fields->toArray(); foreach ($fields as $key => $field) { if ($field['type'] == 'textarea') { $fields[$key]['buttons'] = false; } } $form = new Form($fields, null, $fieldName); $form->save = get('_id') ? l('fields.structure.save') : l('fields.structure.add'); return view('editor/structure', array('page' => $page, 'form' => $form)); }