当前位置: 首页>>代码示例>>PHP>>正文


PHP General::right方法代码示例

本文整理汇总了PHP中General::right方法的典型用法代码示例。如果您正苦于以下问题:PHP General::right方法的具体用法?PHP General::right怎么用?PHP General::right使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在General的用法示例。


在下文中一共展示了General::right方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action

 function action()
 {
     $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
     if (array_key_exists('save', $_POST['action']) || array_key_exists('done', $_POST['action'])) {
         $fields = $_POST['fields'];
         $this->_errors = array();
         if (!isset($fields['name']) || trim($fields['name']) == '') {
             $this->_errors['name'] = __('Name is a required field.');
         }
         if (!isset($fields['body']) || trim($fields['body']) == '') {
             $this->_errors['body'] = __('Body is a required field.');
         } elseif (!General::validateXML($fields['body'], $errors, false, new XSLTProcess())) {
             $this->_errors['body'] = __('This document is not well formed. The following error was returned: <code>%s</code>', array($errors[0]['message']));
         }
         if (empty($this->_errors)) {
             $fields['name'] = Lang::createFilename($fields['name']);
             if (General::right($fields['name'], 4) != '.xsl') {
                 $fields['name'] .= '.xsl';
             }
             $file = UTILITIES . '/' . $fields['name'];
             ##Duplicate
             if ($this->_context[0] == 'edit' && ($this->_existing_file != $fields['name'] && is_file($file))) {
                 $this->_errors['name'] = __('A Utility with that name already exists. Please choose another.');
             } elseif ($this->_context[0] == 'new' && is_file($file)) {
                 $this->_errors['name'] = __('A Utility with that name already exists. Please choose another.');
             } elseif (!($write = General::writeFile($file, $fields['body'], $this->_Parent->Configuration->get('write_mode', 'file')))) {
                 $this->pageAlert(__('Utility could not be written to disk. Please check permissions on <code>/workspace/utilities</code>.'), Alert::ERROR);
             } else {
                 ## Remove any existing file if the filename has changed
                 if ($this->_existing_file && $file != UTILITIES . '/' . $this->_existing_file) {
                     General::deleteFile(UTILITIES . '/' . $this->_existing_file);
                 }
                 ## TODO: Fix me
                 ###
                 # Delegate: Edit
                 # Description: After saving the asset, the file path is provided.
                 //$ExtensionManager->notifyMembers('Edit', getCurrentPage(), array('file' => $file));
                 redirect(URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $fields['name']) . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/');
             }
         }
     } elseif ($this->_context[0] == 'edit' && @array_key_exists('delete', $_POST['action'])) {
         ## TODO: Fix me
         ###
         # Delegate: Delete
         # Description: Prior to deleting the asset file. Target file path is provided.
         //$ExtensionManager->notifyMembers('Delete', getCurrentPage(), array('file' => WORKSPACE . '/' . $this->_existing_file_rel));
         General::deleteFile(UTILITIES . '/' . $this->_existing_file);
         redirect(URL . '/symphony/blueprints/components/');
     }
 }
开发者ID:bauhouse,项目名称:sym-fluidgrids,代码行数:50,代码来源:content.blueprintsutilities.php

