예제 #1
0
파일: admin.php 프로젝트: ngdvan/lntguitar
function getImage($image)
{
    if ($image) {
        $thumbImage = new Image(Yii::getPathOfAlias('webroot') . '/' . $image);
        $img_url = $thumbImage->createThumb(110, 70);
        return CHtml::image($img_url);
    }
}
예제 #2
0
파일: admin.php 프로젝트: ngdvan/lntguitar
function showImage($model)
{
    if (isset($model->image) && $model->image) {
        $thumbImage = new Image(Yii::getPathOfAlias('webroot') . '/' . $model->image);
        $img_url = $thumbImage->createThumb(110, 70);
        echo CHtml::image($img_url);
    }
}
예제 #3
0
파일: view.php 프로젝트: ngdvan/lntguitar
function getImgThumb($item)
{
    $path = Yii::getPathOfAlias('webroot') . $item['image'];
    if (file_exists($path)) {
        $img = new Image($path);
        return $img->createThumb(105, 70);
    } else {
        return Lnt::getYoutubeImage($item['link_youtube']);
    }
}
예제 #4
0
파일: admin.php 프로젝트: ngdvan/lntguitar
function getImage($image)
{
    $img = Yii::getPathOfAlias('webroot') . '/' . $image;
    if (file_exists($img) && is_file($img)) {
        //var_dump($img);die;
        $thumbImage = new Image($img);
        $img_url = $thumbImage->createThumb(110, 70);
        echo CHtml::image($img_url);
    }
    //var_dump($img);
}
예제 #5
0
 function image($conf, $multi = false)
 {
     $conf = $conf + ['dir' => '', 'key' => 'image', 'rename' => false, 'width' => false, 'height' => false, 'multi' => false, 'extensions' => Image::$extensions, 'conversion' => null];
     extract($conf);
     $func = 'file' . ($multi ? 's' : '');
     $dir = rtrim($dir, '/') . '/';
     return $this->{$func}($dir, $key, 'image/', function ($file) use($width, $height, $rename, $conversion) {
         $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
         if ($conversion && $ext != $conversion && ($imgFormat = exif_imagetype($file)) != constant('IMAGETYPE_' . strtoupper($conversion))) {
             switch ($imgFormat) {
                 case IMAGETYPE_GIF:
                     $img = imagecreatefromgif($file);
                     break;
                 case IMAGETYPE_JPEG:
                     $img = imagecreatefromjpeg($file);
                     break;
                 case IMAGETYPE_PNG:
                     $img = imagecreatefrompng($file);
                     break;
                 default:
                     throw new UploadException('image format conversion not supported');
                     break;
             }
             $oldFile = $file;
             $file = substr($file, 0, -1 * strlen($ext)) . $conversion;
             $ext = $conversion;
             $convertF = 'image' . $conversion;
             $convertF($img, $file);
             unlink($oldFile);
         }
         if ($rename) {
             if ($rename === true) {
                 $rename = 'image';
             }
             $rename = $this->formatFilename($rename);
             rename($file, dirname($file) . '/' . $rename . '.' . $ext);
         }
         if (($width || $height) && in_array($ext, Image::$extensions_resizable)) {
             $thumb = dirname($file) . '/' . pathinfo($file, PATHINFO_FILENAME) . '.' . $width . 'x' . $height . '.' . $ext;
             Image::createThumb($file, $thumb, $width, $height, 100, true);
         }
     }, function ($file) use($extensions) {
         $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
         if (!in_array($ext, (array) $extensions)) {
             throw new UploadException('extension');
         }
     });
 }
예제 #6
0
 public function renderContent()
 {
     $criteria1 = new CDbCriteria(array('condition' => 'status=1'));
     $all = (int) Teacher::model()->count($criteria1);
     if ($all > 5) {
         $offset = rand(0, $all - 5);
     } else {
         $offset = rand(0, $all);
     }
     $criteria = new CDbCriteria(array('condition' => 'status=1', 'order' => 'RAND()', 'limit' => '5,' . $offset));
     //echo $all;
     $teachers = Teacher::model()->findAll($criteria);
     if ($teachers) {
         echo CHtml::openTag("ul");
         foreach ($teachers as $teacher) {
             $img = '';
             if ($teacher->picture) {
                 Yii::import('application.extensions.image.Image');
                 $thumbImage = new Image(Yii::getPathOfAlias('webroot') . $teacher->picture);
                 $img_url = $thumbImage->createThumb(70, 60);
                 /*$thumbImage->resize(70, 60, Image::WIDTH);
                   $arr = explode("/",$teacher->picture);
                   $file_name = $arr[count($arr)-1];
                   $thumb = Yii::getPathOfAlias('webroot') . '/resources/images/85x72/' . $file_name;
                   $thumbImage->save($thumb);*/
                 $img = '<img src="' . $img_url . '" />';
             }
             echo CHtml::openTag("li", array('class' => 'clearfix'));
             echo CHtml::openTag("div", array('class' => 'avatar'));
             echo CHtml::link($img, Yii::app()->createUrl('/teacher/view', array('id' => $teacher->id, 'title' => Lnt::safeTitle($teacher->name))));
             echo "<div>Giảng viên</div>";
             echo CHtml::closeTag("div");
             echo CHtml::openTag("div", array('class' => 'title'));
             echo CHtml::link($teacher->name, Yii::app()->createUrl('/teacher/view', array('id' => $teacher->id, 'title' => Lnt::safeTitle($teacher->name))));
             echo CHtml::closeTag("div");
             echo CHtml::openTag("div", array('style' => 'margin-top:10px;float:left;width:80px;height:14px;background:#ce1f46;color:#fff;padding:8px 0px;text-align:center'));
             echo "5.1232";
             echo CHtml::closeTag("div");
             echo CHtml::openTag("div", array('style' => 'float:right;text-align:left;width:127px;margin-top:10px;font-weight:bold;color:#a8a8a8;'));
             echo $teacher->videoCount . " bài giảng | " . $teacher->likeTeachersCount . " " . CHtml::ajaxLink(CHtml::image(Yii::app()->baseUrl . '/images/tim_03.jpg', 'Like', array('title' => 'Yêu thích')), Yii::app()->createUrl('/teacher/like', array('id' => $teacher->id)), array('success' => 'js:function(res){alert(res.msg);}'), array('class' => 'teacher_like'));
             echo CHtml::closeTag("div");
             echo CHtml::closeTag("li");
         }
         echo CHtml::closeTag("ul");
     }
 }
