本文整理汇总了PHP中Template::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::find方法的具体用法?PHP Template::find怎么用?PHP Template::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init_templates
function init_templates()
{
load_lib();
require_once MODELS . DS . 'template.php';
$template = new Template();
$templateListTMP = $template->find(array('order' => 'name'));
$templateList = array();
foreach ($templateListTMP as $k => $v) {
$templateList[$v['id']] = $v;
}
return $templateList;
}
示例2: sendResponse
public static function sendResponse($nameOrStatus, $data = [])
{
$type = Request::guessResponseType();
$template = Template::find($nameOrStatus, $type);
$status = is_numeric($nameOrStatus) ? $nameOrStatus : static::HTTP_200;
static::setStatus($status);
static::setContentType($type);
if ($type == static::HTML) {
Template::setDecorator('baseHtml');
}
$data['_status'] = $status;
static::setContent(Template::renderPage($template, $data));
static::send();
}
示例3: postActivate
public function postActivate()
{
$id = Input::get('id');
$_id = new MongoId($id);
$actives = Template::where('status', 'active')->where('type', 'brochure')->get();
$incl = false;
foreach ($actives as $deactive) {
if ($deactive->_id == $id) {
$incl = true;
} else {
$deactive->status = 'inactive';
$deactive->save();
}
}
if ($incl == false) {
$active = Template::find($id);
$active->status = 'active';
$active->save();
}
return Response::json(array('status' => 'OK'));
}
示例4: loadDefaultValues
public static function loadDefaultValues($input = '')
{
$parent = Content::find($input['parent_id']);
if (!@$input['template_id']) {
$parentTemplate = Template::find($parent->template_id);
// dd($parent->template_id);
if ($parentTemplate) {
//since we occasionally want to process a looped back tree (which makes the whole tree
//invalid, we can't use baum's built in functions to get the first child.
if ($parentTemplate->loopback) {
$parentTemplateChild = Template::find($parentTemplate->loopback);
} else {
$parentTemplateChild = @$parentTemplate->getImmediateDescendants()->first();
}
$input['template_id'] = @$parentTemplateChild->id;
}
if (!@$input['template_id']) {
//if it's still nothing we can safely set this to 0;
$input['template_id'] = null;
}
}
$template = Template::find($input['template_id']);
//dd($template->name);
//TODO: replace with something like this: dd($this->default_fields()->first()->id);
//$contentDefaultFields = Contentdefaultfield::where('content_type_id', '=', $this->content_type_id)->get();
//plug in the fields we wanted..
if (!@$input['template_id']) {
$input['template_id'] = @$template->id;
}
if (!@$input['name']) {
$input['name'] = @$template->name;
}
if (!@$input['view']) {
$input['view'] = @$template->view;
}
if (!@$input['identifier']) {
$input['identifier'] = @$template->identifier;
}
if (!@$input['package']) {
$input['package'] = @$template->package;
}
if (!@$input['edit_view']) {
$input['edit_view'] = @$template->edit_view;
}
if (!@$input['edit_package']) {
$input['edit_package'] = @$template->edit_package;
}
if (!@$input['edit_action']) {
$input['edit_action'] = @$template->edit_action;
}
//work out the slug if not manually set
if (!@$input['slug']) {
$input['slug'] = Content::createSlug($input, $parent);
}
//and the user_id (author)
$input['user_id'] = Auth::user()->id;
//and the application:
if (!@$input['application_id']) {
$application = Application::getApplication();
$input['application_id'] = $application->id;
}
//set language
if (!@$input['language']) {
$input['language'] = App::getLocale();
}
//and the package if not set
if (!@$input['package']) {
//set it as parent one..
$input['package'] = @$parent->package;
//still nothing - set from application
$application = Application::getApplication();
if ($application->package) {
$input['package'] = $application->package;
}
//still nothing - we have to set it to default.
if (!$input['package']) {
//last ditch attempt to put something sensible in here
$input['package'] = Content::PACKAGE;
}
}
if (!@$input['edit_package']) {
//set it as parent one..
$input['edit_package'] = @$parent->edit_package;
//still nothing - we have to set it to default.
if (!$input['edit_package']) {
//last ditch attempt to put something sensible in here
$input['edit_package'] = Content::PACKAGE;
}
}
if (!@$input['edit_view']) {
//set it as parent one..
$input['edit_view'] = @$parent->edit_view;
//still nothing - we have to set it to default.
if (!$input['edit_view']) {
//last ditch attempt to put something sensible in here
$input['edit_view'] = Content::EDIT_VIEW;
}
}
if (!@$input['view']) {
$input['view'] = Content::VIEW;
//.........这里部分代码省略.........
示例5: getPreview
public function getPreview($template, $type = null)
{
$tmpl = Template::find($template)->first();
if (!is_null($type) && $type != 'pdf') {
$content = DbView::make($tmpl)->field('body')->render();
return $content;
} else {
//return PDF::loadView('print.brochure',array('prop'=>$prop))
// ->stream('download.pdf');
$tmpl = $tmpl->toArray();
return PDF::loadView('brochuretmpl.' . $template, array('prop' => $prop, 'contact' => $contact, 'roi3' => $roi3, 'roi5' => $roi5))->setOption('margin-top', $tmpl['margin-top'])->setOption('margin-left', $tmpl['margin-left'])->setOption('margin-right', $tmpl['margin-right'])->setOption('margin-bottom', $tmpl['margin-bottom'])->setOption('dpi', $tmpl['dpi'])->setPaper($tmpl['paper-size'])->stream($prop['propertyId'] . '.pdf');
//return PDF::html('print.brochure',array('prop' => $prop), 'download.pdf');
}
}
示例6: getTemplates
public function getTemplates()
{
$templates = Template::find();
return $templates->toArray();
}
示例7: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$this->template->find($id)->delete();
return Redirect::route('templates.index');
}
示例8: edit
/**
* Show the form for editing the specified template.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$template = Template::find($id);
return View::make('templates.edit', compact('template'));
}
示例9: edit
/**
* Show the form for editing the specified template.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$template = Template::find($id);
return View::make('templates.edit', ['template' => $template])->withTitle("Ubah {$template->nama}");
}
示例10: superSave
public function superSave($input)
{
$input['application_id'] = Application::getApplication()->id;
$parent = Template::find($input['parent_id']);
unset($input['parent_id']);
//SAVE CONTENT ITEM
$saved = $parent->children()->create($input);
return $saved;
}
示例11: GetTemplatesAction
/**
* @Route("/getTemplates", methods = {"GET", "OPTIONS"})
*/
public function GetTemplatesAction()
{
$uid = $this->request->get('uid');
$templates = Template::find(['conditions' => 'handler_id=?1', 'bind' => [1 => $uid]]);
$templateList = array();
if ($templates->getFirst() == null) {
$this->response->setJsonContent(['message' => 'No Templates Found!']);
$this->response->send();
return;
}
foreach ($templates as $template) {
$template_id = $template->id;
$name = base64_decode($template->name);
$subject = base64_decode($template->subject);
$body = base64_decode($template->body);
$templateList[] = ['template_id' => $template_id, 'name' => $name, 'subject' => $subject, 'body' => $body];
}
$this->response->setJsonContent($templateList);
$this->response->send();
return;
}
示例12: populatevars
public function populatevars($type)
{
$temp = Template::find($type);
return View::make('variables.index')->with('templates', $temp);
}
示例13: saveTemplate
public function saveTemplate($truth_name, $tpl_name = '', $temptype = 0)
{
if ($tpl_name != '') {
$tpl_exists = Template::where('name', $tpl_name)->first();
if ($tpl_exists) {
$unpack_resuslt = $this->unpack($truth_name, $tpl_name, true, $temptype);
} else {
$tpl_exists = false;
$unpack_resuslt = $this->unpack($truth_name, $tpl_name, true, $temptype);
}
} else {
$tpl_exists = false;
$unpack_resuslt = $this->unpack($truth_name, $tpl_name, false, $temptype);
}
if ($unpack_resuslt) {
$tpl_info = $unpack_resuslt['config'];
if ($tpl_exists) {
$template = Template::find($tpl_exists->id);
} else {
$template = new Template();
$template->name = $unpack_resuslt['tpl_dir'];
$template->tpl_num = $unpack_resuslt['tpl_num'];
}
$template->tpl_name = $tpl_info['template']['tpl_name'];
$template->classify = $tpl_info['template']['classify'];
$template->demo = $tpl_info['template']['demo'];
$template->type = $tpl_info['template']['type'];
$template->description = $tpl_info['template']['description'];
$template->list1showtypetotal = $tpl_info['template']['list1showtypetotal'];
$template->list2showtypetotal = $tpl_info['template']['list2showtypetotal'];
$template->list3showtypetotal = $tpl_info['template']['list3showtypetotal'];
$template->list4showtypetotal = $tpl_info['template']['list4showtypetotal'];
$template->updated_at = date("Y-m-d H:i:s", time());
$insert_rst = $template->save();
if ($insert_rst) {
$insert_id = $template->id;
$color_arr = $tpl_info['tpl_color'];
$tpl_color = array();
$i = 0;
TemplateToColor::where('template_id', $insert_id)->delete();
if (count($color_arr) > 0) {
foreach ($color_arr as $color) {
$tpl_color[$i]['template_id'] = $insert_id;
$tpl_color[$i]['color_code'] = Config::get('color.' . $color);
$tpl_color[$i]['color_id'] = Color::where('color_en', $color)->pluck('id');
$i++;
}
TemplateToColor::insert($tpl_color);
}
}
$result = ['err' => 1000, 'msg' => '上传模板成功'];
} else {
$result = ['err' => 1003, 'msg' => '解压文件失败'];
}
return $result;
}
示例14: _indexTemplate
/**
* Index of type Template
*
* @param type $id
* @return void
* @throws NotFoundException
*/
protected function _indexTemplate()
{
$this->redirect('admin');
$this->paginate['limit'] = 50;
$this->paginate['conditions']['Webpage.type'] = 'template';
$this->set('webpages', $this->paginate());
App::uses('Template', 'Model');
$Template = new Template();
$this->set('templates', $templates = $Template->find('all', array('conditions' => array('Template.install NOT' => null))));
$sync = $this->Webpage->syncFiles('template');
$this->view = 'index_template';
$this->set('page_title_for_layout', 'Site Templates');
$this->set('title_for_layout', 'Site Templates');
}
示例15: build
/**
* Build method
*
*/
public function build()
{
$currentlyLoadedPlugins = CakePlugin::loaded();
CakePlugin::loadAll();
foreach (CakePlugin::loaded() as $plugin) {
$Plugin = ClassRegistry::init($plugin . '.' . $plugin . 'AppModel');
if (method_exists($Plugin, 'menuInit')) {
$plugins[] = $plugin;
}
}
$this->set('plugins', $plugins);
//$plugins = array_diff(CakePlugin::loaded(), array('Activities', 'Answers', 'Categories', 'Connections', 'Contacts', 'Drafts', 'Facebook', 'Feeds', 'Forms', 'Media', 'Privileges', 'Recaptcha', 'Searchable', 'Subscribers', 'Tags', 'Twitter', 'Utils', 'Webpages', 'Wizards', 'Workflows')));
CakePlugin::unload();
CakePlugin::load($currentlyLoadedPlugins);
// create some links to, and install the plugin if it isn't already
if (($this->request->is('post') || $this->request->is('put')) && $this->request->data['WebpageMenuItem']['page_type'] == 'plugin') {
$this->request->data['WebpageMenuItem']['item_text'] = $plugins[$this->request->data['WebpageMenuItem']['item_text']];
// if not already installed, then install the plugin
if (!in_array($this->request->data['WebpageMenuItem']['item_text'], $currentlyLoadedPlugins)) {
$this->_plugin($this->request->data['WebpageMenuItem']['item_text']);
}
// create the menu (independent of the plugin - we can always install later)
$MenuItem = ClassRegistry::init('Webpages.WebpageMenuItem');
if ($MenuItem->saveAll($this->request->data)) {
$this->Session->setFlash(__('Flow updated.'));
} else {
$this->Session->setFlash(__('Error occurred, please try again.'));
}
}
$this->layout = 'default';
App::uses('UserRole', 'Users.Model');
$UserRole = new UserRole();
$this->set('userRoles', $userRoles = $UserRole->find('all'));
$this->set('userRoleOptions', Set::combine($userRoles, '{n}.UserRole.session_user_role_id', '{n}.UserRole.name'));
App::uses('Template', 'Model');
$Template = new Template();
$this->set('templates', $templates = $Template->find('all', array('conditions' => array('Template.install NOT' => null))));
$this->set('page_title_for_layout', 'SITE buildrr');
$this->set('title_for_layout', 'SITE buildrr');
$defaultTemplate = Set::combine(templateSettings(), '{n}.isDefault', '{n}');
$defaultTemplate = Set::extract('/Template[layout=' . $defaultTemplate[1]['templateName'] . ']', $templates);
$defaultTemplate = !empty($defaultTemplate) ? $defaultTemplate : $Template->placeholder();
$this->set(compact('defaultTemplate'));
$Menu = ClassRegistry::init('Webpages.WebpageMenu');
foreach ($userRoles as $userRole) {
$varName = preg_replace("/[^A-Za-z]/", '', $userRole['UserRole']['name']) . 'Sections';
$conditions = $userRole['UserRole']['id'] == __SYSTEM_GUESTS_USER_ROLE_ID ? array('OR' => array(array('WebpageMenu.user_role_id' => ''), array('WebpageMenu.user_role_id' => null))) : array('WebpageMenu.user_role_id' => $userRole['UserRole']['id']);
$menu = $Menu->find('threaded', array('conditions' => $conditions));
// remove --Home from Home menu
for ($i = 0; $i < count($menu[0]['children']); $i++) {
if ($menu[0]['children'][$i]['WebpageMenu']['name'] == $menu[0]['WebpageMenu']['name']) {
unset($menu[0]['children'][$i]);
}
}
$this->set($varName, $menu);
}
//$this->set('sections', $Menu->find('threaded', array('conditions' => array('WebpageMenu.lft >=' => $menu['WebpageMenu']['lft'], 'WebpageMenu.rght <=' => $menu['WebpageMenu']['rght']))));
// used for re-ordering items $this->request->data['WebpageMenu']['children'] = $this->WebpageMenu->find('count', array('conditions' => array('WebpageMenu.lft >' => $menu['WebpageMenu']['lft'], 'WebpageMenu.rght <' => $menu['WebpageMenu']['rght'])));
//$this->set('sections', $sections = $Menu->find('all', array('conditions' => array('OR' => array(array('WebpageMenu.parent_id' => null), array('WebpageMenu.parent_id' => ''))))));
$menus = $Menu->generateTreeList(null, null, null, '--');
foreach ($menus as $menu) {
if (strpos($menu, '-') !== 0) {
// this key should be removed, because if there is a link to the same page as the menu name
$menus = ZuhaSet::devalue($menus, '--' . $menu, true);
}
}
$this->set(compact('menus'));
}