Example #1
0
 public function article($id)
 {
     if (!($id && ($article = Article::find('one', array('include' => array('sources'), 'conditions' => array('id = ? AND is_visibled = ? AND destroy_user_id IS NULL', $id, Article::IS_VISIBLED)))))) {
         return array();
     }
     if ($article->tags) {
         usort($article->tags, function ($a, $b) {
             return count($a->mappings) < count($b->mappings);
         });
     }
     if ($article->tags && ($article_ids = column_array(ArticleTagMapping::find('all', array('select' => 'article_id', 'order' => 'RAND()', 'limit' => 5, 'conditions' => array('article_id != ? AND article_tag_id = ?', $article->id, $article->tags[0]->id))), 'article_id'))) {
         Article::addConditions($conditions, 'id IN (?)', $article_ids);
     } else {
         Article::addConditions($conditions, 'id != ?', $article->id);
     }
     Article::addConditions($conditions, 'is_visibled = ? AND destroy_user_id IS NULL', Article::IS_VISIBLED);
     $others = Article::find('all', array('select' => 'id, title', 'limit' => 5, 'conditions' => $conditions));
     return array('article' => array_merge($article->to_array(array('only' => array('id', 'title', 'content', 'pv'), 'methods' => array('site_show_page_last_uri'))), array('mini_content' => array('150' => $article->mini_content(150), '300' => $article->mini_content(300)), 'cover_url' => array('1200x630c' => $article->cover->url('1200x630c')), 'updated_at' => array('c' => $article->updated_at->format('c'), 'Y-m-d H:i:s' => $article->updated_at->format('Y-m-d H:i:s')), 'created_at' => array('c' => $article->created_at->format('c'), 'Y-m-d H:i:s' => $article->created_at->format('Y-m-d H:i:s')))), 'tags' => array_map(function ($tag) {
         return $tag->to_array(array('only' => array('id', 'name')));
     }, $article->tags), 'others' => array_map(function ($article) {
         return $article->to_array(array('only' => array(), 'methods' => array('site_show_page_last_uri')));
     }, $others), 'sources' => array_map(function ($source) {
         return $source->to_array(array('only' => array('title', 'href'), 'methods' => array('mini_href')));
     }, $article->sources), 'user' => $article->user->to_array(array('only' => array('name'), 'methods' => array('facebook_link'))));
 }
Example #2
0
 public function index($tag_id, $offset = 0)
 {
     $columns = array();
     $configs = array('article-tag', $this->tag->id, 'articles', '%s');
     $conditions = conditions($columns, $configs);
     ArticleTagMapping::addConditions($conditions, 'article_tag_id = ?', $this->tag->id);
     $limit = 7;
     $total = ArticleTagMapping::count(array('conditions' => $conditions));
     $offset = $offset < $total ? $offset : 0;
     $this->load->library('pagination');
     $pagination = $this->pagination->initialize(array_merge(array('total_rows' => $total, 'num_links' => 3, 'per_page' => $limit, 'uri_segment' => 0, 'base_url' => '', 'page_query_string' => false, 'first_link' => '第一頁', 'last_link' => '最後頁', 'prev_link' => '上一頁', 'next_link' => '下一頁', 'full_tag_open' => '<ul class="pagination">', 'full_tag_close' => '</ul>', 'first_tag_open' => '<li class="f">', 'first_tag_close' => '</li>', 'prev_tag_open' => '<li class="p">', 'prev_tag_close' => '</li>', 'num_tag_open' => '<li>', 'num_tag_close' => '</li>', 'cur_tag_open' => '<li class="active"><a href="#">', 'cur_tag_close' => '</a></li>', 'next_tag_open' => '<li class="n">', 'next_tag_close' => '</li>', 'last_tag_open' => '<li class="l">', 'last_tag_close' => '</li>'), $configs))->create_links();
     $article_ids = column_array(ArticleTagMapping::find('all', array('select' => 'article_id', 'offset' => $offset, 'limit' => $limit, 'order' => 'article_id DESC', 'conditions' => $conditions)), 'article_id');
     $articles = $article_ids ? Article::find('all', array('order' => 'FIELD(id,' . implode(',', $article_ids) . ')', 'conditions' => array('is_visibled = ? AND id IN (?) AND destroy_user_id IS NULL', Article::IS_VISIBLED, $article_ids))) : array();
     if ($articles) {
         $this->add_meta(array('name' => 'keywords', 'content' => implode(',', column_array($articles, 'title')) . ',' . implode(',', Cfg::setting('site', 'site', 'keywords'))))->add_meta(array('name' => 'description', 'content' => $articles[0]->mini_content(150)))->add_meta(array('property' => 'og:title', 'content' => $this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:description', 'content' => $articles[0]->mini_content(300)))->add_meta(array('property' => 'og:image', 'tag' => 'larger', 'content' => $img = $articles[0]->cover->url('1200x630c'), 'alt' => $this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title')))->add_meta(array('property' => 'og:image:type', 'tag' => 'larger', 'content' => 'image/' . pathinfo($img, PATHINFO_EXTENSION)))->add_meta(array('property' => 'og:image:width', 'tag' => 'larger', 'content' => '1200'))->add_meta(array('property' => 'og:image:height', 'tag' => 'larger', 'content' => '630'))->add_meta(array('property' => 'article:modified_time', 'content' => $articles[0]->updated_at->format('c')))->add_meta(array('property' => 'article:published_time', 'content' => $articles[0]->created_at->format('c')));
         if (($tags = column_array($articles[0]->tags, 'name')) || ($tags = Cfg::setting('site', 'site', 'keywords'))) {
             foreach ($tags as $i => $tag) {
                 if (!$i) {
                     $this->add_meta(array('property' => 'article:section', 'content' => $tag))->add_meta(array('property' => 'article:tag', 'content' => $tag));
                 } else {
                     $this->add_meta(array('property' => 'article:tag', 'content' => $tag));
                 }
             }
         }
     }
     return $this->set_title($this->tag->name . '文章' . ' - ' . Cfg::setting('site', 'site', 'title'))->set_class('articles')->set_method('index')->load_view(array('tag' => $this->tag, 'articles' => $articles, 'pagination' => $pagination, 'columns' => $columns));
 }