예제 #7
0
 public static function handleUpload($file, $path, $nameWithoutExtension, $thumbWidth = null)
 {
     $old = umask(0);
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
         $exploded = explode('/', rtrim('/', $path));
         $length = count($exploded) - 1;
         for ($i = 0; $i < $length; $i++) {
             array_pop($exploded);
             //pop off the last one every time. First one was already set so works perfectly.
             $chmod_path = implode('/', $exploded);
             chmod($chmod_path, 0777);
         }
     }
     umask($old);
     $extension = self::getExtension($file['name']);
     $destination = $path . $nameWithoutExtension . '.' . $extension;
     move_uploaded_file($file['tmp_name'], $destination);
     if ($thumbWidth) {
         Image::createThumb($destination, 100);
     }
     return $destination;
 }
예제 #8
0
파일: _form.php 프로젝트: ngdvan/lntguitar
echo $form->labelEx($model, 'image');
?>
        <?php 
//echo $form->textField($model, 'file_path', array('maxlength' => 255));
echo $form->fileField($model, 'image');
?>
        <?php 
echo $form->error($model, 'image');
?>
        <div id="image_box">
            <?php 
$imagPath = Yii::getPathOfAlias('webroot') . '/' . $model->image;
//var_dump($imagPath);die;
if (file_exists($imagPath) && is_file($imagPath)) {
    $thumbImage = new Image($imagPath);
    $img_url = $thumbImage->createThumb(110, 70);
    echo CHtml::image($img_url, $model->title, array('id' => 'image'));
    echo CHtml::ajaxButton('Xóa', $this->createUrl('delImage', array('id' => $model->id)), array('success' => 'js:function(){$("#image_box").remove()}'));
}
?>
        </div>
    </div>
    <!-- row -->
    <div class="row">
        <?php 
echo $form->labelEx($model, 'body');
?>
        <?php 
