Example #1
0
 /**
  * Processes the request.
  *
  * @param  object    $page       CRM_Core_Form the current form-page
  * @param  string    $actionName Current action name, as one Action object can serve multiple actions
  *
  * @return void
  * @access public
  */
 function perform(&$page, $actionName)
 {
     $pageName = $page->getAttribute('id');
     // If the original action was 'display' and we have values in container then we load them
     // BTW, if the page was invalid, we should later call validate() to get the errors
     list(, $oldName) = $page->controller->getActionName();
     if ('display' == $oldName) {
         // If the controller is "modal" we should not allow direct access to a page
         // unless all previous pages are valid (see also bug #2323)
         if ($page->controller->isModal() && !$page->controller->isValid($page->getAttribute('id'))) {
             $target =& $page->controller->getPage($page->controller->findInvalid());
             return $target->handle('jump');
         }
         $data =& $page->controller->container();
         if (!empty($data['values'][$pageName])) {
             $page->loadValues($data['values'][$pageName]);
             $validate = FALSE === $data['valid'][$pageName];
         }
     }
     // set "common" defaults and constants
     $page->controller->applyDefaults($pageName);
     $page->isFormBuilt() or $page->buildForm();
     // if we had errors we should show them again
     if (isset($validate) && $validate) {
         $page->validate();
     }
     //will this work generally as TRUE (i.e., return output)
     //was default, i.e., FALSE
     return $this->renderForm($page);
 }
Example #2
0
 /**
  * Check the PDO driver
  *
  * @param string $name
  * @param bool $exception
  *
  * @return bool
  */
 protected function checkPdoDriver($name = false, $exception = false)
 {
     if ($name === false) {
         $name = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
     }
     if (array_search($name, $this->pdo->getAvailableDrivers()) === false) {
         if ($exception) {
             throw new PDOException("PDO does not support any driver.");
         }
         return false;
     }
     return true;
 }
Example #3
0
File: Tag.php Project: roojs/pear
 /**
  * reWriteURL - can using the config option 'url_rewrite'
  *  format "from:to,from:to"
  * only handle left rewrite. 
  * so 
  *  "/images:/myroot/images"
  * would change
  *   /images/xyz.gif to /myroot/images/xyz.gif
  *   /images/stylesheet/imagestyles.css to  /myroot/images/stylesheet/imagestyles.css
  *   note /imagestyles did not get altered.
  * will only work on strings (forget about doing /images/{someimage}
  *
  *
  * @param    string attribute to rewrite
  * @return   none
  * @access   public
  */
 function reWriteURL($which)
 {
     global $_HTML_TEMPLATE_FLEXY;
     if (!is_string($original = $this->element->getAttribute($which))) {
         return;
     }
     if ($original == '') {
         return;
     }
     if (empty($_HTML_TEMPLATE_FLEXY['currentOptions']['url_rewrite'])) {
         return;
     }
     $bits = explode(",", $_HTML_TEMPLATE_FLEXY['currentOptions']['url_rewrite']);
     $new = $original;
     foreach ($bits as $bit) {
         if (!strlen(trim($bit))) {
             continue;
         }
         $parts = explode(':', $bit);
         if (!isset($parts[1])) {
             return HTML_Template_Flexy::staticRaiseError('HTML_Template_Flexy: url_rewrite syntax incorrect' . print_r(array($bits, $bits), true), null, HTML_TEMPLATE_FLEXY_ERROR_DIE);
         }
         $new = preg_replace('#^' . $parts[0] . '#', $parts[1], $new);
     }
     if ($original == $new) {
         return;
     }
     $this->element->ucAttributes[$which] = '"' . $new . '"';
 }
 /**
  * Construct
  *
  * @param string $type the crud type
  * @param object $db the sql object
  */
 public function __construct($type, $db)
 {
     $this->db = $db;
     //get a new factory
     $factory = new QueryFactory($db->getAttribute(PDO::ATTR_DRIVER_NAME));
     $this->query = call_user_func([$factory, 'new' . ucfirst($type)]);
 }
