/**
  * Insert initial data
  *
  * @author Johnny Karhinen, http://fullkorn.nu, johnny@fullkorn.nu
  * @return boolean
  */
 protected function insert_initial_data()
 {
     Tags::add('page_welcome');
     Tags::add('Puff 1');
     Tags::add('Puff 2');
     Tags::add('Puff 3');
     $this->new_content('# A First Level Header' . "\n\n" . '## A Second Level Header' . "\n\n" . 'Some of these words *are emphasized*.' . "\n" . 'Some of these words _are emphasized also_.' . "\n\n" . 'Use two asterisks for **strong emphasis**.' . "\n" . 'Or, if you prefer, __use two underscores instead__.' . "\n\n" . 'Unordered (bulleted) lists use asterisks, pluses, and hyphens (*, +, and -) as list markers. These three markers are interchangable; this:' . "\n\n" . '*   Candy.' . "\n" . '*   Gum.' . "\n" . '*   Booze.' . "\n\n" . 'Ordered (numbered) lists use regular numbers, followed by periods, as list markers:' . "\n\n" . '1.  Red' . "\n" . '2.  Green' . "\n" . '3.  Blue' . "\n\n" . 'More basics at [Daring Fireball](http://daringfireball.net/projects/markdown/basics).', array('page_welcome'));
     $this->new_content('### Help' . "\n\n" . 'You can access the admin with [this link](admin).' . "\n\n" . 'See online help [here](http://larvit.se/pajas).' . "\n\n" . 'Wiki [here](https://github.com/lillem4n/kohana-module-pajas/wiki)', array('Puff 1'));
     $this->new_content('### Col 2' . "\n\n" . 'Lorem ipsum dolor sit amet, consectetur adipizscing elit. Fusce velit quam, pharetra id, vehicula eu, consectetur ut, orci. Donec odio. Donec non neque. Ut rutrum lectus nec elit. Ut id quam. Cras aliquam erat eu mi. Aliquam orci neque, lobortis a, tempus ut, lacinia sit amet, purus.', array('Puff 2'));
     $this->new_content('### Col 3' . "\n\n" . 'Lorem ipsum dolor sit amet, consectetur adipizscing elit. Fusce velit quam, pharetra id, vehicula eu, consectetur ut, orci. Donec odio. Donec non neque. Ut rutrum lectus nec elit. Ut id quam. Cras aliquam erat eu mi. Aliquam orci neque, lobortis a, tempus ut, lacinia sit amet, purus.', array('Puff 3'));
     // We set the URI to 'welcome' since that is Kohanas default route
     $this->new_page('Hello world!', 'welcome', array(1 => 1, 2 => 2, 3 => 3, 4 => 4));
     return TRUE;
 }