Example #3
0
 public function mail()
 {
     if (!(($id = OAInput::post('id')) && ($contact = Contact::find_by_id($id, array('select' => 'name, email, message'))))) {
         return false;
     }
     if (!(($admin_ids = array_unique(column_array(UserRole::find('all', array('select' => 'user_id', 'conditions' => array('name IN (?)', array('root', 'contact_manager')))), 'user_id'))) && ($admins = User::find('all', array('select' => 'name, email', 'conditions' => array('id IN (?)', $admin_ids)))))) {
         return false;
     }
     $this->load->library('OAMail');
     $email = $contact->email;
     $name = $contact->name;
     $message = $contact->message;
     $mail = OAMail::create()->setSubject('[系統通知] 官網有新的留言!')->setBody("<article style='font-size:15px;line-height:22px;color:rgb(85,85,85)'><p style='margin-bottom:0'>Hi 管理員,</p><section style='padding:5px 20px'><p>剛剛有一個訪客在您的「聯絡我們」留言囉,以下他所留下的聯絡資料:</p><table style='width:100%;border-collapse:collapse'><tbody><tr><th style='width:100px;text-align:right;padding:11px 5px 10px 0;border-bottom:1px dashed rgba(200,200,200,1)'>E-Mail:</th><td style='text-align:left;text-align:left;padding:11px 0 10px 5px;border-bottom:1px dashed rgba(200,200,200,1)'>" . $email . "</td></tr><tr><th style='width:100px;text-align:right;padding:11px 5px 10px 0;border-bottom:1px dashed rgba(200,200,200,1)'>稱 呼:</th><td style='text-align:left;text-align:left;padding:11px 0 10px 5px;border-bottom:1px dashed rgba(200,200,200,1)'>" . $name . "</td></tr><tr><th style='width:100px;text-align:right;padding:11px 5px 10px 0;border-bottom:1px dashed rgba(200,200,200,1)'>內容:</th><td style='text-align:left;text-align:left;padding:11px 0 10px 5px;border-bottom:1px dashed rgba(200,200,200,1)'>" . $message . "</td></tr></tbody></table><br/><p style='text-align:right'>如果需要詳細列表,可以置<a href='" . base_url('admin', 'contacts') . "' style='color:rgba(96,156,255,1);margin:0 2px'>管理後台</a>檢閱。</p></section></article>");
     foreach ($admins as $admin) {
         $mail->addTo($admin->email, $admin->name);
     }
     $mail->send();
     $mail = OAMail::create()->setSubject('[宙思設計] 留言成功通知!')->setBody("<article style='font-size:15px;line-height:22px;color:rgb(85, 85, 85)'><p style='margin-bottom:0'>Hi " . $name . ",</p><section style='padding:5px 20px'><p>您好,我們是<a href='http://www.zeusdesign.com.tw/' style='color:rgba(96, 156, 255, 1);margin:0 2px'>宙思設計</a>團隊,我們已經收到您的留言囉。</p><p>我們稍後會有專人主動與您聯絡或回信給您!</p><p>若是尚未得到回覆,您可以至<a href='https://www.facebook.com/ZeusDesignStudio/' style='color:rgba(96, 156, 255, 1);margin:0 2px'>宙思設計臉書粉絲專頁</a>留言,或來電(02-2941-6737)聯絡我們。</p><p style='text-align:right'>- <a href='http://www.zeusdesign.com.tw/' style='color:rgba(96, 156, 255, 1);margin:0 2px'>宙思設計</a>團隊感謝您。</p></section></article>")->addTo($email, $name);
     $mail->send();
 }
