public function update($id, $data) { $comment = $this->commentRepo->get($id); $user = Auth::user(); if (array_key_exist('likes', $data)) { if (!$this->comment->isLiked($comment)) { $data = ['dog_comment_id' => $comment->id, 'user_id' => $user->id]; $this->commentLikeRepo->create($data); } else { $likeid = $this->comment->getCommentLike($data); $this->dogCommentLike->delete($id); } } }
function offsetExists($key) { $key = trim($key, "/"); if (strpos(trim($key, "/"), "/") !== false) { // Break up the path, work on the top part and pass the rest on. $keys = explode("/", $key); $tk = array_shift($keys); $key = join("/", $keys); if (!array_key_exists($tk, $this->nodes)) { return false; } } return array_key_exist($key, $this->nodes[$tk]); }
/** * Clears objects from the cache * @param string $type Type of the objects to clear, provide null to clear the complete cache * @param string $id Id of the cache object to clear * @return null */ public function clearCache($type = null, $id = null) { $this->readTypes(); if (is_null($type)) { foreach ($this->cache as $type => $cache) { $this->cache[$type] = array(); } return; } if (is_null($id)) { if (array_key_exist($type, $this->cache)) { $this->cache[$type] = array(); } return; } if (array_key_exists($id, $this->cache[$type])) { unset($this->cache[$type]); } }
function set_fields_insert_prototyped($field, $value, $index) { if (!array_key_exist($field, $this->inserts[$index]['data'])) { $this->inserts[$index]['fields'] .= ', ' . $field; $this->inserts[$index]['values'] .= ', ' . $value; } }
/** * tag : PAGE * mode : OPEN * * @param array $param * @return boolean */ protected function _tag_open_PAGE($param) { if ($this->_isForOneLine) { return false; } if ($this->_debugActif) { $this->_DEBUG_add('PAGE ' . ($this->_page + 1), true); } $newPageSet = !isset($param['pageset']) || $param['pageset'] != 'old'; $resetPageNumber = isset($param['pagegroup']) && $param['pagegroup'] == 'new'; if (array_key_exist('hideheader', $param) && $param['hideheader'] != 'false' && !empty($param['hideheader'])) { $this->_hideHeader = (array) array_merge($this->_hideHeader, split(',', $param['hideheader'])); } $this->_maxH = 0; // if new page set asked if ($newPageSet) { $this->_subHEADER = array(); $this->_subFOOTER = array(); // orientation $orientation = ''; if (isset($param['orientation'])) { $param['orientation'] = strtolower($param['orientation']); if ($param['orientation'] == 'p') { $orientation = 'P'; } if ($param['orientation'] == 'portrait') { $orientation = 'P'; } if ($param['orientation'] == 'l') { $orientation = 'L'; } if ($param['orientation'] == 'paysage') { $orientation = 'L'; } if ($param['orientation'] == 'landscape') { $orientation = 'L'; } } // format $format = null; if (isset($param['format'])) { $format = strtolower($param['format']); if (preg_match('/^([0-9]+)x([0-9]+)$/isU', $format, $match)) { $format = array(intval($match[1]), intval($match[2])); } } // background $background = array(); if (isset($param['backimg'])) { $background['img'] = isset($param['backimg']) ? $param['backimg'] : ''; // src of the image $background['posX'] = isset($param['backimgx']) ? $param['backimgx'] : 'center'; // horizontale position of the image $background['posY'] = isset($param['backimgy']) ? $param['backimgy'] : 'middle'; // vertical position of the image $background['width'] = isset($param['backimgw']) ? $param['backimgw'] : '100%'; // width of the image (100% = page width) // convert the src of the image, if parameters $background['img'] = str_replace('&', '&', $background['img']); // convert the positions if ($background['posX'] == 'left') { $background['posX'] = '0%'; } if ($background['posX'] == 'center') { $background['posX'] = '50%'; } if ($background['posX'] == 'right') { $background['posX'] = '100%'; } if ($background['posY'] == 'top') { $background['posY'] = '0%'; } if ($background['posY'] == 'middle') { $background['posY'] = '50%'; } if ($background['posY'] == 'bottom') { $background['posY'] = '100%'; } if ($background['img']) { // get the size of the image // WARNING : if URL, "allow_url_fopen" must turned to "on" in php.ini $infos = @getimagesize($background['img']); if (count($infos) > 1) { $imageWidth = $this->parsingCss->ConvertToMM($background['width'], $this->pdf->getW()); $imageHeight = $imageWidth * $infos[1] / $infos[0]; $background['width'] = $imageWidth; $background['posX'] = $this->parsingCss->ConvertToMM($background['posX'], $this->pdf->getW() - $imageWidth); $background['posY'] = $this->parsingCss->ConvertToMM($background['posY'], $this->pdf->getH() - $imageHeight); } else { $background = array(); } } else { $background = array(); } } // margins of the page $background['top'] = isset($param['backtop']) ? $param['backtop'] : '0'; $background['bottom'] = isset($param['backbottom']) ? $param['backbottom'] : '0'; $background['left'] = isset($param['backleft']) ? $param['backleft'] : '0'; $background['right'] = isset($param['backright']) ? $param['backright'] : '0'; // if no unit => mm if (preg_match('/^([0-9]*)$/isU', $background['top'])) { $background['top'] .= 'mm'; } if (preg_match('/^([0-9]*)$/isU', $background['bottom'])) { $background['bottom'] .= 'mm'; } if (preg_match('/^([0-9]*)$/isU', $background['left'])) { $background['left'] .= 'mm'; } if (preg_match('/^([0-9]*)$/isU', $background['right'])) { $background['right'] .= 'mm'; } // convert to mm $background['top'] = $this->parsingCss->ConvertToMM($background['top'], $this->pdf->getH()); $background['bottom'] = $this->parsingCss->ConvertToMM($background['bottom'], $this->pdf->getH()); $background['left'] = $this->parsingCss->ConvertToMM($background['left'], $this->pdf->getW()); $background['right'] = $this->parsingCss->ConvertToMM($background['right'], $this->pdf->getW()); // get the background color $res = false; $background['color'] = isset($param['backcolor']) ? $this->parsingCss->convertToColor($param['backcolor'], $res) : null; if (!$res) { $background['color'] = null; } $this->parsingCss->save(); $this->parsingCss->analyse('PAGE', $param); $this->parsingCss->setPosition(); $this->parsingCss->fontSet(); // new page $this->_setNewPage($format, $orientation, $background, null, $resetPageNumber); // automatic footer if (isset($param['footer'])) { $lst = explode(';', $param['footer']); foreach ($lst as $key => $val) { $lst[$key] = trim(strtolower($val)); } $page = in_array('page', $lst); $date = in_array('date', $lst); $hour = in_array('heure', $lst); $form = in_array('form', $lst); } else { $page = null; $date = null; $hour = null; $form = null; } $this->pdf->SetMyFooter($page, $date, $hour, $form); // else => we use the last page set used } else { $this->parsingCss->save(); $this->parsingCss->analyse('PAGE', $param); $this->parsingCss->setPosition(); $this->parsingCss->fontSet(); $this->_setNewPage(null, null, null, null, $resetPageNumber); } return true; }