コード例 #1
0
ファイル: Index.php プロジェクト: A1Gard/ToosFrameWork
<?php

$prefix = GetLinkPrefix('order');
$listview = new TListView('plugin_id');
$listview->SetList($this->plugins);
$listview->AddColum(_lg('plugin name'), 'plugin_name', 10);
$listview->AddColum(_lg('plugin author'), 'plugin_author', 10);
$listview->SetPattern(1, '<img src="' . UR_MP_ASSETS . 'images/active%s.png" alt="[plugin status]" />');
$listview->AddColum(_lg('status'), '%1plugin_status', 2);
$listview->AddColum('', 'plugin_discrption', 16);
$pattern = '<a class="button delete" href="' . UR_MP . 'Plugin/Delete/%id%"> ' . _lg('Delete') . ' </a>
                <a class="button active" href="' . UR_MP . 'Plugin/Status/%id%/1"> ' . _lg('Active') . ' </a>
                <a class="button deactive" href="' . UR_MP . 'Plugin/Status/%id%/0"> ' . _lg('Deactive') . '</a>';
$listview->AddAction($pattern, 6, 'plugin_status');
$listview->AddFilter(_lg('Deactived'), 'plugin_status', '0');
$listview->AddFilter(_lg('Actived'), 'plugin_status', '1');
$listview->AddBulkAcction(_lg('Deactive'), 'Edit', 'plugin_status,0');
$listview->AddBulkAcction(_lg('Active'), 'Edit', 'plugin_status,1');
$listview->AddBulkAcction(_lg('Delete'), 'Delete', null);
$listview->Render('Plugin');
$frm = new TForm(UR_MP . 'Plugin/upload');
$frm->AddField('file', _lg('zip file'), null, array('name' => 'file'));
$frm->AddField('submit', '', _lg('Upload'));
?>
<br />

<div style="background: #1392e9;padding:1em;margin:1em;">
    <h2>
        <?php 