Example #5
0
 /**
  * Called by HTML_QuickForm whenever form event is made on this element
  *
  * @param     string    $event  Name of event
  * @param     mixed     $arg    event arguments
  * @param     object    $caller calling object
  * @since     1.0
  * @access    public
  * @return    void
  */
 function onQuickFormEvent($event, $arg, &$caller)
 {
     switch ($event) {
         case 'createElement':
             $this->_formid = $caller->getAttribute('id');
             break;
     }
     return parent::onQuickFormEvent($event, $arg, $caller);
 }
Example #6
0
 /**
  * Processes the request.
  *
  * @param  object    $page       CRM_Core_Form the current form-page
  * @param  string    $actionName Current action name, as one Action object can serve multiple actions
  *
  * @return void
  * @access public
  */
 function perform(&$page, $actionName)
 {
     // save the form values and validation status to the session
     $page->isFormBuilt() or $page->buildForm();
     $pageName = $page->getAttribute('name');
     $data =& $page->controller->container();
     $data['values'][$pageName] = $page->exportValues();
     return $page->handle('display');
 }
 /**
  * Normalizes an object into a set of arrays/scalars
  *
  * @param object $object  object to normalize
  * @param string $format  format the normalization result will be encoded as
  * @param array  $context Context options for the normalizer
  *
  * @return array|scalar
  */
 public function normalize($object, $format = null, array $context = [])
 {
     $attributeCode = strtolower($context['attributeCodeMapping']->getTarget($object->getAttribute()->getCode()));
     if ($this->isValueNormalizable($object, $context['identifier'], $attributeCode, $context['scopeCode'], $context['localeCode'], $context['onlyLocalized'])) {
         return $this->getNormalizedValue($object, $attributeCode, $context['magentoAttributes'], $context['magentoAttributesOptions'], $context['attributeCodeMapping'], $context['currencyCode']);
     } else {
         return null;
     }
 }
 /**
  * @param object     $attributeOption
  * @param Constraint $constraint
  */
 public function validate($attributeOption, Constraint $constraint)
 {
     /** @var AttributeOptionInterface */
     if ($attributeOption instanceof AttributeOptionInterface) {
         $attribute = $attributeOption->getAttribute();
         $authorizedTypes = [AttributeTypes::OPTION_SIMPLE_SELECT, AttributeTypes::OPTION_MULTI_SELECT];
         if (!in_array($attribute->getAttributeType(), $authorizedTypes)) {
             $this->addInvalidAttributeViolation($constraint, $attributeOption);
         }
     }
 }
Example #9
0
 /**
  * Method to display details about the target server's database connected
  * 
  * @access public static
  * @param void
  * @return void
  */
 public static function showServerInfo()
 {
     try {
         if (self::$instance instanceof \PDO) {
             $driver = self::getDriver();
             $info = $driver == 'sqlite' || $driver == 'mssql' ? 'not available' : self::$instance->getAttribute(\PDO::ATTR_SERVER_INFO);
             echo '<h7>Server Information - ', is_array($info) ? implode(', ', $info) : $info, '</h7>';
         } else {
             throw new \PDOException(self::$exception['no-instance']);
         }
     } catch (\PDOException $e) {
         self::stackTrace($e);
     }
 }
