- 1
- 2
function pageOutput() {
foreach($GLOBALS as $var => $val) $$var = &$GLOBALS[$var];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+6
function pageOutput() {
foreach($GLOBALS as $var => $val) $$var = &$GLOBALS[$var];
очередная находка..
...для тех, кто не уверен, какие переменные из global scope понадобятся...
+1
<?php if($this->config->get('UniversumControl_status') == '1'){ ?>
<style type="text/css">
body {
<?php if(( $this->config->get('UniversumControl_body_bg_pattern') != null) && ($this->config->get('UniversumControl_body_bg_pattern') != 'pattern0.png')){ ?>
background:url("catalog/view/theme/<?php echo $this->config->get('config_template'); ?>/image/backgrounds/<?php echo $this->config->get('UniversumControl_body_bg_pattern');?>") top center repeat;
<?php } ?>
background-color:#<?php echo $this->config->get('UniversumControl_body_bg_color') ?>;
font-family:<?php echo $this->config->get('UniversumControl_body_font') ?>;
color:#<?php echo $this->config->get('UniversumControl_text_color') ?>;
}
h1,h2,h3,h4,h5,h6, #menu ul li a, #column-left .box .box-heading, #column-right .box .box-heading, .htabs a, .product-info .price-old, .product-info .price-new, .product-info .cart .button, .offer_title, div.prod_hold .prod-info-fly .name a, .accordeonHolder .name a, .prod_hold .name a, #content .boxPlain .box-heading {
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_custom_font') != null)){ ?>
font-family: '<?php echo $this->config->get('UniversumControl_custom_font_family');?>';
<?php } elseif (($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_custom_font') == null) && ( $this->config->get('UniversumControl_header_font') != 'Arial')){ ?>
<?php $headerFont = $this->config->get('UniversumControl_headings_font');
$font = str_replace("+", " ", $headerFont);
?> font-family: '<?php echo $font; ?>';
<?php } else { ?>
font-family: 'Ubuntu Condensed';
<?php } ?>
}
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings_color') != null)){ ?>
h1, h2, h2.heading_title, h3, h4, h5, h6, #column-left .box .box-heading, #column-right .box .box-heading {
color:#<?php echo $this->config->get('UniversumControl_headings_color') ?>;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings1_size') != null)){ ?>
h1 {
font-size:<?php echo $this->config->get('UniversumControl_headings1_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings2_size') != null)){ ?>
h2, #content .boxPlain .box-heading {
font-size:<?php echo $this->config->get('UniversumControl_headings2_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings3_size') != null)){ ?>
h3 {
font-size:<?php echo $this->config->get('UniversumControl_headings3_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_headings4_size') != null)){ ?>
h4 {
font-size:<?php echo $this->config->get('UniversumControl_headings4_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_price_size') != null)){ ?>
.product-info .price {
font-size:<?php echo $this->config->get('UniversumControl_price_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_module_title_size') != null)){ ?>
#content h2.heading_title span {
font-size:<?php echo $this->config->get('UniversumControl_module_title_size') ?>px;
}
<?php } ?>
<?php if(($this->config->get('UniversumControl_status') == '1') && ( $this->config->get('UniversumControl_column_title_size') != null)){ ?>
#column-left .box .box-heading, #column-right .box .box-heading {
font-size:<?php echo $this->config->get('UniversumControl_column_title_size') ?>px;
}
И такого кода там еще на 1000 строк.
Интернет-магазин на опенкарте. Видимо кто то сделал систему настраивания css через админку))
+2
try {
$files->load($avatar);
$this->fail('Fail message');
} catch (\Exception $ex) {
//All good
}
Это авто тест на метод $files->load
$this->fail - здесь кидает исключение
All good - и не важно какое исключение кинет $files->load, а если не кинет, то вызовем fail который наверняка кинет исключение
−3
$this->strQueryText = $strQuery = trim($arParams["QUERY"]);
$this->strTags = $strTags = $arParams["TAGS"];
Из ядра.
Многобуков не любят.
+9
<ul>
<?php if($user_comment_rating == '1') { ?>
<li><span class="icon-star"></span></li>
<?php } else if($user_comment_rating == '2') { ?>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<?php } else if($user_comment_rating == '3') { ?>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<?php } else if($user_comment_rating == '4') { ?>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<?php } else if($user_comment_rating == '5') { ?>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<li><span class="icon-star"></span></li>
<?php } ?>
</ul>
Из шаблона одной платной вордпрессовской темы.
+5
foreach ($this->diafan->select_arr("status_id") as $id => $value)
{
$first_status = $id;
break;
}
Сниппет для получения первого ключа массива.
+2
$table = (object) null;
$table->fields = array();
Повышенная хитрость
0
public function getDialogs($offset = 0) {
$offset = (int) $offset;
$to_id = $_SESSION['user_id'];
if(!$to_id) {
return false;
}
$get_dialogs = $this->database->prepare("SELECT * FROM `messages` WHERE `to_id` = :to_id GROUP BY `from_id` LIMIT :offset, :max_posts");
$get_dialogs->bindParam(':to_id', $to_id, PDO::PARAM_INT);
$get_dialogs->bindParam(':offset', $offset, PDO::PARAM_INT);
$get_dialogs->bindParam(':max_posts', $this->max_dialogs, PDO::PARAM_INT);
$get_dialogs->execute();
$post_owners = array();
while ($row = $get_dialogs->fetch(PDO::FETCH_ASSOC)) {
$owner_id = $row['from_id'];
if($post_owners[$owner_id]) {
$row['owner_name'] = $post_owners[$owner_id];
} else {
$owner_name = $this->user->getInitials($owner_id);
$post_owners[$owner_id] = $owner_name;
$row['owner_name'] = $owner_name;
}
$row['date'] = $this->common->parseTimestamp($row['date_created']);
$arr[] = $row;
}
return $arr;
}
получение сообщений
+1
<?php
class Controller_Messages extends Controller {
function __construct() {
$this->log = new Log;
if(!defined('SECURITY_CONST')) {
$this->log->log('[controller_messages.php:'.__LINE__.'] SECURITY_CONST is undefined');
exit;
}
$this->user = new User;
$this->lang = new Lang;
$this->view = new View;
$this->model = new Model_Messages;
if(!$this->user->isAuth()) {
header('Location: /not_auth');
}
$this->user_lang = $this->user->getLang();
$this->lang->setLang($this->user_lang);
}
Открыл исходник и тут такое....
+2
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
foreach ($arResult["ITEMS"] as $key => $arItem)
{
$res = CIBlockSection::GetList(array(), array("ID" => $arItem['IBLOCK_SECTION_ID']), false, array("SECTION_PAGE_URL", "NAME"));
if($ar_res = $res->GetNext())
$arResult["ITEMS"][$key]["SECTION_URL"] = '<a href="'.$ar_res["SECTION_PAGE_URL"] .'">'.$ar_res["NAME"].'</a>';
$arResult["ITEMS"][$key]["SECTION_URI"] = $ar_res['SECTION_PAGE_URL'];
$arResult["ITEMS"][$key]["SECTION_NAME"] = $ar_res['NAME'];
if(is_array($arItem["PREVIEW_PICTURE"]))
{
$arFileTmp = CFile::ResizeImageGet(
$arItem["PREVIEW_PICTURE"],
array("width" => $arParams["DISPLAY_IMG_WIDTH"], "height" => $arParams["DISPLAY_IMG_HEIGHT"]),
BX_RESIZE_IMAGE_EXACT,
true
);
$arResult['ITEMS'][$key]['PREVIEW_PICTURE']['SRC'] = $arFileTmp['src'];
}
$arResult['ITEMS'][$key]["NAME"] = TruncateText($arResult['ITEMS'][$key]["NAME"],45);
$arResult['ITEMS'][$key]["PREVIEW_TEXT"] = TruncateText($arResult['ITEMS'][$key]["PREVIEW_TEXT"],80);
}
?>
Я программист 1C-bitrix и с каждой новой итерацией я делаю новый запрос к инфоблоку.