//echo $form->textArea($model, 'body');
/*$this->widget('application.extensions.cleditor.ECLEditor', array(
      'model' => $model,
예제 #9
0
파일: index.php 프로젝트: ngdvan/lntguitar
 ?>
 <ul class="banchay">
     <?php 
 Yii::import('application.extensions.image.Image');
 $i = 1;
 foreach ($items as $item) {
     $class = 'item';
     if ($i == 1 | $i % 4 == 1) {
         $class .= ' first';
     } elseif ($i % 4 == 0) {
         $class .= ' last';
     }
     $i++;
     //var_dump($item);die;
     $thumb = new Image(Yii::getPathOfAlias('webroot') . $item['image']);
     $img_url = $thumb->createThumb(140, 195);
     echo CHtml::openTag("li", array('class' => $class));
     echo CHtml::link(CHtml::image($img_url), $this->createUrl('view', array('id' => $item['id'], 'title' => Lnt::safeTitle($item['title']))));
     echo CHtml::openTag("div", array('class' => 'title'));
     echo CHtml::encode($item['title']);
     echo CHtml::closeTag("div");
     echo CHtml::openTag("div", array('class' => 'price'));
     echo CHtml::encode(number_format($item['price'], 0, ',', '.') . 'đ');
     echo CHtml::closeTag("div");
     echo CHtml::openTag("div", array('class' => 'body'));
     echo Lnt::limitWord($item['body'], 10, ',', '.');
     echo CHtml::closeTag("div");
     echo CHtml::closeTag("li");
 }
 ?>
 </ul>
예제 #10
0
파일: Lnt.php 프로젝트: ngdvan/lntguitar
 static function createImage($image, $width, $height)
 {
     if (!class_exists('Image', false)) {
         Yii::import('application.extensions.image.Image');
     }
     $path = Yii::getPathOfAlias('webroot') . $image;
     if (!is_file($path)) {
         $path = Yii::getPathOfAlias('webroot') . '/guitar.jpg';
     }
     $img = new Image($path);
     return $img->createThumb($width, $height);
 }
예제 #11
0
 private function getPrimaryImage($xml, $isPerson)
 {
     global $wgServer, $wgStylePath;
     foreach ($xml->image as $image) {
         if ($image['primary'] == 'true') {
             $t = Title::makeTitle(NS_IMAGE, (string) $image['filename']);
             if ($t && $t->exists()) {
                 $image = new Image($t);
                 $thumbURL = $wgServer . $image->createThumb(SearchForm::THUMB_WIDTH, SearchForm::THUMB_HEIGHT);
                 //               if ($isPerson) {
                 //                  $iconURL = $wgServer.$image->createThumb(TreeData::PERSON_ICON_WIDTH, TreeData::PERSON_ICON_HEIGHT);
                 //               }
                 //               else {
                 //                  $iconURL = '';
                 //               }
                 return $thumbURL;
             }
         }
     }
     if ($isPerson) {
         return $wgServer . $wgStylePath . ((string) $xml->gender == 'F' ? TreeData::WOMAN_THUMB : TreeData::MAN_THUMB);
     } else {
         return '';
     }
 }
예제 #12
0
     }
 } else {
     //货号不存在,自动增长货号
     $goodsinfo['g_sn'] = $goods->createAutoSn();
 }
 //接收图片并处理,不管图片是否上传成功,都不会影响整个商品记录的插入
 //var_dump($_FILES);exit;
 if ($path = Upload::uploadSingle($_FILES['goods_img'], $config['goods_img_upload'], $config['goods_img_upload_max'])) {
     //上传成功,将上传文件的相对路径存放到数据对应的字段下
     $goodsinfo['g_img'] = $path;
 } else {
     //上传失败,获取错误信息
     $error = Upload::$errorInfo;
 }
 $image = new Image();
 if ($thumb_path = $image->createThumb($goodsinfo['g_img'])) {
     //成功
     $goodsinfo['g_thumb_img'] = $thumb_path;
 }
 //插入到数据库
 if ($goods->insertGoods($goodsinfo)) {
     //插入成功
     //需要判断文件上传情况
     if (isset($error)) {
         //文件上传失败
         admin_redirect('goods.php?act=list', '新增商品成功!但是文件上传失败,失败原因是:' . $error, 2);
     } else {
         //文件上传成功
         admin_redirect('goods.php?act=list', '新增商品成功!', 2);
     }
 } else {
예제 #13
0
파일: Person.php 프로젝트: k-hasan-19/wiki
    /**
     * Create wiki text from xml property
     */
    protected function toWikiText($parser)
    {
        //        wfDebug("toWikiText=" . $this->xml->asXML() . "\n");
        global $wgESINHandler, $wgOut;
        $result = '';
        if (isset($this->xml)) {
            // check rename needed
            if (!$this->isGedcomPage && mb_strpos($this->titleString, 'Unknown') !== false) {
                $correctTitle = StructuredData::constructName(@$this->xml->name['given'], @$this->xml->name['surname']);
                if (Person::isRenameNeeded($this->titleString, $correctTitle)) {
                    $t = Title::makeTitle(NS_SPECIAL, 'Movepage');
                    $url = $t->getLocalURL('target=' . $this->title->getPrefixedURL() . '&wpNewTitle=' . wfUrlencode("Person:{$correctTitle}") . '&wpReason=' . wfUrlencode('make page title agree with name'));
                    $parser->mOutput->mSubtitle = 'This page can be <a href="' . $url . '">renamed</a>';
                    $wgOut->setSubtitle($parser->mOutput->mSubtitle);
                }
            }
            // add infoboxes
            $gender = (string) $this->xml->gender;
            switch ($gender) {
                case 'M':
                    $genderClass = '-male';
                    break;
                case 'F':
                    $genderClass = '-female';
                    break;
                default:
                    $genderClass = '';
            }
            $image = $wgESINHandler->getPrimaryImage($this->xml);
            $imageText = "<div class=\"wr-infobox-noimage{$genderClass}\"></div>";
            $imageURL = '';
            if (isset($image)) {
                $thumbWidth = SearchForm::THUMB_WIDTH;
                $filename = (string) $image['filename'];
                $t = Title::makeTitle(NS_IMAGE, $filename);
                if ($t && $t->exists()) {
                    $img = new Image($t);
                    $caption = (string) $image['caption'];
                    if (!$caption) {
                        $caption = $filename;
                    }
                    $maxWidth = 700;
                    $maxHeight = 300;
                    $width = $img->getWidth();
                    $height = $img->getHeight();
                    if ($maxWidth > $width * $maxHeight / $height) {
                        $maxWidth = wfFitBoxWidth($width, $height, $maxHeight);
                    }
                    $imageURL = $img->createThumb($maxWidth, $maxHeight);
                    $caption = str_replace('|', ' ', $caption);
                    $titleAttr = StructuredData::escapeXml("{$imageURL}|{$maxWidth}|{$caption}");
                    $imageText = "<span class=\"wr-imagehover\" title=\"{$titleAttr}\">[[Image:{$filename}|{$thumbWidth}x{$thumbWidth}px]]</span>";
                }
            }
            $fullname = StructuredData::getFullname($this->xml->name);
            if (!$fullname) {
                $fullname = '&nbsp;';
            }
            $birthDate = $birthPlace = $deathDate = $deathPlace = '';
            $chrDate = $chrPlace = $burDate = $burPlace = '';
            $birthFound = $deathFound = $chrFound = $burFound = false;
            $birthSource = $deathSource = false;
            if (isset($this->xml->event_fact)) {
                foreach ($this->xml->event_fact as $eventFact) {
                    if ($eventFact['type'] == 'Birth') {
                        $birthFound = true;
                        $birthDate = (string) $eventFact['date'];
                        $birthPlace = (string) $eventFact['place'];
                        $birthSource = (string) $eventFact['sources'];
                    } else {
                        if ($eventFact['type'] == 'Christening' || $eventFact['type'] == 'Baptism') {
                            $chrFound = true;
                            $chrDate = (string) $eventFact['date'];
                            $chrPlace = (string) $eventFact['place'];
                        } else {
                            if ($eventFact['type'] == 'Death') {
                                $deathFound = true;
                                $deathDate = (string) $eventFact['date'];
                                $deathPlace = (string) $eventFact['place'];
                                $deathSource = (string) $eventFact['sources'];
                            } else {
                                if ($eventFact['type'] == 'Burial') {
                                    $burFound = true;
                                    $burDate = (string) $eventFact['date'];
                                    $burPlace = (string) $eventFact['place'];
                                }
                            }
                        }
                    }
                }
            }
            $this->initHistoricalDataPerson($fullname, $gender, $imageURL);
            $birthLabel = '&nbsp;';
            if ($birthFound) {
                $birthLabel = 'b.';
                $this->addHistoricalDataEvent('birth', $birthDate, $birthPlace);
            } else {
                if ($chrFound) {
                    $birthLabel = 'chr.';
                    $this->addHistoricalDataEvent('christening', $chrDate, $chrPlace);
                    $birthDate = $chrDate;
                    $birthPlace = $chrPlace;
                }
            }
            $deathLabel = '&nbsp;';
            if ($deathFound) {
                $deathLabel = 'd.';
                $this->addHistoricalDataEvent('death', $deathDate, $deathPlace);
            } else {
                if ($burFound) {
                    $deathLabel = 'bur.';
                    $this->addHistoricalDataEvent('burial', $burDate, $burPlace);
                    $deathDate = $burDate;
                    $deathPlace = $burPlace;
                }
            }
            $fmtBirthPlace = Person::formatPlace($birthPlace);
            $fmtDeathPlace = Person::formatPlace($deathPlace);
            $familybadges = '';
            $marriageEvents = array();
            $parentFamilies = array();
            foreach ($this->xml->child_of_family as $f) {
                $parentFamilies[] = (string) $f['title'];
            }
            $found = false;
            foreach ($this->xml->child_of_family as $f) {
                list($key, $text) = $this->getFamilyBadge($f, true, $gender, $parentFamilies, $marriageEvents);
                $found = true;
                $familybadges .= $text;
            }
            if (!$found) {
                $familybadges .= $this->getAddFamilyLink(0);
            }
            $sort = array();
            $ix = 0;
            $prevKey = 0;
            $found = false;
            foreach ($this->xml->spouse_of_family as $f) {
                list($key, $text) = $this->getFamilyBadge($f, false, $gender, null, $marriageEvents);
                $found = true;
                if ($key) {
                    $prevKey = $key;
                } else {
                    $key = $prevKey;
                }
                $sort[$key * 50 + $ix] = $text;
                $ix++;
            }
            $result = <<<END
<div class="wr-infobox wr-infobox-person clearfix">
   <div class="wr-infobox-image">
      {$imageText}
   </div>
   <div class="wr-infobox-content">
      <div class="wr-infobox-fullname">{$fullname}</div>
      <div class="wr-infobox-event">{$birthLabel}<span class="wr-infobox-date">{$birthDate}</span> <span class="wr-infobox-place">{$fmtBirthPlace}</span></div>
      <div class="wr-infobox-event">{$deathLabel}<span class="wr-infobox-date">{$deathDate}</span> <span class="wr-infobox-place">{$fmtDeathPlace}</span></div>

   </div>
</div>
<wr_ad></wr_ad>
<div style="margin-top:2px" class="clearfix"><div id="wr_familytreelink" style="float:left">
<span class="wr-familytreelink-text">Family tree</span><span class="wr-familytreelink-arrow">▼</span>
</div><div style="float:right; margin-right:10px;">
</div></div>
END;
            ksort($sort, SORT_NUMERIC);
            foreach ($sort as $key => $text) {
                $familybadges .= $text;
            }
            $familybadges .= $this->getAddFamilyLink(!$found ? 1 : 2, (string) @$this->xml->name['given'], (string) @$this->xml->name['surname']);
            if ($familybadges) {
                $result .= "<div class=\"wr-infobox-familybadges\">{$familybadges}</div>";
            }
            //         $result .= '<div class="visualClearLeft"></div>';
            // add source citations, images, notes
            $result .= $wgESINHandler->addSourcesImagesNotes($this, $parser, $marriageEvents);
            // add categories
            $surnames = array();
            $surnames[] = (string) $this->xml->name['surname'];
            foreach ($this->xml->alt_name as $altName) {
                $surnames[] = (string) $altName['surname'];
            }
            $places = ESINHandler::getPlaces($this->xml);
            $result .= StructuredData::addCategories($surnames, $places, false);
        }
        return $result;
    }