示例2: __construct

 function __construct(&$parent, $env = NULL)
 {
     $szRootElement = get_class($this);
     $this->ROOT_ELEMENT = Lang::createHandle(General::right($szRootElement, strlen($szRootElement) - 5));
     parent::__construct($parent, $env);
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:6,代码来源:class.eventex.php

示例3: action

 public function action()
 {
     $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
     if (array_key_exists('save', $_POST['action']) || array_key_exists('done', $_POST['action'])) {
         $fields = $_POST['fields'];
         $this->_errors = array();
         if (!isset($fields['name']) || trim($fields['name']) == '') {
             $this->_errors['name'] = __('Name is a required field.');
         }
         if (!isset($fields['body']) || trim($fields['body']) == '') {
             $this->_errors['body'] = __('Body is a required field.');
         } elseif (!General::validateXML($fields['body'], $errors, false, new XSLTProcess())) {
             $this->_errors['body'] = __('This document is not well formed. The following error was returned: <code>%s</code>', array($errors[0]['message']));
         }
         $fields['name'] = Lang::createFilename($fields['name']);
         if (General::right($fields['name'], 4) != '.xsl') {
             $fields['name'] .= '.xsl';
         }
         $file = UTILITIES . '/' . $fields['name'];
         ##Duplicate
         if ($this->_context[0] == 'edit' && ($this->_existing_file != $fields['name'] && is_file($file))) {
             $this->_errors['name'] = __('A Utility with that name already exists. Please choose another.');
         } elseif ($this->_context[0] == 'new' && is_file($file)) {
             $this->_errors['name'] = __('A Utility with that name already exists. Please choose another.');
         }
         if (empty($this->_errors)) {
             if ($this->_context[0] == 'new') {
                 /**
                  * Just before the Utility has been created
                  *
                  * @delegate UtilityPreCreate
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/utilities/'
                  * @param string $file
                  *  The path to the Utility file
                  * @param string $contents
                  *  The contents of the `$fields['body']`, passed by reference
                  */
                 Symphony::ExtensionManager()->notifyMembers('UtilityPreCreate', '/blueprints/utilities/', array('file' => $file, 'contents' => &$fields['body']));
             } else {
                 /**
                  * Just before the Utility has been updated
                  *
                  * @delegate UtilityPreEdit
                  * @since Symphony 2.2
                  * @param string $context
                  * '/blueprints/utilities/'
                  * @param string $file
                  *  The path to the Utility file
                  * @param string $contents
                  *  The contents of the `$fields['body']`, passed by reference
                  */
                 Symphony::ExtensionManager()->notifyMembers('UtilityPreEdit', '/blueprints/utilities/', array('file' => $file, 'contents' => &$fields['body']));
             }
             ##Write the file
             if (!($write = General::writeFile($file, $fields['body'], Symphony::Configuration()->get('write_mode', 'file')))) {
                 $this->pageAlert(__('Utility could not be written to disk. Please check permissions on <code>/workspace/utilities</code>.'), Alert::ERROR);
             } else {
                 ## Remove any existing file if the filename has changed
                 if ($this->_existing_file && $file != UTILITIES . '/' . $this->_existing_file) {
                     General::deleteFile(UTILITIES . '/' . $this->_existing_file);
                 }
                 if ($this->_context[0] == 'new') {
                     /**
                      * Just after the Utility has been written to disk
                      *
                      * @delegate UtilityPostCreate
                      * @since Symphony 2.2
                      * @param string $context
                      * '/blueprints/utilities/'
                      * @param string $file
                      *  The path to the Utility file
                      */
                     Symphony::ExtensionManager()->notifyMembers('UtilityPostCreate', '/blueprints/utilities/', array('file' => $file));
                 } else {
                     /**
                      * Just after a Utility has been edited and written to disk
                      *
                      * @delegate UtilityPostEdit
                      * @since Symphony 2.2
                      * @param string $context
                      * '/blueprints/utilities/'
                      * @param string $file
                      *  The path to the Utility file
                      */
                     Symphony::ExtensionManager()->notifyMembers('UtilityPostEdit', '/blueprints/utilities/', array('file' => $file));
                 }
                 redirect(SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $fields['name']) . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/');
             }
         }
     } elseif ($this->_context[0] == 'edit' && @array_key_exists('delete', $_POST['action'])) {
         /**
          * Prior to deleting the Utility
          *
          * @delegate UtilityPreDelete
          * @since Symphony 2.2
          * @param string $context
          * '/blueprints/utilities/'
          * @param string $file
//.........这里部分代码省略.........
开发者ID:benesch,项目名称:hilton-unar,代码行数:101,代码来源:content.blueprintsutilities.php

示例4: __actionEdit

 public function __actionEdit()
 {
     $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
     if (array_key_exists('save', $_POST['action']) || array_key_exists('done', $_POST['action'])) {
         $fields = $_POST['fields'];
         //$this->errors = array();
         if (!isset($fields['name']) || trim($fields['name']) == '') {
             $this->errors->name = __('Name is a required field.');
         }
         if (!isset($fields['template']) || trim($fields['template']) == '') {
             $this->errors->template = __('XSLT is a required field.');
         } elseif (!General::validateXML($fields['template'], $errors)) {
             $fragment = $this->createDocumentFragment();
             $fragment->appendChild(new DOMText(__('This document is not well formed. The following error was returned: ')));
             $fragment->appendChild($this->createElement('code', $errors->current()->message));
             $this->errors->template = $fragment;
         }
         if (!$this->errors->valid()) {
             $fields['name'] = Lang::createFilename($fields['name']);
             if (General::right($fields['name'], 4) != '.xsl') {
                 $fields['name'] .= '.xsl';
             }
             $file = UTILITIES . '/' . $fields['name'];
             // TODO: Does it really need stripslashed? Funky.
             $fields['template'] = stripslashes($fields['template']);
             ##Duplicate
             if ($this->_context[0] == 'edit' && ($this->_existing_file != $fields['name'] && is_file($file))) {
                 $this->errors->name = __('A Utility with that name already exists. Please choose another.');
             } elseif ($this->_context[0] == 'new' && is_file($file)) {
                 $this->errors->name = __('A Utility with that name already exists. Please choose another.');
             } elseif (!($write = General::writeFile($file, $fields['template'], Symphony::Configuration()->core()->symphony->{'file-write-mode'}))) {
                 $this->alerts()->append(__('Utility could not be written to disk. Please check permissions on <code>/workspace/utilities</code>.'), AlertStack::SUCCESS);
             } else {
                 ## Remove any existing file if the filename has changed
                 if ($this->_existing_file && $file != UTILITIES . '/' . $this->_existing_file) {
                     General::deleteFile(UTILITIES . '/' . $this->_existing_file);
                 }
                 ## FIXME: Fix this delegate
                 ###
                 # Delegate: Edit
                 # Description: After saving the asset, the file path is provided.
                 //Extension::notify('Edit', getCurrentPage(), array('file' => $file));
                 redirect(ADMIN_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $fields['name']) . '/' . ($this->_context[0] == 'new' ? 'created' : 'saved') . '/');
             }
         }
     } elseif ($this->_context[0] == 'edit' && array_key_exists('delete', $_POST['action'])) {
         ## FIXME: Fix this delegate
         ###
         # Delegate: Delete
         # Description: Prior to deleting the asset file. Target file path is provided.
         //Extension::notify('Delete', getCurrentPage(), array('file' => WORKSPACE . '/' . $this->_existing_file_rel));
         $this->__actionDelete(UTILITIES . '/' . $this->_existing_file, ADMIN_URL . '/blueprints/components/');
     }
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:54,代码来源:content.blueprintsutilities.php


注:本文中的General::right方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。