PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи

Страниц (1): [1]

> Найдено сообщений: 9
lola_lola Отправлено: 27 Октября, 2015 - 21:00:37 • Тема: Добавление alt в fancybox • Форум: JavaScript & VBScript

Ответов: 0
Просмотров: 304
Кто сталкивался с fancybox? Помогите разобраться: есть код для фотогалереи, мне необходимо, чтобы добавлялся атрибут alt в изображении в строке <img class="fancybox-image" src="{href}" alt="" /> по тому же принципе, что и href. Помогите, пожалуйста, разобраться куда и какие строки надо дописать. Заранее спасибо
lola_lola Отправлено: 26 Октября, 2015 - 20:32:59 • Тема: Помогите с fancybox • Форум: Напишите за меня, пожалуйста

Ответов: 0
Просмотров: 33
Есть код для фотогалереи, мне необходимо, чтобы добавлялся атрибут alt в изображении в строке <img class="fancybox-image" src="{href}" alt="" /> по тому же принципе, что и href. Помогите, пожалуйста, разобраться куда и какие строки надо дописать. Заранее спасибо

CODE (htmlphp):
скопировать код в буфер обмена
  1. /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
  2. (function(r, G, f, v) {
  3.     var J = f("html"),
  4.         n = f(r),
  5.         p = f(G),
  6.         b = f.fancybox = function() {
  7.             b.open.apply(this, arguments)
  8.         },
  9.         I = navigator.userAgent.match(/msie/i),
  10.         B = null,
  11.         s = G.createTouch !== v,
  12.         t = function(a) {
  13.             return a && a.hasOwnProperty && a instanceof f
  14.        },
  15.        q = function(a) {
  16.            return a && "string" === f.type(a)
  17.        },
  18.        E = function(a) {
  19.            return q(a) && 0 < a.indexOf("%")
  20.        },
  21.        l = function(a, d) {
  22.            var e = parseInt(a, 10) || 0;
  23.             d && E(a) && (e *= b.getViewport()[d] / 100);
  24.             return Math.ceil(e)
  25.         },
  26.         w = function(a, b) {
  27.             return l(a, b) + "px"
  28.         };
  29.     f.extend(b, {
  30.         version: "2.1.5",
  31.         defaults: {
  32.             padding: 15,
  33.             margin: 20,
  34.             width: 800,
  35.             height: 600,
  36.             minWidth: 100,
  37.             minHeight: 100,
  38.             maxWidth: 9999,
  39.             maxHeight: 9999,
  40.             pixelRatio: 1,
  41.             autoSize: !0,
  42.             autoHeight: !1,
  43.             autoWidth: !1,
  44.             autoResize: !0,
  45.             autoCenter: !s,
  46.             fitToView: !0,
  47.             aspectRatio: !1,
  48.             topRatio: 0.5,
  49.             leftRatio: 0.5,
  50.             scrolling: "auto",
  51.             wrapCSS: "",
  52.             arrows: !0,
  53.             closeBtn: !0,
  54.             closeClick: !1,
  55.             nextClick: !1,
  56.             mouseWheel: !0,
  57.             autoPlay: !1,
  58.             playSpeed: 3E3,
  59.             preload: 3,
  60.             modal: !1,
  61.             loop: !0,
  62.             ajax: {
  63.                 dataType: "html",
  64.                 headers: {
  65.                     "X-fancyBox": !0
  66.                 }
  67.             },
  68.             iframe: {
  69.                 scrolling: "auto",
  70.                 preload: !0
  71.             },
  72.             swf: {
  73.                 wmode: "transparent",
  74.                 allowfullscreen: "true",
  75.                 allowscriptaccess: "always"
  76.             },
  77.             keys: {
  78.                 next: {
  79.                     13: "left",
  80.                     34: "up",
  81.                     39: "left",
  82.                     40: "up"
  83.                 },
  84.                 prev: {
  85.                     8: "right",
  86.                     33: "down",
  87.                     37: "right",
  88.                     38: "down"
  89.                 },
  90.                 close: [27],
  91.                 play: [32],
  92.                 toggle: [70]
  93.             },
  94.             direction: {
  95.                 next: "left",
  96.                 prev: "right"
  97.             },
  98.             scrollOutside: !0,
  99.             index: 0,
  100.             type: null,
  101.             href: null,
  102.             content: null,
  103.             title: null,
  104.             tpl: {
  105.                 wrap: '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
  106.                 image: '<img class="fancybox-image" src="{href}" alt="{alt}" />',
  107.                 iframe: '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' +
  108.                    (I ? ' allowtransparency="true"' : "") + "></iframe>",
  109.                 error: '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
  110.                 closeBtn: '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
  111.                 next: '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
  112.                 prev: '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
  113.             },
  114.             openEffect: "fade",
  115.             openSpeed: 250,
  116.             openEasing: "swing",
  117.             openOpacity: !0,
  118.             openMethod: "zoomIn",
  119.             closeEffect: "fade",
  120.             closeSpeed: 250,
  121.             closeEasing: "swing",
  122.             closeOpacity: !0,
  123.             closeMethod: "zoomOut",
  124.             nextEffect: "elastic",
  125.             nextSpeed: 250,
  126.             nextEasing: "swing",
  127.             nextMethod: "changeIn",
  128.             prevEffect: "elastic",
  129.             prevSpeed: 250,
  130.             prevEasing: "swing",
  131.             prevMethod: "changeOut",
  132.             helpers: {
  133.                 overlay: !0,
  134.                 title: !0
  135.             },
  136.             onCancel: f.noop,
  137.             beforeLoad: f.noop,
  138.             afterLoad: f.noop,
  139.             beforeShow: f.noop,
  140.             afterShow: f.noop,
  141.             beforeChange: f.noop,
  142.             beforeClose: f.noop,
  143.             afterClose: f.noop
  144.         },
  145.         group: {},
  146.         opts: {},
  147.         previous: null,
  148.         coming: null,
  149.         current: null,
  150.         isActive: !1,
  151.         isOpen: !1,
  152.         isOpened: !1,
  153.         wrap: null,
  154.         skin: null,
  155.         outer: null,
  156.         inner: null,
  157.         player: {
  158.             timer: null,
  159.             isActive: !1
  160.         },
  161.         ajaxLoad: null,
  162.         imgPreload: null,
  163.         transitions: {},
  164.         helpers: {},
  165.         open: function(a, d) {
  166.             if (a && (f.isPlainObject(d) || (d = {}), !1 !== b.close(!0))) return f.isArray(a) || (a = t(a) ? f(a).get() : [a]), f.each(a, function(e, c) {
  167.                var k = {},
  168.                    g, g1, h, j, m, l;
  169.                 "object" === f.type(c) && (c.nodeType && (c = f(c)), t(c) ? (k = {
  170.                    href: c.data("fancybox-href") || c.attr("href"),
  171.                    alt: c.data("fancybox_alt") || c.attr("alt"),
  172.                    title: c.data("fancybox-title") || c.attr("title"),
  173.                    isDom: !0,
  174.                    element: c
  175.                }, f.metadata && f.extend(!0, k,
  176.                    c.metadata())) : k = c);
  177.                 g = d.href || k.href || (q(c) ? c : null);
  178.                 g1 = d.alt || k.alt || (q(c) ? c : null);
  179.                 h = d.title !== v ? d.title : k.title || "";
  180.                 m = (j = d.content || k.content) ? "html" : d.type || k.type;
  181.                 !m && k.isDom && (m = c.data("fancybox-type"), m || (m = (m = c.prop("class").match(/fancybox\.(\w+)/)) ? m[1] : null));
  182.                 q(g) && (m || (b.isImage(g) ? m = "image" : b.isSWF(g) ? m = "swf" : "#" === g.charAt(0) ? m = "inline" : q(c) && (m = "html", j = c)), "ajax" === m && (l = g.split(/\s+/, 2), g = l.shift(), l = l.shift()));
  183.                 j || ("inline" === m ? g ? j = f(q(g) ? g.replace(/.*(?=#[^\s]+$)/, "") : g) : k.isDom && (j = c) : "html" === m ? j = g : !m && (!g &&
  184.                    k.isDom) && (m = "inline", j = c));
  185.                 f.extend(k, {
  186.                     href: g,
  187.                     alt: g1,
  188.                     type: m,
  189.                     content: j,
  190.                     title: h,
  191.                     selector: l
  192.                 });
  193.                 a[e] = k
  194.             }), b.opts = f.extend(!0, {}, b.defaults, d), d.keys !== v && (b.opts.keys = d.keys ? f.extend({}, b.defaults.keys, d.keys) : !1), b.group = a, b._start(b.opts.index)
  195.        },
  196.        cancel: function() {
  197.            var a = b.coming;
  198.             a && !1 !== b.trigger("onCancel") && (b.hideLoading(), b.ajaxLoad && b.ajaxLoad.abort(), b.ajaxLoad = null, b.imgPreload && (b.imgPreload.onload = b.imgPreload.onerror = null), a.wrap && a.wrap.stop(!0, !0).trigger("onReset").remove(), b.coming = null, b.current ||
  199.                b._afterZoomOut(a))
  200.        },
  201.        close: function(a) {
  202.            b.cancel();
  203.             !1 !== b.trigger("beforeClose") && (b.unbindEvents(), b.isActive && (!b.isOpen || !0 === a ? (f(".fancybox-wrap").stop(!0).trigger("onReset").remove(), b._afterZoomOut()) : (b.isOpen = b.isOpened = !1, b.isClosing = !0, f(".fancybox-item, .fancybox-nav").remove(), b.wrap.stop(!0, !0).removeClass("fancybox-opened"), b.transitions[b.current.closeMethod]())))
  204.        },
  205.        play: function(a) {
  206.            var d = function() {
  207.                    clearTimeout(b.player.timer)
  208.                },
  209.                e = function() {
  210.                    d();
  211.                     b.current && b.player.isActive && (b.player.timer =
  212.                        setTimeout(b.next, b.current.playSpeed))
  213.                },
  214.                c = function() {
  215.                    d();
  216.                     p.unbind(".player");
  217.                     b.player.isActive = !1;
  218.                     b.trigger("onPlayEnd")
  219.                 };
  220.             if (!0 === a || !b.player.isActive && !1 !== a) {
  221.                if (b.current && (b.current.loop || b.current.index < b.group.length - 1)) b.player.isActive = !0, p.bind({
  222.                    "onCancel.player beforeClose.player": c,
  223.                    "onUpdate.player": e,
  224.                    "beforeLoad.player": d
  225.                }), e(), b.trigger("onPlayStart")
  226.            } else c()
  227.        },
  228.        next: function(a) {
  229.            var d = b.current;
  230.             d && (q(a) || (a = d.direction.next), b.jumpto(d.index + 1, a, "next"))
  231.        },
  232.        prev: function(a) {
  233.            var d = b.current;
  234.             d && (q(a) || (a = d.direction.prev), b.jumpto(d.index - 1, a, "prev"))
  235.        },
  236.        jumpto: function(a, d, e) {
  237.            var c = b.current;
  238.             c && (a = l(a), b.direction = d || c.direction[a >= c.index ? "next" : "prev"], b.router = e || "jumpto", c.loop && (0 > a && (a = c.group.length + a % c.group.length), a %= c.group.length), c.group[a] !== v && (b.cancel(), b._start(a)))
  239.        },
  240.        reposition: function(a, d) {
  241.            var e = b.current,
  242.                c = e ? e.wrap : null,
  243.                k;
  244.             c && (k = b._getPosition(d), a && "scroll" === a.type ? (delete k.position, c.stop(!0, !0).animate(k, 200)) : (c.css(k), e.pos = f.extend({}, e.dim, k)))
  245.        },
  246.        update: function(a) {
  247.            var d =
  248.                a && a.type,
  249.                e = !d || "orientationchange" === d;
  250.             e && (clearTimeout(B), B = null);
  251.             b.isOpen && !B && (B = setTimeout(function() {
  252.                var c = b.current;
  253.                 c && !b.isClosing && (b.wrap.removeClass("fancybox-tmp"), (e || "load" === d || "resize" === d && c.autoResize) && b._setDimension(), "scroll" === d && c.canShrink || b.reposition(a), b.trigger("onUpdate"), B = null)
  254.            }, e && !s ? 0 : 300))
  255.        },
  256.        toggle: function(a) {
  257.            b.isOpen && (b.current.fitToView = "boolean" === f.type(a) ? a : !b.current.fitToView, s && (b.wrap.removeAttr("style").addClass("fancybox-tmp"), b.trigger("onUpdate")),
  258.                b.update())
  259.        },
  260.        hideLoading: function() {
  261.            p.unbind(".loading");
  262.             f("#fancybox-loading").remove()
  263.         },
  264.         showLoading: function() {
  265.             var a, d;
  266.             b.hideLoading();
  267.             a = f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body");
  268.             p.bind("keydown.loading", function(a) {
  269.                 if (27 === (a.which || a.keyCode)) a.preventDefault(), b.cancel()
  270.             });
  271.             b.defaults.fixed || (d = b.getViewport(), a.css({
  272.                 position: "absolute",
  273.                 top: 0.5 * d.h + d.y,
  274.                 left: 0.5 * d.w + d.x
  275.             }))
  276.         },
  277.         getViewport: function() {
  278.             var a = b.current && b.current.locked || !1,
  279.                d = {
  280.                    x: n.scrollLeft(),
  281.                    y: n.scrollTop()
  282.                };
  283.             a ? (d.w = a[0].clientWidth, d.h = a[0].clientHeight) : (d.w = s && r.innerWidth ? r.innerWidth : n.width(), d.h = s && r.innerHeight ? r.innerHeight : n.height());
  284.             return d
  285.         },
  286.         unbindEvents: function() {
  287.             b.wrap && t(b.wrap) && b.wrap.unbind(".fb");
  288.             p.unbind(".fb");
  289.             n.unbind(".fb")
  290.         },
  291.         bindEvents: function() {
  292.             var a = b.current,
  293.                 d;
  294.             a && (n.bind("orientationchange.fb" + (s ? "" : " resize.fb") + (a.autoCenter && !a.locked ? " scroll.fb" : ""), b.update), (d = a.keys) && p.bind("keydown.fb", function(e) {
  295.                var c = e.which || e.keyCode,
  296.                    k = e.target || e.srcElement;
  297.                 if (27 === c && b.coming) return !1;
  298.                 !e.ctrlKey && (!e.altKey && !e.shiftKey && !e.metaKey && (!k || !k.type && !f(k).is("[contenteditable]"))) && f.each(d, function(d, k) {
  299.                    if (1 < a.group.length && k[c] !== v) return b[d](k[c]), e.preventDefault(), !1;
  300.                     if (-1 < f.inArray(c, k)) return b[d](), e.preventDefault(), !1
  301.                })
  302.            }), f.fn.mousewheel && a.mouseWheel && b.wrap.bind("mousewheel.fb", function(d, c, k, g) {
  303.                for (var h = f(d.target || null), j = !1; h.length && !j && !h.is(".fancybox-skin") && !h.is(".fancybox-wrap");) j = h[0] && !(h[0].style.overflow && "hidden" === h[0].style.overflow) &&
  304.                    (h[0].clientWidth && h[0].scrollWidth > h[0].clientWidth || h[0].clientHeight && h[0].scrollHeight > h[0].clientHeight), h = f(h).parent();
  305.                 if (0 !== c && !j && 1 < b.group.length && !a.canShrink) {
  306.                    if (0 < g || 0 < k) b.prev(0 < g ? "down" : "left");
  307.                     else if (0 > g || 0 > k) b.next(0 > g ? "up" : "right");
  308.                     d.preventDefault()
  309.                 }
  310.             }))
  311.         },
  312.         trigger: function(a, d) {
  313.             var e, c = d || b.coming || b.current;
  314.             if (c) {
  315.                 f.isFunction(c[a]) && (e = c[a].apply(c, Array.prototype.slice.call(arguments, 1)));
  316.                 if (!1 === e) return !1;
  317.                 c.helpers && f.each(c.helpers, function(d, e) {
  318.                    if (e && b.helpers[d] && f.isFunction(b.helpers[d][a])) b.helpers[d][a](f.extend(!0, {}, b.helpers[d].defaults, e), c)
  319.                });
  320.                 p.trigger(a)
  321.             }
  322.         },
  323.         isImage: function(a) {
  324.             return q(a) && a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)
  325.        },
  326.        isSWF: function(a) {
  327.            return q(a) && a.match(/\.(swf)((\?|#).*)?$/i)
  328.        },
  329.        _start: function(a) {
  330.            var d = {},
  331.                e, c;
  332.             a = l(a);
  333.             e = b.group[a] || null;
  334.             if (!e) return !1;
  335.             d = f.extend(!0, {}, b.opts, e);
  336.             e = d.margin;
  337.             c = d.padding;
  338.             "number" === f.type(e) && (d.margin = [e, e, e, e]);
  339.             "number" === f.type(c) && (d.padding = [c, c, c, c]);
  340.             d.modal && f.extend(!0, d, {
  341.                closeBtn: !1,
  342.                closeClick: !1,
  343.                nextClick: !1,
  344.                arrows: !1,
  345.                mouseWheel: !1,
  346.                keys: null,
  347.                helpers: {
  348.                    overlay: {
  349.                        closeClick: !1
  350.                    }
  351.                }
  352.            });
  353.             d.autoSize && (d.autoWidth = d.autoHeight = !0);
  354.             "auto" === d.width && (d.autoWidth = !0);
  355.             "auto" === d.height && (d.autoHeight = !0);
  356.             d.group = b.group;
  357.             d.index = a;
  358.             b.coming = d;
  359.             if (!1 === b.trigger("beforeLoad")) b.coming = null;
  360.             else {
  361.                 c = d.type;
  362.                 e = d.href;
  363.                 f = d.alt;
  364.                 if (!c) return b.coming = null, b.current && b.router && "jumpto" !== b.router ? (b.current.index = a, b[b.router](b.direction)) : !1;
  365.                 b.isActive = !0;
  366.                 if ("image" === c || "swf" === c) d.autoHeight = d.autoWidth = !1, d.scrolling = "visible";
  367.                 "image" === c && (d.aspectRatio = !0);
  368.                 "iframe" === c && s && (d.scrolling = "scroll");
  369.                 d.wrap = f(d.tpl.wrap).addClass("fancybox-" + (s ? "mobile" : "desktop") + " fancybox-type-" + c + " fancybox-tmp " + d.wrapCSS).appendTo(d.parent || "body");
  370.                 f.extend(d, {
  371.                     skin: f(".fancybox-skin", d.wrap),
  372.                     outer: f(".fancybox-outer", d.wrap),
  373.                     inner: f(".fancybox-inner", d.wrap)
  374.                 });
  375.                 f.each(["Top", "Right", "Bottom", "Left"], function(a, b) {
  376.                     d.skin.css("padding" + b, w(d.padding[a]))
  377.                 });
  378.                 b.trigger("onReady");
  379.                 if ("inline" === c || "html" === c) {
  380.                     if (!d.content || !d.content.length) return b._error("content")
  381.                 } else if (!e) return b._error("href");
  382.                 "image" === c ? b._loadImage() : "ajax" === c ? b._loadAjax() : "iframe" === c ? b._loadIframe() : b._afterLoad()
  383.             }
  384.         },
  385.         _error: function(a) {
  386.             f.extend(b.coming, {
  387.                 type: "html",
  388.                 autoWidth: !0,
  389.                 autoHeight: !0,
  390.                 minWidth: 0,
  391.                 minHeight: 0,
  392.                 scrolling: "no",
  393.                 hasError: a,
  394.                 content: b.coming.tpl.error
  395.             });
  396.             b._afterLoad()
  397.         },
  398.         _loadImage: function() {
  399.             var a = b.imgPreload = new Image;
  400.             a.onload = function() {
  401.                 this.onload = this.onerror = null;
  402.                 b.coming.width = this.width / b.opts.pixelRatio;
  403.                 b.coming.height = this.height / b.opts.pixelRatio;
  404.                 b._afterLoad()
  405.             };
  406.             a.onerror = function() {
  407.                 this.onload =
  408.                     this.onerror = null;
  409.                 b._error("image")
  410.             };
  411.             a.src = b.coming.href;
  412.             !0 !== a.complete && b.showLoading()
  413.        },
  414.        _loadAjax: function() {
  415.            var a = b.coming;
  416.             b.showLoading();
  417.             b.ajaxLoad = f.ajax(f.extend({}, a.ajax, {
  418.                 url: a.href,
  419.                 error: function(a, e) {
  420.                     b.coming && "abort" !== e ? b._error("ajax", a) : b.hideLoading()
  421.                },
  422.                success: function(d, e) {
  423.                    "success" === e && (a.content = d, b._afterLoad())
  424.                }
  425.            }))
  426.        },
  427.        _loadIframe: function() {
  428.            var a = b.coming,
  429.                d = f(a.tpl.iframe.replace(/\{rnd\}/g, (new Date).getTime())).attr("scrolling", s ? "auto" : a.iframe.scrolling).attr("src", a.href);
  430.             f(a.wrap).bind("onReset", function() {
  431.                 try {
  432.                     f(this).find("iframe").hide().attr("src", "//about:blank").end().empty()
  433.                 } catch (a) {}
  434.             });
  435.             a.iframe.preload && (b.showLoading(), d.one("load", function() {
  436.                f(this).data("ready", 1);
  437.                 s || f(this).bind("load.fb", b.update);
  438.                 f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();
  439.                 b._afterLoad()
  440.             }));
  441.             a.content = d.appendTo(a.inner);
  442.             a.iframe.preload || b._afterLoad()
  443.         },
  444.         _preloadImages: function() {
  445.             var a = b.group,
  446.                 d = b.current,
  447.                 e = a.length,
  448.                 c = d.preload ? Math.min(d.preload,
  449.                     e - 1) : 0,
  450.                 f, g;
  451.             for (g = 1; g <= c; g += 1) f = a[(d.index + g) % e], "image" === f.type && f.href && ((new Image).src = f.href)
  452.        },
  453.        _afterLoad: function() {
  454.            var a = b.coming,
  455.                d = b.current,
  456.                e, c, k, g, h;
  457.            b.hideLoading();
  458.            if (a && !1 !== b.isActive)
  459.                if (!1 === b.trigger("afterLoad", a, d)) a.wrap.stop(!0).trigger("onReset").remove(), b.coming = null;
  460.                else {
  461.                    d && (b.trigger("beforeChange", d), d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());
  462.                    b.unbindEvents();
  463.                    e = a.content;
  464.                    c = a.type;
  465.                    k = a.scrolling;
  466.                    f.extend(b, {
  467.                        wrap: a.wrap,
  468.                        skin: a.skin,
  469.                        outer: a.outer,
  470.                        inner: a.inner,
  471.                        current: a,
  472.                        previous: d
  473.                    });
  474.                    g = a.href;
  475.                    switch (c) {
  476.                        case "inline":
  477.                        case "ajax":
  478.                        case "html":
  479.                            a.selector ? e = f("<div>").html(e).find(a.selector) : t(e) && (e.data("fancybox-placeholder") || e.data("fancybox-placeholder", f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()), e = e.show().detach(), a.wrap.bind("onReset", function() {
  480.                                f(this).find(e).length && e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder", !1)
  481.                            }));
  482.                             break;
  483.                         case "image":
  484.                             e = a.tpl.image.replace("{href}",
  485.                                 g);
  486.                             break;
  487.                         case "swf":
  488.                             e = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + g + '"></param>', h = "", f.each(a.swf, function(a, b) {
  489.                                 e += '<param name="' + a + '" value="' + b + '"></param>';
  490.                                 h += " " + a + '="' + b + '"'
  491.                             }), e += '<embed src="' + g + '" type="application/x-shockwave-flash" width="100%" height="100%"' + h + "></embed></object>"
  492.                     }(!t(e) || !e.parent().is(a.inner)) && a.inner.append(e);
  493.                     b.trigger("beforeShow");
  494.                     a.inner.css("overflow", "yes" === k ? "scroll" :
  495.                         "no" === k ? "hidden" : k);
  496.                     b._setDimension();
  497.                     b.reposition();
  498.                     b.isOpen = !1;
  499.                     b.coming = null;
  500.                     b.bindEvents();
  501.                     if (b.isOpened) {
  502.                         if (d.prevMethod) b.transitions[d.prevMethod]()
  503.                     } else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();
  504.                     b.transitions[b.isOpened ? a.nextMethod : a.openMethod]();
  505.                     b._preloadImages()
  506.                 }
  507.         },
  508.         _setDimension: function() {
  509.             var a = b.getViewport(),
  510.                 d = 0,
  511.                 e = !1,
  512.                 c = !1,
  513.                 e = b.wrap,
  514.                 k = b.skin,
  515.                 g = b.inner,
  516.                 h = b.current,
  517.                 c = h.width,
  518.                 j = h.height,
  519.                 m = h.minWidth,
  520.                 u = h.minHeight,
  521.                 n = h.maxWidth,
  522.                 p = h.maxHeight,
  523.                 s = h.scrolling,
  524.                 q = h.scrollOutside ?
  525.                 h.scrollbarWidth : 0,
  526.                 x = h.margin,
  527.                 y = l(x[1] + x[3]),
  528.                 r = l(x[0] + x[2]),
  529.                 v, z, t, C, A, F, B, D, H;
  530.             e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");
  531.             x = l(k.outerWidth(!0) - k.width());
  532.             v = l(k.outerHeight(!0) - k.height());
  533.             z = y + x;
  534.             t = r + v;
  535.             C = E(c) ? (a.w - z) * l(c) / 100 : c;
  536.             A = E(j) ? (a.h - t) * l(j) / 100 : j;
  537.             if ("iframe" === h.type) {
  538.                 if (H = h.content, h.autoHeight && 1 === H.data("ready")) try {
  539.                    H[0].contentWindow.document.location && (g.width(C).height(9999), F = H.contents().find("body"), q && F.css("overflow-x", "hidden"), A = F.outerHeight(!0))
  540.                } catch (G) {}
  541.            } else if (h.autoWidth ||
  542.                h.autoHeight) g.addClass("fancybox-tmp"), h.autoWidth || g.width(C), h.autoHeight || g.height(A), h.autoWidth && (C = g.width()), h.autoHeight && (A = g.height()), g.removeClass("fancybox-tmp");
  543.             c = l(C);
  544.             j = l(A);
  545.             D = C / A;
  546.             m = l(E(m) ? l(m, "w") - z : m);
  547.             n = l(E(n) ? l(n, "w") - z : n);
  548.             u = l(E(u) ? l(u, "h") - t : u);
  549.             p = l(E(p) ? l(p, "h") - t : p);
  550.             F = n;
  551.             B = p;
  552.             h.fitToView && (n = Math.min(a.w - z, n), p = Math.min(a.h - t, p));
  553.             z = a.w - y;
  554.             r = a.h - r;
  555.             h.aspectRatio ? (c > n && (c = n, j = l(c / D)), j > p && (j = p, c = l(j * D)), c < m && (c = m, j = l(c / D)), j < u && (j = u, c = l(j * D))) : (c = Math.max(m, Math.min(c, n)), h.autoHeight &&
  556.                "iframe" !== h.type && (g.width(c), j = g.height()), j = Math.max(u, Math.min(j, p)));
  557.             if (h.fitToView)
  558.                 if (g.width(c).height(j), e.width(c + x), a = e.width(), y = e.height(), h.aspectRatio)
  559.                     for (;
  560.                         (a > z || y > r) && (c > m && j > u) && !(19 < d++);) j = Math.max(u, Math.min(p, j - 10)), c = l(j * D), c < m && (c = m, j = l(c / D)), c > n && (c = n, j = l(c / D)), g.width(c).height(j), e.width(c + x), a = e.width(), y = e.height();
  561.                 else c = Math.max(m, Math.min(c, c - (a - z))), j = Math.max(u, Math.min(j, j - (y - r)));
  562.             q && ("auto" === s && j < A && c + x + q < z) && (c += q);
  563.             g.width(c).height(j);
  564.             e.width(c + x);
  565.             a = e.width();
  566.             y = e.height();
  567.             e = (a > z || y > r) && c > m && j > u;
  568.             c = h.aspectRatio ? c < F && j < B && c < C && j < A : (c < F || j < B) && (c < C || j < A);
  569.            f.extend(h, {
  570.                dim: {
  571.                    width: w(a),
  572.                    height: w(y)
  573.                },
  574.                origWidth: C,
  575.                origHeight: A,
  576.                canShrink: e,
  577.                canExpand: c,
  578.                wPadding: x,
  579.                hPadding: v,
  580.                wrapSpace: y - k.outerHeight(!0),
  581.                skinSpace: k.height() - j
  582.            });
  583.            !H && (h.autoHeight && j > u && j < p && !c) && g.height("auto")
  584.        },
  585.        _getPosition: function(a) {
  586.            var d = b.current,
  587.                e = b.getViewport(),
  588.                c = d.margin,
  589.                f = b.wrap.width() + c[1] + c[3],
  590.                g = b.wrap.height() + c[0] + c[2],
  591.                c = {
  592.                    position: "absolute",
  593.                    top: c[0],
  594.                    left: c[3]
  595.                };
  596.             d.autoCenter && d.fixed &&
  597.                !a && g <= e.h && f <= e.w ? c.position = "fixed" : d.locked || (c.top += e.y, c.left += e.x);
  598.             c.top = w(Math.max(c.top, c.top + (e.h - g) * d.topRatio));
  599.             c.left = w(Math.max(c.left, c.left + (e.w - f) * d.leftRatio));
  600.             return c
  601.         },
  602.         _afterZoomIn: function() {
  603.             var a = b.current;
  604.             a && (b.isOpen = b.isOpened = !0, b.wrap.css("overflow", "visible").addClass("fancybox-opened"), b.update(), (a.closeClick || a.nextClick && 1 < b.group.length) && b.inner.css("cursor", "pointer").bind("click.fb", function(d) {
  605.                !f(d.target).is("a") && !f(d.target).parent().is("a") && (d.preventDefault(),
  606.                    b[a.closeClick ? "close" : "next"]())
  607.            }), a.closeBtn && f(a.tpl.closeBtn).appendTo(b.skin).bind("click.fb", function(a) {
  608.                a.preventDefault();
  609.                 b.close()
  610.             }), a.arrows && 1 < b.group.length && ((a.loop || 0 < a.index) && f(a.tpl.prev).appendTo(b.outer).bind("click.fb", b.prev), (a.loop || a.index < b.group.length - 1) && f(a.tpl.next).appendTo(b.outer).bind("click.fb", b.next)), b.trigger("afterShow"), !a.loop && a.index === a.group.length - 1 ? b.play(!1) : b.opts.autoPlay && !b.player.isActive && (b.opts.autoPlay = !1, b.play()))
  611.        },
  612.        _afterZoomOut: function(a) {
  613.            a =
  614.                a || b.current;
  615.             f(".fancybox-wrap").trigger("onReset").remove();
  616.             f.extend(b, {
  617.                 group: {},
  618.                 opts: {},
  619.                 router: !1,
  620.                 current: null,
  621.                 isActive: !1,
  622.                 isOpened: !1,
  623.                 isOpen: !1,
  624.                 isClosing: !1,
  625.                 wrap: null,
  626.                 skin: null,
  627.                 outer: null,
  628.                 inner: null
  629.             });
  630.             b.trigger("afterClose", a)
  631.         }
  632.     });
  633.     b.transitions = {
  634.         getOrigPosition: function() {
  635.             var a = b.current,
  636.                 d = a.element,
  637.                 e = a.orig,
  638.                 c = {},
  639.                 f = 50,
  640.                 g = 50,
  641.                 h = a.hPadding,
  642.                 j = a.wPadding,
  643.                 m = b.getViewport();
  644.             !e && (a.isDom && d.is(":visible")) && (e = d.find("img:first"), e.length || (e = d));
  645.             t(e) ? (c = e.offset(), e.is("img") && (f = e.outerWidth(), g = e.outerHeight())) :
  646.                (c.top = m.y + (m.h - g) * a.topRatio, c.left = m.x + (m.w - f) * a.leftRatio);
  647.             if ("fixed" === b.wrap.css("position") || a.locked) c.top -= m.y, c.left -= m.x;
  648.             return c = {
  649.                 top: w(c.top - h * a.topRatio),
  650.                 left: w(c.left - j * a.leftRatio),
  651.                 width: w(f + j),
  652.                 height: w(g + h)
  653.             }
  654.         },
  655.         step: function(a, d) {
  656.             var e, c, f = d.prop;
  657.             c = b.current;
  658.             var g = c.wrapSpace,
  659.                 h = c.skinSpace;
  660.             if ("width" === f || "height" === f) e = d.end === d.start ? 1 : (a - d.start) / (d.end - d.start), b.isClosing && (e = 1 - e), c = "width" === f ? c.wPadding : c.hPadding, c = a - c, b.skin[f](l("width" === f ? c : c - g * e)), b.inner[f](l("width" ===
  661.                f ? c : c - g * e - h * e))
  662.        },
  663.        zoomIn: function() {
  664.            var a = b.current,
  665.                d = a.pos,
  666.                e = a.openEffect,
  667.                c = "elastic" === e,
  668.                k = f.extend({
  669.                    opacity: 1
  670.                }, d);
  671.             delete k.position;
  672.             c ? (d = this.getOrigPosition(), a.openOpacity && (d.opacity = 0.1)) : "fade" === e && (d.opacity = 0.1);
  673.             b.wrap.css(d).animate(k, {
  674.                 duration: "none" === e ? 0 : a.openSpeed,
  675.                 easing: a.openEasing,
  676.                 step: c ? this.step : null,
  677.                 complete: b._afterZoomIn
  678.             })
  679.         },
  680.         zoomOut: function() {
  681.             var a = b.current,
  682.                 d = a.closeEffect,
  683.                 e = "elastic" === d,
  684.                 c = {
  685.                     opacity: 0.1
  686.                 };
  687.             e && (c = this.getOrigPosition(), a.closeOpacity && (c.opacity = 0.1));
  688.             b.wrap.animate(c, {
  689.                 duration: "none" === d ? 0 : a.closeSpeed,
  690.                 easing: a.closeEasing,
  691.                 step: e ? this.step : null,
  692.                 complete: b._afterZoomOut
  693.             })
  694.         },
  695.         changeIn: function() {
  696.             var a = b.current,
  697.                 d = a.nextEffect,
  698.                 e = a.pos,
  699.                 c = {
  700.                     opacity: 1
  701.                 },
  702.                 f = b.direction,
  703.                 g;
  704.             e.opacity = 0.1;
  705.             "elastic" === d && (g = "down" === f || "up" === f ? "top" : "left", "down" === f || "right" === f ? (e[g] = w(l(e[g]) - 200), c[g] = "+=200px") : (e[g] = w(l(e[g]) + 200), c[g] = "-=200px"));
  706.             "none" === d ? b._afterZoomIn() : b.wrap.css(e).animate(c, {
  707.                 duration: a.nextSpeed,
  708.                 easing: a.nextEasing,
  709.                 complete: b._afterZoomIn
  710.             })
  711.         },
  712.         changeOut: function() {
  713.             var a =
  714.                 b.previous,
  715.                 d = a.prevEffect,
  716.                 e = {
  717.                     opacity: 0.1
  718.                 },
  719.                 c = b.direction;
  720.             "elastic" === d && (e["down" === c || "up" === c ? "top" : "left"] = ("up" === c || "left" === c ? "-" : "+") + "=200px");
  721.             a.wrap.animate(e, {
  722.                 duration: "none" === d ? 0 : a.prevSpeed,
  723.                 easing: a.prevEasing,
  724.                 complete: function() {
  725.                     f(this).trigger("onReset").remove()
  726.                 }
  727.             })
  728.         }
  729.     };
  730.     b.helpers.overlay = {
  731.         defaults: {
  732.             closeClick: !0,
  733.             speedOut: 200,
  734.             showEarly: !0,
  735.             css: {},
  736.             locked: !s,
  737.             fixed: !0
  738.         },
  739.         overlay: null,
  740.         fixed: !1,
  741.         el: f("html"),
  742.         create: function(a) {
  743.             a = f.extend({}, this.defaults, a);
  744.             this.overlay && this.close();
  745.             this.overlay =
  746.                 f('<div class="fancybox-overlay"></div>').appendTo(b.coming ? b.coming.parent : a.parent);
  747.             this.fixed = !1;
  748.             a.fixed && b.defaults.fixed && (this.overlay.addClass("fancybox-overlay-fixed"), this.fixed = !0)
  749.        },
  750.        open: function(a) {
  751.            var d = this;
  752.             a = f.extend({}, this.defaults, a);
  753.             this.overlay ? this.overlay.unbind(".overlay").width("auto").height("auto") : this.create(a);
  754.             this.fixed || (n.bind("resize.overlay", f.proxy(this.update, this)), this.update());
  755.             a.closeClick && this.overlay.bind("click.overlay", function(a) {
  756.                if (f(a.target).hasClass("fancybox-overlay")) return b.isActive ?
  757.                    b.close() : d.close(), !1
  758.            });
  759.             this.overlay.css(a.css).show()
  760.         },
  761.         close: function() {
  762.             var a, b;
  763.             n.unbind("resize.overlay");
  764.             this.el.hasClass("fancybox-lock") && (f(".fancybox-margin").removeClass("fancybox-margin"), a = n.scrollTop(), b = n.scrollLeft(), this.el.removeClass("fancybox-lock"), n.scrollTop(a).scrollLeft(b));
  765.             f(".fancybox-overlay").remove().hide();
  766.             f.extend(this, {
  767.                 overlay: null,
  768.                 fixed: !1
  769.             })
  770.         },
  771.         update: function() {
  772.             var a = "100%",
  773.                 b;
  774.             this.overlay.width(a).height("100%");
  775.             I ? (b = Math.max(G.documentElement.offsetWidth, G.body.offsetWidth),
  776.                 p.width() > b && (a = p.width())) : p.width() > n.width() && (a = p.width());
  777.             this.overlay.width(a).height(p.height())
  778.         },
  779.         onReady: function(a, b) {
  780.             var e = this.overlay;
  781.             f(".fancybox-overlay").stop(!0, !0);
  782.             e || this.create(a);
  783.             a.locked && (this.fixed && b.fixed) && (e || (this.margin = p.height() > n.height() ? f("html").css("margin-right").replace("px", "") : !1), b.locked = this.overlay.append(b.wrap), b.fixed = !1);
  784.             !0 === a.showEarly && this.beforeShow.apply(this, arguments)
  785.        },
  786.        beforeShow: function(a, b) {
  787.            var e, c;
  788.             b.locked && (!1 !== this.margin && (f("*").filter(function() {
  789.                return "fixed" ===
  790.                    f(this).css("position") && !f(this).hasClass("fancybox-overlay") && !f(this).hasClass("fancybox-wrap")
  791.            }).addClass("fancybox-margin"), this.el.addClass("fancybox-margin")), e = n.scrollTop(), c = n.scrollLeft(), this.el.addClass("fancybox-lock"), n.scrollTop(e).scrollLeft(c));
  792.             this.open(a)
  793.         },
  794.         onUpdate: function() {
  795.             this.fixed || this.update()
  796.         },
  797.         afterClose: function(a) {
  798.             this.overlay && !b.coming && this.overlay.fadeOut(a.speedOut, f.proxy(this.close, this))
  799.        }
  800.    };
  801.     b.helpers.title = {
  802.         defaults: {
  803.             type: "float",
  804.             position: "bottom"
  805.         },
  806.         beforeShow: function(a) {
  807.             var d =
  808.                 b.current,
  809.                 e = d.title,
  810.                 c = a.type;
  811.             f.isFunction(e) && (e = e.call(d.element, d));
  812.             if (q(e) && "" !== f.trim(e)) {
  813.                d = f('<div class="fancybox-title fancybox-title-' + c + '-wrap">' + e + "</div>");
  814.                 switch (c) {
  815.                     case "inside":
  816.                         c = b.skin;
  817.                         break;
  818.                     case "outside":
  819.                         c = b.wrap;
  820.                         break;
  821.                     case "over":
  822.                         c = b.inner;
  823.                         break;
  824.                     default:
  825.                         c = b.skin, d.appendTo("body"), I && d.width(d.width()), d.wrapInner('<span class="child"></span>'), b.current.margin[2] += Math.abs(l(d.css("margin-bottom")))
  826.                }
  827.                d["top" === a.position ? "prependTo" : "appendTo"](c)
  828.            }
  829.        }
  830.    };
  831.     f.fn.fancybox = function(a) {
  832.         var d,
  833.             e = f(this),
  834.             c = this.selector || "",
  835.             k = function(g) {
  836.                 var h = f(this).blur(),
  837.                     j = d,
  838.                     k, l;
  839.                 !g.ctrlKey && (!g.altKey && !g.shiftKey && !g.metaKey) && !h.is(".fancybox-wrap") && (k = a.groupAttr || "data-fancybox-group", l = h.attr(k), l || (k = "rel", l = h.get(0)[k]), l && ("" !== l && "nofollow" !== l) && (h = c.length ? f(c) : e, h = h.filter("[" + k + '="' + l + '"]'), j = h.index(this)), a.index = j, !1 !== b.open(h, a) && g.preventDefault())
  840.            };
  841.         a = a || {};
  842.         d = a.index || 0;
  843.         !c || !1 === a.live ? e.unbind("click.fb-start").bind("click.fb-start", k) : p.undelegate(c, "click.fb-start").delegate(c +
  844.             ":not('.fancybox-item, .fancybox-nav')", "click.fb-start", k);
  845.         this.filter("[data-fancybox-start=1]").trigger("click");
  846.         return this
  847.     };
  848.     p.ready(function() {
  849.         var a, d;
  850.         f.scrollbarWidth === v && (f.scrollbarWidth = function() {
  851.            var a = f('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),
  852.                 b = a.children(),
  853.                 b = b.innerWidth() - b.height(99).innerWidth();
  854.             a.remove();
  855.             return b
  856.         });
  857.         if (f.support.fixedPosition === v) {
  858.             a = f.support;
  859.             d = f('<div style="position:fixed;top:20px;"></div>').appendTo("body");
  860.             var e = 20 ===
  861.                 d[0].offsetTop || 15 === d[0].offsetTop;
  862.             d.remove();
  863.             a.fixedPosition = e
  864.         }
  865.         f.extend(b.defaults, {
  866.             scrollbarWidth: f.scrollbarWidth(),
  867.             fixed: f.support.fixedPosition,
  868.             parent: f("body")
  869.         });
  870.         a = f(r).width();
  871.         J.addClass("fancybox-lock-test");
  872.         d = f(r).width();
  873.         J.removeClass("fancybox-lock-test");
  874.         f("<style type='text/css'>.fancybox-margin{margin-right:" + (d - a) + "px;}</style>").appendTo("head")
  875.     })
  876. })(window, document, jQuery);
lola_lola Отправлено: 21 Октября, 2015 - 15:20:04 • Тема: Добавление и загрузка изображений с описанием • Форум: Вопросы новичков

Ответов: 2
Просмотров: 149
Пытаюсь так, но не добавляет

function AppendPics($Container)
{
$pattern = '|[0-9_]+|is';
$Container->order = $this->getMaxPicsOrder()+1;
$array = array();
if(($Container->bigPhoto)||($Container->alt)){
$array = $Container->bigPhoto;
$array = $Container->alt;
}
foreach($array as $k=>$v){
preg_match($pattern,$Container->bigPhoto[$k],$arr);
eval('$txt = $Container->img_text'.$arr[0].';');

$Query="INSERT INTO ".TableArticlesPics."(`articleID`,`alt`,`description`,`bigPhoto`,`mediumPhoto`,`smallPhoto`, `order`,`img_txt`) VALUES('{$Container->id}', '{$Container->alt}','{$Container->photoDescription[$k]}','{$Container->bigPhoto[$k]}','{$Container->mediumPhoto[$k]}','{$Container->smallPhoto[$k]}', '{$Container->order}', '{$txt}')";
$Container->order++;
if(strlen($v))
parent::Append($Query);
}

}
lola_lola Отправлено: 21 Октября, 2015 - 00:26:13 • Тема: Добавление и загрузка изображений с описанием • Форум: Вопросы новичков

Ответов: 2
Просмотров: 149
Добрый день, подскажите, пожалуйста, как лучше поступить. Второй день пытаюсь решить проблему и запутываю себя сильнее и сильнее, хотя казалось бы простая вещь.
У меня в системе есть страницы добавления и изменения товара. Товар имеет изображения, которые загружаются с помощью ajax+php скрипта, без перезагрузки страницы. Изначально была задача добавлять только картинки, для дальнейшего создания слайдера. С этим проблем нет, но теперь еще необходимо добавить к каждой картинке input с описанием и сохранить значение в ту же таблицу. У меня две отдельные функции для добавления изображения и описания, но не могу сообразить, как их соединить, чтобы каждое описание было к конкретной картинке. Спасибо
lola_lola Отправлено: 27 Августа, 2015 - 17:22:30 • Тема: Проблема с добавлением записи в базу • Форум: Вопросы новичков

Ответов: 9
Просмотров: 323
ну с колонками title и date проблем нет, проблема возникает в description в строках, где символ тире)) и я не понимаю почему он так на него реагирует
(Добавление)
Всем спасибо, проблема решена
lola_lola Отправлено: 27 Августа, 2015 - 17:07:53 • Тема: Проблема с добавлением записи в базу • Форум: Вопросы новичков

Ответов: 9
Просмотров: 323
Я уже пробовала несколько раз! в phpmyadmin добавляет полную строку без проблем
lola_lola Отправлено: 27 Августа, 2015 - 16:59:11 • Тема: Проблема с добавлением записи в базу • Форум: Вопросы новичков

Ответов: 9
Просмотров: 323
Да, в echo отображает, что все парсится, но на деле в базе строка только до тире! Что странно.
lola_lola Отправлено: 27 Августа, 2015 - 15:54:01 • Тема: Проблема с добавлением записи в базу • Форум: Вопросы новичков

Ответов: 9
Просмотров: 323
andrewkard пишет:
lola_lola
Возможно проблема с кодировкой, проверьте перед вставкой, что передается:
PHP:
скопировать код в буфер обмена
  1.  
  2. echo ("INSERT INTO `tablename` (`title`,`date`,`description`)VALUES('{$out['title'][$i]}','{$out['date'][$i]}','{$out['description'][$i]}');")
  3.  

Кодировка таблиц, БД и полей лучше в utf8 что бы была. После соединения к БД передайте устанавливаемую кодировку


Установила изначально utf8 для базы и таблиц
lola_lola Отправлено: 27 Августа, 2015 - 14:18:04 • Тема: Проблема с добавлением записи в базу • Форум: Вопросы новичков

Ответов: 9
Просмотров: 323
Добрый день. Пытаюсь делать тестовое задание, чтобы устроиться на работу. Второй день не могу понять и решить проблему. В базу строка добавляется только до знака тире, а потом обрывается. Есть делать запрос в phpmyadmin , то добавляется идеально. Что не так в коде? Я новичок и прошу быть помягче в критике

<?php

include_once ('simple_html_dom.php');

require_once('connectvars.php');

$page = file_get_html ('http://tcpulse.zpao.com/news');

foreach ($page->find ('table.page-box tbody tr td table tbody tr td[align=left] p a[class=headline]') as $href){
$article[] = $href -> href;
}

/*print_r($article);*/

for ($i=0; $i<=count($article); $i++) {

$text = file_get_html('http://tcpulse.zpao.com'.$article[$i]);


$title = $text->find('table.page-box tbody tr td table tbody tr td[align=left] span[class=article-headline]');
$date = $text->find ('table.page-box tbody tr td table tbody tr td[align=left] span[class=article-date-author]');
$description = $text->find ('table.page-box tbody tr td table tbody tr td[align=left] span[class=article-body]');


foreach ($title as $temp) {
$out['title'][]=$temp->innertext;
}

foreach ($date as $temp) {
$temp =str_replace(",",'', $temp->innertext);
$dates = explode(" ", $temp);
$string = "$dates[2]-$dates[0]-$dates[1]";
$temp = date("Y-m-d", strtotime($string));

$out['date'][]=$temp;
}


foreach($text->find('table.page-box tbody tr td table tbody tr td[align=left]') as $temp2){ $temp2->outertext = '';}
foreach($text->find('table.page-box tbody tr td table tbody tr td[align=left] div[class=postbox-header]') as $temp3){ $temp3->outertext = ''; }
foreach($text->find('table.page-box tbody tr td table tbody tr td[align=left] div[class=postbox-post]') as $temp4){ $temp4->outertext = ''; }
foreach ($text->find('table.page-box tbody tr td table tbody tr td[align=left] div[class=postbox-blurb]') as $temp5){ $temp5->outertext = ''; }
foreach ($text->find('table.page-box tbody tr td table tbody') as $temp6){ $temp6->outertext = ''; }
foreach ($description as $temp) {
$out['description'][]=strip_tags_deep($temp->innertext);
}
}

function strip_tags_deep($value)
{
return is_array($value) ?
array_map('strip_tags_deep', $value) :
strip_tags($value);
}

$imageName ='logo.gif';
$imageContent = file_get_contents('http://tcpulse.zpao.com/assets/pulse.gif');
file_put_contents('./'.$imageName, $imageContent);

$mysql=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('ERROR CONNECTION');
$db_selected = mysql_select_db(DB_NAME, $mysql);

for($i=0;$i<count($out['title']);$i++)
{

$out['title'][$i]=mysql_real_escape_string($out['title'][$i]);
$out['date'][$i]=mysql_real_escape_string($out['date'][$i]);
$out['description'][$i]=mysql_real_escape_string($out['description'][$i]);

$sql=("INSERT INTO `tablename` (`title`,`date`,`description`)VALUES('{$out['title'][$i]}','{$out['date'][$i]}','{$out['description'][$i]}');");

mysql_query($sql);

}
/* print_r($out);*/

?>

Страниц (1): [1]
Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB