本文整理汇总了PHP中Docs类的典型用法代码示例。如果您正苦于以下问题:PHP Docs类的具体用法?PHP Docs怎么用?PHP Docs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Docs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
$model = Docs::model()->findByPk((int) $id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: action_sidebar
public function action_sidebar()
{
$sidebar = Docs::content('contents');
// For some reason the list is getting br tags.
$sidebar = str_replace('<br />', '', $sidebar);
// Make it work locally
if ($_SERVER['LARAVEL_ENV'] == 'local') {
$sidebar = str_replace('/docs', URL::to() . 'docs', $sidebar);
}
return $sidebar;
}
示例3: ini
private function ini()
{
if (!$this->ini) {
$this->_precision = Yii::app()->user->getSetting('company.precision');
$this->iVatRate = Item::model()->findByPK($this->item_id)->vat;
$this->rate = Currates::model()->GetRate($this->currency_id);
if ($this->doc_rate == 0) {
$doc = Docs::model()->findByPk($this->doc_id);
$this->doc_rate = Currates::model()->GetRate($doc->currency_id);
}
$this->ini != $this->ini;
}
}
示例4: __construct
public function __construct($method, $param)
{
$this->param = new ReflectionParameter($method, $param);
$this->name = $this->param->name;
if ($this->param->isDefaultValueAvailable()) {
$this->default = Docs::dump($this->param->getDefaultValue());
}
if ($this->param->isPassedByReference()) {
$this->reference = TRUE;
}
if ($this->param->isOptional()) {
$this->optional = TRUE;
}
}
示例5: __construct
public function __construct($class, $method)
{
$this->method = new ReflectionMethod($class, $method);
$this->class = $parent = $this->method->getDeclaringClass();
if ($modifiers = $this->method->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
}
do {
if ($parent->hasMethod($method) and $comment = $parent->getMethod($method)->getDocComment()) {
// Found a description for this method
break;
}
} while ($parent = $parent->getParentClass());
list($this->description, $tags) = Docs::parse($comment);
if ($file = $this->class->getFileName()) {
$this->source = Docs::source($file, $this->method->getStartLine(), $this->method->getEndLine());
}
if (isset($tags['param'])) {
$params = array();
foreach ($this->method->getParameters() as $i => $param) {
$param = new Docs_Method_Param(array($this->method->class, $this->method->name), $i);
if (isset($tags['param'][$i])) {
preg_match('/^(\\S+)(?:\\s*(?:\\$' . $param->name . '\\s*)?(.+))?$/', $tags['param'][$i], $matches);
$param->type = $matches[1];
if (isset($matches[2])) {
$param->description = $matches[2];
}
}
$params[] = $param;
}
$this->params = $params;
unset($tags['param']);
}
if (isset($tags['return'])) {
foreach ($tags['return'] as $return) {
if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $return, $matches)) {
$this->return[] = array($matches[1], isset($matches[2]) ? $matches[2] : '');
}
}
unset($tags['return']);
}
$this->tags = $tags;
}
示例6: docsTest
public function docsTest()
{
$types = Doctype::find()->All();
foreach ($types as $type) {
$docs = Docs::find()->where(["doctype" => $type->id])->orderBy('docnum')->All();
$num = 0;
foreach ($docs as $doc) {
if ($num != 0) {
if ($num == $doc->docnum) {
$this->errors[] = 'Duplicate documenet number:' . $doc->docnum . ' id: ' . $doc->id . " type: " . $type->name;
}
if ($num + 1 != $doc->docnum) {
$this->errors[] = 'Invalid documenet number:' . $doc->docnum . ' id: ' . $doc->id . " type: " . $type->name;
}
}
$num = $doc->docnum;
}
}
}
示例7: __construct
/**
* Loads a class and uses [reflection](http://php.net/reflection) to parse
* the class. Reads the class modifiers, constants and comment. Parses the
* comment to find the description and tags.
*
* @param string class name
* @return void
*/
public function __construct($class)
{
$this->class = new ReflectionClass($class);
if ($modifiers = $this->class->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
}
if ($constants = $this->class->getConstants()) {
foreach ($constants as $name => $value) {
$this->constants[$name] = Docs::debug($value);
}
}
$parent = $this->class;
do {
if ($comment = $parent->getDocComment()) {
// Found a description for this class
break;
}
} while ($parent = $parent->getParentClass());
list($this->description, $this->tags) = Docs::parse($comment);
}
示例8: __construct
public function __construct($class, $property)
{
$property = new ReflectionProperty($class, $property);
list($description, $tags) = Docs::parse($property->getDocComment());
$this->description = $description;
if ($modifiers = $property->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
}
if (isset($tags['var'])) {
if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) {
$this->type = $matches[1];
if (isset($matches[2])) {
$this->description = $matches[2];
}
}
}
$this->property = $property;
if ($property->isStatic()) {
$this->value = Docs::debug($property->getValue($class));
}
}
示例9: testReplaceVariables
public function testReplaceVariables()
{
$quote = $this->quotes('docsTest');
$contact = $this->contacts('testAnyone');
$account = $this->accounts('testQuote');
$attrs = $quote->getAttributes();
$contactAttrs = $contact->getAttributes();
$accountAttrs = $account->getAttributes();
// ensure that tokens with references to customized class names get properly replaced
$quoteTemplate = array();
foreach ($attrs as $name => $val) {
$quoteTemplate[$name] = "{" . $name . "}";
}
foreach ($contactAttrs as $name => $val) {
$quoteTemplate[$name] = "{" . self::$contactsField . ".{$name}}";
}
foreach ($accountAttrs as $name => $val) {
$quoteTemplate[$name] = "{" . self::$accountsField . ".{$name}}";
}
foreach (array_intersect(array_keys($contactAttrs), array_keys($attrs), array_keys($accountAttrs)) as $name) {
unset($quoteTemplate[$name]);
unset($attrs[$name]);
unset($contactAttrs[$name]);
unset($accountAttrs[$name]);
}
// add quotes template-specific token
$quoteTemplate['dateNow'] = '{dateNow}';
$quoteTemplate['lineItems'] = '{lineItems}';
$quoteTemplate['quoteOrInvoice'] = '{quoteOrInvoice}';
$quoteTemplate = CJSON::encode($quoteTemplate);
$str = Docs::replaceVariables($quoteTemplate, $quote, array(), false, false);
$this->assertEquals(array_merge(array_map(function ($elem) {
return (string) $elem;
}, $attrs), array_map(function ($elem) {
return (string) $elem;
}, $contactAttrs), array_map(function ($elem) {
return (string) $elem;
}, $accountAttrs), array('lineItems' => preg_replace("/\r|\n/", "", $quote->productTable(true)), 'dateNow' => date("F d, Y", time()), 'quoteOrInvoice' => Yii::t('quotes', $quote->type == 'invoice' ? 'Invoice' : Modules::displayName(false, "Quotes")))), CJSON::decode($str));
}
示例10: url
public static function url($class, $havedir = false, $haveext = false)
{
$url = 'api/' . DOCS_PROJECT . '/';
// . ($havedir ? '' : '/' . Docs::_class2url( $class )) . '/' ;
if ($havedir) {
list($dir) = explode('/', $class);
} else {
$dir = Docs::_class2url($class);
$url .= $dir . '/';
}
if ($dir == 'classes') {
$ext = '.class' . EXT;
$class = str_replace('_', '/', $class);
} elseif ($dir == 'models') {
$ext = '.model' . EXT;
$class = str_replace('_', '/', $class);
} elseif ($dir == 'shell') {
$ext = '.shell' . EXT;
$class = strtolower($class);
} elseif ($dir == 'admin') {
$ext = '.admin' . EXT;
$class = strtolower($class);
} elseif ($dir == 'controllers') {
$ext = '.controller' . EXT;
$class = strtolower($class);
} elseif ($dir == 'config') {
$ext = '.config' . EXT;
} elseif ($dir == 'i18n') {
$ext = '.lang';
}
if ($haveext) {
$url .= $class;
} else {
$url .= $class . $ext;
}
return Core::url($url);
}
示例11: recordEmailSent
public static function recordEmailSent(Campaign $campaign, Contacts $contact)
{
$action = new Actions();
// Disable the unsightly notifications for loads of emails:
$action->scenario = 'noNotif';
$now = time();
$action->associationType = 'contacts';
$action->associationId = $contact->id;
$action->associationName = $contact->firstName . ' ' . $contact->lastName;
$action->visibility = $contact->visibility;
$action->type = 'email';
$action->assignedTo = $contact->assignedTo;
$action->createDate = $now;
$action->completeDate = $now;
$action->complete = 'Yes';
$action->actionDescription = '<b>' . Yii::t('marketing', 'Campaign') . ': ' . $campaign->name . "</b>\n\n" . Yii::t('marketing', 'Subject') . ": " . Docs::replaceVariables($campaign->subject, $contact) . "\n\n" . Docs::replaceVariables($campaign->content, $contact);
if (!$action->save()) {
throw new CException('Campaing email action history record failed to save with validation errors: ' . CJSON::encode($action->errors));
}
}
示例12: array
echo $form->textField($this->model, 'bcc', array('id' => 'email-bcc', 'tabindex' => '3'));
?>
</div>
</div>
<div class="row email-input-row">
<?php
//echo $form->label($this->model, 'subject', array('class' => 'x2-email-label'));
echo $form->textField($this->model, 'subject', array('tabindex' => '4', 'class' => 'x2-default-field', 'data-default-text' => CHtml::encode(Yii::t('app', 'Subject'))));
?>
</div>
<?php
if (!$this->disableTemplates) {
?>
<div class="row email-input-row">
<?php
$templateList = Docs::getEmailTemplates($type, $associationType);
$target = $this->model->targetModel;
echo $form->label($this->model, 'template', array('class' => 'x2-email-label'));
if (!isset($this->template) && $target instanceof Quote && isset($target->template) && !isset($this->model->template)) {
// When sending an InlineEmail targeting a Quote
list($templateName, $selectedTemplate) = Fields::nameAndId($target->template);
$this->model->template = $selectedTemplate;
}
echo $form->dropDownList($this->model, 'template', array('0' => Yii::t('docs', 'Custom Message')) + $templateList, array('id' => 'email-template'));
?>
</div>
<?php
}
?>
<div class="row" id="email-message-box">
<?php
示例13: array
</ul>
</div>
</div> <!-- /.col-md-8 -->
</div> <!-- /.row -->
<br>Презентации <br>
<?php
echo $form->dropDownList($track, 'Docs', CHtml::listData(Docs::model()->findAll(), 'id', 'title'), array("multiple" => true));
?>
<br>Алгоритмы<br>
<?php
echo $form->dropDownList($track, 'Algorithms', CHtml::listData(Algorithms::model()->findAll(), 'id', 'title'), array("multiple" => true));
?>
<br><br>
<button type="submit" class="btn btn-success btn-lg">Сохранить</button>
<?php
$this->endWidget();
?>
示例14: array
$quoteAttributes[$Quote . Yii::t('quotes', "Date printed/emailed")] = '{dateNow}';
$quoteAttributes[$Quote . Yii::t('quotes', '{quote} or Invoice', array('{quote}' => $modTitles['quote']))] = '{quoteOrInvoice}';
foreach (Quote::model()->getAttributeLabels() as $fieldName => $label) {
$index = $Quote . "{$label}";
$quoteAttributes[$index] = "{" . $fieldName . "}";
}
}
if ($model->type === 'email') {
$js = 'x2.insertableAttributes = ' . CJSON::encode(array(Yii::t('contacts', '{contact} Attributes', array('{contact}' => $modTitles['contact'])) => $attributes)) . ';';
} else {
$js = 'x2.insertableAttributes = ' . CJSON::encode(array(Yii::t('docs', '{contact} Attributes', array('{contact}' => $modTitles['contact'])) => $contactAttributes, Yii::t('docs', '{account} Attributes', array('{account}' => $modTitles['account'])) => $accountAttributes, Yii::t('docs', '{quote} Attributes', array('{quote}' => $modTitles['quote'])) => $quoteAttributes)) . ';';
}
}
if ($model->type === 'email') {
// allowable association types
$associationTypeOptions = Docs::modelsWhichSupportEmailTemplates();
// insertable attributes by model type
$insertableAttributes = array();
foreach ($associationTypeOptions as $modelName => $label) {
$insertableAttributes[$modelName] = array();
foreach (X2Model::model($modelName)->getAttributeLabels() as $fieldName => $label) {
$insertableAttributes[$modelName][$label] = '{' . $fieldName . '}';
}
}
Yii::app()->clientScript->registerScript('createEmailTemplateJS', "\n\n;(function () {\n\nvar insertableAttributes = " . CJSON::encode($insertableAttributes) . ";\n\n// reinitialize ckeditor instance with new set of insertable attributes whenever the record type\n// selector is changed\n\$('#email-association-type').change (function () {\n \n var data = window.docEditor.getData ();\n window.docEditor.destroy (true);\n \$('#input').val (data);\n var recordInsertableAttributes = {};\n recordInsertableAttributes[\$(this).val () + ' Attributes'] = \n insertableAttributes[\$(this).val ()];\n instantiateDocEditor (recordInsertableAttributes);\n});\n\n}) ();\n\n");
}
$js .= '
var typingTimer;
function autosave() {
window.docEditor.updateElement();
示例15: run
public function run()
{
if (Yii::app()->user->isGuest) {
Yii::app()->controller->redirect(Yii::app()->controller->createUrl('/site/login'));
}
$this->attachBehaviors($this->behaviors);
// Safety net of handlers - they ensure that errors can be caught and seen easily:
$scenario = 'custom';
if (empty($this->model)) {
$model = new InlineEmail();
} else {
$model = $this->model;
}
if (isset($_POST['contactFlag'])) {
$model->contactFlag = $_POST['contactFlag'];
}
$makeEvent = isset($_GET['skipEvent']) ? !(bool) $_GET['skipEvent'] : 1;
// Check to see if the user is requesting a new template
if (isset($_GET['template'])) {
$scenario = 'template';
}
$model->setScenario($scenario);
$attachments = array();
if (isset($_POST['InlineEmail'])) {
// This could indicate either a template change or a form submission.
$model->attributes = $_POST['InlineEmail'];
// Prepare attachments that may have been uploaded on-the-fly (?)
$mediaLibraryUsed = false;
// is there an attachment from the media library?
if (isset($_POST['AttachmentFiles'], $_POST['AttachmentFiles']['id'], $_POST['AttachmentFiles']['types'])) {
$ids = $_POST['AttachmentFiles']['id'];
$types = $_POST['AttachmentFiles']['types'];
$attachments = array();
for ($i = 0; $i < count($ids); $i++) {
$type = $types[$i];
switch ($type) {
case 'temp':
// attachment is a temp file
$tempFile = TempFile::model()->findByPk($ids[$i]);
$attachments[] = array('filename' => $tempFile->name, 'folder' => $tempFile->folder, 'type' => $type, 'id' => $tempFile->id);
break;
case 'media':
// attachment is from media library
$mediaLibraryUsed = true;
$media = Media::model()->findByPk($ids[$i]);
$attachments[] = array('filename' => $media->fileName, 'folder' => $media->uploadedBy, 'type' => $type, 'id' => $media->id);
break;
default:
throw new CException('Invalid attachment type: ' . $type);
}
}
}
$model->attachments = $attachments;
// Validate/prepare the body, and send if no problems occur:
$sendStatus = array_fill_keys(array('code', 'message'), '');
$failed = false;
$message = '';
$postReplace = isset($_GET['postReplace']) ? $_GET['postReplace'] : 0;
if (isset($_GET['loadTemplate'])) {
// A special override for when it's not possible to include the template in $_POST
$model->template = $_GET['loadTemplate'];
}
if ($model->prepareBody($postReplace)) {
if ($scenario != 'template') {
// Sending the email, not merely requesting a template change
//
// First check that the user has permission to use the
// specified credentials:
if ($model->credId != Credentials::LEGACY_ID) {
if (!Yii::app()->user->checkAccess('CredentialsSelect', array('model' => $model->credentials))) {
$this->respond(Yii::t('app', 'Did not send email because you do not have ' . 'permission to use the specified credentials.'), 1);
}
}
$sendStatus = $model->send($makeEvent);
// $sendStatus = array('code'=>'200','message'=>'sent (testing)');
$failed = $sendStatus['code'] != '200';
$message = $sendStatus['message'];
} else {
if ($model->modelName == 'Quote' && empty($model->template)) {
// Fill in the gap with the default / "semi-legacy" quotes view
$model->message = $this->controller->renderPartial('application.modules.quotes.views.quotes.print', array('model' => $model->targetModel, 'email' => true), true);
// Add a linebreak at the beginning for user-entered notes in the email:
$model->insertInBody('<br />', 1);
}
}
}
// Populate response data:
$modelHasErrors = $model->hasErrors();
$failed = $failed || $modelHasErrors;
$response = array('scenario' => $scenario, 'sendStatus' => $sendStatus, 'attributes' => $model->attributes, 'modelErrors' => $model->errors, 'modelHasErrors' => $modelHasErrors, 'modelErrorHtml' => CHtml::errorSummary($model, Yii::t('app', "Please fix the following errors:"), null, array('style' => 'margin-bottom: 5px;')));
if ($scenario == 'template') {
// There's a chance the inline email form is switching gears into
// quote mode, in which case we need to include templates and
// insertable attributes for setting it all up properly:
$response['insertableAttributes'] = $model->insertableAttributes;
$templates = array(0 => Yii::t('docs', 'Custom Message')) + Docs::getEmailTemplates($model->modelName == 'Quote' ? 'quote' : 'email', $_POST['associationType']);
$response['templateList'] = array();
foreach ($templates as $id => $templateName) {
$response['templateList'][] = array('id' => $id, 'name' => $templateName);
}
//.........这里部分代码省略.........