public function testLogger() { $tModel = new TModel(); $logger = $tModel->getLogger(); $this->assertTrue($logger instanceof Zend_Log); $this->assertNull($logger->debug('Test log priority debug')); $this->assertNull($logger->err('Test log priority err')); }
public static function Active() { $p_model = new TModel('hook'); $data['hook_effect'] = 'P:TNavigator:AddItem'; $data['hook_function_name'] = 'LinkEditor'; $data['hook_plugin'] = __CLASS__; $p_model->Create($data); $data['hook_effect'] = 'R:TNavigator:Render'; $data['hook_function_name'] = 'RenderEditor'; $data['hook_plugin'] = __CLASS__; $p_model->Create($data); }
function GetRecord($id = null) { if ($id == null) { global $ID; $id = (int) $ID; } else { $id = (int) $id; } global $table; $prefix = isset($arg['prefix']) ? $arg['prefix'] : $table . '_'; $rule = ' AND ' . GetRule(); $model = new TModel($table, $prefix); $record = $model->GetRecord($id, $rule); return $record; }
function __construct() { global $hook_store; $plug_exists = $this->GetExistsPlugins(); $plug_active = $this->GetActivePlugins(); // load active and exists plugins foreach ($plug_active as $active) { if (in_array($active['plugin_name'], $plug_exists)) { include_once PLUGIN_DIR . $active['plugin_name'] . '/' . $active['plugin_name'] . '.php'; } } // load all active hook $h_model = new TModel('hook'); foreach ($h_model->ReadEx('hook_effect,hook_function_name') as $hook) { $hook_store[$hook['hook_effect']][] = $hook['hook_function_name']; } }
/** * @todo edit an reocrd with id * @param int $id * @param array $data * @param string $prefix prifex id * @category general */ public function Edit($id, $data, $prefix = null) { $on_edit = $this->GetRecord($id); if ($on_edit['manager_protected'] && $_SESSION['MN_ID'] == $on_edit['manager_id'] || $on_edit['manager_protected'] == 0) { parent::Edit($id, $data, $prefix); return true; } return false; }
function __construct() { $visit_long = 3600; $online_long = 300; // pre hook _hk('P' . ':' . __CLASS__ . ':' . __FUNCTION__, $this, $visit_long, $online_long); parent::__construct('statistic'); define('VISIT_LONG', $visit_long); // on hour define('ONLINE_LONG', $online_long); // 5 min }
<?php //你应该在.h文件顶部放入如下信息,然后在命令行执行 php Pods/TeemoV2/TModel.php //你可以将必要的信息放置在Pods/TeemoV2/cookie/目录下 //比如,需要在bbs.duowan.com域下传输指定cookie信息,则在cookie目录下放置一个文件名为bbs.duowan.com的文件,文件内容为cookie //若PostData:为空,则为GET方式获取示例数据,格式如下PostData:id=123&name=你妹&sex=male //【你也可以在h文件的目录下放置同名的.json后缀文件,程序将以此json文件内容为准,生成对应的数据结构】 /** * TModel * Url:http://duanzi.duowan.com/index.php?r=duanzi/topicList&page=1&pageSize=10&type=1&sort=2 * PostData: * Usage: Open Terminal -> cd $projectDir -> php Pods/TeemoV2/TModel.php -> Done! * Note that your project directory must Writeable -> sudo chown -R (User) ./ */ // These Code Is Generate By TModel cuiminghui@yy.com $m = new TModel(); $m->scan(); $m->tryFetch(); class TModel { private $_Files = array(); public function scan($dir = './') { $fileList = scandir($dir); foreach ($fileList as $fileItem) { if ($fileItem == '.' || $fileItem == '..') { continue; } elseif (is_dir($dir . $fileItem)) { $this->scan($dir . $fileItem . '/'); } else { $this->checkFile($dir . $fileItem);
function __construct() { parent::__construct('relation'); }
function __construct() { parent::__construct('category'); }
function __construct() { parent::__construct('comment', 'comment_'); }
function __construct() { parent::__construct('topic', 'topic_'); $this->tag = new TTag(); }
<?php if (!isset($_COOKIE['mid'])) { Redirect('/msg/شما وارد نشده اید'); } $topix = GetTopicByLiker($_COOKIE['mid'], 10); $a = new TModel('member', 'member_'); $mem = $a->GetRecord($_COOKIE['mid']); $rep = new TModel('report', 'report_'); $repz = $rep->Read('report_id,report_title', 99, 'report', 'report_'); $smarty->assign('topix', $topix); $smarty->assign('left', floor(($_COOKIE['mact'] - time()) / (60 * 60 * 24))); $smarty->assign('frindz', GetFrienz($_COOKIE['mid'], 999)); $smarty->assign('mem', $mem); $smarty->assign('repz', $repz);
/** * Sets a component property to be null. * This method overrides the parent implementation by clearing * the specified attribute value. * @param string the property name or the event name * @since 1.0.1 */ public function __unset($name) { if (isset($this->getMetaData()->columns[$name])) { unset($this->_attributes[$name]); } else { if (isset($this->getMetaData()->relations[$name])) { unset($this->_related[$name]); } else { parent::__unset($name); } } }
/** * 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 .= ' <button><span class="fa fa-search"></span></button>'; if (isset($_GET['search']) && $_GET['search'] != '') { $result .= ' <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 .= ' <button><span class="fa fa-search"></span></button>'; if (isset($_GET['rel']) && $_GET['rel'] != '') { $result .= ' <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'] . '"> </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; }
function __construct($table_name = 'category', $sulg = 'category') { parent::__construct($table_name, $table_name . '_'); $this->table_name = $table_name; $this->sulg = $sulg; }
function __construct() { parent::__construct('widget', 'widget_'); }
function __construct() { parent::__construct('plugin'); $this->tag = new TTag(); }
function __construct() { parent::__construct('regitery'); }
case 'msg': if (!isset($url[1])) { $url[1] = 'خطا'; } $smarty->assign('title', $url[1] . '-' . $title); $smarty->display('header.tpl'); $smarty->assign('msg', $url[1]); $smarty->display('message.tpl'); break; case 'member': if ((int) $url[1] < 1) { $smarty->assign('title', '404 : چیزی پیدا نشد - ' . $title); $smarty->display('header.tpl'); $smarty->display('404.tpl'); } else { $m = new TModel('member', 'member_'); $member = $m->GetRecord($url[1]); if ($member == FALSE) { $smarty->assign('title', '404 : چیزی پیدا نشد - ' . $title); $smarty->display('header.tpl'); $smarty->display('404.tpl'); } else { $smarty->assign('title', $member['member_name'] . '- نمایه عضو دپارتمان - ' . $title); $smarty->display('header.tpl'); require './inc/member.php'; $smarty->display('member.tpl'); } } break; case 'err': $smarty->assign('err', $reg->GetValue(ROOT_SYSTEM, 'error'));
function __construct() { parent::__construct(); }
function __construct() { parent::__construct('member', 'member_'); }
} else { $result['success'] = $r->Remove($_COOKIE['mid'], $clean['id'], REALTION_FRIEND); $result['value'] = 'افزودن با موفقیت انجام نشد'; echo json_encode($result); die; } } $result['success'] = false; $result['value'] = 'اعتبار حساب کاربری شما برای لایک خدشه دار است.'; echo json_encode($result); break; case 'comment': if (isset($_COOKIE['mid'])) { $valid = array('comment_parent', 'comment_text', 'comment_topic_id'); $edit = promis($clean, $valid); $m = new TModel('comment', 'comment_'); $data = array('comment_parent' => $clean['comment_parent'], 'comment_text' => $clean['comment_text'], 'comment_topic_id' => $clean['comment_topic_id'], 'comment_member_id' => $_COOKIE['mid'], 'comment_time' => time(), 'comment_ip' => _ipi()); $tmp = $m->Create($data); if (isset($clean['ajax'])) { $result['success'] = $tmp != false ? true : false; echo json_encode($result); die; } else { GoBack(); } } else { $result['value'] = 'شما بایستی وارده شده باشید'; echo json_encode($result); die; } break;
function __construct($table_name = 'dropdown') { parent::__construct($table_name, 'dropdown_'); $this->table_name = $table_name; }
function __construct() { parent::__construct('attach'); }
function __construct($table = 'tag', $prefix = 'tag_') { parent::__construct($table, $prefix); $this->table = $table; $this->prefix = $prefix; }
function __construct() { parent::__construct('dropdown', 'dropdown_'); }