_lp('Upload new plugin');
?>
コード例 #2
0
 /**
  * Proccess record values
  *
  * @param array $record
  * @param array $data
  * @param string $keylink
  */
 function proccessRecordValue(&$data, &$keylink, $listFieldInfo)
 {
     $value = "";
     if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_IMAGE) {
         if (ShowThumbnail($listFieldInfo['fName'], $this->tName)) {
             $thumbPref = GetThumbnailPrefix($listFieldInfo['fName'], $this->tName);
             $value .= "<a";
             if (IsUseiBox($listFieldInfo['fName'], $this->tName)) {
                 $value .= " rel='ibox'";
             } else {
                 $value .= " target=_blank";
             }
             $value .= " href='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>";
             $value .= "<img border=0";
             if ($this->is508) {
                 $value .= " alt=\"Image from DB\"";
             }
             $value .= " src='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($thumbPref) . "&alt=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>";
             $value .= "</a>";
         } else {
             $value = "<img";
             if ($this->is508) {
                 $value .= " alt=\"Image from DB\"";
             }
             $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName);
             $value .= $imgWidth ? " width=" . $imgWidth : "";
             $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName);
             $value .= $imgHeight ? " height=" . $imgHeight : "";
             $value .= " border=0";
             $value .= " src='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>";
         }
     } else {
         if ($listFieldInfo['viewFormat'] == FORMAT_FILE_IMAGE) {
             if (CheckImageExtension($data[$listFieldInfo['fName']])) {
                 if (ShowThumbnail($listFieldInfo['fName'], $this->tName)) {
                     // show thumbnail
                     $thumbPref = GetThumbnailPrefix($listFieldInfo['fName'], $this->tName);
                     $thumbname = $thumbPref . $data[$listFieldInfo['fName']];
                     if (substr(GetLinkPrefix($listFieldInfo['fName'], $this->tName), 0, 7) != "http://" && !myfile_exists(GetUploadFolder($listFieldInfo['fName']) . $thumbname)) {
                         $thumbname = $data[$listFieldInfo['fName']];
                     }
                     $value = "<a";
                     if (IsUseiBox($listFieldInfo['fName'], $this->tName)) {
                         $value .= " rel='ibox'";
                     } else {
                         $value .= " target=_blank";
                     }
                     $value .= " href=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $data[$listFieldInfo['fName']])) . "\">";
                     $value .= "<img";
                     if ($thumbname == $data[$listFieldInfo['fName']]) {
                         $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName);
                         $value .= $imgWidth ? " width=" . $imgWidth : "";
                         $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName);
                         $value .= $imgHeight ? " height=" . $imgHeight : "";
                     }
                     $value .= " border=0";
                     if ($this->is508) {
                         $value .= " alt=\"" . htmlspecialchars($data[$listFieldInfo['fName']]) . "\"";
                     }
                     $value .= " src=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $thumbname)) . "\"></a>";
                 } else {
                     $value = "<img";
                     $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName);
                     $value .= $imgWidth ? " width=" . $imgWidth : "";
                     $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName);
                     $value .= $imgHeight ? " height=" . $imgHeight : "";
                     $value .= " border=0";
                     if ($this->is508) {
                         $value .= " alt=\"" . htmlspecialchars($data[$listFieldInfo['fName']]) . "\"";
                     }
                     $value .= " src=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $data[$listFieldInfo['fName']])) . "\">";
                 }
             }
         } else {
             if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_FILE) {
                 $fileNameF = GetFilenameField($listFieldInfo['fName'], $this->tName);
                 if ($fileNameF) {
                     $fileName = $data[$fileNameF];
                     if (!$fileName) {
                         $fileName = "file.bin";
                     }
                 } else {
                     $fileName = "file.bin";
                 }
                 if (strlen($data[$listFieldInfo['fName']])) {
                     $value = "<a href='getfile.php?table=" . $this->shortTableName . "&filename=" . rawurlencode($fileName) . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>";
                     $value .= htmlspecialchars($fileName);
                     $value .= "</a>";
                 }
             } else {
                 if ($listFieldInfo['viewFormat'] == FORMAT_AUDIO) {
                     $fileName = GetData($data, $listFieldInfo['fName'], FORMAT_NONE);
                     $fieldIsUrl = GetFieldData($this->tName, $listFieldInfo['fName'], "fieldIsVideoUrl", false);
                     if (strlen($fileName)) {
                         $absFileName = "";
                         if (!$fieldIsUrl && GetFieldData($this->tName, $listFieldInfo['fName'], "Absolute", false)) {
                             $absFileName = GetUploadFolder($listFieldInfo['fName']) . $fileName;
                         } elseif (!$fieldIsUrl) {
                             $absFileName = getabspath(GetUploadFolder($listFieldInfo['fName']) . $fileName);
                         }
                         // if file
                         if ($fieldIsUrl || file_exists($absFileName)) {
                             $titleField = GetFieldData($this->tName, $listFieldInfo['fName'], 'audioTitleField', "");
                             $title = "";
                             if ($titleField) {
                                 $title = htmlspecialchars(GetData($data, $titleField, ViewFormat($titleField, $titleField)));
                             }
                             if ($fieldIsUrl) {
                                 $href = $fileName;
                             } else {
                                 $href = 'download.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink;
                             }
                             $value = '<a class="htrack" type="audio/mpeg" title="' . $title . '" href="' . $href . '">' . $title . '</a>';
                         }
                     }
                 } else {
                     if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_AUDIO) {
                         $titleField = GetFieldData($this->tName, $listFieldInfo['fName'], 'audioTitleField', "");
                         $title = "";
                         if ($titleField) {
                             $title = htmlspecialchars(GetData($data, $titleField, ViewFormat($titleField, $titleField)));
                         }
                         if (@$data[$listFieldInfo['fName']] != NULL) {
                             $value = '<a class="htrack" type="audio/mpeg" title="' . $title . '" href="getfile.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink . '">' . $title . '</a>';
                         } else {
                             $value = $title;
                         }
                     } else {
                         if ($listFieldInfo['viewFormat'] == FORMAT_VIDEO) {
                             $value = "";
                             $fieldIsUrl = GetFieldData($this->tName, $listFieldInfo['fName'], "fieldIsVideoUrl", false);
                             $fileName = GetData($data, $listFieldInfo['fName'], FORMAT_NONE);
                             if (strlen($fileName)) {
                                 $absFileName = "";
                                 if (!$fieldIsUrl && GetFieldData($this->tName, $listFieldInfo['fName'], "Absolute", false)) {
                                     $absFileName = GetUploadFolder($listFieldInfo['fName']) . $fileName;
                                 } elseif (!$fieldIsUrl) {
                                     $absFileName = getabspath(GetUploadFolder($listFieldInfo['fName']) . $fileName);
                                 }
                                 // if file
                                 if ($fieldIsUrl || file_exists($absFileName)) {
                                     $videoId = 'video_' . GoodFieldName(htmlspecialchars($listFieldInfo['fName'])) . '_' . $this->recId;
                                     if ($fieldIsUrl) {
                                         $href = $fileName;
                                     } else {
                                         $href = 'download.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink;
                                     }
                                     $value = '<a href="' . $href . '" style="display:block;width:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoWidth', "") . 'px;height:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoHeight', "") . 'px;" id="' . $videoId . '"></a>';
                                     $this->controlsMap['video'][] = $videoId;
                                 }
                             }
                         } else {
                             if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_VIDEO) {
                                 if (@$data[$listFieldInfo['fName']] != NULL) {
                                     $videoId = 'video_' . GoodFieldName(htmlspecialchars($listFieldInfo['fName'])) . '_' . $this->recId;
                                     $value = '<a href="getfile.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink . '" style="display:block;width:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoWidth', 0) . 'px;height:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoHeight', 0) . 'px;" id="' . $videoId . '"></a>';
                                     $this->controlsMap['video'][] = $videoId;
                                 }
                             } else {
                                 if ($listFieldInfo['viewFormat'] == FORMAT_MAP) {
                                     $value = '<div id="littleMap_' . GoodFieldName($listFieldInfo['fName']) . '_' . $this->recId . '" style="width: ' . $this->googleMapCfg['fieldsAsMap'][$listFieldInfo['fName']]['width'] . 'px; height: ' . $this->googleMapCfg['fieldsAsMap'][$listFieldInfo['fName']]['height'] . 'px;"></div>';
                                 } else {
                                     if (($listFieldInfo['editFormat'] == EDIT_FORMAT_LOOKUP_WIZARD || $listFieldInfo['editFormat'] == EDIT_FORMAT_RADIO) && GetLookupType($listFieldInfo['fName'], $this->tName) == LT_LOOKUPTABLE && GetLWLinkField($listFieldInfo['fName'], $this->tName) != GetLWDisplayField($listFieldInfo['fName'], $this->tName)) {
                                         $value = DisplayLookupWizard($listFieldInfo['fName'], $data[$listFieldInfo['fName']], $data, $keylink, MODE_LIST);
                                     } else {
                                         if (NeedEncode($listFieldInfo['fName'], $this->tName)) {
                                             $value = ProcessLargeText(GetData($data, $listFieldInfo['fName'], $listFieldInfo['viewFormat']), "field=" . rawurlencode($listFieldInfo['fName']) . $keylink, "", MODE_LIST);
                                         } else {
                                             $value = GetData($data, $listFieldInfo['fName'], $listFieldInfo['viewFormat']);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // create address field as center link
     $value = $this->addCenterLink($value, $listFieldInfo['fName']);
     return $value;
 }
コード例 #3
0
function AddLinkPrefix($field, $link, $table = "")
{
    if (strpos($link, "://") === false && substr($link, 0, 7) != "mailto:") {
        return GetLinkPrefix($field, $table) . $link;
    }
    return $link;
}
コード例 #4
0
ファイル: TListView.php プロジェクト: A1Gard/ToosFrameWork
 /**
  * render listview and show
  * @param string $location base of controller class name
  */
 public function Render($location = '')
 {
     $date_format = 'Y/m/d H:i';
     // pre hook
     _hk('P' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $location, $date_format);
     $date = TDate::GetInstance();
     $result = null;
     // show saerch or item
     if ($this->search != null || $this->relation != array()) {
         $result .= '<div class="listview-search row" action="' . UR_MP . $location . '" >';
         // show search here
         if ($this->search != null) {
             //            die($prefix);
             $result .= '<form class="grd12"  action="' . UR_MP . $location . '">';
             $result .= '<input type="text" name="search" class="search-box" placeholder="' . _lg('Search') . '..." />';
             $result .= '<input type="hidden" name="fields" class="search-fields" value="' . $this->search . '"  />';
             if (isset($_GET['filter'])) {
                 $result .= '<input type="hidden" name="filter" value="' . $_GET['filter'] . '"  />';
             }
             $result .= '&nbsp;<button><span class="fa fa-search"></span></button>';
             if (isset($_GET['search']) && $_GET['search'] != '') {
                 $result .= '&nbsp;<button onclick="$(this).parent().find(\'.search,.search-fields\').remove();"><span class="fa fa-close"></span></button>';
             }
             $result .= '</form>';
         }
         // relation info
         if ($this->relation != array()) {
             $md = new TModel($this->relation['table']);
             $result .= '<form class="grd12 "  action="' . UR_MP . $location . '">' . ($this->relation['ico'] != '' ? '<span class="fa fa-' . $this->relation['ico'] . '"></span>' : '') . '<select name="rel" class="rel">';
             $result .= '<option value="0" >' . _lg('Select an item to search') . '</option>';
             foreach ($md->Selectable($this->relation['title'], $this->relation['value']) as $item) {
                 $result .= '<option value="' . $item[0] . '" ' . (isset($_GET['rel']) && $_GET['rel'] == $item[0] ? 'selected="selected"' : '') . ' >' . $item[1] . '</option>';
             }
             $result .= '</select>';
             $result .= '<input type="hidden" name="typ" class="rel-type" value="' . $this->relation['rel_type'] . '" />';
             $result .= '&nbsp;<button><span class="fa fa-search"></span></button>';
             if (isset($_GET['rel']) && $_GET['rel'] != '') {
                 $result .= '&nbsp;<button onclick="$(this).parent().find(\'.rel,.rel-type\').remove();"><span class="fa fa-close"></span></button>';
             }
             $result .= '</form>';
         }
         $result .= '</div>';
     }
     // show all filter here
     if ($this->filter['title'] != array()) {
         $result .= '<div class="filter">';
         // get prefix
         $prefix = GetLinkPrefix('filter');
         // show title and no filter item named "All";
         $result .= '<span> ' . _lg('Filter') . ': </span> <a class="button" href="' . $prefix . '"> ' . _lg('All') . '</a>';
         // show filter lisr
         foreach ($this->filter['title'] as $key => $value) {
             $result .= '<a class="button" href="' . $prefix . 'filter=' . $this->filter['key'][$key] . ',' . $this->filter['value'][$key] . '">' . $value . '</a>';
         }
         $result .= '</div>';
     }
     // get order by column
     $prefix = GetLinkPrefix('order,desc');
     // get id order and choose good value for this
     if (isset($_GET['order']) && $_GET['order'] == $this->id) {
         $id_order = $prefix;
     } else {
         $id_order = $prefix . 'order=' . $this->id;
     }
     // show form head here when have bulk action
     if ($this->bulk_action['title'] != array()) {
         $result .= '<form method="post" action="' . UR_MP . $location . '/BulkAction">';
     }
     //start render listview header
     // start with bulk action checkbox and id header
     $result .= '<ul class="listview">
 <li class="pinned animate"> 
     <div  class="row">
         <div class="grd1"> <input type="checkbox" class="checkall" />  </div>
         <a href="' . $id_order . '"><div class="grd2 header"> ' . _lg('no.') . ' </div></a>';
     // show header column title
     foreach ($this->column['title'] as $key => $value) {
         if (substr($this->column['key'][$key], 0, 1) == '%') {
             $col_name = substr($this->column['key'][$key], 2);
         } else {
             $col_name = $this->column['key'][$key];
         }
         $result .= '<a href="' . $prefix . 'order=' . $col_name . (!isset($_GET['desc']) && isset($_GET['order']) && $_GET['order'] == $col_name ? '&desc=1' : '') . '"><div class="grd' . $this->column['size'][$key] . '">' . $value . '</div></a>';
     }
     // action haader
     $result .= '<div class="grd' . $this->action['size'] . '"> &nbsp; </div>';
     $result .= '</div>
 </li>';
     // show all records in this page
     foreach ($this->assoc_list as $record) {
         //start with bulk action checkbox and id
         $result .= '<li> 
     <div  class="row">';
         $result .= '<div class="grd1">' . PHP_EOL . ' <input type="checkbox" ' . 'class="listview-checkbox" name="id[]" value="' . $record[$this->id] . '" />' . PHP_EOL . ' </div>' . PHP_EOL;
         $result .= '<div class="grd2"> ' . $record[$this->id] . ' </div>';
         // show record columns added before by size
         foreach ($this->column['key'] as $key => $value) {
             if (strpos($value, ',') == false) {
                 $result .= PHP_EOL . '<div class="grd' . $this->column['size'][$key] . '">' . PHP_EOL;
                 switch (substr($value, 0, 2)) {
                     case '%i':
                         $a = substr($value, 2);
                         $result .= long2ip($record[$a]);
                         break;
                     case '%t':
                         $a = substr($value, 2);
                         $result .= $date->PDate($date_format, $record[$a]);
                         break;
                         // show array
                     // show array
                     case '%a':
                         $a = substr($value, 2);
                         $v = explode('|', $a);
                         $arr = $v[0];
                         global ${$arr};
                         $array = ${$arr};
                         $result .= $array[$record[$v[1]]];
                         break;
                     case '%1':
                     case '%2':
                     case '%3':
                     case '%4':
                     case '%5':
                     case '%6':
                     case '%7':
                     case '%8':
                     case '%9':
                         $p = substr($value, 1, 1);
                         $a = substr($value, 2);
                         $result .= sprintf($this->pattren[$p], $record[$a]);
                         break;
                     default:
                         $result .= $record[$value];
                         break;
                 }
                 $result .= '</div>' . PHP_EOL;
             } else {
                 $temp = explode(',', $value);
                 $result .= PHP_EOL . '<div class="grd' . $this->column['size'][$key] . '">';
                 foreach ($temp as $col) {
                     $result .= $record[$col] . PHP_EOL;
                 }
                 $result .= '</div>' . PHP_EOL;
             }
         }
         // add action to record
         $result .= PHP_EOL . '<div class="grd' . $this->action['size'] . ' c' . ($this->action['class'] == '' ? '' : $record[$this->action['class']]) . '">';
         $tmp = str_replace("%id%", $record[$this->id], $this->action['pattern']);
         if ($this->id == 'comment_id') {
             $result .= str_replace("%topic%", $record['comment_topic_id'], $tmp);
         } else {
             $result .= $tmp;
         }
         $result .= '</div>' . PHP_EOL;
         $result .= '</div>' . PHP_EOL . '</li>' . PHP_EOL;
     }
     $result .= '</ul>' . PHP_EOL;
     // if have bulk action show this after list view
     if ($this->bulk_action['title'] != array()) {
         $result .= '<div class="bulk-action">
                 <select name="action">';
         // list of bulk actions
         foreach ($this->bulk_action['function'] as $key => $value) {
             $result .= '<option  value="' . $value . ',' . $this->bulk_action['value'][$key] . '">' . $this->bulk_action['title'][$key] . '</option>';
         }
         $result .= '</select>';
         $result .= '<input type="submit" value="' . _lg('Bulk apply') . '" />' . '<div class="left" > ' . '<input type="button" value="' . _lg('Check All') . '" class="chkall" data-chekbox="listview-checkbox" /> ' . '<input type="button" value="' . _lg('Check None') . '" class="chknone" data-chekbox="listview-checkbox" /> ' . '<input type="button" value="' . _lg('Check Toggle') . '" class="chktoggle" data-chekbox="listview-checkbox" /> ' . '</div>' . '</div>' . '</form>';
     }
     // result hook
     _hk('R' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $result);
     echo $result;
 }