예제 #14
0
파일: cart.php 프로젝트: ngdvan/lntguitar
        if ($product->image) {
            /*$thumb = '/upload/images/thumb/product100/'.substr_replace($product->image,'',0,14);
            		if(!is_file(Yii::getPathOfAlias('webroot').$thumb)){
            			Yii::import('application.extensions.image.Image');
            			$image = new Image(Yii::getPathOfAlias('webroot').'/'.$product->image);
            			$image->resize(100, 100);
            			if(!is_dir(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product100/')){
            				mkdir(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product100/');
            				chmod(Yii::getPathOfAlias('webroot').'/upload/images/thumb/product100/',0777);
            			}
            			$image->save(Yii::getPathOfAlias('webroot').$thumb);
            		}*/
        }
        $i++;
        $img = new Image(Yii::getPathOfAlias("webroot") . $product->image);
        $img_url = $img->createThumb(70, 70);
        echo "<tr><td>{$i}</td><td><div style='float:left;border: 1px solid #CCCCCC;padding:5px;margin-right:5px;'><a href='" . $this->createUrl('product/view', array('id' => $product->id, 'title' => Lnt::safeTitle($product->title))) . "' target='_blank'><img src='" . $img_url . "' /></a></div></td><td><div>{$product->title}</div></td><td><div style='text-align:center;color:#990000;font-weight: bold;'>" . number_format($product->price * $item['count'], 0, ',', '.') . " đ</div></td><td>" . CHtml::listBox('price', $item['count'], array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10), array('size' => 1, 'onchange' => 'updateCart(' . $product->id . ',this);')) . "</td><td>" . CHtml::ajaxLink('Xóa', $this->createUrl('remove', array('id' => $product->id)), array('success' => 'js:function(data){if(data.success){window.location.reload();}}')) . "</td></tr>";
    }
    ?>

		<tr><td colspan="3" ><?php 
    echo CHtml::link('', $this->createUrl('index'), array('id' => 'btnbackBuy'));
    ?>
