static function createForm($id, $action) { $form = new Form_Admin_Links($id, $action); $form->add(QForm::ELEMENT, 'name', array('_ui' => 'textbox', '_label' => '友情链接名称', '_req' => true, '_tips' => '友情链接的网站名'))->add(QForm::ELEMENT, 'url', array('_ui' => 'textbox', '_label' => '网站地址', '_req' => true, '_tips' => '友情链接网站的网址'))->add(QForm::ELEMENT, 'link_id', array('_ui' => 'hidden'))->add(QForm::ELEMENT, 'img', array('_ui' => 'admin_picpreview', '_label' => '已上传图片', 'attr' => array('dir' => 'links')))->add(QForm::ELEMENT, 'ico', array('_ui' => 'upload', '_label' => '上传图标', '_tips' => ''))->add(QForm::ELEMENT, 'order_num', array('_ui' => 'textbox', '_label' => '排序', 'value' => 0)); $form->addValidations(Links::meta()); //上传图片的限制 $types = Q::normalize(Q::ini('appini/teapics/upload_allowed_types')); $size = intval(Q::ini('appini/teapics/upload_allowed_size') * 1024); $dim = Q::ini('appini/teapics/img_pic_width') . 'x' . Q::ini('appini/teapics/img_pic_height'); $form['ico']->_tips = sprintf($form['ico']->_tips, implode('/', $types), $size / 1024, $dim); $form->selectUploadElement('ico')->uploadAllowedSize($size)->uploadAllowedTypes($types)->enableSkipUpload(); //表单验证规则 return $form; }
/** * 删除或者更新排序 * */ function actionUpdate() { $linkid = (array) $this->_context->link_id; //是否要选择了删除复选框 if (!empty($linkid)) { Links::meta()->destroyWhere('link_id in(?)', $linkid); } //的到要更新的列表 $ordernum = (array) $this->_context->order_num; foreach ($ordernum as $id => $num) { //是否是要删除的 if (in_array($linkid, $id)) { continue; } Links::meta()->updateWhere(array('order_num' => $num), 'link_id =?', $id); } return $this->_redirectMessage('更新友情链接成功', '如果你不做出选择系统将自动跳转', url('links/index'), 3); }