Example #4
0
 public function update()
 {
     if (!$this->has_post()) {
         return redirect_message(array('admin', $this->get_class(), $this->user->id, 'edit'), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。'));
     }
     $posts = OAInput::post();
     if ($msg = $this->_validation_posts($posts)) {
         return redirect_message(array('admin', $this->get_class(), $this->user->id, 'edit'), array('_flash_message' => $msg, 'posts' => $posts));
     }
     if ($columns = array_intersect_key($posts, $this->user->table()->columns)) {
         foreach ($columns as $column => $value) {
             $this->user->{$column} = $value;
         }
     }
     $user = $this->user;
     $update = user::transaction(function () use($user) {
         return $user->save();
     });
     if (!$update) {
         return redirect_message(array('admin', $this->get_class(), $this->user->id, 'edit'), array('_flash_message' => '更新失敗!', 'posts' => $posts));
     }
     $ori_keys = column_array($user->roles, 'name');
     if (($del_keys = array_diff($ori_keys, $posts['roles'])) && ($roles = UserRole::find('all', array('select' => 'id', 'conditions' => array('user_id = ? AND name IN (?)', $user->id, $del_keys))))) {
         foreach ($roles as $role) {
             UserRole::transaction(function () use($role) {
                 return $role->destroy();
             });
         }
     }
     if ($add_keys = array_diff($posts['roles'], $ori_keys)) {
         foreach ($add_keys as $add_key) {
             UserRole::transaction(function () use($add_key, $user) {
                 return verifyCreateOrm(UserRole::create(Array_intersect_key(array('name' => $add_key, 'user_id' => $user->id), UserRole::table()->columns)));
             });
         }
     }
     return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '更新成功!'));
 }