<span style="float:right;font-weight: bold;">Tổng tiền:</span></td><td style="text-align:center;color:#990000;font-weight: bold;"><?php 
    echo number_format($total_price, 0, ',', '.');
    ?>
 đ</td><td colspan="2"><?php 
    echo CHtml::link("", $this->createUrl('pay'), array('id' => 'btnPay'));
    ?>
</td></tr>
		<?php 
예제 #15
0
 public function getItems()
 {
     global $wrIconSize;
     $result = '';
     $this->places = array();
     $this->externals = array();
     $this->otherEvents = array();
     $this->latlngs = array();
     foreach ($this->people as $titleText => $p) {
         $given = $surname = $fullname = '';
         $birthDate = $birthPlace = $birthPlaceText = $birthYear = '';
         $deathDate = $deathPlace = $deathPlaceText = $deathYear = '';
         $imageURL = $iconURL = '';
         $parents = $spouse = $allPlace = '';
         $otherEvents = '';
         $xml = $p['xml'];
         $position = $p['position'];
         $allPlaces = array();
         if ($xml) {
             foreach ($xml->name as $name) {
                 $given = (string) $name['given'];
                 $surname = (string) $name['surname'];
                 $fullname = StructuredData::getFullname($name);
                 break;
             }
             list($birthEventType, $birthDate, $birthPlace, $birthPlaceText, $birthYear) = $this->getEventData($xml, array('Birth', 'Christening', 'Baptism'));
             list($deathEventType, $deathDate, $deathPlace, $deathPlaceText, $deathYear) = $this->getEventData($xml, array('Death', 'Burial'));
             $otherEvents = $this->getOtherEventData($xml, array($birthEventType, $deathEventType));
             foreach ($xml->image as $image) {
                 if ($image['primary'] == 'true') {
                     $t = Title::makeTitle(NS_IMAGE, (string) $image['filename']);
                     if ($t && $t->exists()) {
                         $image = new Image($t);
                         $imageURL = $image->createThumb(SearchForm::THUMB_WIDTH);
                         $iconURL = $image->createThumb(PedigreeData::ICON_WIDTH, -1, true);
                         break;
                     }
                 }
             }
             $parents = $this->getTitles($xml, 'child_of_family', 'Family');
             $this->addExternals($parents);
             $spouse = $this->getTitles($xml, 'spouse_of_family', 'Family');
             $this->addExternals($spouse);
             $allPlaces = $this->getAllEventPlaces($xml);
             $this->addPlaces($allPlaces);
         }
         if (substr($position, 0, 1) == 'P') {
             $pos = substr($position, 1);
             $line = self::$LINES[$pos];
             $generation = self::$GENERATIONS[$pos];
         } else {
             if ($position == 'Spouse') {
                 $line = self::$LINES[1];
                 $generation = self::$GENERATIONS[1];
             } else {
                 // $position == 'Child'
                 $line = self::$LINES[0];
                 $generation = self::$GENERATIONS[0];
             }
         }
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'Person') . PedigreeData::outJSON('label', 'Person:' . $titleText) . PedigreeData::outJSON('Surname', $surname) . PedigreeData::outJSON('Givenname', $given) . PedigreeData::outJSON('FullName', $fullname) . PedigreeData::outJSON('BirthYear', $birthYear) . PedigreeData::outJSON('BirthDate', $birthDate) . PedigreeData::outJSON('BirthPlace', $birthPlace) . PedigreeData::outJSON('BirthPlaceText', $birthPlaceText) . PedigreeData::outJSON('DeathYear', $deathYear) . PedigreeData::outJSON('DeathDate', $deathDate) . PedigreeData::outJSON('DeathPlace', $deathPlace) . PedigreeData::outJSON('DeathPlaceText', $deathPlaceText) . PedigreeData::outJSON('OtherEvents', $otherEvents) . PedigreeData::outJSON('ImageURL', $imageURL) . PedigreeData::outJSON('IconURL', $iconURL) . PedigreeData::outJSON('Parents', $parents) . PedigreeData::outJSON('Spouse', $spouse) . PedigreeData::outJSON('AllPlaces', $allPlaces) . PedigreeData::outJSON('Line', $line) . PedigreeData::outJSON('Generation', $generation) . PedigreeData::outJSON('Position', $position, false) . "}";
     }
     foreach ($this->families as $titleText => $p) {
         $marriageDate = $marriagePlace = $marriagePlaceText = $marriageYear = '';
         $husband = $wife = $children = '';
         $otherEvents = '';
         $xml = $p['xml'];
         $position = $p['position'];
         if ($xml) {
             list($marriageEventType, $marriageDate, $marriagePlace, $marriagePlaceText, $marriageYear) = $this->getEventData($xml, array('Marriage'));
             $otherEvents = $this->getOtherEventData($xml, array($marriageEventType));
             $husband = $this->getTitles($xml, 'husband', 'Person');
             $this->addExternals($husband);
             $wife = $this->getTitles($xml, 'wife', 'Person');
             $this->addExternals($wife);
             $children = $this->getTitles($xml, 'child', 'Person');
             $this->addExternals($children);
         }
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'Family') . PedigreeData::outJSON('label', 'Family:' . $titleText) . PedigreeData::outJSON('MarriageYear', $marriageYear) . PedigreeData::outJSON('MarriageDate', $marriageDate) . PedigreeData::outJSON('MarriagePlace', $marriagePlace) . PedigreeData::outJSON('MarriagePlaceText', $marriagePlaceText) . PedigreeData::outJSON('OtherEvents', $otherEvents) . PedigreeData::outJSON('Husband', $husband) . PedigreeData::outJSON('Wife', $wife) . PedigreeData::outJSON('Child', $children) . PedigreeData::outJSON('Position', $position, false) . "}";
     }
     // add externals
     foreach ($this->externals as $titleText => $dummy) {
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'External') . PedigreeData::outJSON('label', $titleText, false) . "}";
     }
     // add other events
     foreach ($this->otherEvents as $index => $event) {
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'Event') . PedigreeData::outJSON('label', 'Event:' . ($index + 1)) . PedigreeData::outJSON('Date', $event['date']) . PedigreeData::outJSON('Place', $event['place']) . PedigreeData::outJSON('PlaceText', $event['placetext']) . PedigreeData::outJSON('EventType', $event['type'], false) . "}";
     }
     // add places
     $stdPlaces = PlaceSearcher::getPlaceTitlesLatLong($this->places);
     foreach ($stdPlaces as $titleText => $stdPlace) {
         if ($stdPlace['lat'] || $stdPlace['lon']) {
             $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'Place') . PedigreeData::outJSON('label', 'Place:' . $titleText) . PedigreeData::outJSON('addressLatLng', $stdPlace['lat'] . ',' . $stdPlace['lon'], false) . "}";
         }
     }
     foreach ($this->latlngs as $latlng) {
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'LatLng') . PedigreeData::outJSON('label', 'LatLng:' . $latlng) . PedigreeData::outJSON('addressLatLng', $latlng, false) . "}";
     }
     return $result;
 }
