function __construct()
 {
     global $wgRequest, $wgTitle;
     parent::__construct('CreateFromTemplate', '', true);
     $bits = explode('/', $wgTitle->getDBkey(), 2);
     if (!empty($bits[1])) {
         $this->mType = $bits[1];
     } else {
         $this->mType = $wgRequest->getText('type');
     }
     // setup list of fields for recipe form
     $key = "recipes-template-{$this->mType}-fields";
     $fieldsRaw = wfMsgForContent($key);
     //		if ( wfMsgEmpty( $key, $fieldsRaw ) ) {
     //			return null;
     //		}
     $this->mFields = array();
     $parent = '';
     $fieldsRaw = explode("\n", $fieldsRaw);
     foreach ($fieldsRaw as $row) {
         if (strpos($row, '* ') === 0) {
             $row = trim($row, '* ');
             $this->mFields[$row] = array();
             $parent = $row;
         } elseif (strpos($row, '** ') === 0) {
             $row = trim($row, '** ');
             $row = explode('|', $row);
             $row[1] = $row[1] === 'true' ? true : $row[1];
             $row[1] = $row[1] === 'false' ? false : $row[1];
             $this->mFields[$parent][$row[0]] = $row[1];
         }
         // other cases are ignored
     }
 }
 /**
  * Check whether given page exists
  */
 public static function pageExists()
 {
     global $wgRequest;
     wfProfileIn(__METHOD__);
     $ret = array();
     $formType = $wgRequest->getVal('formType');
     $pageName = $wgRequest->getVal('pageName');
     // format page title using proper recipe template
     $className = "Special{$formType}";
     if (method_exists($className, 'formatPageTitle')) {
         $instance = new $className();
         $pageName = $instance->formatPageTitle($pageName);
     }
     $title = Title::newFromText($pageName);
     $exists = !empty($title) && $title->exists();
     $ret = array('exists' => $exists);
     if ($exists) {
         $ret['msg'] = Xml::openElement('div', array('class' => 'recipes-template-error plainlinks')) . wfMsgExt('recipes-template-error-title-exists', array('parseinline'), $pageName) . Xml::closeElement('div');
     }
     RecipesTemplate::log(__METHOD__, "'{$pageName}' - " . ($exists ? 'yes' : 'no'));
     wfProfileOut(__METHOD__);
     return $ret;
 }
 function __construct()
 {
     parent::__construct('CreateRecipe', '', true);
     // setup list of fields for recipe form
     $this->mFields = array('wpTitle' => array('type' => 'input', 'label' => 'title', 'hint' => 'title', 'hintHideable' => true, 'required' => true, 'noToolbar' => true), 'wpIngredients' => array('type' => 'multifield', 'label' => 'ingredients', 'hint' => 'ingredients', 'hintHideable' => true, 'required' => true), 'wpDirections' => array('type' => 'textarea', 'label' => 'directions', 'hint' => 'directions', 'hintHideable' => true, 'required' => true), 'wpPrepTime' => array('type' => 'time', 'label' => 'prep-time'), 'wpCookTime' => array('type' => 'time', 'label' => 'cook-time'), 'wpYields' => array('type' => 'input', 'label' => 'yields', 'hint' => 'yields', 'hintHideable' => true), 'wpDescription' => array('type' => 'textarea', 'label' => 'description', 'hint' => 'description', 'hintHideable' => true), 'wpPhoto' => array('type' => 'upload', 'label' => 'photo', 'default' => 'Image:Placeholder'), array('type' => 'heading', 'label' => 'kind-of-recipe-heading', 'editLink' => 'recipe-menus'), 'wpCategories' => array('type' => 'multiselect', 'values' => 'recipe-menus', 'required' => true));
 }
Example #4
0
        } else {
            $editLink = '';
        }
        ?>
			<td colspan="3"><h3 class="dark_text_1"><?php 
        echo wfMsg("recipes-template-{$field['label']}-label");
        ?>
</h3><?php 
        echo $editLink;
        ?>
</td>
<?php 
    } else {
        if ($field['type'] == 'multiselect') {
            // get category chooser structure and values
            $value = isset($field['value']) ? $field['value'] : RecipesTemplate::parseCategoryChooserMessage($field['values']);
            // let's render each category chooser row
            $row = 0;
            foreach ($value as $rowName => $rowValues) {
                ?>
			<td><label><?php 
                echo htmlspecialchars($rowName);
                ?>
:</label></td>
			<td>
				<select name="<?php 
                echo $id;
                ?>
[]" id="<?php 
                echo $id;
                ?>
 function __construct()
 {
     parent::__construct('CreateIngredient', '', true);
     // setup list of fields for recipe form
     $this->mFields = array('wpTitle' => array('type' => 'input', 'label' => 'title', 'required' => true, 'noToolbar' => true), 'wpDescription' => array('type' => 'textarea', 'label' => 'description', 'hint' => 'ingredient-description'), 'wpBuying' => array('type' => 'textarea', 'label' => 'buying', 'hint' => 'buying'), 'wpProduction' => array('type' => 'textarea', 'label' => 'production', 'hint' => 'production'), 'wpPreparation' => array('type' => 'textarea', 'label' => 'preparation', 'hint' => 'preparation'), 'wpNutrition' => array('type' => 'textarea', 'label' => 'nutrition', 'hint' => 'nutrition'), 'wpPhoto' => array('type' => 'upload', 'label' => 'photo', 'default' => 'Image:Placeholder'), array('type' => 'heading', 'label' => 'kind-of-ingredient-heading', 'editLink' => 'ingredient-menus'), 'wpCategories' => array('type' => 'multiselect', 'values' => 'ingredient-menus', 'required' => true));
 }