Example #5
0
<form action='<?php 
echo base_url('admin', 'banners');
?>
' method='get' class="search<?php 
echo $has_search = array_filter(column_array($columns, 'value')) ? ' show' : '';
?>
">
<?php 
if ($columns) {
    ?>
    <div class='l i<?php 
    echo count($columns);
    ?>
 n1'>
<?php 
    foreach ($columns as $column) {
        if (isset($column['select']) && $column['select']) {
            ?>
          <select name='<?php 
            echo $column['key'];
            ?>
'>
            <option value=''>請選擇 <?php 
            echo $column['title'];
            ?>
..</option>
      <?php 
            foreach ($column['select'] as $option) {
                ?>
              <option value='<?php 
                echo $option['value'];
Example #6
0
?>
'></button>

  <table class='table-list-rwd'>
    <tbody>
<?php 
if ($tags) {
    foreach ($tags as $tag) {
        ?>
          <tr>
            <td data-title='名稱' ><?php 
        echo $tag->name;
        ?>
</td>
            <td data-title='子標籤'width='230'><?php 
        echo implode('<br/>', column_array($tag->tags, 'name'));
        ?>
</td>
            <td data-title='作品數量' width='100'><?php 
        echo count($tag->mappings);
        ?>
 個</td>
            <td data-title='編輯' width='100'>
              <!-- <a href='<?php 
        echo base_url('admin', 'work_tags', $tag->id, 'works');
        ?>
' class='icon-images'></a> -->
              <a href='<?php 
        echo base_url('admin', 'work_tags', $tag->id, 'tags');
        ?>
' class='icon-tags'></a>
Example #7
0
        ?>
          <tr>
            <td data-title='封面' width='50'><?php 
        echo (string) $article->cover ? img($article->cover->url('100x100c'), false, 'class="i_30"') : '-';
        ?>
</td>
            <td data-title='標題' width='130'><?php 
        echo $article->title;
        ?>
</td>
            <td data-title='作者' width='100'><?php 
        echo $article->user->name;
        ?>
</td>
            <td data-title='分類' width='130'><?php 
        echo implode('<br/>', column_array($article->tags, 'name'));
        ?>
</td>
            <td data-title='內容' ><?php 
        echo $article->mini_content();
        ?>
</td>
            <td data-title='是否顯示' width='90'>
              <label class='checkbox'>
                <input type='checkbox' data-id='<?php 
        echo $article->id;
        ?>
'<?php 
        echo $article->is_visibled ? ' checked' : '';
        ?>
>
Example #8
0
        <td>
          <input type='text' name='email' value='<?php 
echo isset($posts['email']) ? $posts['email'] : $user->email;
?>
' placeholder='請輸入電子郵件..' maxlength='200' pattern='.{1,200}' required title='輸入電子郵件!' />
        </td>
      </tr>

<?php 
if ($roles = Cfg::setting('role', 'role_names')) {
    ?>
        <tr>
          <th>角 色:</th>
          <td>
      <?php 
    $last_roles = isset($posts['roles']) ? $posts['roles'] : column_array($user->roles, 'name');
    foreach ($roles as $key => $name) {
        ?>
              <label><input type='checkbox' name='roles[]' value='<?php 
        echo $key;
        ?>
'<?php 
        echo $last_roles && in_array($key, $last_roles) ? ' checked' : '';
        ?>
/><div><?php 
        echo $name;
        ?>
</div></label>
      <?php 
    }
    ?>
Example #9
0
 public function update()
 {
     if (!$this->has_post()) {
         return redirect_message(array('admin', $this->get_class(), $this->article->id, 'edit'), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。'));
     }
     $posts = OAInput::post();
     $posts['content'] = OAInput::post('content', false);
     $cover = OAInput::file('cover');
     if (!((string) $this->article->cover || $cover)) {
         return redirect_message(array('admin', $this->get_class(), $this->article->id, 'edit'), array('_flash_message' => '請選擇圖片(gif、jpg、png)檔案!', 'posts' => $posts));
     }
     if ($msg = $this->_validation_posts($posts)) {
         return redirect_message(array('admin', $this->get_class(), $this->article->id, 'edit'), array('_flash_message' => $msg, 'posts' => $posts));
     }
     if ($columns = array_intersect_key($posts, $this->article->table()->columns)) {
         foreach ($columns as $column => $value) {
             $this->article->{$column} = $value;
         }
     }
     $article = $this->article;
     $update = ArticleTag::transaction(function () use($article, $cover) {
         if (!$article->save()) {
             return false;
         }
         if ($cover && !$article->cover->put($cover)) {
             return false;
         }
         return true;
     });
     if (!$update) {
         return redirect_message(array('admin', $this->get_class(), $this->article->id, 'edit'), array('_flash_message' => '更新失敗!', 'posts' => $posts));
     }
     $ori_ids = column_array($article->mappings, 'article_tag_id');
     if (($del_ids = array_diff($ori_ids, $posts['tag_ids'])) && ($mappings = ArticleTagMapping::find('all', array('select' => 'id, article_tag_id', 'conditions' => array('article_id = ? AND article_tag_id IN (?)', $article->id, $del_ids))))) {
         foreach ($mappings as $mapping) {
             ArticleTagMapping::transaction(function () use($mapping) {
                 return $mapping->destroy();
             });
         }
     }
     if (($add_ids = array_diff($posts['tag_ids'], $ori_ids)) && ($tags = ArticleTag::find('all', array('select' => 'id', 'conditions' => array('id IN (?)', $add_ids))))) {
         foreach ($tags as $tag) {
             ArticleTagMapping::transaction(function () use($tag, $article) {
                 return verifyCreateOrm(ArticleTagMapping::create(Array_intersect_key(array('article_tag_id' => $tag->id, 'article_id' => $article->id), ArticleTagMapping::table()->columns)));
             });
         }
     }
     if ($article->sources) {
         foreach ($article->sources as $source) {
             ArticleSource::transaction(function () use($source) {
                 return $source->destroy();
             });
         }
     }
     if ($posts['sources']) {
         foreach ($posts['sources'] as $i => $source) {
             ArticleSource::transaction(function () use($i, $source, $article) {
                 return verifyCreateOrm(ArticleSource::create(array_intersect_key(array_merge($source, array('article_id' => $article->id, 'sort' => $i)), ArticleSource::table()->columns)));
             });
         }
     }
     $this->_clean_cell($article);
     return redirect_message(($url = Session::getData('admin_articles_index_url')) ? $url : array('admin', $this->get_class()), array('_flash_message' => '更新成功!'));
 }
Example #10
0
 public function role_names()
 {
     return array_filter(array_map(function ($role) {
         return Cfg::setting('role', 'role_names', $role);
     }, column_array($this->roles, 'name')));
 }
Example #11
0
        <td>
          <?php 
echo (string) $article->cover ? img($article->cover->url('100x100c'), false, 'class="cover"') : '';
?>
          <input type='file' name='cover' value='' />
        </td>
      </tr>

<?php 
if ($tags = ArticleTag::all()) {
    ?>
        <tr>
          <th>標 籤:</th>
          <td>
      <?php 
    $tag_ids = isset($posts['tag_ids']) ? $posts['tag_ids'] : column_array($article->mappings, 'article_tag_id');
    foreach ($tags as $tag) {
        ?>
              <label><input type='checkbox' name='tag_ids[]' value='<?php 
        echo $tag->id;
        ?>
'<?php 
        echo $tag_ids && in_array($tag->id, $tag_ids) ? ' checked' : '';
        ?>
/><div><?php 
        echo $tag->name;
        ?>
</div></label>
      <?php 
    }
    ?>
Example #12
0
 public function update()
 {
     if (!$this->has_post()) {
         return redirect_message(array('admin', $this->get_class(), $this->invoice->id, 'edit'), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。'));
     }
     $posts = OAInput::post();
     $cover = OAInput::file('cover');
     // if (!((string)$this->invoice->cover || $cover))
     //   return redirect_message (array ('admin', $this->get_class (), $this->invoice->id, 'edit'), array (
     //       '_flash_message' => '請選擇圖片(gif、jpg、png)檔案!',
     //       'posts' => $posts
     //     ));
     if ($msg = $this->_validation_posts($posts)) {
         return redirect_message(array('admin', $this->get_class(), $this->invoice->id, 'edit'), array('_flash_message' => $msg, 'posts' => $posts));
     }
     if ($columns = array_intersect_key($posts, $this->invoice->table()->columns)) {
         foreach ($columns as $column => $value) {
             $this->invoice->{$column} = $value;
         }
     }
     $invoice = $this->invoice;
     $update = InvoiceTag::transaction(function () use($invoice, $cover) {
         if (!$invoice->save()) {
             return false;
         }
         if ($cover && !$invoice->cover->put($cover)) {
             return false;
         }
         return true;
     });
     if (!$update) {
         return redirect_message(array('admin', $this->get_class(), $this->invoice->id, 'edit'), array('_flash_message' => '更新失敗!', 'posts' => $posts));
     }
     if (($del_ids = array_diff(column_array($invoice->pictures, 'id'), $posts['pic_ids'])) && ($pictures = InvoicePicture::find('all', array('select' => 'id, name', 'conditions' => array('id IN (?)', $del_ids))))) {
         foreach ($pictures as $picture) {
             InvoicePicture::transaction(function () use($picture) {
                 return $picture->destroy();
             });
         }
     }
     if ($pictures = OAInput::file('pictures[]')) {
         foreach ($pictures as $picture) {
             InvoicePicture::transaction(function () use($picture, $invoice) {
                 return verifyCreateOrm($pic = InvoicePicture::create(array_intersect_key(array_merge($picture, array('invoice_id' => $invoice->id)), InvoicePicture::table()->columns))) && $pic->name->put($picture);
             });
         }
     }
     return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '更新成功!'));
 }
Example #13
0
 public function update()
 {
     if (!$this->has_post()) {
         return redirect_message(array('admin', 'work_tags', $this->tag->id, 'works', $this->work->id, 'edit'), array('_flash_message' => '非 POST 方法,錯誤的頁面請求。'));
     }
     $posts = OAInput::post();
     $cover = OAInput::file('cover');
     if (!((string) $this->work->cover || $cover)) {
         return redirect_message(array('admin', 'work_tags', $this->tag->id, 'works', $this->work->id, 'edit'), array('_flash_message' => '請選擇圖片(gif、jpg、png)檔案!', 'posts' => $posts));
     }
     if ($msg = $this->_validation_posts($posts)) {
         return redirect_message(array('admin', 'work_tags', $this->tag->id, 'works', $this->work->id, 'edit'), array('_flash_message' => $msg, 'posts' => $posts));
     }
     if ($columns = array_intersect_key($posts, $this->work->table()->columns)) {
         foreach ($columns as $column => $value) {
             $this->work->{$column} = $value;
         }
     }
     $work = $this->work;
     $update = WorkTag::transaction(function () use($work, $cover) {
         if (!$work->save()) {
             return false;
         }
         if ($cover && !$work->cover->put($cover)) {
             return false;
         }
         return true;
     });
     if (!$update) {
         return redirect_message(array('admin', 'work_tags', $this->tag->id, 'works', $this->work->id, 'edit'), array('_flash_message' => '更新失敗!', 'posts' => $posts));
     }
     if (($del_ids = array_diff(column_array($work->pictures, 'id'), $posts['pic_ids'])) && ($pictures = WorkPicture::find('all', array('select' => 'id, name', 'conditions' => array('id IN (?)', $del_ids))))) {
         foreach ($pictures as $picture) {
             WorkPicture::transaction(function () use($picture) {
                 return $picture->destroy();
             });
         }
     }
     if ($pictures = OAInput::file('pictures[]')) {
         foreach ($pictures as $picture) {
             WorkPicture::transaction(function () use($picture, $work) {
                 return verifyCreateOrm($pic = WorkPicture::create(array_intersect_key(array_merge($picture, array('work_id' => $work->id)), WorkPicture::table()->columns))) && $pic->name->put($picture);
             });
         }
     }
     $clean_blocks = WorkBlock::transaction(function () use($work) {
         foreach ($work->blocks as $block) {
             if (!$block->destroy()) {
                 return false;
             }
         }
         return true;
     });
     if ($blocks = $posts['blocks']) {
         foreach ($blocks as $block) {
             if (!($b = null) && WorkBlock::transaction(function () use($block, $work, &$b) {
                 return verifyCreateOrm($b = WorkBlock::create(array_intersect_key(array_merge($block, array('work_id' => $work->id)), WorkBlock::table()->columns)));
             })) {
                 if (($items = $block['items']) && $b) {
                     foreach ($items as $item) {
                         WorkBlockItem::transaction(function () use($item, $b) {
                             return verifyCreateOrm(WorkBlockItem::create(array_intersect_key(array_merge($item, array('work_block_id' => $b->id)), WorkBlockItem::table()->columns)));
                         });
                     }
                 }
             }
         }
     }
     return redirect_message(array('admin', 'work_tags', $this->tag->id, 'works', $this->work->id, 'edit'), array('_flash_message' => '更新成功!'));
 }
Example #14
0
            </div>
    <?php 
}
?>
          <div class='ps'>
            <button type='button' class='icon-plus' data-i='0'></button>
          </div>
        </td>
      </tr>

      <tr>
        <th class='tst'>分 類:</th>
        <td class='ts'>
    <?php 
if ($tags = WorkTag::find('all', array('include' => array('tags'), 'conditions' => array('work_tag_id = ?', 0)))) {
    $tag_ids = $posts['tag_ids'] && $posts['tag_ids'] ? $posts['tag_ids'] : column_array($work->mappings, 'work_tag_id');
    foreach ($tags as $i => $tag) {
        ?>
              <div class='t'>
                <label class='main'><input type='checkbox' name='tag_ids[]' value='<?php 
        echo $tag->id;
        ?>
'<?php 
        echo $tag_ids && in_array($tag->id, $tag_ids) ? ' checked' : '';
        ?>
 /> <?php 
        echo $tag->name;
        ?>
</label>
          <?php 
        if ($tag->tags) {