示例#2
0
     }
     break;
 case 'addTagChildFolder':
     $tag = $this->params['tag'];
     $tagName = $this->params['tagName'];
     if (!$tagName) {
         $tagName = $itext['TXT_TAG_NEW'];
     }
     // Check if root node is selected
     if ($tag === 'root') {
         // Get real Page-ID of Root-Node
         $tags = $tagMgr->getList();
         $tag = $tags[0]['ID'];
     }
     // Add new child node
     $new_id = $tagMgr->add($tag, $tagName);
     if ($new_id != false) {
         $icons = new Icons();
         $jsQueue->add($new_id, HISTORYTYPE_TAG, 'TAG_ADD', sGuiUS(), NULL);
     } else {
         $koala->alert($itext['TXT_ERROR_ACCESS_DENIED']);
     }
     break;
 case 'deleteTag':
     $tagID = $this->params['tagID'];
     $siteID = $this->params['site'];
     // Delete tag
     $successfullyDeleted = $tagMgr->remove($tagID);
     if (in_array($tagID, $successfullyDeleted)) {
         foreach ($successfullyDeleted as $successfullyDeletedItem) {
             $jsQueue->add($successfullyDeletedItem, HISTORYTYPE_TAG, 'OBJECT_DELETE', sGuiUS(), 'tag', NULL, NULL, $successfullyDeletedItem . '-' . $siteID, 'name');
示例#3
0
    function onAddNewTag()
    {
        if (!isset($_SESSION['CATS']) || empty($_SESSION['CATS'])) {
            echo 'CATS has lost your session data!';
            return;
        }
        $tags = new Tags($this->_siteID);
        $arr = $tags->add(isset($_POST['tag_parent_id']) ? $_POST['tag_parent_id'] : null, $_POST['tag_title'], "-");
        if (isset($_POST['tag_parent_id'])) {
            printf('
				<li id="id_li_tag_%d">
					<a href="javascript:;" onclick="doDelete(%d);"><img src="images/actions/delete.gif" /></a>
					<div id="id_tag_%d"><a href="javascript:;" onclick="editTag(%d);">%s</a><div></div></div>
				</li>', $arr['id'], $arr['id'], $arr['id'], $arr['id'], $arr['tag_title']);
        } else {
            printf('
				<li id="id_li_tag_%d">
					<a href="javascript:;" onclick="doDelete(%d);"><img src="images/actions/delete.gif" /></a> %s
					<ul>
						<li>
							<img src="images/actions/add.gif" />
							<form method="post" action="%s?m=settings&amp;a=ajax_tags_add">
								<input type="hidden" name="tag_parent_id" value="%d" />
								<input type="text" name="tag_title" value="" />
								<input type="button" value="Add" onclick="doAdd(this.form);" />
							</form>
						</li>
					</ul>
				</li>', $arr['id'], $arr['id'], $arr['tag_title'], CATSUtility::getIndexName(), $arr['id']);
        }
        return;
    }
示例#4
0
 /**
  * 查看相片
  */
 public function action_view()
 {
     $tag = new Tags();
     $this->template->pid = $pid = $this->request->param('id');
     $imgSelect = DB::select('i.id', 'i.cate_id', 'i.uploadtime', 'i.picname', 'i.userid', 'i.disk_id', 'i.picname', 'i.custom_name', array('i.disk_id', 'disk_domain'), 'i.click', 'i.comment_num', 'i.support', 'i.oppose', array('i.disk_name', 'img_dir'))->from(array('imgs', 'i'))->order_by('i.id', 'DESC');
     $imgInfo = $imgSelect->where('i.id', '=', (int) $pid)->fetch_row();
     $this->template->pageTitle = $imgInfo['custom_name'];
     $imgInfo['cate_name'] = DB::select('cate_name')->from('img_categories')->where('cate_id', '=', (int) $imgInfo['cate_id'])->fetch_one();
     $user = ORM::factory('user', $imgInfo['userid']);
     $imgInfo['username'] = $user->username;
     $imgInfo['avatar'] = $user->avatar;
     $imgInfo['uid'] = $user->uid;
     $imgInfo['sign'] = ORM::factory('user_field', (int) $imgInfo['userid'])->sign;
     $this->template->imgInfo = $imgInfo;
     if (empty($imgInfo)) {
         $this->show_message('非法访问', 0, array(), true);
     }
     if ($user->status != 'approved' || $user->expire_time < time()) {
         $links[] = array('text' => '返回首页', 'href' => '/');
         $this->show_message('该用户已经过期或者禁止,不允许访问其所属的图片', 1, $links, true, 10000);
     }
     $this->template->tags = $tags = $tag->get($pid, 'img');
     $select = DB::select('c.*', 'u.username', 'u.avatar')->from(array('comments', 'c'))->where('c.item_id', '=', (int) $pid)->where('c.app', '=', 'img')->join(array('users', 'u'), 'LEFT')->on('u.uid', '=', 'c.author');
     $this->template->commentList = $select->execute()->as_array();
     if ($this->isPost()) {
         $tags = trim($this->getPost('tags'));
         $pid = (int) $this->getPost('pid');
         $tags = explode(' ', $tags);
         $tag->add($pid, 'img', $tags, $imgInfo['userid']);
         $this->request->redirect('/' . $pid . '.html');
     }
     // 更新访问量
     DB::update('users')->set(array('visit' => DB::expr("visit + 1")))->where('uid', '=', (int) $imgInfo['userid'])->execute();
     DB::update('imgs')->set(array('click' => DB::expr('click + 1')))->where('id', '=', (int) $pid)->execute();
 }
 /**
  * 添加专题
  *
  */
 public function action_add()
 {
     $this->checklogin();
     $this->template->pageTitle = '添加专题';
     $this->_add_css('styles/album/add_topics.css');
     $this->_add_script('scripts/copy.js');
     $specialpic = ORM::factory('specialpic');
     if ($this->isPost()) {
         $post = Validate::factory($this->getPost())->filter(TRUE, 'trim')->rule('title', 'not_empty')->rule('content', 'not_empty');
         if ($post->check()) {
             $specialpic->values($post);
             $specialpic->uid = $this->auth['uid'];
             $specialpic->save();
             $specialpic->sid;
             // 添加专题标签
             $tag = new Tags();
             $tags = trim($this->getPost('tags'));
             $tags = explode(' ', $tags);
             $tag->add($specialpic->sid, 'img_subject', $tags, $this->auth['uid']);
             $links[] = array('text' => '返回专题列表', 'href' => '/picsubject/list');
             $this->show_message('发现专题图片操作成功。', 1, $links, true);
         } else {
             // 校验失败,获得错误提示
             $str = '';
             $this->template->registerErr = $errors = $post->errors('default/pic/pic');
             foreach ($errors as $item) {
                 $str .= $item . '<br>';
             }
             $this->show_message($str);
         }
     }
     $pid = $this->getQuery('id');
     $arr = explode('-', $pid);
     $select = DB::select('imgs.picname', 'imgs.userid', 'imgs.custom_name', 'd.disk_domain', 'd.disk_name', array('imgs.disk_name', 'img_dir'))->from('imgs')->join(array('img_disks', 'd'))->on('d.disk_domain', '=', 'imgs.disk_id')->where('imgs.id', 'in', $arr)->where('imgs.userid', '=', $this->auth['uid']);
     $rows = $select->execute()->as_array();
     $str = '';
     foreach ($rows as $item) {
         $temp_img = $item['img_dir'] . '/' . $item['picname'];
         list($width, $height) = getimagesize($temp_img);
         if ($width >= 640) {
             $temp_img = $this->thumb->create($temp_img, 640, 640, 's');
             $temp_img = Str::changeLoad($temp_img, false);
         } else {
             $temp_img = Str::changeLoad($temp_img, true);
         }
         $str .= '<p>' . "<img src=\"" . URL::domain() . $temp_img . '" alt="' . $item['custom_name'] . '"/></p><p style="text-align:center;">' . $item['custom_name'] . '</p>';
     }
     $this->template->content = $str;
 }