OSDN Git Service

Admin側整備
authorCake <cake_67@users.sourceforge.jp>
Thu, 24 Feb 2011 11:31:12 +0000 (20:31 +0900)
committerCake <cake_67@users.sourceforge.jp>
Thu, 24 Feb 2011 11:33:07 +0000 (20:33 +0900)
app/plugins/links/controllers/links_controller.php
app/plugins/links/models/link.php
app/plugins/links/views/elements/link_edit.ctp
app/plugins/links/views/elements/link_index.ctp
app/plugins/links/views/elements/link_view.ctp
app/plugins/links/views/helpers/link_select.php
app/plugins/links/views/links/admin_add.ctp
app/plugins/links/views/links/admin_delete.ctp
app/plugins/links/views/links/admin_edit.ctp
app/plugins/links/views/links/admin_listview.ctp [new file with mode: 0644]

index e2116b5..093aa3d 100644 (file)
@@ -150,7 +150,7 @@ class LinksController extends AppController {
        }
 
        function admin_edit($id = null) {
-               $this->_edit($id, false);
+               $this->_edit($id, true);
        }
 
        function admin_delete($id = null) {
@@ -185,6 +185,11 @@ class LinksController extends AppController {
                        $fieldList = $this->Link->fields['admin_add'];
                } else {
                        $fieldList = $this->Link->fields['add'];
+
+
+                       if (isset($this->data['Link']['type'])) {
+                               unset($this->data['Link']['type']);
+                       }
                }
 
                $this->data['Link']['user_id'] = $this->user_id;
@@ -222,6 +227,10 @@ class LinksController extends AppController {
                                $this->Session->setFlash(__('No Permission', true));
                                $this->redirect(array('action' => 'listview'));
                        }
+
+                       if (isset($this->data['Link']['type'])) {
+                               unset($this->data['Link']['type']);
+                       }
                }
 
                if (!empty($this->data)) {
@@ -255,7 +264,7 @@ class LinksController extends AppController {
                        $this->data = $this->_restore_html_link($link, false, true);
                }
 
-               $this->set('title_for_layout', " - ". __('Edit Link', true));
+               $this->set('title_for_layout', " - ". __('Edit Link', true). " - ". $link['Link']['title']. "(". $link['Link']['url']. ")");
        }
 
        function _delete($id = null, $isAdmin = false) {
@@ -293,7 +302,7 @@ class LinksController extends AppController {
                $confirm_message = __('Are you sure you want to delete it?', true);
 
                $this->Session->setFlash($confirm_message);
-               $this->set('title_for_layout', " - ". $confirm_message);
+               $this->set('title_for_layout', " - ". $confirm_message. " - ". $link['Link']['title']. "(". $link['Link']['url']. ")");
        }
 
        /* get link By Id */
@@ -365,7 +374,7 @@ class LinksController extends AppController {
        function set_type_i18n() {
                $this->type_settings = array(
                        'member' => array(
-                               'title' => '',
+                               'title' => __('Normal', true),
                                'description' => '',
                        ),
                        'creators' => array(
@@ -408,6 +417,10 @@ class LinksController extends AppController {
                        }
                }
 
+               if (isset($data['Link']['ring'])  && !empty($data['Link']['ring'])) {
+                       $data['Link']['ring'] = $this->{$this->modelClass}->restore_html($data['Link']['ring'], false, false, false);
+               }
+
                return $data;
        }
 
index 65ada95..a77c6ec 100644 (file)
@@ -248,6 +248,25 @@ class Link extends AppModel {
                return parent::beforeSave($options);
        }
 
+
+       /* validate */
+       function validType($data) {
+               if (!isset($data["type"])) {
+                       return true;
+               }
+
+               $params = Router::getParams();
+               if ($params->admin) {
+                       if (!in_array($data["type"], array_keys($this->type))) {
+                               return false;
+                       }
+               }
+               unset($data["type"]);
+
+               return true;
+       }
+
+
        /* URLのマルチバイトを変換 */
        function mb_urlEncode($data) {
                if (!isset($data['Link']['url'])) {
index cc0ba8d..d8582fe 100644 (file)
                'url' => $url,
                'type' => 'file',
        ));
-
 ?>
 <fieldset>
-<legend><?php if ($action = 'add'): ?><?php __('Add Link'); ?><?php else: ?><?php __('Edit Link'); ?><?php endif ?></legend>
+<legend><?php if (!$isEdit): ?><?php __('Add Link'); ?><?php else: ?><?php __('Edit Link'); ?><?php endif ?></legend>
 <?php
        echo $this->Form->input('url', array(
                'type' => 'text',
                'label' => __('Description', true)
        ));
 
+if ($isAdmin) {
+       echo $select->create_boolean_select('pickup', array(
+               'label' => __('PickUp', true),
+               'default' => 0,
+       ));
+
+       echo $linkSelect->create_type_select($type);
+
+       echo $form->input('ring', array(
+               'label' => __('Ring text', true),
+               'after' => $html->tag('div',
+                       __('HTML tags OK. It is for RING Tags setting.', true),
+                       array('class' => 'attention')
+               )
+       ));
+}
+
        echo $token->create();
 ?>
 </fieldset>
index 0d0fe3a..c5696db 100644 (file)
@@ -34,7 +34,7 @@ $this->Paginator->options(array('url' => $this->passedArgs));
 $header = __('Links', true);
 
 $header .= $this->Html->tag('span',  
-       '['.$this->Html->link(__('New Link', true), array(
+       '['.$this->Html->link(__('Add Link', true), array(
                'action' => 'add'
        ), array(
                'class' => 'edit'
index 2e191d2..ddb08c5 100644 (file)
 
 <div class="boxHeader">
 <?php
+$url = array(
+       'controller' => 'links',
+       'action' => 'visit',
+       'plugin' => 'links',
+       'admin' => false,
+       $link['Link']['id']
+);
+
 
 if (!empty($link['Link']['title'])) {
        $title = $link['Link']['title'];
@@ -38,7 +46,7 @@ if (!empty($link['Attachment'])) {
        echo $this->Upfile->embed(
                $file,
                array(
-                       'linkTo' => $link['Link']['url'],
+                       'linkTo' => $url,
                        'alt' => $title,
                        'restrict' => array('image'),
                        'htmlAttributes' => array(
@@ -51,17 +59,6 @@ if (!empty($link['Attachment'])) {
 ?>
 <h3>
 <?php
-if (!$isAdmin) {
-       $url = array(
-                       'controller' => 'links',
-                       'action' => 'visit',
-                       'plugin' => 'links',
-                       $link['Link']['id']
-               );
-} else {
-       $url =$link['Link']['url'];
-}
-
        echo $this->Html->link(
                $title,
                $url, 
@@ -80,13 +77,11 @@ if (!$isAdmin) {
 </h3></div>
 <div class="boxBody">
 <div class="infoBody">
-<?php if (!$isAdmin): ?>
 <script language="JavaScript">
 <!--
-       var thumbnailweb_jump = 'visit/<?php echo $link['Link']['id']; ?>';
+       var thumbnailweb_jump = '<?php echo $this->Html->url($url) ?>';
 //-->
 </script>
-<?php endif ?>
 <?php
 $ThumnailNotice = null;
 if ($this->Time->wasWithinLast('2 hours', $link['Link']['modified'])) {
index 3830f7d..1d9ffd0 100644 (file)
@@ -27,10 +27,8 @@ class LinkSelectHelper extends Helper {
                        return null;
                }
 
-               $type_list = $this->set_type($type_list);
-
-               if (isset($type_list[$type])) {
-                       return $type_list[$type];
+               if (isset($type_list[$type]['title'])) {
+                       return $type_list[$type]['title'];
                } else {
                        return null;
                }
@@ -47,13 +45,13 @@ class LinkSelectHelper extends Helper {
                if (!isset($options['options'])) {
                        $options['options'] = array();
                }
-               $options['options'] = $this->set_type($type_list, $options['options']);
+               $options['options'] = $this->set_type_select($type_list, $options['options']);
 
                return $this->Form->input($fieldName, $options);
        }
 
-       /* typeの設定を、key->value(多言語化対応)に変換 */
-       function set_type($type_list = array(), $options = array())
+       /* typeの設定を、key->value(プルダウン用)に変換 */
+       function set_type_select($type_list = array(), $options = array())
        {
                static $i18n_type;
 
@@ -61,31 +59,17 @@ class LinkSelectHelper extends Helper {
                        return $i18n_type;
                }
 
-               if (!empty($options)) {
-                       $i18n_type = $options;
+               if (empty($type_list)) {
+                       return array();
                }
 
-               if (empty($type_list)) {
-                       $type_list = $this->default_type;
+               if (!empty($options)) {
+                       $i18n_type = $options;
                }
 
                foreach ($type_list as $k => $v) {
-                       if ($v == 'member') {
-                               $i18n_type[$v] = __('Member\'s Links', true);
-                       } elseif($v == 'official') {
-                               $i18n_type[$v] = __('Official Site', true);
-                       } elseif($v == 'ring') {
-                               $i18n_type[$v] = __('Web Ring', true);
-                       } elseif($v == 'material') {
-                               $i18n_type[$v] = __('Material Site', true);
-                       } elseif($v == 'thanks') {
-                               $i18n_type[$v] = __('Thanks Links', true);
-                       } elseif($v == 'mutual') {
-                               $i18n_type[$v] = __('Mutual Links', true);
-                       } elseif($v == 'admin') {
-                               $i18n_type[$v] = __('Administrator\'s Links', true);
-                       } else {
-                               $i18n_type[$v] = $v;
+                       if (isset($v['title'])) {
+                               $i18n_type[$k] = $v['title'];
                        }
                }
 
index 7a8ffce..1a5ca58 100644 (file)
  * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
  * @link     http://trpgtools-onweb.sourceforge.jp/
  */
-?>
-<div class="links form">
-<?php 
-       $url = array(
+
+echo $this->element('link_edit', array(
+       'url' => array(
                'plugin' => 'links',
                'controller' => 'links',
                'action' => 'add',
-       );
-       echo $form->create('Link', array('url' => $url));
-
-?>
-<fieldset>
-<legend><?php __('Add Link'); ?></legend>
-<?php
-       echo $this->Form->input('url', array(
-               'type' => 'text',
-               'label' =>  __('URL', true),
-               'style' => 'ime-mode:inactive;',
-               'class' => 'longInput',
-               'after' => $html->div(
-                       'required',
-                       __(' required', true)
-               )
-       ));
-       echo $this->Html->div(
-               'attention', 
-                __('URL must be less than 512 letters. The Multi-byte letters will counted after UTF-8 encoded.', true)
-       );
-
-       echo $this->Form->input('title', array(
-               'type' => 'text',
-               'label' =>  __('Title', true),
-               'class' => 'longInput',
-               'after' => $html->div(
-                       '',
-                       __('If empty, the site title will be automatically inputted.', true)
-               )
-       ));
-
-       echo $linkSelect->create_type_select($type, 'type', array(
-               'label' => __('Link Type', true),
-               'selected' => '99',
-       ));
-
-       echo $this->Form->input('pickup', array(
-               'type' => 'checkbox',
-               'label' =>  __('PickUp', true),
-       ));
-
-       echo $token->create();
-?>
-</fieldset>
-<?php echo $this->Form->end(__('Submit', true));?>
-</div>
-
-<div class="backButton">
-<?php
-       echo $form->create('', array('url' => array(
-               'action' => 'index'), 
-               'type' => 'GET', 
-               'id' => 'CancelButton'
-       ));
-       echo $form->end(array('label' => __('Cancel', true)));
-?>
-</div>
+       ),
+       'isEdit' => false,
+       'isAdmin' => true,
+));
index 567080e..f9ae7c8 100644 (file)
  * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
  * @link     http://trpgtools-onweb.sourceforge.jp/
  */
+echo $this->Html->css('/links/css/link.css');
 
+?>
+<script language="JavaScript">
+<!--
+       var thumbnailweb_jump = "";
+       var thumbnailweb_target = "_blank";
+       var thumbnailweb_lpos = "right";
+       var thumbnailweb_lposv = "10";
+
+//-->
+</script>
+<?php
 echo $this->element('link_view', array(
+       'link' => $link,
        'isDelete' => true,
        'isAdmin' => true,
 ));
index 65b93b3..d6836ea 100644 (file)
  * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
  * @link     http://trpgtools-onweb.sourceforge.jp/
  */
-?>
-<div class="links form">
-<?php echo $this->Form->create('Link');?>
-       <fieldset>
-               <legend><?php __('Admin Edit Link'); ?></legend>
-       <?php
-               echo $this->Form->input('id');
-               echo $this->Form->input('title');
-               echo $this->Form->input('user_id');
-               echo $this->Form->input('url');
-               echo $this->Form->input('type');
-               echo $this->Form->input('pickup');
-               echo $this->Form->input('not_found');
-       ?>
-       </fieldset>
-<?php echo $this->Form->end(__('Submit', true));?>
-</div>
-<div class="actions">
-       <h3><?php __('Actions'); ?></h3>
-       <ul>
 
-               <li><?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $this->Form->value('Link.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $this->Form->value('Link.id'))); ?></li>
-               <li><?php echo $this->Html->link(__('List Links', true), array('action' => 'index'));?></li>
-               <li><?php echo $this->Html->link(__('List Users', true), array('controller' => 'users', 'action' => 'index')); ?> </li>
-               <li><?php echo $this->Html->link(__('New User', true), array('controller' => 'users', 'action' => 'add')); ?> </li>
-       </ul>
-</div>
\ No newline at end of file
+echo $this->element('link_edit', array(
+       'url' => array(
+               'plugin' => 'links',
+               'controller' => 'links',
+               'action' => 'edit',
+               $this->data['Link']['id'],
+       ),
+       'isEdit' => true,
+       'isAdmin' => true,
+));
diff --git a/app/plugins/links/views/links/admin_listview.ctp b/app/plugins/links/views/links/admin_listview.ctp
new file mode 100644 (file)
index 0000000..0f1576f
--- /dev/null
@@ -0,0 +1,19 @@
+<?php 
+/*
+ * Link Plugin for TRPG Databank
+ * 
+ * PHP version 5
+ *
+ * @copyright Copyright 2010, Cake. (http://trpgtools-onweb.sourceforge.jp/)
+ * @category View
+ * @package  plugin for TRPG Data Bank
+ * @version  beta
+ * @author   Cake <cake_67@users.sourceforge.jp>
+ * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
+ * @link     http://trpgtools-onweb.sourceforge.jp/
+ */
+
+echo $this->element('link_index', array(
+       'links' => $links,
+       'isAdmin' => true,
+));