예제 #16
0
파일: Family.php 프로젝트: k-hasan-19/wiki
    protected function getImageInfo($image, $firstChildClass = '')
    {
        $imageText = '';
        $thumbWidth = SearchForm::THUMB_WIDTH;
        $filename = (string) $image['filename'];
        $t = Title::makeTitle(NS_IMAGE, $filename);
        if ($t && $t->exists()) {
            $img = new Image($t);
            $caption = (string) $image['caption'];
            if (!$caption) {
                $caption = $filename;
            }
            $maxWidth = 700;
            $maxHeight = 300;
            $width = $img->getWidth();
            $height = $img->getHeight();
            if ($maxWidth > $width * $maxHeight / $height) {
                $maxWidth = wfFitBoxWidth($width, $height, $maxHeight);
            }
            $imageURL = $img->createThumb($maxWidth, $maxHeight);
            $caption = str_replace('|', ' ', $caption);
            $titleAttr = StructuredData::escapeXml("{$imageURL}|{$maxWidth}|{$caption}");
            $imageText = <<<END
<td style="width: 1%" class="{$firstChildClass}">
   <div class="wr-infobox-image wr-imagehover" title="{$titleAttr}">[[Image:{$filename}|{$thumbWidth}x{$thumbWidth}px]]</div>
</td>
END;
        }
        return $imageText;
    }