Example #10
0
 /**
  * 构造方法
  *
  * 用于初始化运行环境,或对基本变量进行赋值
  *
  * @access public
  *
  * @param array $params 数据库连接参数,如主机名,数据库用户名,密码等
  *
  * @return boolean
  */
 public function __construct($params = array())
 {
     //参数分析
     if (!$params['dsn']) {
         Controller::halt('database config params error!', 'Normal');
     }
     $params += $this->_defaultConfig;
     //数据库连接
     try {
         $flags = array(PDO::ATTR_PERSISTENT => $params['persistency'], PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
         //实例化数据库连接
         $this->_dbLink = new PDO($params['dsn'], $params['username'], $params['password'], $flags);
     } catch (PDOException $exception) {
         //当调试模式关闭时
         if (DOIT_DEBUG === false) {
             //记录错误日志
             Log::write("Database server connect error! Error Code:{$exception->getCode()} Error Message:{$exception->getMessage()}", 'Warning');
             //提示错误信息
             Controller::showMsg('数据库连接失败!');
         }
         //抛出异常信息
         throw new DoitException('Database connect error!<br/>' . $exception->getMessage(), $exception->getCode());
     }
     //设置数据编码
     $driverName = $this->_dbLink->getAttribute(PDO::ATTR_DRIVER_NAME);
     switch ($driverName) {
         case 'mysql':
         case 'pgsql':
             $this->_dbLink->exec("SET NAMES {$params['charset']}");
             break;
         case 'sqlsrv':
             $this->_dbLink->setAttribute(PDO::SQLSRV_ATTR_ENCODING, $params['charset']);
             break;
     }
     return true;
 }
 /**
  * @param object     $productValue
  * @param Constraint $constraint
  */
 public function validate($productValue, Constraint $constraint)
 {
     /** @var ProductValueInterface */
     if ($productValue instanceof ProductValueInterface) {
         $isLocalizable = $productValue->getAttribute()->isLocalizable();
         $localeCode = $productValue->getLocale();
         if ($isLocalizable && null === $localeCode) {
             $this->addExpectedLocaleViolation($constraint, $productValue);
         } elseif ($isLocalizable && !$this->doesLocaleExist($localeCode)) {
             $this->addUnexistingLocaleViolation($constraint, $productValue, $localeCode);
         } elseif (!$isLocalizable && null !== $localeCode) {
             $this->addUnexpectedLocaleViolation($constraint, $productValue);
         }
     }
 }
Example #12
0
 /**
  * Processes the request. 
  *
  * @param  object    $page       CRM_Core_Form the current form-page
  * @param  string    $actionName Current action name, as one Action object can serve multiple actions
  *
  * @return void
  * @access public
  */
 function perform(&$page, $actionName)
 {
     $page->isFormBuilt() or $page->buildForm();
     $pageName = $page->getAttribute('name');
     $data =& $page->controller->container();
     $data['values'][$pageName] = $page->exportValues();
     $data['valid'][$pageName] = $page->validate();
     // Modal form and page is invalid: don't go further
     if ($page->controller->isModal() && !$data['valid'][$pageName]) {
         return $page->handle('display');
     }
     // the page is valid, process it before we jump to the next state
     $page->mainProcess();
     return $page->handle('display');
 }
 /**
  * @param object     $productValue
  * @param Constraint $constraint
  */
 public function validate($productValue, Constraint $constraint)
 {
     /** @var ProductValueInterface */
     if ($productValue instanceof ProductValueInterface) {
         $isScopable = $productValue->getAttribute()->isScopable();
         $channelCode = $productValue->getScope();
         if ($isScopable && null === $channelCode) {
             $this->addExpectedScopeViolation($constraint, $productValue);
         } elseif ($isScopable && !$this->doesChannelExist($channelCode)) {
             $this->addUnexistingScopeViolation($constraint, $productValue, $channelCode);
         } elseif (!$isScopable && null !== $channelCode) {
             $this->addUnexpectedScopeViolation($constraint, $productValue);
         }
     }
 }
Example #14
0
 /**
  * Processes the request.
  * this is basically a self submit, so validate the page
  * and if success, call post process
  * when done processing pop to user context
  *
  * @param  object    $page       CRM_Core_Form the current form-page
  * @param  string    $actionName Current action name, as one Action object can serve multiple actions
  *
  * @return void
  * @access public
  */
 function perform(&$page, $actionName)
 {
     $page->isFormBuilt() or $page->buildForm();
     $pageName = $page->getAttribute('name');
     $data =& $page->controller->container();
     $data['values'][$pageName] = $page->exportValues();
     $data['valid'][$pageName] = $page->validate();
     // Modal form and page is invalid: don't go further
     if ($page->controller->isModal() && !$data['valid'][$pageName]) {
         return $page->handle('display');
     }
     // the page is valid, process it before we jump to the next state
     $page->mainProcess();
     // ok so we are done now, pop stack and jump back to where we came from
     // we do not reset the context because u can achieve that affect using next
     // use Done when u want to pop back to the same context without a reset
     $this->popUserContext();
 }
 /**
  * Processes the request.
  *
  * @param  object    $page       CRM_Core_Form the current form-page
  * @param  string    $actionName Current action name, as one Action object can serve multiple actions
  *
  * @return void
  * @access public
  */
 function perform(&$page, $actionName)
 {
     // check whether the page is valid before trying to go to it
     if ($page->controller->isModal()) {
         // we check whether *all* pages up to current are valid
         // if there is an invalid page we go to it, instead of the
         // requested one
         $pageName = $page->getAttribute('id');
         if (!$page->controller->isValid($pageName)) {
             $pageName = $page->controller->findInvalid();
         }
         $current =& $page->controller->getPage($pageName);
     } else {
         $current =& $page;
     }
     // generate the URL for the page 'display' event and redirect to it
     $action = $current->getAttribute('action');
     $url = $action . (FALSE === strpos($action, '?') ? '?' : '&') . $current->getButtonName('display') . '=true' . '&qfKey=' . $page->get('qfKey');
     CRM_Utils_System::redirect($url);
 }
 /**
  * Processes the request.
  *
  * @param  object    $page       CRM_Core_Form the current form-page
  * @param  string    $actionName Current action name, as one Action object can serve multiple actions
  *
  * @return void
  * @access public
  */
 function perform(&$page, $actionName)
 {
     $page->isFormBuilt() or $page->buildForm();
     $pageName = $page->getAttribute('name');
     $data =& $page->controller->container();
     $data['values'][$pageName] = $page->exportValues();
     $data['valid'][$pageName] = $page->validate();
     // Modal form and page is invalid: don't go further
     if ($page->controller->isModal() && !$data['valid'][$pageName]) {
         return $page->handle('display');
     }
     // the page is valid, process it before we jump to the next state
     $page->mainProcess();
     // check if destination is set, if so goto destination
     $destination = $this->_stateMachine->getDestination();
     if ($destination) {
         $destination = urldecode($destination);
         CRM_Utils_System::redirect($destination);
     } else {
         return $page->handle('display');
     }
 }
Example #17
0
 private function filter($table, $info)
 {
     $driver = $this->db->getAttribute(\PDO::ATTR_DRIVER_NAME);
     if ($driver == 'sqlite') {
         $sql = "PRAGMA table_info('" . $table . "');";
         $key = "name";
     } elseif ($driver == 'mysql') {
         $sql = "DESCRIBE " . $table . ";";
         $key = "Field";
     } else {
         $sql = "SELECT column_name FROM information_schema.columns WHERE table_name = '" . $table . "';";
         $key = "column_name";
     }
     if (false !== ($list = $this->init($sql))) {
         $fields = array();
         foreach ($list as $record) {
             $fields[] = $record[$key];
         }
         return array_values(array_intersect($fields, array_keys($info)));
     }
     return array();
 }
 /**
  * testLoadConfig method
  *
  * @return void
  */
 public function testLoadConfig()
 {
     $path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS;
     $result = $this->Html->loadConfig('htmlhelper_tags', $path);
     $expected = array('tags' => array('form' => 'start form', 'formend' => 'finish form'));
     $this->assertEquals($expected, $result);
     $tags = $this->Html->getAttribute('_tags');
     $this->assertEquals('start form', $tags['form']);
     $this->assertEquals('finish form', $tags['formend']);
     $this->assertEquals('</select>', $tags['selectend']);
     $result = $this->Html->loadConfig(array('htmlhelper_minimized.ini', 'ini'), $path);
     $expected = array('minimizedAttributeFormat' => 'format');
     $this->assertEquals($expected, $result);
     $this->assertEquals('format', $this->Html->getAttribute('_minimizedAttributeFormat'));
 }
 /**
  * @param object $element
  * @param mixed $required
  * @param mixed $error
  */
 function renderElement(&$element, $required, $error)
 {
     //manipulate id of all elements before rendering
     if (!is_null($element->getAttribute('id'))) {
         $id = $element->getAttribute('id');
     } else {
         $id = $element->getName();
     }
     //strip qf_ prefix and replace '[' with '_' and strip ']'
     $id = preg_replace(array('/^qf_|\\]/', '/\\[/'), array('', '_'), $id);
     if (strpos($id, 'id_') !== 0) {
         $element->updateAttributes(array('id' => 'id_' . $id));
     }
     //adding stuff to place holders in template
     //check if this is a group element first
     if ($this->_inGroup and !empty($this->_groupElementTemplate)) {
         // so it gets substitutions for *each* element
         $html = $this->_groupElementTemplate;
     } elseif (method_exists($element, 'getElementTemplateType')) {
         $html = $this->_elementTemplates[$element->getElementTemplateType()];
     } else {
         $html = $this->_elementTemplates['default'];
     }
     if ($this->_showAdvanced) {
         $advclass = ' advanced';
     } else {
         $advclass = ' advanced hide';
     }
     if (isset($this->_advancedElements[$element->getName()])) {
         $html = str_replace(' {advanced}', $advclass, $html);
     } else {
         $html = str_replace(' {advanced}', '', $html);
     }
     if (isset($this->_advancedElements[$element->getName()]) || $element->getName() == 'mform_showadvanced') {
         $html = str_replace('{advancedimg}', $this->_advancedHTML, $html);
     } else {
         $html = str_replace('{advancedimg}', '', $html);
     }
     $html = str_replace('{type}', 'f' . $element->getType(), $html);
     $html = str_replace('{name}', $element->getName(), $html);
     if (method_exists($element, 'getHelpButton')) {
         $html = str_replace('{help}', $element->getHelpButton(), $html);
     } else {
         $html = str_replace('{help}', '', $html);
     }
     if ($this->_inGroup and !empty($this->_groupElementTemplate)) {
         $this->_groupElementTemplate = $html;
     } elseif (!isset($this->_templates[$element->getName()])) {
         $this->_templates[$element->getName()] = $html;
     }
     parent::renderElement($element, $required, $error);
 }
Example #20
0
 /**
  * get page's action button
  *
  * @author                                    youzhao.zxw<swustnjtu@gmail.com>
  * @param   string          $infoType         bug,case or result
  * @param   string          $actionType       page's action now
  * @param   object          $model            basic info attributes
  * @return  string                            button list html str
  */
 public static function getButtonList($infoType, $actionType, $model)
 {
     $listStr = '';
     $infoStatus = $model->getAttribute($infoType . '_status');
     $needToConfirmStr = '$needToConfirm = false;';
     if ('view' == $actionType) {
         $preId = '';
         $nextId = '';
         $preDisabled = 'disabled';
         $nextDisabled = 'disabled';
         $listStr .= '<span id="preNextSpan">';
         $listStr .= CHtml::button(Yii::t('Common', 'Previous') . '(P)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $preId)) . '"', 'class' => 'btn', 'disabled' => $preDisabled, 'accesskey' => 'P'));
         $listStr .= CHtml::button(Yii::t('Common', 'Next') . '(N)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $nextId)) . '"', 'class' => 'btn', 'disabled' => $nextDisabled, 'accesskey' => 'N'));
         $listStr .= '</span>';
         $listStr .= '&nbsp;&nbsp;&nbsp;&nbsp;';
         if (Info::TYPE_BUG == $infoType) {
             if (BugInfo::STATUS_ACTIVE == $infoStatus) {
                 $listStr .= CHtml::button(Yii::t('BugInfo', 'opened_edit') . '(E)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'action' => BugInfo::ACTION_OPEN_EDIT, 'id' => $model->id)) . '"', 'class' => 'btn', 'accesskey' => 'E'));
             } else {
                 $listStr .= CHtml::button(Yii::t('BugInfo', strtolower($infoStatus) . '_edit') . '(E)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'action' => strtolower($infoStatus) . '_edit', 'id' => $model->id)) . '"', 'class' => 'btn', 'accesskey' => 'E'));
             }
         } else {
             $listStr .= CHtml::button(Yii::t('BugInfo', 'opened_edit') . '(E)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'action' => BugInfo::ACTION_OPEN_EDIT, 'id' => $model->id)) . '"', 'class' => 'btn', 'accesskey' => 'E'));
         }
         if (Info::TYPE_RESULT != $infoType) {
             $listStr .= CHtml::button(Yii::t('Common', 'Copy') . '(C)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'action' => BugInfo::ACTION_OPEN, 'source_id' => $model->id)) . '"', 'class' => 'btn', 'accesskey' => 'C'));
         }
         if (Info::TYPE_BUG == $infoType) {
             $listStr .= CHtml::button(Yii::t('BugInfo', BugInfo::ACTION_NEW_CASE) . '(S)', array('onclick' => $needToConfirmStr . 'openWindow("' . Yii::app()->createUrl('info/edit', array('type' => Info::TYPE_CASE, 'action' => CaseInfo::ACTION_OPEN, 'bug_id' => $model->id)) . '","_blank")', 'class' => 'btn', 'accesskey' => 'S'));
             $disableResolve = 'disabled';
             if (BugInfo::STATUS_ACTIVE == $infoStatus && 'view' == $actionType) {
                 $disableResolve = '';
             }
             $listStr .= CHtml::button(Yii::t('BugInfo', BugInfo::ACTION_RESOLVE) . '(R)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'action' => BugInfo::ACTION_RESOLVE, 'id' => $model->id)) . '"', 'class' => 'btn', 'disabled' => $disableResolve, 'accesskey' => 'R'));
             $disableClose = 'disabled';
             if (BugInfo::STATUS_RESOLVED == $infoStatus && 'view' == $actionType) {
                 $disableClose = '';
             }
             $listStr .= CHtml::button(Yii::t('BugInfo', BugInfo::ACTION_CLOSE) . '(L)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'action' => BugInfo::ACTION_CLOSE, 'id' => $model->id)) . '"', 'class' => 'btn', 'disabled' => $disableClose, 'accesskey' => 'L'));
             $disableActive = 'disabled';
             if ((BugInfo::STATUS_CLOSED == $infoStatus || BugInfo::STATUS_RESOLVED == $infoStatus) && 'view' == $actionType) {
                 $disableActive = '';
             }
             $listStr .= CHtml::button(Yii::t('BugInfo', BugInfo::ACTION_ACTIVATE) . '(A)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'action' => BugInfo::ACTION_ACTIVATE, 'id' => $model->id)) . '"', 'class' => 'btn', 'disabled' => $disableActive, 'accesskey' => 'A'));
         } elseif (Info::TYPE_CASE == $infoType) {
             $listStr .= CHtml::button(Yii::t('CaseInfo', CaseInfo::ACTION_RUN) . '(R)', array('onclick' => $needToConfirmStr . 'openWindow("' . Yii::app()->createUrl('info/edit', array('type' => Info::TYPE_RESULT, 'action' => ResultInfo::ACTION_OPEN, 'case_id' => $model->id)) . '","_blank")', 'class' => 'btn', 'accesskey' => 'R'));
             $listStr .= CHtml::button(Yii::t('CaseInfo', CaseInfo::ACTION_STEP_RUN) . '(S)', array('onclick' => $needToConfirmStr . 'openWindow("' . Yii::app()->createUrl('info/edit', array('type' => Info::TYPE_RESULT, 'action' => ResultInfo::ACTION_OPEN, 'case_id' => $model->id, 'step_run' => 1)) . '","_blank")', 'class' => 'btn', 'accesskey' => 'S'));
         } elseif (Info::TYPE_RESULT == $infoType) {
             $listStr .= CHtml::button(Yii::t('ResultInfo', ResultInfo::ACTION_OPEN) . '(B)', array('onclick' => $needToConfirmStr . 'openWindow("' . Yii::app()->createUrl('info/edit', array('type' => Info::TYPE_BUG, 'action' => BugInfo::ACTION_OPEN, 'result_id' => $model->id)) . '","_blank")', 'class' => 'btn', 'accesskey' => 'B'));
         }
     } else {
         $listStr = CHtml::button(Yii::t('Common', 'Save') . '(S)', array('onclick' => $needToConfirmStr . 'submitForm();', 'class' => 'btn', 'accesskey' => 'S'));
         if ('result' != $infoType) {
             $listStr .= '&nbsp;&nbsp;';
             $listStr .= CHtml::button(Yii::t('Common', 'Save as template') . '(T)', array('onclick' => $needToConfirmStr . '$("#template_dialog").dialog("open"); return false;', 'class' => 'btn', 'style' => 'width:120px;', 'accesskey' => 'T'));
         }
     }
     return $listStr;
 }
Example #21
0
/**
 * Add from a node.
 *
 * @param object $phar   The Phar class.
 * @param object $node   The node to add.
 * @param string $prefix The prefix of the structure.
 *
 * @return void
 */
function buildFromNode(&$phar, $node, $prefix = '')
{
    $nodeName = $node->nodeName;
    if ($nodeName !== 'dir' && $nodeName !== 'file') {
        // Invalid node.
        return;
    }
    $path = $prefix . $node->getAttribute('name');
    if ($node->getAttribute('role') === 'php' || $node->getAttribute('role') === 'data') {
        $path = ltrim($path, '/');
        $phar->addFile(realpath(__DIR__ . '/../' . $path), $path);
        $phar[$path]->compress(Phar::GZ);
    }
    if ($nodeName === 'dir') {
        // Descend into the depths.
        $path = rtrim($path, '/') . '/';
        $children = $node->childNodes;
        $childLn = $children->length;
        for ($c = 0; $c < $childLn; $c++) {
            $child = $children->item($c);
            buildFromNode($phar, $child, $path);
        }
    }
}
Example #22
0
 /**
  * get or create attribute data for given object
  *
  * @param object $object
  * @return \Shopware\Models\Attribute\OrderDetail
  * @throws Exception 
  */
 public function getOrCreateAttribute($object)
 {
     if ($attribute = $object->getAttribute()) {
         return $attribute;
     }
     if ($object instanceof Shopware\Models\Order\Order) {
         if (!($attribute = Shopware()->Models()->getRepository('Shopware\\Models\\Attribute\\Order')->findOneBy(array('orderId' => $object->getId())))) {
             $attribute = new Shopware\Models\Attribute\Order();
         }
     } elseif ($object instanceof Shopware\Models\Order\Detail) {
         if (!($attribute = Shopware()->Models()->getRepository('Shopware\\Models\\Attribute\\OrderDetail')->findOneBy(array('orderDetailId' => $object->getId())))) {
             $attribute = new Shopware\Models\Attribute\OrderDetail();
         }
     } else {
         throw new Exception('Unknown attribute base class');
     }
     $object->setAttribute($attribute);
     return $attribute;
 }
Example #23
0
 /**
  * do a state transition jump. Currently only supported types are
  * Next and Back. The other actions (Cancel, Done, Submit etc) do
  * not need the state machine to figure out where to go
  *
  * @param  object    $page       CRM_Core_Form the current form-page
  * @param  string    $actionName Current action name, as one Action object can serve multiple actions
  * @param  string    $type       The type of transition being requested (Next or Back)
  *
  * @return void
  * @access public
  */
 function perform(&$page, $actionName, $type = 'Next')
 {
     // save the form values and validation status to the session
     $page->isFormBuilt() or $page->buildForm();
     $pageName = $page->getAttribute('name');
     $data =& $page->controller->container();
     $data['values'][$pageName] = $page->exportValues();
     $data['valid'][$pageName] = $page->validate();
     // if we are going to the next state
     // Modal form and page is invalid: don't go further
     if ($type == 'Next' && !$data['valid'][$pageName]) {
         return $page->handle('display');
     }
     $state =& $this->_states[$pageName];
     // dont know how or why we landed here so abort and display
     // current page
     if (empty($state)) {
         return $page->handle('display');
     }
     // the page is valid, process it if we are jumping to the next state
     if ($type == 'Next') {
         $page->mainProcess();
         // we get the state again, since postProcess might have changed it
         // this bug took me forever to find :) Lobo
         $state =& $this->_states[$pageName];
         $state->handleNextState($page);
     } else {
         $state->handleBackState($page);
     }
 }
Example #24
0
/**
 * Get 'content', depending on the type
 *
 * @param   array      &$args       the array to which the content is to be appended
 * @param   object      $atom_doc   current DOMDocument
 * @param   object      $node       the 'content' node
 * @todo    I guess we could at least support 'text/plain', 'text/html', etc.
 */
function WS_getContent(&$args, $atom_doc, $node)
{
    $type = (string) $node->getAttribute('type');
    if (empty($type)) {
        $type = 'text';
    }
    switch ($type) {
        case 'text':
        case 'text/plain':
            $args['content'] = (string) $node->nodeValue;
            $args['content_type'] = 'text';
            break;
        case 'html':
        case 'text/html':
            $args['content'] = (string) $node->nodeValue;
            $args['content_type'] = 'html';
            break;
        case 'xhtml':
            /* The XHTML div element itself MUST NOT be considered part of the
             * content. -- RFC 4287, 3.1.1.3. XHTML
             */
            $div = $node->firstChild;
            if ($div->nodeName == 'div' || $div->nodeName == 'xhtml:div') {
                $args['content'] = '';
                foreach ($div->childNodes as $item) {
                    $args['content'] .= $atom_doc->saveXML($item);
                }
                $args['content_type'] = 'html';
                // it's all the same to us ...
            } elseif ($div->nodeType == XML_TEXT_NODE) {
                // hack for Yulup which sometimes sends Text nodes within the XHTML
                $args['content'] = trim((string) $node->nodeValue);
                $args['content_type'] = 'html';
            }
            break;
        default:
            // we can't handle any other types yet
            break;
    }
}
Example #25
0
 /**
  * Deal with XUL tags
  *
  * @return   string | false = html output or ignore (just output the tag)
  * @access   public
  */
 function parseXulTag()
 {
     // does it contain any flexy tags??
     if ($this->elementUsesDynamic($this->element)) {
         return false;
     }
     return $this->compiler->appendPhp($this->getElementPhp($this->element->getAttribute('ID')));
 }
 /**
  * Return a selected attribute
  *
  * @param constant The attribute to check.
  * @return string The value of the attribute.
  */
 function get_attribute($attribute)
 {
     $attribute = $this->db->getAttribute(constant("PDO::" . $attribute . ""));
     return $attribute;
 }
Example #27
0
 /**
  * Set identifier from user object.
  *
  * @param  \Illuminate\Database\Eloquent\Model|object  $user
  * @param  string  $attribute
  *
  * @return $this
  */
 public function setIdentifierFromUser($user, $attribute = 'email')
 {
     return $this->setIdentifier($user->getAttribute($attribute));
 }
Example #28
0
 /**
  * Get the users current expiration time, OR current timestamp OR future expiration time
  *
  * @version  0.6.5
  * @since 0.6.5
  * @param  object $param_data
  * @return integer $return_data
  */
 private static function getCurrentExpiration($param_data)
 {
     $prev_expiration = Device::find()->where(['user_id' => $param_data['user_id']])->one();
     // calculate the new expiration time
     $return_data = isset($prev_expiration) && count($prev_expiration) > 0 ? $prev_expiration->getAttribute('expiration') : time();
     // if the form wants to set a new expiratin time
     if ($param_data->getAttribute('time_amount_id') !== null) {
         $return_data = $return_data + TimeAmountOptions::find()->where(['id' => $param_data->getAttribute('time_amount_id')])->one()->getAttribute('value');
     }
     return $return_data;
 }
Example #29
0
 /**
  * Update template attribute if it exists, works on already added attributes
  *
  * @param object $templateEntity
  * @param object $attribute
  * @param object $values
  */
 protected function updateTemplateAttribute($templateEntity, $attribute, $values = [])
 {
     if ($attributeEntity = $templateEntity->getAttribute($attribute)) {
         if ($attributeEntity->getId()) {
             foreach ($values as $key => $value) {
                 $update = 'set' . ucfirst($key);
                 $attributeEntity->{$update}($value);
             }
             $this->entityManager->persist($attributeEntity);
         } else {
             $templateEntity->removeAttribute($attributeEntity);
         }
     }
 }
Example #30
0
 /**
  * Get attribute from request object
  *
  * @param object $request Request object
  * @param string $name string Name of the attribute
  * @return string Attribute for $name
  */
 protected function getRequestAttribute($request, $name)
 {
     return $request->getAttribute($name);
 }