예제 #17
0
 protected function formatImage($image, $inCitation = false)
 {
     $filename = (string) $image['filename'];
     if (!$filename) {
         return '';
     }
     $caption = (string) $image['caption'];
     $iconWidth = SearchForm::THUMB_WIDTH;
     $iconHeight = 48;
     $t = Title::makeTitle(NS_IMAGE, $filename);
     if (!$t || !$t->exists()) {
         return '';
     }
     $image = new Image($t);
     $maxHoverWidth = 700;
     $maxHoverHeight = 300;
     $width = $image->getWidth();
     $height = $image->getHeight();
     if ($height > 0 && $maxHoverWidth > $width * $maxHoverHeight / $height) {
         $maxHoverWidth = wfFitBoxWidth($width, $height, $maxHoverHeight);
     }
     $imageURL = $image->createThumb($maxHoverWidth, $maxHoverHeight);
     $titleAttr = StructuredData::escapeXml("{$imageURL}|{$maxHoverWidth}");
     if ($inCitation) {
         return "<span class=\"wr-citation-image wr-imagehover inline-block\" title=\"{$titleAttr}\">{$caption} [[Image:{$filename}|{$iconWidth}x{$iconHeight}px]]</span>";
     } else {
         return "<span class=\"wr-imagehover inline-block\"  title=\"{$titleAttr}\">[[Image:{$filename}|thumb|left|{$caption}]]</span>";
     }
     //      return <<<END
     //<div class="inline-block">
     //   <span id="$id">[[Image:$filename|thumb|left|$id. $caption]]</span>
     //</div>
     //END;
 }
예제 #18
0
 private function formatResult($doc, $hl, $pos, $condensed)
 {
     global $wgUser;
     $skin =& $wgUser->getSkin();
     $ns = @$doc['NamespaceStored'];
     $titleString = $doc['TitleStored'];
     $title = Title::newFromText($ns . ':' . $titleString);
     if ($this->pagetitle && $ns == $this->namespace && $title->getDBkey() == $this->pagetitle) {
         return '';
     }
     if (!$condensed) {
         $birth = $chr = $death = $burial = $marriage = $banns = '';
         $husbandBirth = $husbandDeath = $wifeBirth = $wifeDeath = '';
         if ($ns == 'Person') {
             $birth = $this->getEventInfo($hl, 'PersonBirth');
             $chr = $this->getEventInfo($hl, 'PersonChr');
             $death = $this->getEventInfo($hl, 'PersonDeath');
             $burial = $this->getEventInfo($hl, 'PersonBurial');
         } else {
             if ($ns == 'Family') {
                 $marriage = $this->getEventInfo($hl, 'Marriage');
                 $banns = $this->getEventInfo($hl, 'Banns');
                 $husbandBirth = $this->getEventInfo($doc, 'HusbandBirth');
                 if (!$husbandBirth) {
                     $husbandBirth = $this->getEventInfo($doc, 'HusbandChr');
                 }
                 $husbandDeath = $this->getEventInfo($doc, 'HusbandDeath');
                 if (!$husbandDeath) {
                     $husbandDeath = $this->getEventInfo($doc, 'HusbandBurial');
                 }
                 $wifeBirth = $this->getEventInfo($doc, 'WifeBirth');
                 if (!$wifeBirth) {
                     $wifeBirth = $this->getEventInfo($doc, 'WifeChr');
                 }
                 $wifeDeath = $this->getEventInfo($doc, 'WifeDeath');
                 if (!$wifeDeath) {
                     $wifeDeath = $this->getEventInfo($doc, 'WifeBurial');
                 }
             }
         }
         $imageURL = '';
         if (@$doc['PrimaryImage']) {
             $t = Title::makeTitle(NS_IMAGE, $doc['PrimaryImage']);
             if ($t && $t->exists()) {
                 $i = new Image($t);
                 $imageURL = $i->createThumb(SearchForm::THUMB_WIDTH, SearchForm::THUMB_HEIGHT);
                 $imagePageURL = $t->getLocalURL();
             }
         } else {
             if ($doc['NamespaceStored'] == 'Image') {
                 $t = Title::makeTitle(NS_IMAGE, $doc['TitleStored']);
                 if ($t && $t->exists()) {
                     $i = new Image($t);
                     $imageURL = $i->createThumb(SearchForm::THUMB_WIDTH, SearchForm::THUMB_HEIGHT);
                     $imagePageURL = $t->getLocalURL();
                 }
             }
         }
     }
     $displayTitle = '';
     if ($ns == 'Family') {
         if (@$hl['TitleStored']) {
             $displayTitle = SearchForm::removeId($hl['TitleStored'][0]);
         } else {
             $displayTitle = SearchForm::removeId($titleString);
         }
     } else {
         if ($ns == 'Person') {
             if (@$hl['FullnameStored'][0] && mb_strpos($hl['FullnameStored'][0], ' ') !== false) {
                 $displayTitle = $hl['FullnameStored'][0];
             } else {
                 if (@$hl['TitleStored']) {
                     $displayTitle = SearchForm::removeId($hl['TitleStored'][0]);
                 } else {
                     $displayTitle = SearchForm::removeId($titleString);
                 }
             }
         } else {
             if (@$hl['TitleStored']) {
                 $displayTitle = $hl['TitleStored'][0];
             } else {
                 $displayTitle = $titleString;
             }
         }
     }
     $titleText = $this->prepareValue(($ns ? $ns . ':' : '') . $displayTitle, 200);
     $result = '<tr><td class="searchresult" colspan=2>' . ($this->addSelectButtons() ? $this->getSelectButton($ns, $titleString) : '') . ($this->match ? $this->getMatchCheckbox($titleString, $pos + 1) : '') . '<span class="searchresulttitle">' . $skin->makeKnownLinkObj($title, $titleText, $this->addSelectButtons() ? 'target=' . urlencode($this->target) : '') . '</span></td>' . ($pos >= 0 ? '' : '<td>Recent edit, not yet indexed</td>') . '</tr>';
     // $pos is -1 for recent contribs
     if ($pos >= 0 && !$condensed) {
         $result .= '<tr><td ' . ($imageURL ? 'width="55%"' : 'colspan=2 width="70%"') . '><table width="100%">' . $this->formatValue('Birth', $birth) . (!$birth && $chr ? $this->formatValue('Chr/Bap', $chr) : '') . $this->formatValue('Death', $death) . (!$death && $burial ? $this->formatValue('Burial', $burial) : '') . $this->formatValue('Parents', SearchForm::removeId(@$hl['ParentFamilyTitle'][0])) . $this->formatValue('Spouse', SearchForm::removeSelf($titleString, SearchForm::removeId(@$hl['SpouseFamilyTitle'][0]))) . ($husbandBirth || $husbandDeath ? $this->formatValue('Husband', "{$husbandBirth} - {$husbandDeath}") : '') . ($wifeBirth || $wifeDeath ? $this->formatValue('Wife', "{$wifeBirth} - {$wifeDeath}") : '') . $this->formatValue('Marriage', $marriage) . (!$marriage && $banns ? $this->formatValue('Banns', $banns) : '') . $this->formatValue('Children', SearchForm::removeId(@$hl['ChildTitle'][0])) . $this->formatValue('Author', @$hl['AuthorStored'][0]) . $this->formatValue('Title', @$hl['SourceTitleStored'][0]) . $this->formatValue('Surnames', @$hl['SurnameStored'][0]) . $this->formatValue('Places', @$hl['PlaceStored'][0]) . (@$hl['SourceSubjectStored'][0] ? $this->formatValue('Subject', @$hl['SourceSubjectStored'][0] . (@$doc['SourceSubSubject'] ? ' - ' . @$doc['SourceSubSubject'] : '')) : '') . (@$doc['FromYear'] || @$doc['ToYear'] ? $this->formatValue('Year range', @$doc['FromYear'] . ' - ' . @$doc['ToYear']) : '') . $this->formatValue('Availability', @$hl['SourceAvailabilityStored'][0]) . $this->formatValue('Type', @$hl['PlaceType'][0]) . $this->formatValue('', @$hl['TextStored'][0], true) . '</table></td>' . ($imageURL ? "<td width=\"15%\"><a href=\"{$imagePageURL}\"><img alt=\"\" src=\"{$imageURL}\"/></a></td>" : '') . "<td width=\"24%\" align=\"right\"><table>" . ($this->ecp == 'e' ? '' : $this->formatValue('', $this->getStarsImage($doc['score']), false, false)) . $this->formatValue('Watching', $this->makeUserLinks(@$hl['UserStored'][0]), false, false) . $this->formatValue('Modified', @$doc['LastModDate'] ? date('j M Y', wfTimestamp(TS_UNIX, $doc['LastModDate'] . '000000')) : '') . "</table></td></tr>\n";
     }
     return $result;
 }